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

Manually adding source terms

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 12, 2020, 11:54
Default Manually adding source terms
  #1
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
Gerry Kan is on a distinguished road
Howdy Foamers:

I have the following question. In a compressible solver I am modifying the FV formation of YEqn.H to include a source term based on a uniform but transient injection rate for species "i":

Code:
fvScalarMatrix YiEqn  (
    fvm::ddt(rho, Yi) == fvOptions(rho, Yi) + rhoSp
);
The term rhoSp is a rate of mass fraction based on the injection rate for cell k, that is

rhoSp[k] = rho[k] * mdot[k] / ( rho[k]*V[k] + mdot[k]*dt )

where

k is the cell ID
rho[k] is the density of cell k
mdot[k] is the injection rate of species i into cell k
V[k] is the volume of cell k
dt is the current time step

The total mass of species i injected into the domain can be recovered by summing the amount of it over all cells (it does in my case), and the mass fraction of species i is expected to be very small ( < 1e-7 ).

As a test case I have the injection take place in a closed chamber, where upon the amount of species i introduced into the domain is known a priori, and verification is made by summing up the amount (not mass fraction) of species i at each time step. In other words, at each time step, the difference between the computed and expected mass of species i at each time step should be very, very small.

What I have noticed, however, is that, as time goes on, this difference creeps up geometrically and at some point early on in the simulation, it could double or triple the expected injection mass. My hunch is that it might have something to do with implicit vs explicit source terms. But unfortunately I don't really know how to proceed. Could someone shed some light on this matter?

Thanks in advance, Gerry.

Last edited by Gerry Kan; August 12, 2020 at 13:48.
Gerry Kan is offline   Reply With Quote

Old   September 14, 2020, 09:23
Default
  #2
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
Gerry Kan is on a distinguished road
It turned out the implementation was correct from the get go. My original boundary conditions were simply non-conserving and therefore it appeared as if I was losing mass. In the end, I had all wall in my test domain (except for the boundary where the source term is implemented) into cyclic and the problem was solved.

Gerry.
Gerry Kan is offline   Reply With Quote

Old   May 18, 2022, 14:07
Default
  #3
Member
 
MNM
Join Date: Aug 2017
Posts: 69
Rep Power: 8
SHUBHAM9595 is on a distinguished road
Hi Gerry,

While looking for an explicit source addition in the governing equation, I came across your post. I've minor query regarding the implementation....

Is there any specific reason why u opt to divide by cell volume ?

rhoSp[k] = rho[k] * mdot[k] / ( rho[k]*V[k] + mdot[k]*dt )
SHUBHAM9595 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
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 ordinary OpenFOAM Installation 19 September 3, 2019 18:13
[Other] How to use finite area method in official OpenFOAM 2.2.0? Detian Liu OpenFOAM Meshing & Mesh Conversion 4 November 3, 2015 03:04
[foam-extend.org] problem when installing foam-extend-1.6 Thomas pan OpenFOAM Installation 7 September 9, 2015 21:53
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 06:42
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 06:12.