programmer's documentation
cs_cf_thermo.h
Go to the documentation of this file.
1 #ifndef __CS_CF_THERMO_H__
2 #define __CS_CF_THERMO_H__
3 
4 /*============================================================================
5  * Thermodynamic laws for the compressible module
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2015 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 
31 #include "cs_defs.h"
32 
33 /*----------------------------------------------------------------------------
34  * Standard C library headers
35  *----------------------------------------------------------------------------*/
36 
37 /*----------------------------------------------------------------------------
38  * Local headers
39  *----------------------------------------------------------------------------*/
40 
41 /*----------------------------------------------------------------------------*/
42 
44 
45 /*=============================================================================
46  * Public function prototypes
47  *============================================================================*/
48 
49 /*----------------------------------------------------------------------------
50  * Set variability of isobaric specific heat and isochoric specific heat
51  * according to the chosen thermodynamic law.
52  *----------------------------------------------------------------------------*/
53 
54 void
56 
57 /*----------------------------------------------------------------------------
58  * Retrieve molar mass.
59  *
60  * parameters:
61  * xmasml --> molar mass
62  *----------------------------------------------------------------------------*/
63 
64 void
66 
67 /*----------------------------------------------------------------------------
68  * Compute gamma.
69  *
70  * parameters:
71  * gamma --> ratio of specific heat
72  *----------------------------------------------------------------------------*/
73 
74 void
76 
77 /*----------------------------------------------------------------------------
78  * Initialize density, total energy and isochoric specific heat
79  * according to the chosen thermodynamic law using the default parameters.
80  *
81  * parameters:
82  * isuite <-- indicator of resumed computation
83  * l_size <-- local size
84  *----------------------------------------------------------------------------*/
85 
86 void
88 
89 // TODO: the check function should be generalized (pass the name as argument).
90 
91 /*----------------------------------------------------------------------------
92  * Check the positivity of the pressure.
93  *
94  * parameters:
95  * pres <-- array of pressure values
96  * l_size <-- l_size of the array
97  *----------------------------------------------------------------------------*/
98 
99 void
101  cs_lnum_t l_size);
102 
103 /*----------------------------------------------------------------------------
104  * Check the positivity of the internal energy.
105  *
106  * parameters:
107  * ener <-- array of total energy values
108  * l_size <-- l_size of the array
109  * vel <-- array of velocity values
110  *----------------------------------------------------------------------------*/
111 
112 void
114  cs_lnum_t l_size,
115  cs_real_3_t *vel);
116 
117 /*----------------------------------------------------------------------------
118  * Check the positivity of the density given by the user.
119  *
120  * parameters:
121  * dens <-- array of density values
122  * l_size <-- l_size of the array
123  *----------------------------------------------------------------------------*/
124 
125 void
127  cs_lnum_t l_size);
128 
129 /*----------------------------------------------------------------------------
130  * Check strict positivity of temperature (Celsius) given by the user.
131  *
132  * parameters:
133  * temp <-- array of temperature values
134  * l_size <-- l_size of the array
135  *----------------------------------------------------------------------------*/
136 
137 void
139  cs_lnum_t l_size);
140 
141 /*----------------------------------------------------------------------------
142  * Compute temperature and total energy from density and pressure.
143  *
144  * parameters:
145  * pres <-- array of pressure values
146  * dens <-- array of density values
147  * temp --> array of temperature values
148  * ener --> array of total energy values
149  * vel <-- array of velocity component values
150  * l_size <-- l_size of the array
151  *----------------------------------------------------------------------------*/
152 
153 void
155  cs_real_t *dens,
156  cs_real_t *temp,
157  cs_real_t *ener,
158  cs_real_3_t *vel,
159  cs_lnum_t l_size);
160 
161 /*----------------------------------------------------------------------------
162  * Compute density and total energy from pressure and temperature
163  *
164  * parameters:
165  * pres <-- array of pressure values
166  * temp <-- array of temperature values
167  * dens --> array of density values
168  * ener --> array of total energy values
169  * vel <-- array of velocity component values
170  * l_size <-- l_size of the array
171  *----------------------------------------------------------------------------*/
172 
173 void
175  cs_real_t *temp,
176  cs_real_t *dens,
177  cs_real_t *ener,
178  cs_real_3_t *vel,
179  cs_lnum_t l_size);
180 
181 /*----------------------------------------------------------------------------
182  * Compute density and temperature from pressure and total energy.
183  *
184  * parameters:
185  * pres <-- array of pressure values
186  * ener <-- array of total energy values
187  * dens --> array of density values
188  * temp --> array of temperature values
189  * vel <-- array of velocity component values
190  * l_size <-- l_size of the array
191  *----------------------------------------------------------------------------*/
192 
193 void
195  cs_real_t *ener,
196  cs_real_t *dens,
197  cs_real_t *temp,
198  cs_real_3_t *vel,
199  cs_lnum_t l_size);
200 
201 /*----------------------------------------------------------------------------
202  * Compute pressure and total energy from density and temperature
203  *
204  * parameters:
205  * dens <-- array of density values
206  * temp <-- array of temperature values
207  * pres --> array of pressure values
208  * ener --> array of total energy values
209  * vel <-- array of velocity component values
210  * l_size <-- l_size of the array
211  *----------------------------------------------------------------------------*/
212 
213 void
215  cs_real_t *temp,
216  cs_real_t *pres,
217  cs_real_t *ener,
218  cs_real_3_t *vel,
219  cs_lnum_t l_size);
220 
221 /*----------------------------------------------------------------------------
222  * Compute pressure and temperature from density and total energy.
223  *
224  * parameters:
225  * dens <-- array of density values
226  * ener <-- array of total energy values
227  * pres --> array of pressure values
228  * temp --> array of temperature values
229  * vel <-- array of velocity component values
230  * l_size <-- l_size of the array
231  *----------------------------------------------------------------------------*/
232 
233 void
235  cs_real_t *ener,
236  cs_real_t *pres,
237  cs_real_t *temp,
238  cs_real_3_t *vel,
239  cs_lnum_t l_size);
240 
241 /*----------------------------------------------------------------------------
242  * Compute square of sound velocity for perfect gas.
243  *
244  * parameters:
245  * pres <-- array of pressure values
246  * dens <-- array of density values
247  * c2 --> array of the values of the square of sound velocity
248  * l_size <-- l_size of the array
249  *----------------------------------------------------------------------------*/
250 
251 void
253  cs_real_t *dens,
254  cs_real_t *c2,
255  cs_lnum_t l_size);
256 
257 /*----------------------------------------------------------------------------
258  * Compute the thermal expansion coefficient for a perfect gas.
259  *
260  * parameters:
261  * dens <-- array of density values
262  * beta --> array of beta values
263  * l_size <-- l_size of the array
264  *----------------------------------------------------------------------------*/
265 
266 void
268  cs_real_t *beta,
269  cs_lnum_t l_size);
270 
271 /*----------------------------------------------------------------------------
272  * Compute the isochoric specific heat:
273  *
274  * parameters:
275  * cp <-- array of isobaric specific heat values
276  * cv --> array of isochoric specific heat values
277  * l_size <-- l_size of the array
278  *----------------------------------------------------------------------------*/
279 
280 void
282  cs_real_t *cv,
283  cs_lnum_t l_size);
284 
285 /*----------------------------------------------------------------------------
286  * Compute entropy from pressure and density:
287  *
288  * parameters:
289  * dens <-- array of density values
290  * pres <-- array of pressure values
291  * entr --> array of total energy values
292  * l_size <-- l_size of the array
293  *----------------------------------------------------------------------------*/
294 
295 void
297  cs_real_t *pres,
298  cs_real_t *entr,
299  cs_lnum_t l_size);
300 
301 /*----------------------------------------------------------------------------
302  * Compute wall boundary condition values.
303  *
304  * parameters:
305  * wbfa --> output work array
306  * wbfb --> output work array
307  * face_id <-- boundary face index
308  *----------------------------------------------------------------------------*/
309 
310 void
312  cs_real_t *wbfb,
313  cs_lnum_t face_id);
314 
315 /*----------------------------------------------------------------------------
316  * Compute subsonic outlet boundary conditions values.
317  *
318  * parameters:
319  * bc_en <--> total energy values at boundary faces
320  * bc_pr <--> pressure values at boundary faces
321  * bc_vel <--> velocity values at boundary faces
322  * face_id <-- boundary face index
323  *----------------------------------------------------------------------------*/
324 
325 void
327  cs_real_t *bc_pr,
328  cs_real_3_t *bc_vel,
329  cs_lnum_t face_id);
330 
331 /*----------------------------------------------------------------------------
332  * Compute inlet boundary condition with total pressure and total
333  * enthalpy imposed.
334  *
335  * parameters:
336  * bc_en <--> total energy values at boundary faces
337  * bc_pr <--> pressure values at boundary faces
338  * bc_vel <--> velocity values at boundary faces
339  * face_id <-- boundary face number
340  *----------------------------------------------------------------------------*/
341 
342 void
344  cs_real_t *bc_pr,
345  cs_real_3_t *bc_vel,
346  cs_lnum_t face_id);
347 
348 /*----------------------------------------------------------------------------
349  * Compute epsilon sup for perfect gas.
350  *
351  * parameters:
352  * dens <-- array of density values
353  * eps_sup --> epsilon sup array
354  * l_size <-- l_size of the array
355  *----------------------------------------------------------------------------*/
356 
357 void
359  cs_real_t *eps_sup,
360  cs_lnum_t l_size);
361 
362 /*----------------------------------------------------------------------------
363  * This subroutine is a driver allowing to call the appropriate
364  * thermodynamical functions depending on the quantities provided by the user.
365  * Hence it is only used during the initialization step and at the boundaries
366  * of type supersonic inlet. It is described in the following how to select the
367  * quantity to be returned.
368  *
369  * When calling the user subroutine, the integer 'iccfth' specifies which
370  * calculation has to be performed (and which quantity has to be returned).
371  * The values for 'iccfth' for each case are provided below.
372  *
373  * The variables are referred to using a different index i:
374  *
375  * - pressure: 2
376  * - density: 3
377  * - temperature: 5
378  * - internal energy: 7
379  * - entropy: 13
380  *
381  * iccfth is as follows, depending on which quantity needs to be computed:
382  * - variables at cell centers from variable i and variable j (i<j):
383  * iccfth = i*j*10000
384  * - variables at boundary faces from variable i and variable j (i<j):
385  * iccfth = i*j*10000+900
386  *
387  * Detailed values of iccfth and corresponding computations:
388  *
389  * Values at the cell centers:
390  *
391  * - temperature and energy from pressure and density: iccfth = 60000
392  * - density and energy from pressure and temperature: iccfth = 100000
393  * - density and temperature from pressure and energy: iccfth = 140000
394  * - pressure and energy from density and temperature: iccfth = 150000
395  * - pressure and temperature from density and energy: iccfth = 210000
396  *
397  * Values at the faces for boundary conditions:
398  * - temperature and energy from pressure and density: iccfth = 60900
399  * - density and energy from pressure and temperature: iccfth = 100900
400  * - density and temperature from pressure and energy: iccfth = 140900
401  * - pressure and energy from density and temperature: iccfth = 150900
402  * - pressure and temperature from density and energy: iccfth = 210900
403  *
404  * parameters:
405  * iccfth --> id of computation
406  * face_id --> face index if the computation is for a B.C.
407  * bc_en <-- total energy values at boundary faces
408  * bc_pr <-- pressure values at boundary faces
409  * bc_tk <-- temperature values at boundary faces
410  * bc_vel <-- velocity values at boundary faces
411  *----------------------------------------------------------------------------*/
412 
413 void
414 cs_cf_thermo(const int iccfth,
415  cs_lnum_t face_id,
416  cs_real_t *bc_en,
417  cs_real_t *bc_pr,
418  cs_real_t *bc_tk,
419  cs_real_3_t *bc_vel);
420 
421 /*----------------------------------------------------------------------------*/
422 
424 
425 #endif /* __CS_CF_THERMO_H__ */
void cs_cf_check_density(cs_real_t *dens, cs_lnum_t l_size)
Check the positivity of the density given by the user.
Definition: cs_cf_thermo.c:333
void cs_cf_thermo_cv(cs_real_t *cp, cs_real_t *cv, cs_lnum_t l_size)
Compute the isochoric specific heat:
Definition: cs_cf_thermo.c:713
void cs_cf_thermo_c_square(cs_real_t *pres, cs_real_t *dens, cs_real_t *c2, cs_lnum_t l_size)
Compute square of sound velocity:
Definition: cs_cf_thermo.c:643
void cs_cf_thermo_pe_from_dt(cs_real_t *dens, cs_real_t *temp, cs_real_t *pres, cs_real_t *ener, cs_real_3_t *vel, cs_lnum_t l_size)
Compute pressure and total energy from density and temperature.
Definition: cs_cf_thermo.c:549
#define BEGIN_C_DECLS
Definition: cs_defs.h:419
void cs_cf_set_thermo_options(void)
Set variability of isobaric specific heat and isochoric specific heat according to the chosen thermod...
Definition: cs_cf_thermo.c:94
void cs_cf_thermo_te_from_dp(cs_real_t *pres, cs_real_t *dens, cs_real_t *temp, cs_real_t *ener, cs_real_3_t *vel, cs_lnum_t l_size)
Compute temperature and total energy from density and pressure.
Definition: cs_cf_thermo.c:411
double precision, dimension(ncharm), save beta
Definition: cpincl.f90:97
Definition: cs_field_pointer.h:98
void cs_cf_check_internal_energy(cs_real_t *ener, cs_lnum_t l_size, cs_real_3_t *vel)
Check the positivity of the internal energy.
Definition: cs_cf_thermo.c:290
integer, save isuite
Definition: optcal.f90:381
double precision, dimension(ncharm), save c2
Definition: cpincl.f90:226
void cs_cf_thermo(const int iccfth, cs_lnum_t face_id, cs_real_t *bc_en, cs_real_t *bc_pr, cs_real_t *bc_tk, cs_real_3_t *bc_vel)
This subroutine is a driver allowing to call the appropriate thermodynamical functions depending on t...
Definition: cs_cf_thermo.c:1488
void cs_cf_thermo_default_init(int isuite)
Initialize density, total energy and isochoric specific heat according to the chosen thermodynamic la...
Definition: cs_cf_thermo.c:190
void cs_cf_thermo_wall_bc(cs_real_t *wbfa, cs_real_t *wbfb, cs_lnum_t face_id)
Compute wall boundary condition values.
Definition: cs_cf_thermo.c:771
void cs_cf_thermo_subsonic_outlet_bc(cs_real_t *bc_en, cs_real_t *bc_pr, cs_real_3_t *bc_vel, cs_lnum_t face_id)
Compute subsonic outlet boundary conditions values.
Definition: cs_cf_thermo.c:866
void cs_cf_thermo_gamma(cs_real_t *gamma)
Compute .
Definition: cs_cf_thermo.c:136
void cs_cf_check_temperature(cs_real_t *temp, cs_lnum_t l_size)
Check strict positivity of temperature (Celsius) given by the user.
Definition: cs_cf_thermo.c:370
void cs_cf_thermo_dt_from_pe(cs_real_t *pres, cs_real_t *ener, cs_real_t *dens, cs_real_t *temp, cs_real_3_t *vel, cs_lnum_t l_size)
Compute density and temperature from pressure and total energy;.
Definition: cs_cf_thermo.c:502
void cs_cf_check_pressure(cs_real_t *pres, cs_lnum_t l_size)
Check the positivity of the pressure.
Definition: cs_cf_thermo.c:249
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:307
double precision, dimension(ncharm), save gamma
Definition: cpincl.f90:97
void cs_cf_thermo_beta(cs_real_t *dens, cs_real_t *beta, cs_lnum_t l_size)
Compute the thermal expansion coefficient:
Definition: cs_cf_thermo.c:681
void cs_cf_thermo_s_from_dp(cs_real_t *dens, cs_real_t *pres, cs_real_t *entr, cs_lnum_t l_size)
Compute entropy from pressure and density:
Definition: cs_cf_thermo.c:737
void cs_cf_get_molar_mass(cs_real_t *xmasml)
Retrieve molar mass.
Definition: cs_cf_thermo.c:116
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
void cs_cf_thermo_ph_inlet_bc(cs_real_t *bc_en, cs_real_t *bc_pr, cs_real_3_t *bc_vel, cs_lnum_t face_id)
Compute inlet boundary condition with total pressure and total enthalpy imposed.
Definition: cs_cf_thermo.c:1101
#define END_C_DECLS
Definition: cs_defs.h:420
double cs_real_t
Definition: cs_defs.h:296
void cs_cf_thermo_pt_from_de(cs_real_t *dens, cs_real_t *ener, cs_real_t *pres, cs_real_t *temp, cs_real_3_t *vel, cs_lnum_t l_size)
Compute pressure and temperature from density and total energy.
Definition: cs_cf_thermo.c:592
void cs_cf_thermo_de_from_pt(cs_real_t *pres, cs_real_t *temp, cs_real_t *dens, cs_real_t *ener, cs_real_3_t *vel, cs_lnum_t l_size)
Compute density and total energy from pressure and temperature.
Definition: cs_cf_thermo.c:458
void cs_cf_thermo_eps_sup(cs_real_t *dens, cs_real_t *eps_sup, cs_lnum_t l_size)
Compute epsilon sup:
Definition: cs_cf_thermo.c:1420