57
ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model Teaching within: CFD with OpenSource software (TME050) Isabelle Choquet [email protected] University West 2015-09-28 1 [email protected]

ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

  • Upload
    others

  • View
    13

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x)

How to implement a new thermophysical model

Teaching within: CFD with OpenSource software (TME050)

Isabelle [email protected]

University West

2015-09-28

[email protected]

hani
Sticky Note
The reader should be careful when copy-pasting (as usual), since some spaces may be omitted and some dashes are of the wrong type. Go ahead line-by-line and make sure that the commands work.
Page 2: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Exemples of thermodynamic and transport properties: density ρ equation of state (Ia, see slide 4) heat capacity 𝐶𝐶𝑣𝑣 , 𝐶𝐶𝑝𝑝 internal energy e, enthalpy h diffusivity D,α … viscosity μ thermal conductivity κ electric conductivity

Depend on: temperature T pressure P fluid (possibly solid) composition

Involved in heat transfer, compressible flow, multiphase problems, combustion, etc.

thermophysical properties ( Ib, see slide 5)

transport properties (Ic, see slide 6)

Mixture (II, see slide 7)

Pure mixture (Ia-Ic, see slide 4-6)

2

hani
Cross-Out
hani
Inserted Text
a
Page 3: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Content Slides

Thermophysical models available in OpenFOAM …………….………….. 4-11

Other examples of thermophysical models ………………………………… 12-14

Problem needing a new thermophysical model …………………………... 15-30- Example- Heat transfer solvers in OpenFOAM, thermoFOAM

Implement a new transport property (𝜅𝜅) ……………………………………. 31-42-Import, declare, define, link to solver, run a case

Implement a new equation of state (for 𝜌𝜌)and new thermodynamic properties (ℎ and 𝐶𝐶𝑝𝑝) …………………………. 43-58-Import, declare, define, link to solver, run a case

3

Page 4: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Models available in OpenFOAM (see UserGuide) (1/8)

Ia

4

Page 5: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Ib

Models available in OpenFOAM (see UserGuide) (2/8)

5

Page 6: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Ic

Models available in OpenFOAM (see UserGuide) (3/8)

6

Page 7: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Ia, Ib & Ic

Ia, Ib & Icfor all species

&suited mixingrules

II

Models available in OpenFOAM (see UserGuide) (4/8)

7

Page 8: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Combines Ia, Ib, Ic & II

Models available in OpenFOAM (see UserGuide) (5/8)

III

8

Page 9: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Example: go to tuturials/heatTransfer/buoyantSimpleFoam/buoyantCavity/constantin thermophysicalProperties change ”transport const” to ”transport dummy”and run the solver buoyantSimpleFoam; it returns the list of thermophysical models available for this solver:

Models available in OpenFOAM (for a given solver) (6/8)

IaIbIcIIIII

… (+ 2 following slides)

9

hani
Cross-Out
hani
Inserted Text
$FOAM_TUTORIALS
hani
Sticky Note
Here is a suggested procedure: run cp -r $FOAM_TUTORIALS/heatTransfer/buoyantSimpleFoam/buoyantCavity . cd buoyantCavity sed -ie s/"\(transport[ \t]*\) const;"/"\1 dummy;"/g constant/thermoPhysicalProperties buoyantSimpleFoam
Page 10: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Models available in OpenFOAM (for a given solver) (7/8)

10

Page 11: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Models available in OpenFOAM (for a given solver) (8/8)

11

Page 12: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

From ”Recommended values of thermophysical properties for selected commetcial alloys”, Kenneth C Mills, ASM International, ISBN 0-87170-753-5, (page 213)

Other example of thermophysical model : phase change in solid state (1/3)

12

Page 13: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

From “Thermal plasma properties for Ar–Cu, Ar–Fe and Ar–Al mixtures used in welding plasmas processes: II. Transport coefficients at atmospheric pressure”, Y Cressault, A B Murphy, Ph Teulet, A Gleizes and M Schnick, J. Phys. D: Appl. Phys. 46 (2013) 415207

Other example of thermophysical model : thermal plasma (2/3)

13

Page 14: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Other example of thermophysical model : thermal plasma (3/3)

