simulkade / FVTool

Finite volume toolbox for Matlab/Octave
http://fvt.simulkade.com
BSD 2-Clause "Simplified" License
99 stars 56 forks source link

advection-diffusion-reaction #20

Closed SA8416 closed 2 months ago

SA8416 commented 5 years ago

Hi, I need to solve the 1D advection diffusion equation for a species concentration, with a sink term. At the left BC there is a constant concentration for all time steps, at the right BC, the advective flux equals the diffusive flux initially. I want to add an optional sink term "k(phi-phi_max)", which should be zero for cells when phi<phi_max, and which should have a value that sets the cells concentration equal to phi_max when concentration reaches phi_max, not allowing the concentration to rise above phi_max. Sorry for the long description, but is this possible with your code?

simulkade commented 5 years ago

It is possible. Could you start modifying one of the examples? Then I can help if you run into problems.

On Wed, 23 Jan 2019, 19:23 SA8416 <notifications@github.com wrote:

Hi, I need to solve the 1D advection diffusion equation for a species concentration, with a sink term. At the left BC there is a constant concentration for all time steps, at the right BC, the advective flux equals the diffusive flux initially. I want to add an optional sink term "k(phi-phi_max)", which should be zero for cells when phi<phi_max, and which should have a value that sets the cells concentration equal to phi_max when concentration reaches phi_max, not allowing the concentration to rise above phi_max. Sorry for the long description, but is this possible with your code?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/simulkade/FVTool/issues/20, or mute the thread https://github.com/notifications/unsubscribe-auth/ABy1xpDaY0IcT6OPyC11oTOphoYGWNY7ks5vGKiVgaJpZM4aPXRD .

SA8416 commented 5 years ago

Here is my first attempt, with the correct BC for the case without a maximum concentration. I would like to impose a maximum possible concentration (say for this case phi_max=2.5), and not allow the concentration to surpass this value. I'm having some difficulty with the sink term and the boundary conditions at the right side.

1DconvdiffPPT.m.txt

SA8416 commented 5 years ago

update: I have obtained what appears to be the correct profile for the steady state by explicitly stating where the source becomes active in the mesh, in the steady file.

The transient file is what I'm trying to fix, where the source becomes active at a certain value of "phi", but I think the BC need to be changed at each time step. Is there a way to do this?

Thanks! C_1D_PPT_steady.m.txt C_1D_PPT_trans.m.txt

SA8416 commented 5 years ago

I seem to have gotten the concentration profile I was expecting with this code, but am still unsure if the boundary conditions are correct. C_1D_PPT_trans_newest.m.txt

iftikhar8 commented 5 years ago

Does this tool work if the reaction term is nonlinear? I am trying to solve an advection-diffusion PDE which also has a nonlinear reaction term in it. Thanks for your help.

simulkade commented 5 years ago

It is possible to solve nonlinear equations, but first you it has to be linearised using Taylor expansion. I'll write about it soon.

iftikhar8 commented 5 years ago

Thank you!