CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Rho %3d thermorho what does it do (https://www.cfd-online.com/Forums/openfoam-solving/58940-rho-3d-thermorho-what-does-do.html)

 arkangel June 8, 2007 10:34

Hi can someone enlighten m

Hi

can someone enlighten me ?
rho = thermo->rho();
in the Xoodles solver, after calculating the pressure field in the time for, I am almost sure this update the rho field using the gas ideal equation.

Is that true ?

 gschaider June 12, 2007 10:16

Depends on the thermoModel you

Depends on the thermoModel you're using. But in general: yes

 morteza July 11, 2007 06:06

Hi guys I want to know about

Hi guys
I want to know about the exact effect of thermo->rho() or thermo->p() and thermo->correct() on codes.
As mentioned above thermo->rho() update the rho field using the gas ideal equation, but i studied "hThermo.c","hThermo.H", "basicThermo.c" and "basicThermo.H" and found no ideal gas relation.

Am i looking into incorrect files?
How does thermo->rho() update ideal gas relation?

Morteza

 gschaider July 11, 2007 07:18

Hi Morteza! What you are en

Hi Morteza!

What you are encountering is the technical wonder called polymorphism (a thing that makes object oriented programming so attractive).

basicThermo for instance declares the method p() as virtual which basically says: "I have no idea how to calculate a pressure, but there will come at least one subclass that knows how to do it". The call thermo->p() says: "Hey thermo, you are an instance of a subclass of basicThermo. How does your type calculate p()?" What actually gets calculated depends on the concrete type of thermo (which is defined by the thermoType parameter in constant/thermophysicalProperties), it may be a perfect gas relation, it may be something different (but perfect gas is implemented in \$FOAM_SRC/thermophysicalModels/specie/equationOfState/perfectGas/perfectGasI.H)

Bernhard

 morteza July 11, 2007 09:24

Hi Bernard Thanks for your re

Hi Bernard

I have put it in two different lacations just for more attention. But your right.

Morteza

 arkangel July 12, 2007 10:50

Hi , that was really good i

Hi ,

that was really good information , but can we go a bit further, because i was looking for the actual implementation of the ideal gas equation and i couldnt find it , so let's take for example a solver: coodles

there is an instance call thermo of (either basicThermo, hThermo or something else) and somewhere in the coodles code there is a declaration of this kind:
basicThermo thermo(init param ) ;
maybe using an autoPrt or the like (The idea is that there is an instance call thermo of either basicThermo , hThermo or whatever)

inside the basicThermo.H there is a "p" public function :

volScalarField& p()
{
return p_;
}
in coodles.C file without knowing how p_ is calculated i now this is clear

p=thermo->p();
which says in words: "The Pressure field P in the coodles solver is equal to the pressure calculated by basicThermo.p()

Well here is the difficult part for me.

basicThermo.p() returns a protected term p_ and in this solver "coodles" in particular I cannot find the implementation of the the pressure calculation based on temperature and density. i.e. How p_ is calculated and this is exactly what i want to know.

for example here
http://foam.sourceforge.net/doc/Doxy...sicThermo.html

i cannot find any clue where it is , so , in short , in this particular example (coodles) where can I find the implementation of the gas ideal equation ? and most importantly , how can i found the relationship between the declaration and the actual implementation? that means if I would like to find the ideal gas equation for species used in Xoodels how can I find the implementation ?

Regards

Rivera

 evan January 9, 2008 16:16

Hi Rivera, See the include

Hi Rivera,

See the include statements here:

thermophysicalModels/basic/basicThermo/basicThermos.C

Hope that helps,
Evan

 arkangel April 21, 2008 09:27

Hi Foamers, I am trying

Hi Foamers,

I am trying to write a solver like coodles ,

in coodles in the hEqu.H, the enthalpy is transported , when this equation is solved , a new enthalpy field is found.

then comes : thermo.correct(); the simplest implementation of this virtual function is in hThermo/hThermo.C one directory up , the constructor calls (in line 71) a function calculate() (see what is below "===" line).

the implementation of calculate() begins in line 86(hThermo.C). Several values, boundary conditions , etc are updated

Can anyone tell me what is updated, Honestly i am pretty lost. is Temperature updated using the new h , and pressure , and psi ?

My question is , in C++/foam language:

solve( fvm::ddt(rho, h)+ fvm::div..........);
thermo->correct();

is equivalent to (paper/physic language)

solve a transport eq for h ;
T=(h-0.5*U^2)/Cp;
psi = 1/(R*T);

?

or what does calculate() do?

Regards

==================================================
template<class>
void hThermo<mixturetype>::calculate()
{
forAll(T_, celli)
{
const typename MixtureType::thermoType& mixture_ =
this->cellMixture(celli);

T_[celli] = mixture_.TH(h_[celli], T_[celli]);
psi_[celli] = mixture_.psi(p_[celli], T_[celli]);

mu_[celli] = mixture_.mu(T_[celli]);
alpha_[celli] = mixture_.alpha(T_[celli]);
}

forAll(T_.boundaryField(), patchi)
{
fvPatchScalarField& pp = p_.boundaryField()[patchi];
fvPatchScalarField& pT = T_.boundaryField()[patchi];
fvPatchScalarField& ppsi = psi_.boundaryField()[patchi];

fvPatchScalarField& ph = h_.boundaryField()[patchi];

fvPatchScalarField& pmu = mu_.boundaryField()[patchi];
fvPatchScalarField& palpha = alpha_.boundaryField()[patchi];

if (pT.fixesValue())
{
forAll(pT, facei)
{
const typename MixtureType::thermoType& mixture_ =
this->patchFaceMixture(patchi, facei);

ph[facei] = mixture_.H(pT[facei]);

ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
pmu[facei] = mixture_.mu(pT[facei]);
palpha[facei] = mixture_.alpha(pT[facei]);
}
}
else
{
forAll(pT, facei)
{
const typename MixtureType::thermoType& mixture_ =
this->patchFaceMixture(patchi, facei);

pT[facei] = mixture_.TH(ph[facei], pT[facei]);

ppsi[facei] = mixture_.psi(pp[facei], pT[facei]);
pmu[facei] = mixture_.mu(pT[facei]);
palpha[facei] = mixture_.alpha(pT[facei]);
}
}
}
}
===============

 All times are GMT -4. The time now is 08:42.