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

the problem in writing the energy conservation equation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 26, 2015, 08:52
Default the problem in writing the energy conservation equation
  #1
New Member
 
Join Date: Jan 2015
Posts: 14
Rep Power: 11
Gary51075607 is on a distinguished road
Hi, all

I want to solve the energy conservation equations as attached in the OpenFoam.

The problem lies in the second and third terms in the right. For example, i can not use the keyword grap(p) in the OpenFoam. if i shoud add them as a source term?

Thanks

Gary
Attached Files
File Type: docx energy conservation.docx (20.5 KB, 39 views)
Gary51075607 is offline   Reply With Quote

Old   January 26, 2015, 09:38
Default
  #2
Senior Member
 
Join Date: Mar 2010
Location: Germany
Posts: 154
Rep Power: 16
cutter is on a distinguished road
Hi,

could you please repost the formula as image file. Unfortunately LibreOffice is not able to open the file properly. This excludes many potential readers of your post.

Please also post the code you've already written. This allows to understand your problems more easily.

Have a look at http://www.openfoam.org/docs/user/pr...#x9-670003.1.3, section 'Equation representation'.

Cutter
cutter is offline   Reply With Quote

Old   January 26, 2015, 10:02
Default
  #3
Senior Member
 
dkxls's Avatar
 
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19
dkxls will become famous soon enough
Quote:
Originally Posted by Gary51075607 View Post
i can not use the keyword grap(p) in the OpenFoam.
Code:
fvc::grad(p)
You might want to have a look at exciting OpenFOAM solvers, e.g. the code in UEqn.H or EEqn.H is pretty self explanatory.

Also, can you please write the equation you want to solve properly in the forum using the [math] tags, e.g. \nabla{p} to denote the gradient of p?
Have a look at this http://www.cfd-online.com/Forums/sit...ne-forums.html
dkxls is offline   Reply With Quote

Old   January 26, 2015, 22:16
Default
  #4
New Member
 
Join Date: Jan 2015
Posts: 14
Rep Power: 11
Gary51075607 is on a distinguished road
The energy conservation is as follows:
{\nabla \bullet \left( \rho c_p \vec u T \right)}={\nabla \bullet \left( \lambda \nabla T \right)}  + T {\nabla \bullet \left( \rho c_p \vec u \right)} - \frac{T}{\rho} \left( \frac{\partial \rho}{\partial T} \right)_p \vec u \bullet {\nabla p}
The thermophysical properties, including the density, heat capacity and thermal conductivity, are the functions of pressure and temperature.

The code i have written is listed below:
Code:
fvScalarMatrix TEqn
(
    fvm::div(phi, T)
  - fvm::laplacian(lamdaEff, T)
 ==
   -T/rho*drho/dT*U*grad(p)

);
The problem lies in the second and third terms in the right of the equation. I don't know how can l add the second term and the form i write the third term is wrong.

Thanks

Gary

Last edited by Gary51075607; January 27, 2015 at 01:57.
Gary51075607 is offline   Reply With Quote

Old   January 27, 2015, 04:53
Default
  #5
New Member
 
Join Date: Feb 2014
Posts: 24
Rep Power: 12
hajott is on a distinguished road
You should calculate \left(\frac{\partial \rho}{\partial T}\right)_p from your equation of state. For example, for an ideal gas
\left(\frac{\partial \rho}{\partial T}\right)_p=-\frac \rho T.
hajott is offline   Reply With Quote

Old   January 27, 2015, 06:41
Default
  #6
Senior Member
 
dkxls's Avatar
 
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19
dkxls will become famous soon enough
Quote:
Originally Posted by Gary51075607 View Post
The thermophysical properties, including the density, heat capacity and thermal conductivity, are the functions of pressure and temperature.
...
The problem lies in the second and third terms in the right of the equation. I don't know how can l add the second term and the form i write the third term is wrong.
Without checking your actual equation, I see there several possible problems:
  1. You are using several fields OpenFOAM does not provide per default, i.e. you need to make sure that all fields like lamdaEff, drho and dT are correctly initialized.
  2. OpenFOAM denotes the thermal diffusivity for temperature typically with kappa and not lambda, hence make sure you are really using the right fields there. (see src/thermophysicalModels/basic/heThermo/heThermo.H)
  3. You are still missing fvc for the pressure gradient!
  4. You are multiplying several scalar (T,rho) fields with two vector fields (U,\nabla(p)), I'm not quite sure, but that code should give you a tensor fields if I'm not mistaken now.
Altogether I see very little to no benefit in writing the thermal energy in this way. I admit that the energy equation in OF versions 2.1 and later is a bit more involved, but they work just fine.

If you are really just interested in the thermal energy, why not solve for sensible enthalpy as it was done up to OF version 2.0, see here for example:
https://github.com/OpenFOAM/OpenFOAM...pleFoam/hEqn.H
dkxls is offline   Reply With Quote

Old   January 29, 2015, 04:26
Default
  #7
New Member
 
Join Date: Jan 2015
Posts: 14
Rep Power: 11
Gary51075607 is on a distinguished road
Thanks, dkxls.
Sorry to forget fvc.
In my case, the thermophysical properties, including the density, heat capacity, enthalpy, viscosity and thermal conductivities, are strongly depended on the temperature and pressure. So i want the obtain the temperature directly from the energy equation.

The fields, such as lamdaEff, drho and dT has been correctly defined and initialized.

Could i group the terms of T {\nabla \bullet \left( \rho c_p \vec u \right)} and - \frac{T}{\rho} \left( \frac{\partial \rho}{\partial T} \right)_p \vec u \bullet {\nabla p} as the source terms? And then how to write the source term?
Gary51075607 is offline   Reply With Quote

Old   January 29, 2015, 08:25
Default
  #8
Senior Member
 
dkxls's Avatar
 
Armin
Join Date: Feb 2011
Location: Helsinki, Finland
Posts: 156
Rep Power: 19
dkxls will become famous soon enough
Quote:
Originally Posted by Gary51075607 View Post
In my case, the thermophysical properties, including the density, heat capacity, enthalpy, viscosity and thermal conductivities, are strongly depended on the temperature and pressure. So i want the obtain the temperature directly from the energy equation.
For me it always was more natural to solve a transport equation for a conserved quantity, i.e. here enthalpy h, and compute the derived quantities, i.e. temperature T, from dh = c_p dT.
This is the way it's done in pretty much all OpenFOAM solvers. Also, this is a widely used approach in combustion simulation, where you have very strong dependencies on temperature.
Note that a formulation in terms of internal energy is equivalent to the above, it's merely a matter of taste!

Quote:
Originally Posted by Gary51075607 View Post
Could i group the terms of T {\nabla \bullet \left( \rho c_p \vec u \right)} and - \frac{T}{\rho} \left( \frac{\partial \rho}{\partial T} \right)_p \vec u \bullet {\nabla p} as the source terms? And then how to write the source term?
Well it doesn't matter how you call it, it boils down to the same thing anyway. Effectively it's an explicit term on the right hand side of the equation (i.e. computed from old time values).
dkxls 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
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 07:27
flow solver - energy equation problem ufocfd Main CFD Forum 0 May 19, 2013 16:00
Source term energy equation for reactive flows DaIN Main CFD Forum 0 October 6, 2011 16:11
how to disable energy equation for for non-newton yueroo FLUENT 2 April 3, 2001 23:11
Why FVM for high-Re flows? Zhong Lei Main CFD Forum 23 May 14, 1999 14:22


All times are GMT -4. The time now is 12:54.