
[Sponsors] 
About the influence of the mass source term on the momentum equation and coding 

LinkBack  Thread Tools  Search this Thread  Display Modes 
May 12, 2023, 05:59 
About the influence of the mass source term on the momentum equation and coding

#1 
New Member
DuanYabo
Join Date: Jul 2022
Posts: 16
Rep Power: 4 
Hello Fomers, Good days. Help!!!
I have been learning openfoam for one year, and I am still a novice. There is a problem that has troubled me for more than half a year and has not been resolved. I would like to ask the predecessors in the forum about the influence of the mass source term on the momentum equation and the encoding. By the way, the solver I mainly use is simpleFoam now. In a stendy, inviscid and incompressible problem, if there is not a mass source term in a continuity equation，one has div(U)=0 (1) div(U*U)=grad(p) (2) If there is a mass source term, one has div(U)=S (3) div(U)*U + U*grad(U)=grad(p) (4) Because if there is not a mass source term, div(U*U)=div(U)*U+U*grad(U) , so equation(2) and equation(4) is equal. Even with the source term, the above equation should be also true, but I don't know if the above equation is true after the equation is discretized in openfoam, because when I don't change the momentum equation and just add a divU, openfoam always reports an error. So my questions are (i) If div(U) is not equal to 0 in openfoam, is the formula div(U*U)=div(U)*U+U*grad(U) still true? (ii) Because the left hand two terms of formula (4) are nonlinear. So how to write a program in openfoam to realize formula (4)? I really need help from all of you, even a small suggestion. 

May 12, 2023, 06:30 

#2 
Member
Zeinab
Join Date: Feb 2023
Posts: 32
Rep Power: 3 
Hi I am quite new to OpenFOAM too and I don't have a clear answer, but have you tried adding the mass source through the fvOptions? or you want to hard code it yourself?


May 12, 2023, 06:43 

#3  
New Member
DuanYabo
Join Date: Jul 2022
Posts: 16
Rep Power: 4 
Quote:
Code:
fvScalarMatrix pEqn ( fvm::laplacian(rAtU(), p) == fvc::div(phiHbyA)  scalarDivU ); 

May 12, 2023, 08:25 

#4 
Member
Zeinab
Join Date: Feb 2023
Posts: 32
Rep Power: 3 
Okay. I find this problem interesting. What exactly the kind of error that you encounter when not editing the momentum equation? Can you post the error message here?


May 12, 2023, 09:05 

#5 
Member
Zeinab
Join Date: Feb 2023
Posts: 32
Rep Power: 3 
Hello,
I noticed sth I don't know it's right or wrong. Please correct me if it doesn't make sense. But I revised How simpleFoam solve for the velocity field. So first if we have the NacierStokes equation: Code:
ρ DU/Dt = ∇ p + ∇ . τ + ρ g Code:
MU = ∇ p Code:
solve(UEqn == fvc::grad(p)) Code:
solve(UEqn == fvc::grad(p) + mass_Source) because the edit I added is the addition of the mass source to the momentum equation and in the pEqn is it's effect on the continuity. Note: be carreful with the units, and you need to enable the momentum predictor option. Also, I used this source to revise how the simple algorithm work: https://medium.com/@mustafaabbs2/the...d61fcc54ab24d 

May 12, 2023, 10:44 

#6  
New Member
DuanYabo
Join Date: Jul 2022
Posts: 16
Rep Power: 4 
Quote:
The above is my own understanding after checking some information recently, please correct me if I am wrong. In addition, if you have WeChat or twitter or other instant messaging tools, welcome to send it to me, and we can have further discussions. 

May 12, 2023, 10:58 

#7 
Member
Zeinab
Join Date: Feb 2023
Posts: 32
Rep Power: 3 
yep I am mistaken, the thing added is the momentum source term not the massSource as I written. But be aware of sth that the mass source term adds momentum to the flow and creates momentum source that you need to add. So, in my opinion it's not just the mass source that should be added.
You said that when you added the mass source term you got an error. Also, are you sure that it's not dimensions error or unit error. Moreover, I thought about adding the momentum source to the momentum predictor if you don't want to add it by fvOptions. My thought about that is that it's not the best practice but it should work because it satisfies the equation. It's basically you have Code:
MU = ∇ p + Forcing term Last edited by Zena27; May 16, 2023 at 06:05. 

May 12, 2023, 11:32 

#8  
New Member
DuanYabo
Join Date: Jul 2022
Posts: 16
Rep Power: 4 
Quote:
In addition, I would like to ask, you said "But be aware of sth that the mass source term adds momentum to the flow and creates momentum source that you need to add." Can you give me some information or some references? I would like to understand how to add momentum due to the mass source term. Thank you very much! In addition, the error I made may have nothing to do with the unit. I declared a volScalarField constant as div(U) in "createFields.H", and wrote the correct unit in this file. Dimensions should be fine too, since fvc::div(phiHbyA) is a volume scalar, as is div(U). 

May 12, 2023, 12:15 

#9 
Member
Zeinab
Join Date: Feb 2023
Posts: 32
Rep Power: 3 
Off course I can search and send you some source. I just have a question can you give me a brief description of your problem, and can you post the error you got here?


May 13, 2023, 05:19 