From “Thermal plasma properties for Ar–Cu, Ar–Fe and Ar–Al mixtures used in welding plasmas processes: II. Transport coefficients at atmospheric pressure”, Y Cressault, A B Murphy, Ph Teulet, A Gleizes and M Schnick, J. Phys. D: Appl. Phys. 46 (2013) 415207

14

Page 15: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Governing equation

𝜕𝜕 𝜌𝜌 𝐶𝐶𝑣𝑣𝑇𝑇𝜕𝜕𝜕𝜕

= 𝛻𝛻 𝜅𝜅 𝛻𝛻.𝑇𝑇

with 𝜌𝜌,𝐶𝐶𝑣𝑣 and 𝜅𝜅 function of T obtained

from kinetic theory for 𝑇𝑇 ∈ 200; 20000 K

Rk: need a heatTransfer solver

Example of problem needing a new thermophysical model : (1/16) thermal conduction in a high temperature argon gas

From ”Plasma arc welding simulation with openFOAM”, M. Sass-Tisovskaya, Lic. thesis, Dept. Applied Mechanics, Chalmers University of Technology, 2009 (page 30)

This equation of state 𝜌𝜌(𝑇𝑇)needs to be implemented

15

Page 16: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

From ”Plasma arc welding simulation with openFOAM”, M. Sass-Tisovskaya, Lic. thesis, Dept. Applied Mechanics, Chalmers University of Technology, 2009 (page 31)

Example of problem needing a new thermophysical model : (2/16) thermal conduction in a high temperature argon gas

This thermodynamic property𝐶𝐶𝑝𝑝(𝑇𝑇) needs to be implemented

This transport property𝜅𝜅(𝑇𝑇) needs to be implemented

16

Page 17: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Example of problem needing a new thermophysical model : (3/16) thermal conduction in a high temperature argon gas

From ”Thermal Plasmas, Fundamentals and Applications”, Boulos M.I., Fauchais P. and Pfender E.: Vol. 1, Plenum Press, New York, 1994 (page 235)

17

Page 18: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Example of problem needing a new thermophysical model : (4/16) thermal conduction in a high temperature argon gas

From ”Plasma arc welding simulation with openFOAM”, M. Sass-Tisovskaya, Lic. thesis, Dept. Applied Mechanics, Chalmers University of Technology, 2009 (page 31) 18

Page 19: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Heat transfer solvers in OpenFOAM: (see UserGuide) : (5/16)

19

Page 20: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Copy the solver in your user directory and rename it:cd $WM_PROJECT_DIRcp -r --parents applications/solvers/heatTransfer/thermoFoam $WM_PROJECT_USER_DIRcd $WM_PROJECT_USER_DIR/applications/solvers/heatTransfermv thermoFoam myThermoFoamcd myThermoFoammv thermoFoam.C myThermoFoam.C

Modify Make/files tomyThermoFoam.CEXE = $(FOAM_USER_APPBIN)/myThermoFoam

Clean and compilewcleanrm -r Make/linux* (to clean also the Debug version in the system)wmake

OpenFOAM solver heatTransfer/thermoFoam: (6/16)

20

Page 21: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

OpenFOAM solver heatTransfer/thermoFoam: (7/16)

Parts of thermoFoam involving a thermophysical model

Include a thermophysic library; that object is used on the next slide.

Include an energy conservation equation (see next slide)

Create the object”thermo”

21

Page 22: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

”he” is either the specific internal energy or the specific enthalpy(choice done when preparing a case, in the dictionaryconstant/thermophysicalProperties)

OpenFOAM solver heatTransfer/thermoFoam: (8/16) Part of the energy conservation equation EEqn.H

This total energy conservation equationis explained in the next slides

22

Page 23: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

𝜕𝜕𝜕𝜕𝜕𝜕

𝜌𝜌 �ℎ + 𝐾𝐾 + 𝛻𝛻 � 𝜌𝜌𝒗𝒗 �ℎ + 𝐾𝐾 − 𝜕𝜕𝑝𝑝𝜕𝜕𝜕𝜕− 𝛻𝛻 � 𝑞𝑞 = 0 where q = 𝛼𝛼𝛻𝛻�ℎ

