CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to calculate Cp (Heat Capacity at Constant Pressure) ? (http://www.cfd-online.com/Forums/openfoam-programming-development/88901-how-calculate-cp-heat-capacity-constant-pressure.html)

 Gian Maria May 30, 2011 05:01

How to calculate Cp (Heat Capacity at Constant Pressure) ?

Hi foamers,

I'm trying to improve a new solver in OpenFOAM, but I have some problems.
I need to calculate Cp (Heat Capacity at Constant Pressure), and I must add it in the standard solver "rhoPorousSimpleFoam".

I tried to add a line in "createFields.H", but it doesn't work.

Quote:
 // these lines are already present autoPtr pThermo ( basicPsiThermo::New(mesh) ); basicPsiThermo& thermo = pThermo(); volScalarField& p = thermo.p(); volScalarField& h = thermo.h(); const volScalarField& psi = thermo.psi(); // this is my add volScalarField& Cp = thermo.Cp();
In "basicPsiThermo" Cp is called with "T" and "patchi" as arguments. Must I do the same?

Or can I load properties of air by an external file?

 l_r_mcglashan May 30, 2011 06:20

What does the error say? Is it a compiler error or a runtime error? You will probably find the mistake is in the type you have given for the variable Cp. Check it against the return type of Cp in basicThermo.

 Gian Maria May 31, 2011 09:09

So, I will explain you what is my problem.

I want to create a new solutor, and I need for my calculations some variables:
- enthalpy
- pressure
- heat costant Cp
- rho

But whenever h, p and rho are already gived, I must find the way to calculate Cp.

Quote:
 Info<< "Reading thermophysical properties\n" << endl; autoPtr pThermo ( basicPsiThermo::New(mesh) ); basicPsiThermo& thermo = pThermo(); volScalarField rho ( IOobject ( "rho", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), thermo.rho() ); volScalarField& p = thermo.p(); volScalarField& h = thermo.h(); const volScalarField& psi = thermo.psi();
so I tried to load Cp value using the same templates:

Quote:
 volScalarField& Cp = thermo.Cp();
But when I try to compile I have this error:

Quote:
 createFields.H:27: error: invalid initialization of non-const reference of type ‘Foam::volScalarField&’ from a temporary of type ‘Foam::tmp >’
Why compare this error?
How can I move to correct it?

PS: if I check in "basicPsiThermo" file, I find this

Quote:
 // Fields derived from thermodynamic state variables //- Temperature [K] virtual const volScalarField& T() const; //- Heat capacity at constant pressure for patch [J/kg/K] virtual tmp Cp ( const scalarField& T, const label patchi ) const;
Can anyone explain me how to use this information, plese?