Nonlinear source term like u*(1-u)?
Hello, everyone!
I have a quick question, how to specify nonlinear terms in the solver? For example, I want to solve the KPP equation which reads U_t = D*(U_{xx} + U_{yy}) + gamma * U * (1 - U) (an example in matlab is: http://www.mathworks.com/matlabcentr...tent/pattern.m) In what way should I express the nonlinear term u*(1-u) in the solver, I tried to do this based on the laplacianFoam.C in several ways, but none seemed to work. I was once told openFOAM can only handle linear forms... Any help would be really appreciated! |
Hi Tom,
It is true that OpenFoam solves the linearised equation, so you have to linearise the equation, e.g. u^(n+1) * (1 - u^n), which makes it possible to formulate a linear set of equations in u^(n+1). Specifically, merely add the [CODE] fvm::Sp( gamma * U, U) // Only the source term! [CODE] in your equation, which then automatically makes it into the linearised form. My feel is that you will gain a lot more stability compared to the Matlab script, which seems to be explicit. BTW: Thanks for the link, it really do create some beautiful patterns and sometimes transient and psychedelic Kind regards, Niels |
Quote:
solve(fvm::ddt(T) - fvm::laplacian(DT, T) - fvm::Sp(gamma * (1-T), T)); the result doesn't appear right compared with the matlab script in the link: the T become T = 1 throughout the domain (except the boundary which is actually irrelevant) in my result. I don't think openfoam will automatically consider gamma*(1-T) or T as from the previous time step. Were you suggesting I use both T^(n+1) and T^(n) in the equation, then how should I write it? I know there is something like T.oldTime(), should that be used? |
Hi
First of all, if you consider carefully the matlab script, then you will find that the boundary values are neglected in the computation of gradients, etc, which you cannot avoid in OpenFoam besides using either zeroGradient (but still considered) or using periodic domains (cyclic). With respect to the equation you are solving the form: Code:
fvm::ddt(T) - fvm::laplacian(DT, T) - fvm::Sp(gamma * (1 - T), T) Code:
gamma^n * (1 - T^n) * T^(n+1) I hope this clarified things a bit. / Niels |
All times are GMT -4. The time now is 08:58. |