specific enthalpy �ℎ or specific internal energy �̂�𝑒

(9/16) Energy conservation -total energy of flowing fluid: 𝜌𝜌 �ℎ + 𝐾𝐾

Enthalpy :

Kinetic energy: K

Thermal diffusivity : 𝛼𝛼

e

23

Page 24: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

𝜕𝜕𝜕𝜕𝜕𝜕

𝜌𝜌 �ℎ + 𝐾𝐾 + 𝛻𝛻 � 𝜌𝜌𝒗𝒗 �ℎ + 𝐾𝐾 − 𝜕𝜕𝑝𝑝𝜕𝜕𝜕𝜕− 𝛻𝛻 � 𝑞𝑞 = 0 where q = 𝛼𝛼𝛻𝛻�ℎ

specific kinetic energy K

(10/16) Energy conservation -total energy of flowing fluid: 𝜌𝜌 �ℎ + 𝐾𝐾

24

Page 25: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

𝜕𝜕𝜕𝜕𝜕𝜕

𝜌𝜌 �ℎ + 𝐾𝐾 + 𝛻𝛻 � 𝜌𝜌𝒗𝒗 �ℎ + 𝐾𝐾 − 𝜕𝜕𝑝𝑝𝜕𝜕𝜕𝜕− 𝛻𝛻 � 𝑞𝑞 = 0 where q = 𝛼𝛼𝛻𝛻�ℎ

(11/16)

If ”he” is the specific enthalpy "�ℎ” This is not true (as he is not ”e”)

so this part is not used

while this term can be calculated.

Energy conservation -total energy of flowing fluid: 𝜌𝜌 �ℎ + 𝐾𝐾

In fact in thermoFOAM dpdt (created in createFields) it is set to zero since this is a frozen field 25

hani
Cross-Out
hani
Inserted Text
"he"
Page 26: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

(12/16) Energy conservation -total energy of flowing fluid: 𝜌𝜌 �ℎ + 𝐾𝐾 - in a control volume moving at 𝐯𝐯𝐛𝐛

If ”he” is the specific internal energy �̂�𝑒 This is true

so this term can be calculated

while this part is not used

Type equation here.

𝜕𝜕𝜕𝜕𝜕𝜕

𝜌𝜌 �ℎ + 𝐾𝐾 + 𝛻𝛻 � 𝜌𝜌𝒗𝒗 �ℎ + 𝐾𝐾 − 𝜕𝜕𝑝𝑝𝜕𝜕𝜕𝜕− 𝛻𝛻 � 𝑞𝑞 = 0 where q = 𝛼𝛼𝛻𝛻�ℎ

Enthalpy : e

26

Page 27: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

𝜕𝜕𝜕𝜕𝜕𝜕

𝜌𝜌 �ℎ + 𝐾𝐾 + 𝛻𝛻 � 𝜌𝜌𝒗𝒗 �ℎ + 𝐾𝐾 − 𝜕𝜕𝑝𝑝𝜕𝜕𝜕𝜕− 𝛻𝛻 � 𝑞𝑞 = 0 where q = 𝛼𝛼𝛻𝛻�ℎ

conduction heat flux

(13/16) Energy conservation -total energy of flowing fluid: 𝜌𝜌 �ℎ + 𝐾𝐾 - in a control volume moving at 𝐯𝐯𝐛𝐛

Enthalpy :

Kinetic energy: K

Thermal diffusivity : 𝛼𝛼

e

27

Page 28: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

alphaEff (the thermal diffusivity) is made of 2 contributions:

alphaEff = alpha laminar + alpha turbulent

It is set in solver/heatTransfer/thermoFoam/setAlphaEff.H

via the turbulence library : src/turbulenceModels

the ”turbulenceModels” library is linked to the thermo library src/thermophysicalModelsso if the file names of thermophysical library(*.so) are changes, also the turbulenceModels need to be recompiled with linksto the new library names

alpha turbulent is defined in src/turbulenceModels

alpha laminar is defined in src/thermophysicalModels (as transport property)

(14/16)

𝛼𝛼 = 𝜅𝜅/(𝜌𝜌𝑐𝑐𝑝𝑝)

28

Page 29: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

