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

Good old source term in a new transport equation

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes
  • 4 Post By Sun

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 30, 2014, 10:44
Default Good old source term in a new transport equation
  #1
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 15
Sun is on a distinguished road
Hi, just cross-checking with you guys:
Say I have this equation:

\frac{\partial {X}}{\partial {t}} + \nabla \cdot (XU) = A X^2

"A" is a temperature dependent variable being computed, separately, via a header file.
Wondering if the implementation of source term is correct?
Code:
solve(fvm::ddt(X)+fvm::div(phi,X)-fvm::SuSp(AX,X));
Thanks and happy new year (almost!)
Sun is offline   Reply With Quote

Old   January 5, 2015, 02:22
Default
  #2
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 15
Sun is on a distinguished road
Any suggestions would be really appreciated. I am impatiently waiting...!
thanks.
Sun is offline   Reply With Quote

Old   January 9, 2015, 04:21
Default
  #3
Sun
Senior Member
 
Sun's Avatar
 
Join Date: Nov 2010
Posts: 103
Rep Power: 15
Sun is on a distinguished road
For future reference:
Quote:
Code:
solve(fvm::ddt(X)+fvm::div(phi,X)-fvm::SuSp(AX,X));
This is totally wrong!

The way to deal with higher order source terms is to linearize them into Sc and Sp parts. I have applied Picard's method which is explained in detailed on page 57 of this document.

For the problem mentioned above, this is how I have implemented it in OF and note that the subscript "o" is for the old value of a field, retrieved by oldTime() function.

Step 1. Source term:
S = A X^2

Step 2. Taylor's expansion around the old value of X
S = S_o + (\frac{\partial S}{ \partial X})_o (X-X_o)

Step 3. Sc and Sp
S_c = S_o - (\frac{\partial S}{\partial X})_o X_o = -AX_o^2

S_p = (\frac{\partial S}{\partial X})_o = 2AX_o

Step 4. Create two volScalarField(s) for Sc and Sp and using a forAll loop over the cells
Code:
forAll(mesh.C(), celli)
	{
            X_valOld = X.oldTime()[celli]
            Su[celli] = -1.0*A*Foam::pow(X_valOld,2);
            Sp[celli] = 2.0*A*X_valOld;
        }
Step 5. solving the PDE with the linearized source term
Code:
fvScalarMatrix XEqn
    (
	fvm::ddt(X)
      + fvm::div(phi,X)
     == Su + fvm::Sp(Sp,X)
    );
   XEqn.solve();
Step 6. Compile and do your victory dance!

I haven't run any test cases though! but for now there is no compilation errors.
thiagopl, cryabroad, Kummi and 1 others like this.
Sun is offline   Reply With Quote

Old   January 13, 2024, 15:05
Default
  #4
New Member
 
Ludwig Bossle
Join Date: Jan 2024
Location: Karlsruhe, Germany
Posts: 1
Rep Power: 0
lbossle is on a distinguished road
I landed on this topic because I had stability issues caused by a very large source term. I couldn't perform a taylor linearization to solve my problem but this discussion more or less directed me to 'Numerical heat transfer and fluid flow' (Patankar 1980). Chapter 4.2-5 and especially 7.2 helped me enormously. So perhaps this can be of use to some for future reference.
lbossle is offline   Reply With Quote

Reply


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
adding a constant volumetric source term to transport equation in a particular region cfdonline2mohsen OpenFOAM Programming & Development 15 February 16, 2017 09:55
implicit - scalar product source term in momentum equation vinch OpenFOAM Running, Solving & CFD 0 October 28, 2014 14:57
turbulent diffusion term in transport equation for additional variables Raijin Thunderkeg CFX 2 May 17, 2014 22:53
Source term energy equation for reactive flows DaIN Main CFD Forum 0 October 6, 2011 15:11
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08


All times are GMT -4. The time now is 10:13.