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

rho calculating and updating in buoyantPimpleFoam

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 20, 2018, 09:00
Default rho calculating and updating in buoyantPimpleFoam
  #1
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 8
calf.Z is on a distinguished road
Hello foamers,

I am facing some issues about rho updating in buoyantPimpleFoam.

I am confused that how rho is calculated and updating.

in pEqn.H:
p = p_rgh + rho*gh;
thermo.correctRho(psi*p - psip0);

#include "rhoEqn.H"


rho is calculated through rhoEqn.H,right?


in buoyantPimpleFoam.C:
while (pimple.loop())
{
#include "UEqn.H"
#include "EEqn.H"
while (pimple.correct())
{
#include "pEqn.H"
}
if (pimple.turbCorr())
{
turbulence->correct();
}
}
rho = thermo.rho();

When the solver finishes pimple.loop(), it appears rho = thermo.rho(). What's its function? Does it also update rho? Where is the final updating place of rho?

I have another related question: If I want to read rho value through looking up constant/rho file. How should I modify the code?

in creatfield.H,I change NO READ to READ_IF_PRESENT:

volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT, //NO READ,
IOobject::AUTO_WRITE //NO WRITE
),
thermo.rho()
);

but it doesn't work.

I have no idea about these questions. Any hints or suggestion is highly appreciated.
calf.Z is offline   Reply With Quote

Old   December 29, 2018, 18:06
Default
  #2
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16
mAlletto will become famous soon enough
buoyantPimpleFoam


is a pressure bases solver. That means that the continuity equation and the momentum equation are used to derive an equation for the pressure to ensure mass conservation.



A derivation of the equations can be found in https://openfoamwiki.net/index.php/ChtMultiRegionFoam and references therein.




So after solving the pressure equation the density is corrected by using the function



thermo.correctRho(psi*p - psip0); -> this function adds the correction psi*p - psip0 to the density previous to the pressure equation psip0.



rho = thermo.rho() -> returns a reference to the rho attribute of the thermo classe



the description of the class can be found in https://www.openfoam.com/documentati...8C_source.html


