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

Enthalpy to temperature

Register Blogs Community New Posts Updated Threads Search

Like Tree9Likes
  • 1 Post By isabel
  • 6 Post By adhiraj
  • 2 Post By lfgmarc

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 1, 2010, 06:25
Default Enthalpy to temperature
  #1
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Hi all,
I am new to OpenFOAM. I was looking at where OpenFOAM does the h to T (or hs top T) conversion, and I noted that they use a Newton iteration mthod. But when I try to trace the sepcific heat they use in this equation, they seem to use Cp=Cp(T) and not Cp=Cp(T,Yi). This is the file I am talking about:-
$FOAM/src/thermophysicalModels/specie/thermo/janaf
Can anyone confirm/explain this?
Thanks in advance.
adhiraj is offline   Reply With Quote

Old   July 17, 2011, 05:39
Default h to T conversion
  #2
Member
 
Farshad
Join Date: Oct 2010
Posts: 76
Rep Power: 16
Farshad_Noravesh is on a distinguished road
Hi,

I have exactly the same question.

Thanks

Farshad
Farshad_Noravesh is offline   Reply With Quote

Old   July 17, 2011, 11:37
Default Enthalpy to T
  #3
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
I have dug deep since this post, and have the answers. When they go for the h->T conversion they hold the composition fixed, and define a new 'gas' with the composition averaged thermal properties. It is the Cp of this mixture gas that is (rightly) used to compute T.
adhiraj is offline   Reply With Quote

Old   February 13, 2012, 11:51
Default
  #4
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Hi all,

I am looking for the extract of the code where the conversion from h to T is done but I do not find it. Can anybody tell me where it is?
isabel is offline   Reply With Quote

Old   February 13, 2012, 18:35
Default
  #5
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Check under
Quote:
$FOAM_SRC/thermophysicalModels/specie/thermo/specieThermo
adhiraj is offline   Reply With Quote

Old   February 14, 2012, 04:44
Default
  #6
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Thank you very much. I found the iteration in these lines:


// return the temperature corresponding to the value of the
// thermodynamic property f, given the function f = F(T) and dF(T)/dT
template<class thermo>
inline scalar specieThermo<thermo>::T
(
scalar f,
scalar T0,
scalar (specieThermo<thermo>::*F)(const scalar) const,
scalar (specieThermo<thermo>::*dFdT)(const scalar) const
) const
{
scalar Test = T0;
scalar Tnew = T0;
scalar Ttol = T0*tol_;
int iter = 0;

do
{
Test = Tnew;
Tnew = Test - ((this->*F)(Test) - f)/(this->*dFdT)(Test);

if (iter++ > maxIter_)
{
FatalErrorIn
(
"specieThermo<thermo>::T(scalar f, scalar T0, "
"scalar (specieThermo<thermo>::*F)(const scalar) const, "
"scalar (specieThermo<thermo>::*dFdT)(const scalar) const"
") const"
) << "Maximum number of iterations exceeded"
<< abort(FatalError);
}

} while (mag(Tnew - Test) > Ttol);

return Tnew;
}


There is something I do not understhand. What does “this->” means?
mm.abdollahzadeh likes this.
isabel is offline   Reply With Quote

Old   February 14, 2012, 10:25
Default
  #7
Member
 
Tibo
Join Date: Jun 2011
Posts: 68
Rep Power: 15
megacrout is on a distinguished road
I might be wrong but I don´t think this is an OF-specific function.
Ecosia (instead of googling it) "this pointer" or "this pointer c++" or such.
Tibo
megacrout is offline   Reply With Quote

Old   February 14, 2012, 10:43
Default
  #8
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
It is a C++ keyword. "this" acts like a pointer to the object whose member function is under consideration.
adhiraj is offline   Reply With Quote

Old   February 15, 2012, 10:15
Default
  #9
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Dear friends,

I have another doubt about these files. Where are defined the functions F and dFdT?
isabel is offline   Reply With Quote

Old   February 15, 2012, 10:25
Default
  #10
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
They are the function and its derivative.
The Newton iteration in this case calculates T, given F(T) and dF/dT(T).
The function gets pointers to the functions F and dF/dt.

If the energy variable is enthalpy h, then F=h(T) and dF/dt=Cp(T).
If it is internal energy e, then F=e and dF/dT=Cv(T).

The code resolves these at runtime, and sends the appropriate pointers to the Newton iteration routine.
Sun, mgg, daire6 and 3 others like this.
adhiraj is offline   Reply With Quote

Old   February 16, 2012, 05:32
Default
  #11
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Dear friends,

Thank you very much for your help. I need to simulate melting of a solid. In that case, the enthalpy is given by the following equation:




where L is the latent heat and alpha_l the mass fraction of the liquid phase.

How do I implement the term alpha_l*L in the functions F and dFdT?

Last edited by isabel; February 16, 2012 at 06:11.
isabel is offline   Reply With Quote

Old   March 21, 2012, 19:58
Default
  #12
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Hi,
I would use
Code:
    F=H
    dFdT=Cp