What do we need to implement ?

The heat flux is : 𝑞𝑞 = − alphaEff 𝛻𝛻 ℎ𝑒𝑒where the laminar part of alphaEff is either:

𝜅𝜅 /𝐶𝐶𝑝𝑝 if ”he” represents the specific enthalpy h (we will work with this case and from now assume he=h)or

𝜅𝜅 /𝐶𝐶𝑣𝑣 if ”he” represents the specific internal energy e

So we need to implement the thermal conductivity 𝜅𝜅 = 𝜅𝜅 𝑇𝑇 - plotted slide 16 (right).the density, and the specific heat capacity, respectively plotted slide 15 and 16, so that 𝐶𝐶𝑝𝑝 = 𝜌𝜌 𝑇𝑇 . 𝑐𝑐𝑝𝑝 𝑇𝑇 .

But this is not sufficient since the conservative variable in EEqn.H is the specific enthalpy hwhile the termodynamic and transport properties depend on another variable: the temperature T. So we also need to determine T from h. This is done solving (with an iterative procedure already implemented in OpenFOAM) the equation of state

Δℎ = ∫𝑇𝑇𝑟𝑟𝑟𝑟𝑟𝑟𝑇𝑇 𝑐𝑐𝑝𝑝 𝑇𝑇 𝑑𝑑𝑇𝑇

It implies that we also need to implement the specific enthalpy h = h(T).

(15/16)

29

Page 30: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

This implementation can be done in 2 parts

1. First, the implementation of the new transport property 𝜅𝜅 (the thermal conductivity) for a temperaturerange from 200K to 20kK. It will be implemented, compiled and tested.

Rk. The resultant thermophysical model will not be consistent from a physical point of view (as it will be associated with constant enthalpy, constant specific heat, …). But it runs and has the advantage of allowing splitting the implementation work in smaller parts (easier to debug).

2. Implement the new thermodynamic properties 𝐶𝐶𝑝𝑝 and ℎ and the new equation of state 𝜌𝜌. These must be implemented together to be able to derive the temperature 𝑇𝑇 from h(T)using 𝑐𝑐𝑝𝑝 𝑇𝑇 .

Rk. The resultant thermophysical model will then be consistent from a physical point of view.It can be observed that the consistent model runs faster than the non-consistent modelimplemented in the 1st part.

(16/16)

30

Page 31: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Implement a new transport property 𝚱𝚱: main steps (1/12)

Step 0 : copy and rename suited parts of the library ”thermophysicalModels”

Step 1 : declare the new transport property model (see Ic)*

Step 2 : define the new transport property model (see Ic)*

Step 3: declare the new thermophysical model (see III)**

Step 4 : link the new thermophysical model to the solver

Step 5 : call the new thermophysical model in a test case

*Slide 6 ** Slide 7

31

Page 32: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Prepare your library thermophysicalModels/specie

Copy the folder “specie” of the library in your user directory :foamcp -r --parents src/thermophysicalModels/specie $WM_PROJECT_USER_DIRcd $WM_PROJECT_USER_DIR/src/thermophysicalModelscd specie

Modify the Make/files to:

LIB = $(FOAM_USER_LIBBIN)/libspecie

Clean & compileYou should be in the directory speciewclean librm –r Make/kinux*wmake libso

Now the executable is in your working space, and your ”libspecie” will be accessed in priority (instead of the OpenFOAM executablein $FOAM_LIBBIN, even if the name is the same)

Then this name of executable can be kept unchanged. Doingso, no need to import the turbulence library, no need to rename its links (in Make/options) to your thermo library, and no need to recompile the turbulence library (See slide28): the $FOAM_LIBBIN turbulence library will link to your ownthermo library.

Implement a new transport property 𝚱𝚱: step 0 (2/12)

Contrary to the usual recommendation, it is not renamed

32

hani
Cross-Out
hani
Inserted Text
linux
hani
Comment on Text
This should be a regular dash
Page 33: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Copy the folder “basic” of the library in your user directory and rename it:foamcp -r --parents src/thermophysicalModels/basic $WM_PROJECT_USER_DIRcd $WM_PROJECT_USER_DIR/src/thermophysicalModelscd basic

