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

using rho in a formula in a solver

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 6, 2014, 09:39
Smile using rho in a formula in a solver
  #1
New Member
 
Gennaro
Join Date: May 2014
Posts: 23
Rep Power: 12
Gennaro is on a distinguished road
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
Gennaro is offline   Reply With Quote

Old   May 6, 2014, 09:55
Default
  #2
Senior Member
 
Join Date: Dec 2011
Posts: 121
Rep Power: 15
fshak92 is on a distinguished road
You can use this in your createFields.H :

scalar rho
(
readScalar(thermophysicalProperties.lookup("rho"))
);
fshak92 is offline   Reply With Quote

Old   May 6, 2014, 10:44
Default
  #3
New Member
 
Gennaro
Join Date: May 2014
Posts: 23
Rep Power: 12
Gennaro is on a distinguished road
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:ow((Foam:ow((T/Tlamda),5.7))*(1-Foam:ow((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 is offline   Reply With Quote

Old   May 6, 2014, 13:33
Default
  #4
New Member
 
Gennaro
Join Date: May 2014
Posts: 23
Rep Power: 12
Gennaro is on a distinguished road
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
Gennaro is offline   Reply With Quote

Old   May 7, 2014, 12:11
Default
  #5
Senior Member
 
Join Date: Dec 2011
Posts: 121
Rep Power: 15
fshak92 is on a distinguished road
Quote:
Originally Posted by Gennaro View Post
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
fshak92 is offline   Reply With Quote

Old   May 8, 2014, 06:44
Default
  #6
New Member
 
Gennaro
Join Date: May 2014
Posts: 23
Rep Power: 12
Gennaro is on a distinguished road
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
Gennaro is offline   Reply With Quote

Old   June 7, 2014, 12:00
Default
  #7
Member
 
Niu
Join Date: Apr 2014
Posts: 55
Rep Power: 12
Z.Q. Niu is on a distinguished road
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
Z.Q. Niu is offline   Reply With Quote

Old   June 8, 2014, 07:06
Default
  #8
New Member
 
Gennaro
Join Date: May 2014
Posts: 23
Rep Power: 12
Gennaro is on a distinguished road
Hi Z.Q,

rho is not defined in case of perfect gas, because the value is calculated from T and p.
Gennaro is offline   Reply With Quote

Reply

Tags
laplacianfoam, rho, thermophysicalproperties


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
icoLagrangianFoam OF1.6 myNewParticleSolver heavy_user OpenFOAM 23 June 2, 2020 03:18
Quarter Burner mesh with periosic condition SamCanuck FLUENT 2 August 31, 2011 12:34
Working directory via command line Luiz CFX 4 March 6, 2011 21:02
Low Mach number Compressible jet flow using LES ankgupta8um OpenFOAM Running, Solving & CFD 7 January 15, 2011 14:38
why the solver reject it? Anyone with experience? bearcat CFX 6 April 28, 2008 15:08


All times are GMT -4. The time now is 13:44.