This is because, H=H(T) is the relationship you are trying to invert.
And, at that point you will typically hold the composition fixed, so that \alpha, L and H_{ref} are fixed. So, dFdT=Cp.
This of course assumes that L is not a function of T.
adhiraj is offline   Reply With Quote

Old   July 20, 2012, 23:00
Question A Little question?
  #13
Member
 
lfgmarc's Avatar
 
Luis Felipe Gutierrez Marcantoni
Join Date: Oct 2010
Location: Cordoba-Argentina
Posts: 47
Rep Power: 16
lfgmarc is on a distinguished road
Send a message via MSN to lfgmarc
Hi, I have a little question,

I understand that if i.e, the energy variable is enthalpy F=h(T) and dF/dT=Cp(T), my question is in where it is defined in the code that F and dF/dt take these variables as arguments.

Thanks in advance.
qjh888 and patricks like this.
__________________
Felipe G

Last edited by lfgmarc; July 21, 2012 at 10:14.
lfgmarc is offline   Reply With Quote

Old   June 13, 2014, 12:07
Default Enthalpy-temperature for melting problem
  #14
Senior Member
 
Mohammad Shakil Ahmmed
Join Date: Oct 2012
Location: AUS
Posts: 137
Rep Power: 15
ahmmedshakil is on a distinguished road
Hi isabel ,
Will you please guide me how you implemented the melting problem ?
thanks in advance.

Quote:
Originally Posted by isabel View Post
Dear friends,

Thank you very much for your help. I need to simulate melting of a solid. In that case, the enthalpy is given by the following equation:




where L is the latent heat and alpha_l the mass fraction of the liquid phase.

How do I implement the term alpha_l*L in the functions F and dFdT?
ahmmedshakil is offline   Reply With Quote

Old   October 31, 2016, 10:36
Default function "f"
  #15
New Member
 
Mahdi Nabil
Join Date: Sep 2015
Posts: 9
Rep Power: 11
Mhmnabil is on a distinguished road
Hi All,

I just don't know where that "f" is coming from in OpenFOAM??? I know "F" and "dFdT", but I don't understand "f" in the Newton's routine!!


Quote:
Originally Posted by adhiraj View Post
They are the function and its derivative.
The Newton iteration in this case calculates T, given F(T) and dF/dT(T).
The function gets pointers to the functions F and dF/dt.

If the energy variable is enthalpy h, then F=h(T) and dF/dt=Cp(T).
If it is internal energy e, then F=e and dF/dT=Cv(T).

The code resolves these at runtime, and sends the appropriate pointers to the Newton iteration routine.
Mhmnabil is offline   Reply With Quote

Old   October 31, 2016, 10:38
Default Newton's Routine
  #16
New Member
 
Mahdi Nabil
Join Date: Sep 2015
Posts: 9
Rep Power: 11
Mhmnabil is on a distinguished road
What is that "f" in the routine?! Where does it come from?

Quote:
Originally Posted by isabel View Post
Thank you very much. I found the iteration in these lines:


// return the temperature corresponding to the value of the
// thermodynamic property f, given the function f = F(T) and dF(T)/dT
template<class thermo>
inline scalar specieThermo<thermo>::T
(
scalar f,
scalar T0,
scalar (specieThermo<thermo>::*F)(const scalar) const,
scalar (specieThermo<thermo>::*dFdT)(const scalar) const
) const
{
scalar Test = T0;
scalar Tnew = T0;
scalar Ttol = T0*tol_;
int iter = 0;

do
{
Test = Tnew;
Tnew = Test - ((this->*F)(Test) - f)/(this->*dFdT)(Test);

if (iter++ > maxIter_)
{
FatalErrorIn
(
"specieThermo<thermo>::T(scalar f, scalar T0, "
"scalar (specieThermo<thermo>::*F)(const scalar) const, "
"scalar (specieThermo<thermo>::*dFdT)(const scalar) const"
") const"
) << "Maximum number of iterations exceeded"
<< abort(FatalError);
}

} while (mag(Tnew - Test) > Ttol);

return Tnew;
}


There is something I do not understhand. What does “this->” means?
Mhmnabil is offline   Reply With Quote

Old   May 31, 2017, 03:26
Default
  #17
Member
 
Janry
Join Date: Oct 2015
Posts: 46
Rep Power: 11
qjh888 is on a distinguished road
Could anybody help me to find where it is defined in the code that F and dF/dt take these variables as arguments??

Thanks!
qjh888 is offline   Reply With Quote

Reply


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
Problem with zeroGradient wall BC for temperature - Total temperature loss cboss OpenFOAM 12 October 1, 2018 07:36
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 07:27
temperature / enthalpy fields depending on type of fvPatchField astein OpenFOAM Programming & Development 0 June 28, 2010 08:10
chemical reaction - decompostition La S. Hyuck CFX 1 May 23, 2001 01:07
Solve Enthalpy or Temperature? sheng Main CFD Forum 5 January 22, 1999 10:40


All times are GMT -4. The time now is 15:51.