# using rho in a formula in a solver

 Register Blogs Members List Search Today's Posts Mark Forums Read

 May 6, 2014, 08:39 using rho in a formula in a solver #1 New Member   Gennaro Join Date: May 2014 Posts: 23 Rep Power: 10 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

 May 6, 2014, 08:55 #2 Senior Member   Join Date: Dec 2011 Posts: 121 Rep Power: 13 You can use this in your createFields.H : scalar rho ( readScalar(thermophysicalProperties.lookup("rho")) );

 May 6, 2014, 09:44 #3 New Member   Gennaro Join Date: May 2014 Posts: 23 Rep Power: 10 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

 May 6, 2014, 12:33 #4 New Member   Gennaro Join Date: May 2014 Posts: 23 Rep Power: 10 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

May 7, 2014, 11:11
#5
Senior Member

Join Date: Dec 2011
Posts: 121
Rep Power: 13
Quote:
 Originally Posted by Gennaro 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

 May 8, 2014, 05:44 #6 New Member   Gennaro Join Date: May 2014 Posts: 23 Rep Power: 10 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 sThermo ( solidThermo::New(mesh) ); solidThermo& thermo = sThermo(); thermo.validate(args.executable(), "h", "e"); Thanks and best regards Gennaro

 June 7, 2014, 11:00 #7 Member   Niu Join Date: Apr 2014 Posts: 55 Rep Power: 10 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

 June 8, 2014, 06:06 #8 New Member   Gennaro Join Date: May 2014 Posts: 23 Rep Power: 10 Hi Z.Q, rho is not defined in case of perfect gas, because the value is calculated from T and p.

 Tags laplacianfoam, rho, thermophysicalproperties