CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Nonlinear source term like u*(1-u)?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 23, 2012, 23:24
Default Nonlinear source term like u*(1-u)?
  #1
New Member
 
Chenguang Zhang
Join Date: Jul 2012
Location: Baton Rouge Louisiana
Posts: 15
Rep Power: 13
Taozi is on a distinguished road
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!
Taozi is offline   Reply With Quote

Old   July 24, 2012, 03:52
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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
ngj is offline   Reply With Quote

Old   July 25, 2012, 22:09
Default
  #3
New Member
 
Chenguang Zhang
Join Date: Jul 2012
Location: Baton Rouge Louisiana
Posts: 15
Rep Power: 13
Taozi is on a distinguished road
Quote:
Originally Posted by ngj View Post
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
Hi Niels, thank you for your reply. I am a little confused about the handling of the explicit/implicit terms in openfoam. I tried the following line:
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?
Taozi is offline   Reply With Quote

Old   July 26, 2012, 03:48
Default
  #4
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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)
It treats the first two terms fully implicitly in a manner depending on your temporal discretisation scheme, and the source term reads
Code:
gamma^n * (1 - T^n) * T^(n+1)
so it is a linearised form of your non-linear source term. The discretisation of the source term will also depend on the temporal scheme.

I hope this clarified things a bit.

/ Niels
ngj is offline   Reply With Quote

Reply

Tags
nonlinear

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem of SOURCE term gradient in UDS wind Fluent UDF and Scheme Programming 6 December 1, 2022 14:21
GPU Linear Solvers for OpenFOAM gocarts OpenFOAM Announcements from Other Sources 37 August 17, 2022 14:22
UDF source term jerome_ FLUENT 2 July 11, 2011 11:55
How to write source term into scalar Fiel JimKnopf OpenFOAM Programming & Development 0 March 23, 2011 05:59
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 11, 2000 03:43


All times are GMT -4. The time now is 01:06.