#10  
New Member
DuanYabo
Join Date: Jul 2022
Posts: 16
Rep Power: 4 
Quote:
Next I paste my modified simpleFoam code。 1. In the createFields.H, I added the following code: Code:
volScalarField scalarDivU ( IOobject ( "scalarDivU", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); fvScalarMatrix pEqn ( fvm::laplacian(rAtU(), p) == fvc::div(phiHbyA)  scalarDivU ) 3. I also added a file named scalarDivU in the 0 folder. the main content is Code:
dimensions [0 0 1 0 0 0 0]; internalField uniform 1.12; boundaryField { SURF_EXTERIOR_OUTLETS { type fixedValue; value uniform 1.12; } SURF_EXTERIOR_INLETS { type fixedValue; value uniform 1.12; } } Code:
solve(UEqn == fvc::grad(p)) p = expression failed to parse:error: <user expression 36>:1:1: use of undeclared ideentifier 'p'p^ signal = SIGFPE (signal SIGFPE: floating point divide by zero) By the way, I really donot know which value is zero??? Maybe the UEqn??? But why??? 

May 15, 2023, 17:38 

#11 
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 735
Rep Power: 14 
Your formula 4, from your first post is in a nonconservative form, and so cannot be discretised simply with the finite volume approach. Apologies, but I haven't read through the rest of the posts in the thread, but it strikes me from your first post that you may be trying to do something impossible.
I think you probably need to read up more about the basic OpenFOAM solver, and its FV approach  search online for Hrv Jasak's thesis, for example  there's a good description in there, I seem to remember. Good luck! 

May 16, 2023, 04:12 

#12  
New Member
DuanYabo
Join Date: Jul 2022
Posts: 16
Rep Power: 4 
Quote:
In addition, I would like to ask a little question, if the mass source term is added to the continuity equation, does the momentum equation need to change some terms? 

May 16, 2023, 05:27 

#13  
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 735
Rep Power: 14 
Quote:
Quote:


May 16, 2023, 05:36 

#14  
New Member
DuanYabo
Join Date: Jul 2022
Posts: 16
Rep Power: 4 
Quote:
I would like to ask one more question. If at the beginning of the system, the whole space is full of mass source items (that is, div(U) is equal to S everywhere in the solution space). And what I am solving is an incompressible steadystate problem, so will the density of the system change? Thanks again for your thoughtful answer ！ 

May 16, 2023, 05:39 

#15 
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 735
Rep Power: 14 
Yes! Think about it from a physical perspective  it is the same as pumping air continuously into a container, where the walls of the container are rigid (i.e. the volume remains fixed). The mass is increasing, and so must be the density.
All the best, T 

May 16, 2023, 06:00 

#16  
New Member
DuanYabo
Join Date: Jul 2022
Posts: 16
Rep Power: 4 
Quote:
Yes, you say the density does increase in this case. But what I want to solve is an incompressible problem. The detailed description of this problem is "a certain substance flows from the inlet to the outlet, and the container is filled with a mass source, during which the whole system is stable, constant temperature, and incompressible". I made the density constant as a precondition. What I can think of is that adding the mass source term will definitely change the velocity of the fluid compared to no mass source term, but I don't know if this change will change the momentum equation. According to your explanation, the momentum equation doesn't change even if the density doesn't change right? Thanks again 

May 16, 2023, 06:10 

#17  
Member
Zeinab
Join Date: Feb 2023
Posts: 32
Rep Power: 3 
Quote:
How the momentum is not changed. Isn't the mass we add has a velocity and this velocity? and then we have the momentum is basically mass*velocity. Also, concerning the energy equation, isn't the mass added has an internal energy thus it changes the energy too. Please, I need more explanation about this. 

May 16, 2023, 06:14 

#18 
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 735
Rep Power: 14 
Apologies  I forgot you were dealing with an incompressible system. In that case, density is indeed constant and instead you will get an increase in velocity downstream to accomodate the extra mass flow. This will be accompanied by a pressure rise to counter the increased momentum of the flow, thereby leaving the momentum equation balance unchanged. This backpressure is the resistance to you pumping the mass source in, and would in a real system affect the upstream conditions ... etc.


May 16, 2023, 06:18 

#19 
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 735
Rep Power: 14 
Apologies  I meant the momentum balance (ie momentum plus body forces like pressure), not the momentum itself  Duan was wanting to know how this affects the momentum equation, and that was what I was trying to answer. Sorry for the confusion. 

May 16, 2023, 06:32 

#20 
Member
Zeinab
Join Date: Feb 2023
Posts: 32
Rep Power: 3 
Okay Now I understand thank you so much, and sorry DuanYB for confusing you earlier. :""


Tags 
equation construction, mass source term, openfoam, simplefoam, source term 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Expanding an Implicit Scalar Source term to a Vector or Tensor  ScalarVectorTensor  OpenFOAM Running, Solving & CFD  1  October 18, 2023 03:31 
Solve poisson equation just add a source term  nandiganavishal  OpenFOAM Running, Solving & CFD  18  November 14, 2022 10:12 
Adding two terms in the momentum equation in in chtMultiRegionSimpleFoam  zahraa  OpenFOAM PreProcessing  0  June 13, 2015 13:42 
Mass flow rate boundary condition for continuity equation for oscillating flow  p07ip705  Main CFD Forum  0  February 28, 2013 02:33 
FEM fortran codes for coupled mass momentum energy  Amit  Main CFD Forum  1  May 17, 2005 21:38 