9.1
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-2025 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 "base/cs_base.h"
41
42/*----------------------------------------------------------------------------*/
43
45
46/*============================================================================
47 * Structure definition
48 *============================================================================*/
49
50/* Structure associated to general properties */
51
52typedef struct {
53
69
71
72/*============================================================================
73 * Public function prototypes for Fortran API
74 *============================================================================*/
75
76/*============================================================================
77 * Prototypes of public function
78 *============================================================================*/
79
80/*----------------------------------------------------------------------------*/
88/*----------------------------------------------------------------------------*/
89
92
93/*----------------------------------------------------------------------------*/
101/*----------------------------------------------------------------------------*/
102
105
106/*----------------------------------------------------------------------------*/
115/*----------------------------------------------------------------------------*/
116
119 cs_real_t p0);
120
121/*----------------------------------------------------------------------------*/
130/*----------------------------------------------------------------------------*/
131
134 cs_real_t x_s);
135
136/*----------------------------------------------------------------------------*/
147/*----------------------------------------------------------------------------*/
148
151 cs_real_t x,
152 cs_real_t x_s,
153 cs_real_t t_h);
154
155/*----------------------------------------------------------------------------*/
166/*----------------------------------------------------------------------------*/
167
170 cs_real_t x,
171 cs_real_t x_s,
172 cs_real_t h_h);
173
174/*----------------------------------------------------------------------------*/
182/*----------------------------------------------------------------------------*/
183
186
187/*----------------------------------------------------------------------------*/
195/*----------------------------------------------------------------------------*/
196
199
200/*----------------------------------------------------------------------------*/
209/*----------------------------------------------------------------------------*/
210
211CS_F_HOST_DEVICE static inline cs_real_t
213{
214 cs_real_t a1, b1, c1, ps, pv;
215
216 /* T between -20 and 0 degrees C */
217
218 if (t_c <= 0.) {
219
220 a1 = 6.4147;
221 b1 = 22.376;
222 c1 = 271.68;
223
224 /* Warning if T less than -20 degrees C */
225
226 ps = a1 + (b1 * t_c)/(c1 + t_c);
227 pv = exp(ps);
228
229 }
230
231 /* T between 0 and 40 degrees C */
232
233 else if (t_c <= 40.) {
234
235 a1 = 6.4147;
236 b1 = 17.438;
237 c1 = 239.78;
238 ps = a1 + (b1 * t_c)/(c1 + t_c);
239 pv = exp(ps);
240 }
241
242 /* T between 40 and 80 degrees C */
243
244 else {
245
246 const cs_real_t t0 = 273.16;
247 const cs_real_t ax = 8.2969;
248 const cs_real_t ay = 4.76955;
249 const cs_real_t a0 = 0.78614;
250 const cs_real_t a2 = 5.028;
251 const cs_real_t a3 = 0.000150475;
252 const cs_real_t a4 = 0.00042873;
253 cs_real_t tt, px, py, g1, g2, g3, g4;
254
255 a1 = 10.7954;
256
257 tt = t_c/t0;
258 /* T greater than 80 degrees C, clipped at 80°C */
259 if (t_c > 80.)
260 tt = 80./t0;
261 px = ax * tt;
262 py = ay * tt/(1. + tt);
263 g1 = a1 * tt/(1. + tt);
264 g2 = -a2 * log10(1. + tt);
265 g3 = a3 * (1. - 1./pow(10.,px));
266 g4 = a4 * (pow(10., py) - 1.);
267 ps = a0 + g1 + g2 + g3 + g4;
268 pv = pow(10., ps) * 100.;
269
270 }
271
272 return pv;
273}
274
275/*----------------------------------------------------------------------------*/
284/*----------------------------------------------------------------------------*/
285
286CS_F_HOST_DEVICE static inline cs_real_t
288 cs_real_t p)
289{
290 cs_real_t pv;
291 cs_real_t x_s = 0.;
292
293 /* Warning if T less than -20 degrees C */
294 /* T between -20 and 80 degrees C */
295
296 if ((t_c <= 80.)) {
297
298 pv = cs_air_pwv_sat(t_c);
299 x_s = 0.622 * pv/(p-pv);
300
301 }
302
303 /* T more than 80 degrees C */
304
305 else if (t_c > 80.) {
306
307 x_s = 0.5 + 0.001*t_c;
308
309 }
310
311 return x_s;
312}
313
314/*----------------------------------------------------------------------------*/
324/*----------------------------------------------------------------------------*/
325
328 cs_real_t p);
329
330/*----------------------------------------------------------------------------*/
339/*----------------------------------------------------------------------------*/
340
343
344/*----------------------------------------------------------------------------*/
353/*----------------------------------------------------------------------------*/
354
357
358/*----------------------------------------------------------------------------*/
370/*----------------------------------------------------------------------------*/
371
372void
374 cs_real_t t_liq,
375 cs_real_t p,
376 cs_real_t *yw_liq,
377 cs_real_t *t_h,
378 cs_real_t *rho_h,
379 cs_real_t *beta_h);
380
381/*----------------------------------------------------------------------------*/
394/*----------------------------------------------------------------------------*/
395
398 cs_real_t rho0,
401 cs_real_t molmassrat,
402 cs_real_t t_h);
403
404/*----------------------------------------------------------------------------*/
405
407
408#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:212
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:354
cs_air_fluid_props_t * cs_glob_air_props
Definition: cs_air_props.cpp:89
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:397
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:262
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:375
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:468
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:422
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:287
cs_real_t cs_air_h_l(cs_real_t t_l)
Calculation water mass enthalpy.
Definition: cs_air_props.cpp:127
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:554
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:443
cs_real_t cs_air_hvap(cs_real_t t_vap)
Calculation water vapor mass enthalpy.
Definition: cs_air_props.cpp:145
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:169
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:326
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:293
#define BEGIN_C_DECLS
Definition: cs_defs.h:554
#define CS_F_HOST_DEVICE
Definition: cs_defs.h:585
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
#define END_C_DECLS
Definition: cs_defs.h:555
@ p
Definition: cs_field_pointer.h:67
real(c_double), pointer, save ps
reference pressure (to compute potential temp: 1.0d+5)
Definition: atincl.f90:129
real(c_double), pointer, save p0
reference pressure for the total pressure.
Definition: cstphy.f90:85
real(c_double), pointer, save t0
reference temperature.
Definition: cstphy.f90:93
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 molar_mass_dry_air
Definition: cs_air_props.h:63
cs_real_t sigma
Definition: cs_air_props.h:66
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:64
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