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

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

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

Reply
 
LinkBack Thread Tools Display Modes
Old   May 30, 2011, 05:01
Default How to calculate Cp (Heat Capacity at Constant Pressure) ?
  #1
New Member
 
Gian Maria Di Stefano
Join Date: Jan 2011
Location: University of Applied Science Manno (CH)
Posts: 10
Rep Power: 6
Gian Maria is on a distinguished road
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<basicPsiThermo> 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?
Gian Maria is offline   Reply With Quote

Old   May 30, 2011, 06:20
Default
  #2
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 14
l_r_mcglashan will become famous soon enough
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.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   May 31, 2011, 09:09
Default
  #3
New Member
 
Gian Maria Di Stefano
Join Date: Jan 2011
Location: University of Applied Science Manno (CH)
Posts: 10
Rep Power: 6
Gian Maria is on a distinguished road
Hi Laurence, thanks for your reply.

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.

My "createFields.H" file start with these lines:

Quote:
Info<< "Reading thermophysical properties\n" << endl;

autoPtr<basicPsiThermo> 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<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’
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<scalarField> Cp
(
const scalarField& T,
const label patchi
) const;
Can anyone explain me how to use this information, plese?

Thanks in advance!
Gian Maria is offline   Reply With Quote

Old   May 31, 2011, 09:45
Default
  #4
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 14
l_r_mcglashan will become famous soon enough
In short: Change 'volScalarField& Cp = thermo.Cp()' to 'volScalarField Cp = thermo.Cp();'
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to achieve constant static pressure in inlet? Zou Jianfeng FLUENT 0 October 21, 2008 01:55
constant pressure drop Smith FLUENT 0 February 4, 2008 16:05
Convective Heat Transfer - Heat Exchanger Mark CFX 6 November 15, 2004 16:55
Gas pressure question Dan Moskal Main CFD Forum 0 October 24, 2002 22:02
Hydrostatic pressure in 2-phase flow modeling (long) DS & HB Main CFD Forum 0 January 8, 2000 16:00


All times are GMT -4. The time now is 02:50.