Modify Make/files to:

LIB = $(FOAM_USER_LIBBIN)/libfluidThermophysicalModels

Similar to the previous slide

Implement a new transport property 𝚱𝚱: step 0 (3/12)

Prepare your library thermophysicalModels/basic

33

Page 34: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Modify the Make/options file to

Clean the dependencies and compileYou should be in the directory basicwclean librm –r Make/linux*wmake libso

(since basic needs to be linked to specie at compilation)

Implement a new transport property 𝚱𝚱: step 0 (4/12)

(1) Gives the path to access your own files located in specie

(2) Indicates that the compiler must 1st look in your ownworking space (in $FOAM_USER_LIBBIN) to pick the libraries listed below. If not found there (ex. may be lfiniteVolume is not in your space $FOAM_USER_LIBBIN) the compiler will next look in the OpenFOAM space (in $FOAM_LIBBIN).If still not found it will complain.

(3) Can check the path used by reading the messageswritten on the screen during compilation (see next slide)

thermophysicalModels/specie/lnInclude

34

hani
Comment on Text
This should be a regular dash
Page 35: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

(5/12)

Here it can be checked that the library ”finiteVolume” is pickedin/home/…/OpenFOAM2.3.x/src

There it can be checked that”myThermophysicalModels/specie” is picked in/home/…/isabelle-2.3.x/src

How to check that the compilerlinks the desired libraries ?

… 35

hani
Cross-Out
hani
Inserted Text
$WM_PROJECT_DIR/src
hani
Cross-Out
hani
Inserted Text
$WM_PROJECT_USER_DIR/src
Page 36: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

In specie/include/thermoPhysicsTypes.H add the following lines

Declare the new transport model in user src/thermophysicalModels/specie

Name given to the new transport model

Name given to the new thermophysical model

To access the new transport model

Implement a new transport property 𝚱𝚱: step 1 (6/12)

36

Page 37: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Copy and rename an existing model:cd transportcp -r const kineticArcd kineticArmv constTransport.C kineticArTransport.Cmv constTransport.H kineticArTransport.Hmv constTransportI.H kineticArTransportI.H

open the files one by one and replace“constTransport” (NOT just “const” !) with “kineticArTransport”

update the “instantiated type name“ in kineticArTransport.H

so look for “instantiated” and below (only there!) replace “return “const” “ with “ return “kineticAr” “

Clean the dependencies and compile specie wclean librm –r Make/linux*wmake libso

(Prepare the structure, you should be in specie)

Implement a new transport property 𝚱𝚱: step 2 (7/12)

Define the new transport model in user src/thermophysicalModels/specie

Use:sed –i.old s/constTransport/kineticArTransport/g*

37

hani
Comment on Text
Should be a regular dash
hani
Comment on Text
The space before the * is not seen in the slide, but it should be there
hani
Sticky Note
Here you can also use the sed command, but be careful not to substitute all "const". So, we do: sed -i.old s/"const<"/"kineticAr<"/g kineticArTransport.H
Page 38: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Go in the directory kineticAr and open kineticArTransportI.H

Comment the original model

insert the newmodel provided in the fileAr_Data_ThermalConduct

Implement a new transport property 𝚱𝚱: step 2 (8/12)

thermal conductivity

38