PHP Code:
I have another related question: If I want to read rho value through looking up constant/rho fileHow should I modify the code?in creatfield.H,I change NO READ to READ_IF_PRESENT:volScalarField rho(    IOobject    (        "rho",        runTime.timeName(),        mesh,        IOobject::READ_IF_PRESENT//NO READ,        IOobject::AUTO_WRITE //NO WRITE    ),    thermo.rho());but it doesn't work.I have no idea about these questions. Any hints or suggestion is highly appreciated. 
in the way you specified it you read the rho file if it is present from the time folders
mAlletto is offline   Reply With Quote

Old   December 29, 2018, 23:04
Default
  #3
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 8
calf.Z is on a distinguished road
Quote:
Originally Posted by mAlletto View Post

So after solving the pressure equation the density is corrected by using the function

thermo.correctRho(psi*p - psip0); -> this function adds the correction psi*p - psip0 to the density previous to the pressure equation psip0.

Thank you for your great answers.

So what's the function of #include "rhoEqn.H" which is in the end of p.Eqn?

I want to use tabular mathod to read rho ,Cp ,mu..... from tabulated tables. the tabular library works well in psithermo-based solver e.g. rhoSimpleFoam. But it doesn't work in rhothermo-based solver e.g. buoyantPimpleFoam.

So I think maybe the reason is the different definitions of rho in two solvers.
Maybe I should write another version of library code which is suitable for rho-based solver.

Thank you for any suggestion given.
calf.Z is offline   Reply With Quote

Old   December 30, 2018, 06:42
Default
  #4
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16
mAlletto will become famous soon enough
equally I do not know the use of rhoEqn.H in pressure based solver. In all tutorials of where pressure based solver are used for compressible flows the equation is not solved.



If you tabular values for rho you have to write your own equation of state. Or maybe you can use one which is already available in openfoam:


https://cfd.direct/openfoam/user-gui...35-2660007.1.5


maybe the linear equation of state is good enough for your purpose. It assumes a linear variation of the density rho with the pressure p.
mAlletto is offline   Reply With Quote

Old   March 12, 2019, 05:41
Default
  #5
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 8
calf.Z is on a distinguished road
Quote:
Originally Posted by mAlletto View Post
equally I do not know the use of rhoEqn.H in pressure based solver. In all tutorials of where pressure based solver are used for compressible flows the equation is not solved.
Thank you for your reply.

With the deeper research, now I should create a low mach number solver, which decouple rho and p, which means the variations of p do not affect rho.

I think the relationship between rho and p in variable-density solver of openfoam is :

rho = psi*p

So I think I cannot use it under low mach number assumption.

For buoyantPimpleFoam, the code:

Code:
   
...... 
fvc::ddt(rho) + psi*correction(fvm::ddt(p_rgh))
......
thermo.correctRho(psi*p - psip0);
******
These codes are related to rho and p. I think I should modify them but I am not sure about it.

So any suggestion is highly appreciated.
calf.Z is offline   Reply With Quote

Old   March 12, 2019, 06:55
Default
  #6
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16
mAlletto will become famous soon enough
I did not understand what you're trying to do but there are different equations of state you can select from. Among this also a constant density. See
https://cfd.direct/openfoam/user-gui...hermophysical/.

Since it is a pressure based solver and not a density based solver it should work fairly well also for low mach number flows
mAlletto is offline   Reply With Quote

Old   March 12, 2019, 09:53
Default
  #7
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 8
calf.Z is on a distinguished road
Quote:
Originally Posted by mAlletto View Post

Since it is a pressure based solver and not a density based solver it should work fairly well also for low mach number flows
But I think in pressure based solver, the update of ρ is related to p, such as ρ = psi*p and thermo.correctRho(psi*p - psip0);

So the aim is decoupling rho and p. But I not sure how to modify the code. Thank you.
calf.Z is offline   Reply With Quote

Old   March 13, 2019, 08:55
Default
  #8
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16
mAlletto will become famous soon enough
psi plays a role only in the compressible part of the pressure equation. For a constant rho (see https://github.com/OpenFOAM/OpenFOAM...st/rhoConstI.H) psi = 0 and you get the incompressible pressure equation.

For the equations used see e.g. and references therein

https://openfoamwiki.net/index.php/ChtMultiRegionFoam
mAlletto is offline   Reply With Quote

Old   March 13, 2019, 10:41
Default
  #9
Senior Member
 
Jianrui Zeng
Join Date: May 2018
Location: China
Posts: 157
Rep Power: 8
calf.Z is on a distinguished road
Quote:
Originally Posted by mAlletto View Post
psi plays a role only in the compressible part of the pressure equation. For a constant rho (see https://github.com/OpenFOAM/OpenFOAM...st/rhoConstI.H) psi = 0 and you get the incompressible pressure equation.
But in my case, rho is strongly changed with T. So it is not constant.

In pressure-based solver, such as buoyantPimpleFoam, the uodate of rho is related to pressure. So I need to decouple them.
calf.Z is offline   Reply With Quote

Old   March 13, 2019, 11:17
Default
  #10
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16
mAlletto will become famous soon enough
There are a few equations of state which you may find usefull: icoPolynomial and incompressiblePerfectGas

see https://cfd.direct/openfoam/user-gui...hermophysical/.

A tutorial where icoPolynomial is used can be found in
tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger
mAlletto 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
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 10:21
Updating the turbulent schmidt number in dynamic smagorinsky model pvpnrao OpenFOAM Running, Solving & CFD 3 November 6, 2020 04:52
Questions on dynamicTopoFvMesh danvica OpenFOAM Running, Solving & CFD 80 April 16, 2019 17:58
Maximum number of iterations exceeded when calculating T with AMI baffles only blebon OpenFOAM Running, Solving & CFD 1 August 26, 2017 18:43
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 18:27


All times are GMT -4. The time now is 17:57.