8.3
general documentation
cs_air_props.h
Go to the documentation of this file.
1#ifndef __CS_AIR_PROPS_H__
2#define __CS_AIR_PROPS_H__
3
4/*============================================================================
5 * Specific laws for air properties (temperature, enthalpy)
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2024 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 * Standard C library headers
32 *----------------------------------------------------------------------------*/
33
34#include <math.h>
35
36/*----------------------------------------------------------------------------
37 * Local headers
38 *----------------------------------------------------------------------------*/
39
40#include "cs_base.h"
41
42/*----------------------------------------------------------------------------*/
43
45
46/*============================================================================
47 * Structure definition
48 *============================================================================*/
49
50/* Structure associated to general properties */
51
52typedef struct {
53
54 cs_real_t humidity0; /* Reference humidity */
55 cs_real_t cp_a; /* Specific heat of dry air */
56 cs_real_t cp_v; /* Specific heat of vapor */
57 cs_real_t cp_l; /* Specific heat of liquid water */
58 cs_real_t hv0; /* Chaleur latente */
59 cs_real_t rho_l; /* Masse volumique de l eau */
60 cs_real_t lambda_h; /* Humid air conductivity */
61 cs_real_t lambda_l; /* Water conductivity */
62 cs_real_t droplet_diam; /* Drop diameter for rain zones */
63 cs_real_t molmass_rat; /* Ratio of the molar mass (H2O) over the
64 molar mass (air) */
65 cs_real_t sigma; /* Surface tension between water and air */
66
68
70
71/*============================================================================
72 * Public function prototypes for Fortran API
73 *============================================================================*/
74
75/*============================================================================
76 * Prototypes of public function
77 *============================================================================*/
78
79/*----------------------------------------------------------------------------*/
87/*----------------------------------------------------------------------------*/
88
91
92/*----------------------------------------------------------------------------*/
100/*----------------------------------------------------------------------------*/
101
104
105/*----------------------------------------------------------------------------*/
114/*----------------------------------------------------------------------------*/
115
118 cs_real_t p0);
119
120/*----------------------------------------------------------------------------*/
129/*----------------------------------------------------------------------------*/
130
133 cs_real_t x_s);
134
135/*----------------------------------------------------------------------------*/
146/*----------------------------------------------------------------------------*/
147
150 cs_real_t x,
151 cs_real_t x_s,
152 cs_real_t t_h);
153
154/*----------------------------------------------------------------------------*/
165/*----------------------------------------------------------------------------*/
166
169 cs_real_t x,
170 cs_real_t x_s,
171 cs_real_t h_h);
172
173/*----------------------------------------------------------------------------*/
181/*----------------------------------------------------------------------------*/
182
185
186/*----------------------------------------------------------------------------*/
194/*----------------------------------------------------------------------------*/
195
198
199/*----------------------------------------------------------------------------*/
208/*----------------------------------------------------------------------------*/
209
210CS_F_HOST_DEVICE static inline cs_real_t
212{
213 cs_real_t a1, b1, c1, ps, pv;
214
215 /* T between -20 and 0 degrees C */
216
217 if (t_c <= 0.) {
218
219 a1 = 6.4147;
220 b1 = 22.376;
221 c1 = 271.68;
222
223 /* Warning if T less than -20 degrees C */
224
225 ps = a1 + (b1 * t_c)/(c1 + t_c);
226 pv = exp(ps);
227
228 }
229
230 /* T between 0 and 40 degrees C */
231
232 else if (t_c <= 40.) {
233
234 a1 = 6.4147;
235 b1 = 17.438;
236 c1 = 239.78;
237 ps = a1 + (b1 * t_c)/(c1 + t_c);
238 pv = exp(ps);
239 }
240
241 /* T between 40 and 80 degrees C */
242
243 else {
244
245 const cs_real_t t0 = 273.16;
246 const cs_real_t ax = 8.2969;
247 const cs_real_t ay = 4.76955;
248 const cs_real_t a0 = 0.78614;
249 const cs_real_t a2 = 5.028;
250 const cs_real_t a3 = 0.000150475;
251 const cs_real_t a4 = 0.00042873;
252 cs_real_t tt, px, py, g1, g2, g3, g4;
253
254 a1 = 10.7954;
255
256 tt = t_c/t0;
257 /* T greater than 80 degrees C, clipped at 80°C */
258 if (t_c > 80.)
259 tt = 80./t0;
260 px = ax * tt;
261 py = ay * tt/(1. + tt);
262 g1 = a1 * tt/(1. + tt);
263 g2 = -a2 * log10(1. + tt);
264 g3 = a3 * (1. - 1./pow(10.,px));
265 g4 = a4 * (pow(10., py) - 1.);
266 ps = a0 + g1 + g2 + g3 + g4;
267 pv = pow(10., ps) * 100.;
268
269 }
270
271 return pv;
272}
273
274/*----------------------------------------------------------------------------*/
283/*----------------------------------------------------------------------------*/
284
285CS_F_HOST_DEVICE static inline cs_real_t
287 cs_real_t p)
288{
289 cs_real_t pv;
290 cs_real_t x_s = 0.;
291
292 /* Warning if T less than -20 degrees C */
293 /* T between -20 and 80 degrees C */
294
295 if ((t_c <= 80.)) {
296
297 pv = cs_air_pwv_sat(t_c);
298 x_s = 0.622 * pv/(p-pv);
299
300 }
301
302 /* T more than 80 degrees C */
303
304 else if (t_c > 80.) {
305
306 x_s = 0.5 + 0.001*t_c;
307
308 }
309
310 return x_s;
311}
312
313/*----------------------------------------------------------------------------*/
323/*----------------------------------------------------------------------------*/
324
327 cs_real_t p);
328
329/*----------------------------------------------------------------------------*/
338/*----------------------------------------------------------------------------*/
339
342
343/*----------------------------------------------------------------------------*/
352/*----------------------------------------------------------------------------*/
353
356
357/*----------------------------------------------------------------------------*/
369/*----------------------------------------------------------------------------*/
370
371void
373 cs_real_t t_liq,
374 cs_real_t p,
375 cs_real_t *yw_liq,
376 cs_real_t *t_h,
377 cs_real_t *rho_h,
378 cs_real_t *beta_h);
379
380/*----------------------------------------------------------------------------*/
393/*----------------------------------------------------------------------------*/
394
397 cs_real_t rho0,
400 cs_real_t molmassrat,
401 cs_real_t t_h);
402
403/*----------------------------------------------------------------------------*/
404
406
407#endif /* __CS_AIR_PROPERTIES_H__ */
static CS_F_HOST_DEVICE cs_real_t cs_air_pwv_sat(cs_real_t t_c)
Computes the saturation water vapor pressure function of the temperature (in Celsius)
Definition: cs_air_props.h:211
cs_real_t cs_liq_h_to_t(cs_real_t h_l)
Calculation of the temperature of liquid water.
Definition: cs_air_props.cpp:353
cs_air_fluid_props_t * cs_glob_air_props
Definition: cs_air_props.cpp:88
cs_real_t cs_air_yw_sat(cs_real_t t_c, cs_real_t p)
Calculation of the air water mass fraction at saturation for a given temperature.
Definition: cs_air_props.cpp:396
cs_real_t cs_air_cp_humidair(cs_real_t x, cs_real_t x_s)
Calculation of the Cp of humid air.
Definition: cs_air_props.cpp:261
cs_real_t cs_liq_t_to_h(cs_real_t t_l)
Calculation of the specific enthalpy of liquid water.
Definition: cs_air_props.cpp:374
void cs_rho_humidair(cs_real_t yw_h, cs_real_t t_liq, cs_real_t p, cs_real_t *yw_liq, cs_real_t *t_h, cs_real_t *rho_h, cs_real_t *beta_h)
Calculation of the density of humid air.
Definition: cs_air_props.cpp:467
cs_real_t cs_air_x_to_yw(const cs_real_t x)
Convert the absolute humidity of humid air to the air water mass fraction qwt = Ym = mw/mh.
Definition: cs_air_props.cpp:421
static CS_F_HOST_DEVICE cs_real_t cs_air_x_sat(cs_real_t t_c, cs_real_t p)
Calculation of the air humidity at saturation for a given temperature.
Definition: cs_air_props.h:286
cs_real_t cs_air_h_l(cs_real_t t_l)
Calculation water mass enthalpy.
Definition: cs_air_props.cpp:126
cs_real_t cs_air_rho_humidair(cs_real_t x, cs_real_t rho0, cs_real_t p0, cs_real_t t0, cs_real_t molmassrat, cs_real_t t_h)
Calculation of the density of humid air.
Definition: cs_air_props.cpp:553
cs_real_t cs_air_yw_to_x(cs_real_t qw)
Convert the air water mass fraction qwt = Ym = mw/mh to the absolute humidity of humid air.
Definition: cs_air_props.cpp:442
cs_real_t cs_air_hvap(cs_real_t t_vap)
Calculation water vapor mass enthalpy.
Definition: cs_air_props.cpp:144
cs_real_t cs_air_dxsath(cs_real_t th, cs_real_t p0)
Calculation of the derivate of the absolute humidity at saturation.
Definition: cs_air_props.cpp:168
cs_real_t cs_air_t_humidair(cs_real_t cp_h, cs_real_t x, cs_real_t x_s, cs_real_t h_h)
Calculation of the temperature of humid air.
Definition: cs_air_props.cpp:325
cs_real_t cs_air_h_humidair(cs_real_t cp_h, cs_real_t x, cs_real_t x_s, cs_real_t t_h)
Calculation of the specific enthalpy of humid air.
Definition: cs_air_props.cpp:292
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
#define CS_F_HOST_DEVICE
Definition: cs_defs.h:561
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
#define END_C_DECLS
Definition: cs_defs.h:543
@ p
Definition: cs_field_pointer.h:67
double precision, dimension(:,:,:), allocatable qw
Definition: atimbr.f90:108
real(c_double), pointer, save ps
reference pressure (to compute potential temp: 1.0d+5)
Definition: atincl.f90:161
real(c_double), pointer, save p0
reference pressure for the total pressure.
Definition: cstphy.f90:170
real(c_double), pointer, save t0
reference temperature.
Definition: cstphy.f90:217
real(c_double), dimension(:), pointer, save th
temperature (in K)
Definition: ppthch.f90:119
real(c_double), dimension(:), pointer, save c1
Definition: cpincl.f90:109
real(c_double), dimension(:), pointer, save a2
Definition: cpincl.f90:109
real(c_double), dimension(:), pointer, save a1
Definition: cpincl.f90:109
real(c_double), dimension(:), pointer, save b1
Definition: cpincl.f90:109
Definition: cs_air_props.h:52
cs_real_t cp_l
Definition: cs_air_props.h:57
cs_real_t cp_v
Definition: cs_air_props.h:56
cs_real_t humidity0
Definition: cs_air_props.h:54
cs_real_t sigma
Definition: cs_air_props.h:65
cs_real_t droplet_diam
Definition: cs_air_props.h:62
cs_real_t lambda_l
Definition: cs_air_props.h:61
cs_real_t molmass_rat
Definition: cs_air_props.h:63
cs_real_t rho_l
Definition: cs_air_props.h:59
cs_real_t cp_a
Definition: cs_air_props.h:55
cs_real_t lambda_h
Definition: cs_air_props.h:60
cs_real_t hv0
Definition: cs_air_props.h:58