hani
Sticky Note
Only Cp in the code
hani
Sticky Note
You can put that file in the same directory as the kineticArTransportI.H file, but with the name Ar_Data_thermalConduct.H (so that it will be linked into the lnInclude directory. Then just insert the following line in the file at that location: #include "Ar_Data_thermalConduct.H"
Page 39: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Clean the dependencies (“wclean lib” and “rm –r Make/linux*”) and compile mySpecie (“wmake libso”)

Comment the original model

Writethe new model

Implement a new transport property 𝚱𝚱: step 2 (9/12)

39

hani
Comment on Text
This should be a regular dash
Page 40: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Declare the new thermophysical model in user src/myThermophysicalModels/myBasic

In basic/rhoThermo/rhoThermos.C add the following lines

Clean the dependencies (“wclean lib” and “ rm –r Make/linux* ”) Compile myBasic (“wmake libso”)

New combination of Ia, Ib, Ic, II and III (see slides 3 to 7) defining a new thermophysical model

Implement a new transport property 𝚱𝚱: step 3 (10/12)

Declare the new thermophysical model in user src/thermophysicalModels/basic

In the header. . .

40

hani
Comment on Text
This should be a regular dash
Page 41: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Link the new thermophysicalModel library to the solver

In myThermoFoam/Make/options do the following changes to access the new library

Implement a new transport property 𝚱𝚱: step 4 (11/12)

Check that the solver is using your library:ldd `which thermoFoam` | grep specieldd `which thermoFoam` | grep specie 41

hani
Cross-Out
hani
Cross-Out
hani
Inserted Text
myThermoFoam
hani
Sticky Note
This actually only shows that any code that want to link to libspecie.so will use the one shown after execution of this line. That one is found using the LD_LIBRARY_PATH environment variable, which lists all the directories where it will look for those .so-files. There are three directories where it could be: The user working directory, a site directory, and the reglar installation directory. Since it finds one in the user working directory it will use that one. However, if the header file included i the solver has been modified, the solver must be re-compiled.
hani
Sticky Note
There is a missing "src/"
Page 42: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Call the new thermophysicalModel in a test case

Use the test case provided: blockThermoFoamCase.tgz

Run blockMesh

Run this case with the solver thermoFoam (the original one)

Copy blockThermoFoamCase to blockNewThermoFoamCase and clean

Update constant/thermophysicalPropersties to

Run this case with the solver myThermoFoam linked to the new thermophysical library

Compare the results : do a plotOverLine of temperature for both cases

Implement a new transport property 𝚱𝚱: step 5 (12/12)

42

hani
Sticky Note
Corrections stopped here.
Page 43: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

This implementation can be done in 2 parts

1. First, the implementation of the new transport property 𝜅𝜅 (the thermal conductivity) for a temperaturerange from 200K to 20kK. It will be implemented, compiled and tested.

Rk. The resultant thermophysical model will not be consistent from a physical point of view (as it will be associated with constant enthalpy, constant specific heat, …). But it runs and has the advantage of allowing splitting the implementation work in smaller parts (easier to debug).

2. Implement the new thermodynamic properties 𝐶𝐶𝑝𝑝 and ℎ and the new equation of state 𝜌𝜌. These must be implemented together since the aim is to be able to derive the temperature 𝑇𝑇 from h(T)and to calculate the heat capacity 𝐶𝐶𝑝𝑝 = 𝜌𝜌 𝑇𝑇 . 𝑐𝑐𝑝𝑝 𝑇𝑇

Rk. The resultant thermophysical model will then be consistent from a physical point of view.It can also be observed that the consitent model runs faster than the non-consistent modelimplemented in the 1st step

Part 1 is done. We now start this 𝟐𝟐𝒏𝒏𝒏𝒏part

(1/16)

43

Page 44: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

(2/16)

Step 1 : declare (see Ia, b) #,* the new thermodynamic properties and the new equation of state

Step 2 : define (see Ia) # the new equation of state

Step 3 : define (see Ib)* the new thermodynamic properties

Step 4: declare (see III)** the new thermophysical model

Step 5 : link the new thermophysical model to the solver

Step 6 : call the new thermophysical model in a test case and run

#See slide 4 *See slide 5 ** See slide 7

Implement new thermodynamic properties and a new equation of state

44

Page 45: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

(3/16)

In specie/include/thermoPhysicsTypes.Hadd in the header

and modify to

Implement new thermodynamic properties and equation of state: step 1

Name given to the new

thermodynamic model&

equation of state

To access the new thermodynamic model& the new equation of state

Declare the new models in user src/thermophysicalModels/specieDeclare the new thermophysical model in user src/thermophysicalModels/basic

45

Page 46: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Copy and rename an existing model:cd equationOfStatecp -r perfectGas rhoKineticArcd rhoKineticArmv perfectGas.C rhoKineticAr.Cmv perfectGas.H rhoKineticAr.Hmv perfectGastI.H rhoKineticArI.Hopen the files one by one and replace

“perfectGas” with “rhoKineticAr”

Prepare the structure

46Isabelle Choquet - 2014-09-16

(4/16) Define a new equation of state in in user src/myThermophysicalModels/mySpecie

Implement new thermodynamic properties and equation of state: step 2

Define a new equation of state model in user src/thermophysicalModels/specie

Page 47: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Open rhoKineticArI.H and do the following modifications:

Comment the original model

insert the newmodel provided in the filedensity_Ar_Data

(5/16) Implement new thermodynamic properties and equation of state: step 2

density

47

Page 48: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Comment the original model (ideal gas)

Write the new modelRk: psi is set to zero since the plasma modelimplemented here is mechanically incompressible, and thermaly expansible: 𝜌𝜌 𝑃𝑃,𝑇𝑇 = 𝜌𝜌(𝑇𝑇).

(6/16)

Modify also

Implement new thermodynamic properties and equation of state: step 2

compressibility

48

Page 49: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Comment the original model (ideal gas)

Write the new model

(7/16)

Compressibility factor

Implement new thermodynamic properties and equation of state: step 2

Modify also

49

Page 50: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Comment the original model

write the new model

(8/16) Implement new thermodynamic properties and equation of state: step 2

Modify also

50

Page 51: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Copy and rename an existing model:cd thermocp -r hConst hKineticArcd hKineticArmv hConstThermo.C hKineticArThermo.Cmv hConstThermo.H hKineticArThermo.Hmv hConstThermoI.H hKineticArThermoI.H

open the files one by one and replace“hConstThermo” with “hKineticArThermo”

update the “instantiated type name” in hKineticArThermo.Hso look for “instantiated” and below replace “return “hConst<” “ with “ return “hKineticAr<” “

Prepare the structure

(9/16) Define the new properties ℎ,𝐶𝐶𝑝𝑝 in user src/myThermophysicalModels/mySpecie

Implement new thermodynamic properties and equation of state: step 3user src/thermophysicalModels/specie

51

Page 52: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Implement new thermodynamic properties and equation of state: step 2

Open hKineticArI.H and do the following modifications:

Comment the original model

insert the newmodel provided in the fileheatCapacity_Cp_Data

(10/16)

Heat capacityat constant pressure

52

Page 53: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Implement new thermodynamic properties and equation of state: step 3 (11/16)

Modify also

Comment the original model

insert the new model provided in the file enthalpy_Data.Rk. The reference temperature was set so that Hf is zero. …

absolute enthalpyHf is the enthalpy of formation

53

Page 54: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Modify also

Comment the original constant model

Write the new temperature dependent model.Rk. As the non constant thermodynamic models in openFOAM depend on both pressure p and temperature, we write ha(p,T) although p is not used.

(12/16) Implement new thermodynamic properties and equation of state: step 3

sensible enthalpy

54

Page 55: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Implement new thermodynamic properties and equation of state: step 3

Modify also

Comment the original model

Write the new modelRk. Here the plasma is considered as one-fluid. The ionization reactionswere accounted for when tabulating the absolute enthalpy ha. For a one-fluid model hc is the enthalpy of formation. Here it is set to zero (see the remark on slide 53).

(13/16)

chemical enthalpy

Clean and compilewclean lib rm –r Make/linux*

wmake libso

55

Page 56: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

In basic/rhoThermo/rhoThermos.C add the following lines in the header

and change to:

Clean and compilewclean lib rm –r Make/linux*

wmake libso

(14/16) Implement new thermodynamic properties and equation of state: step 4

Declare the new thermophysical model in user src/myThermophysicalModels/myBasic

To access the new thermodynamic model& the new equation of state

Name given to the new

thermodynamic model&

equation of state

user src/thermophysicalModels/basic

56

Page 57: ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) · ThermophysicalModels library in OpenFOAM-2.3.x (or 2.4.x) How to implement a new thermophysical model. Teaching within:

Copy blockThermoFoamCase to blockKineticArThermoFoamCase and clean (wclean)

Update constant/thermophysicalProperties to

Run this case with the solver MyThermoFoam (now linked to your new thermophysical library)

Compare the results : do a plotOverLine of temperature for both cases

(15/16) Implement new thermodynamic properties and equation of state: step 6

Call the new thermophysical model in a test case and run

57