CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   using rho in a formula in a solver (https://www.cfd-online.com/Forums/openfoam-programming-development/134857-using-rho-formula-solver.html)

Gennaro May 6, 2014 08:39

using rho in a formula in a solver
 
Dear all,

I'm relatively new to OF programming and C++ programming, so I apologize for any improper question.

I need to write, starting from Laplacian foam, a solver for heat transfer in superfluid helium.

In the superfluid helium the thermal conductivity is a function of the density rho.

I need to write a line of code which would first calculate the thermal conductivity.

In the formula of the thermal conductivity there is rho.

I want rho to be read from the constant/thermophysicalProperties file, and to be icoPolynomial like the following:

equationOfState
{
rhoCoeffs<8> ( 3.6036e2 -8.3495e1 7.5874 -3.4024e-1 8.0052e-3 -9.4653e-5 4.4333e-7 0 ); //[kg/m3] // coeff a + bT+cT˛+...
}

How I can do it? What should I add in createFields.H?

It should be something like

volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
thermo.rho()
);

but I'm not sure that thermo.rho() is the right function and I don't know what else to add in order to make it work?

Thanks in advance

Gennaro

fshak92 May 6, 2014 08:55

You can use this in your createFields.H :

scalar rho
(
readScalar(thermophysicalProperties.lookup("rho"))
);

Gennaro May 6, 2014 09:44

Thanks Omid,

Your help is very appreciated. I'm trying it and I'll let you know if it works as soon as I test it.

But I first need to add a function g which is a function of rho itself.

g reads something like

g = rho*Foam::pow((Foam::pow((T/Tlamda),5.7))*(1-Foam::pow((T/Tlamda),5.7)),3);

Now I'm not sure about how I can declare g in createfields.H. Someone (who tried the same before me) declared it in the following way:

volScalarField g
(
IOobject
(
"g",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("g",dimensionSet(3,1,-9,-1,0,0,0),scalar(0.))
);

But how can this be correct if a constant value of 0 is assigned to g?

Thanks for your help

Kind regards

Gennaro

Gennaro May 6, 2014 12:33

Hi Omid,

I tried to run the solver and unfortunately your implementation of rho doesn't work, because the following lines in constant/thermophysicalProperties are not read:

thermoType
{
type heSolidThermo;
mixture pureMixture;
transport polynomial;
thermo hPolynomial;
equationOfState rhoConst;
specie specie;
energy sensibleEnthalpy;
}

mixture
{
equationOfState
{
rho 7874; // [kg/m3]
}
}

Any ideas on how to make it work?

Thanks

Genn

fshak92 May 7, 2014 11:11

Quote:

Originally Posted by Gennaro (Post 490174)
Hi Omid,

I tried to run the solver and unfortunately your implementation of rho doesn't work, because the following lines in constant/thermophysicalProperties are not read:

thermoType
{
type heSolidThermo;
mixture pureMixture;
transport polynomial;
thermo hPolynomial;
equationOfState rhoConst;
specie specie;
energy sensibleEnthalpy;
}

mixture
{
equationOfState
{
rho 7874; // [kg/m3]
}
}

Any ideas on how to make it work?

Thanks

Genn

You should have put the " rho 7874; " into the body of the thermophysicalProperties, to be able to use the code i wrote for you.
If you need to extract input data as the format you gave, you can have a look at :
http://www.cfd-online.com/Forums/ope...ictionary.html

Gennaro May 8, 2014 05:44

Hi Omid,

at the end I managed to solve the problem. In fact, if I want the thermal properties to be read in a run time selectable way according to

thermoType
{
type heRhoThermo;
mixture pureMixture;
transport const;
thermo hConst;
equationOfState perfectGas;
specie specie;
energy sensibleEnthalpy;
}

I just had to add the following:

autoPtr<solidThermo> sThermo
(
solidThermo::New(mesh)
);
solidThermo& thermo = sThermo();
thermo.validate(args.executable(), "h", "e");

Thanks and best regards

Gennaro

Z.Q. Niu June 7, 2014 11:00

Dear Omid,
I'm new to Open FOAM, I'm confused that why rho(density) is not defined in most tutorial cases such as cavity and channel395?

Regards!

Z.Q. Niu

Gennaro June 8, 2014 06:06

Hi Z.Q,

rho is not defined in case of perfect gas, because the value is calculated from T and p.


All times are GMT -4. The time now is 00:43.