9.1
general documentation
cs_atmo_chemistry.h
Go to the documentation of this file.
1#ifndef __CS_ATMO_CHEMISTRY_H__
2#define __CS_ATMO_CHEMISTRY_H__
3
4/*============================================================================
5 * Main for atmospheric chemistry related functions
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 * Local headers
32 *----------------------------------------------------------------------------*/
33
34#include "base/cs_defs.h"
35
36/*----------------------------------------------------------------------------*/
37
39
40/*============================================================================
41 * Local Macro definitions
42 *============================================================================*/
43
44/*============================================================================
45 * Type definitions
46 *============================================================================*/
47
48/*----------------------------------------------------------------------------
49 * Atmospheric aerosol external library
50 *----------------------------------------------------------------------------*/
51
52typedef enum {
53
56
58
59/*----------------------------------------------------------------------------
60 * Atmospheric chemistry options descriptor
61 *----------------------------------------------------------------------------*/
62
63typedef struct {
64
72 int model;
75
78
79 /* Flag to deactivate photolysis */
81
86
96 int n_size;
118
119 // option for chemestry profiles file
120
128
141
143
144/*----------------------------------------------------------------------------
145 * Useful constants for chemistry
146 *----------------------------------------------------------------------------*/
147
148/*============================================================================
149 * Static global variables
150 *============================================================================*/
151
154
155/*============================================================================
156 * Public function prototypes
157 *============================================================================*/
158
159/*----------------------------------------------------------------------------*/
160/*
161 * \brief This function initializes the external aerosol code
162 */
163/*----------------------------------------------------------------------------*/
164
165void
167
168/*----------------------------------------------------------------------------*/
169/*
170 * \brief This function finalizes the external aerosol code.
171 */
172/*----------------------------------------------------------------------------*/
173
174void
176
177/*----------------------------------------------------------------------------*/
178/*
179 * \brief This function fills the given array with gas concentrations from
180 * the external aerosol code.
181 *
182 * \param[out] array gas concentrations
183 */
184/*----------------------------------------------------------------------------*/
185
186void
188
189/*----------------------------------------------------------------------------*/
190/*
191 * \brief This function computes a time step of gaseous chemistry and aerosols
192 * dynamic using the external aerosol code.
193 */
194/*----------------------------------------------------------------------------*/
195
196void
198
199/*----------------------------------------------------------------------------*/
200/*
201 * \brief Compute aerosol cloud droplets nucleation when using the atmospheric
202 * humid model using a microphysical model.
203 *
204 * It is taken into account as an additional step split from advection-diffusion
205 * equation, hence the droplet number is first clipped if necessary.
206 *
207 * \param[out] nc droplet number (scalar) in 1/cm**3
208 * \param[in] rom density of air in kg/m**3
209 * \param[in] qldia mass fraction of liquid water in kg/kg
210 * \param[in] pphy true pressure in pascals
211 * \param[in] refrad radiative cooling
212 */
213/*----------------------------------------------------------------------------*/
214
215void
217 const cs_real_t *rom,
218 const cs_real_t *qldia,
219 const cs_real_t *pphy,
220 const cs_real_t *refrad);
221
222/*----------------------------------------------------------------------------*/
223/*
224 * \brief Deactivate chemistry initialization procedure
225 */
226/*----------------------------------------------------------------------------*/
227
228void
230
231/*----------------------------------------------------------------------------*/
232/*
233 * \brief initialize gaseous and particulate concentrations and aerosol number
234 */
235/*----------------------------------------------------------------------------*/
236
237void
239
240/*----------------------------------------------------------------------------*/
244/*----------------------------------------------------------------------------*/
245
246void
248
249/*----------------------------------------------------------------------------*/
250/*
251 * \brief Initialize chemistry cell kinetic rates arrays.
252 */
253/*----------------------------------------------------------------------------*/
254
255void
257
258/*----------------------------------------------------------------------------*/
262/*----------------------------------------------------------------------------*/
263
264void
266
267/*----------------------------------------------------------------------------*/
268/*
269 * \brief Print the atmospheric chemistry options to setup.log.
270 */
271/*----------------------------------------------------------------------------*/
272
273void
275
276/*----------------------------------------------------------------------------*/
277/*
278 * \brief Print the atmospheric aerosols options to setup.log.
279 */
280/*----------------------------------------------------------------------------*/
281
282void
284
285/*----------------------------------------------------------------------------*/
286/*
287 * \brief Check if the chemistry module needs initialization
288 *
289 * \return int value : 1 if needed, 0 if not
290 */
291/*----------------------------------------------------------------------------*/
292
293int
295
296/*----------------------------------------------------------------------------*/
297/*
298 * \brief This function sets the file name to initialize the aerosol library.
299 *
300 * \param[in] file_name name of the file.
301 */
302/*----------------------------------------------------------------------------*/
303
304void
305cs_atmo_chemistry_set_aerosol_file_name(const char *file_name);
306
307/*----------------------------------------------------------------------------*/
308/*
309 * \brief This function set the file name of the SPACK file.
310 *
311 * \param[in] file_name name of the file.
312 */
313/*----------------------------------------------------------------------------*/
314
315void
316cs_atmo_chemistry_set_spack_file_name(const char *file_name);
317
318/*----------------------------------------------------------------------------*/
319/*
320 * \brief This function declare additional transported variables for
321 * atmospheric module for the chemistry defined from SPACK.
322 */
323/*----------------------------------------------------------------------------*/
324
325void
327
328/*----------------------------------------------------------------------------*/
329/*
330 * \brief Initialize chemistry array.
331 */
332/*----------------------------------------------------------------------------*/
333
334void
336
337/*----------------------------------------------------------------------------*/
338/*
339 * \brief Reads initial aerosol concentration and number
340 */
341/*----------------------------------------------------------------------------*/
342
343void
345
346/*----------------------------------------------------------------------------*/
347/*
348 * \brief Reads the chemistry profile data for the atmospheric chemistry
349 *
350 * \param[in] mode if false reading of dimensions only else reading of data
351 */
352/*----------------------------------------------------------------------------*/
353
354void
356
357/*----------------------------------------------------------------------------*/
363/*----------------------------------------------------------------------------*/
364
365void
366cs_atmo_set_aero_conc_file_name(const char *file_name);
367
368/*----------------------------------------------------------------------------*/
369/*
370 * \brief This function set the file name of the chemistry concentration file.
371 *
372 * \param[in] file_name name of the file.
373 */
374/*----------------------------------------------------------------------------*/
375
376void
377cs_atmo_set_chem_conc_file_name(const char *file_name);
378
379/*----------------------------------------------------------------------------*/
380/*
381 * \brief Computes the explicit chemical source term for atmospheric
382 * chemistry in case of a semi-coupled resolution
383 *
384 * \param[in] f_id field id
385 * \param[out] st_exp explicit part of the source term
386 */
387/*----------------------------------------------------------------------------*/
388
389void
391 cs_real_t st_exp[]);
392
393/*----------------------------------------------------------------------------*/
394/*
395 * \brief Calls the rosenbrock resolution for atmospheric chemistry
396 */
397/*----------------------------------------------------------------------------*/
398
399void
401
402/*----------------------------------------------------------------------------*/
403
405
406#endif /* __CS_ATMO_CHEMISTRY_H__ */
void cs_atmo_declare_chem_from_spack(void)
This function declares additional transported variables for atmospheric module for the chemistry defi...
Definition: cs_atmo_chemistry.cpp:1707
void cs_atmo_aerosol_time_advance(void)
This function computes a time step of gaseous chemistry and aerosols dynamic using the external aeros...
Definition: cs_atmo_chemistry.cpp:697
void cs_atmo_chem_exp_source_terms(int f_id, cs_real_t st_exp[])
Computes the explicit chemical source term for atmospheric chemistry in case of a semi-coupled resolu...
Definition: cs_atmo_chemistry.cpp:2039
void cs_atmo_aerosol_get_gas(cs_real_t *array)
This function fills the given array with gas concentrations from the external aerosol code.
Definition: cs_atmo_chemistry.cpp:681
void cs_atmo_aerosol_initialize(void)
This function initializes the external aerosol code.
Definition: cs_atmo_chemistry.cpp:646
int cs_atmo_chemistry_need_initialization(void)
Check if the chemistry module needs initialization.
Definition: cs_atmo_chemistry.cpp:1814
void cs_atmo_aerosol_log_setup(void)
Print the atmospheric aerosols options to setup.log.
Definition: cs_atmo_chemistry.cpp:1937
void cs_atmo_chemistry_initialization_deactivate(void)
Deactivate chemistry initialization procedure.
Definition: cs_atmo_chemistry.cpp:1800
void cs_atmo_set_aero_conc_file_name(const char *file_name)
This function set the file name of the aerosol concentration file.
Definition: cs_atmo_chemistry.cpp:1382
void cs_atmo_read_aerosol(void)
Reads initial aerosol concentration and number.
Definition: cs_atmo_chemistry.cpp:1033
void cs_atmo_chemistry_set_spack_file_name(const char *file_name)
This function set the file name of the SPACK file.
Definition: cs_atmo_chemistry.cpp:1658
cs_atmo_chemistry_t * cs_glob_atmo_chemistry
void cs_atmo_chemistry_finalize(void)
Finalize atmospheric chemistry structures.
Definition: cs_atmo_chemistry.cpp:1843
void cs_atmo_read_chemistry_profile(int mode)
Reads the chemistry profile data for the atmospheric chemistry.
Definition: cs_atmo_chemistry.cpp:1119
void cs_atmo_chemistry_initialize_reacnum(void)
Initialize chemistry cell kinetic rates arrays.
Definition: cs_atmo_chemistry.cpp:1826
cs_atmo_aerosol_type_t
Definition: cs_atmo_chemistry.h:52
@ CS_ATMO_AEROSOL_SSH
Definition: cs_atmo_chemistry.h:55
@ CS_ATMO_AEROSOL_OFF
Definition: cs_atmo_chemistry.h:54
void cs_atmo_chem_initialize_dlconc0(void)
initialize gaseous and particulate concentrations and aerosol number
Definition: cs_atmo_chemistry.cpp:1983
void cs_atmo_set_chem_conc_file_name(const char *file_name)
This function set the file name of the chemistry file.
Definition: cs_atmo_chemistry.cpp:1353
void cs_atmo_chemistry_log_setup(void)
Print the atmospheric chemistry options to setup.log.
Definition: cs_atmo_chemistry.cpp:1872
void cs_atmo_chemistry_set_aerosol_file_name(const char *file_name)
This function sets the file name to initialize the aerosol library.
Definition: cs_atmo_chemistry.cpp:1683
void cs_atmo_chemistry_initialize_conc_profiles(void)
initialize (allocate) chemistry concentrations profiles
Definition: cs_atmo_chemistry.cpp:2002
void cs_atmo_init_chemistry(void)
Initialize chemistry array.
Definition: cs_atmo_chemistry.cpp:1412
void cs_atmo_aerosol_finalize(void)
This function finalizes the external aerosol code.
Definition: cs_atmo_chemistry.cpp:661
void cs_atmo_aerosol_nuclea(cs_real_t *nc, const cs_real_t *rom, const cs_real_t *qldia, const cs_real_t *pphy, const cs_real_t *refrad)
Compute aerosol cloud droplets nucleation when using the atmospheric humid model using a microphysica...
Definition: cs_atmo_chemistry.cpp:722
void cs_atmo_compute_gaseous_chemistry(void)
Calls the rosenbrock resolution for atmospheric chemistry.
Definition: cs_atmo_chemistry.cpp:2134
#define BEGIN_C_DECLS
Definition: cs_defs.h:554
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
#define END_C_DECLS
Definition: cs_defs.h:555
Definition: cs_atmo_chemistry.h:63
bool init_gas_with_lib
Definition: cs_atmo_chemistry.h:90
int model
Definition: cs_atmo_chemistry.h:72
cs_real_t * molar_mass
Definition: cs_atmo_chemistry.h:101
cs_real_t * dlconc0
Definition: cs_atmo_chemistry.h:109
int n_species
Definition: cs_atmo_chemistry.h:73
cs_atmo_aerosol_type_t aerosol_model
Definition: cs_atmo_chemistry.h:85
char * aero_file_name
Definition: cs_atmo_chemistry.h:111
cs_real_t * x_conc_profiles
Definition: cs_atmo_chemistry.h:136
bool chemistry_with_photolysis
Definition: cs_atmo_chemistry.h:80
bool frozen_gas_chem
Definition: cs_atmo_chemistry.h:88
int * species_to_field_id
Definition: cs_atmo_chemistry.h:98
cs_real_t * t_conc_profiles
Definition: cs_atmo_chemistry.h:134
cs_real_t * y_conc_profiles
Definition: cs_atmo_chemistry.h:138
int n_species_profiles
Definition: cs_atmo_chemistry.h:127
int n_reactions
Definition: cs_atmo_chemistry.h:74
int * species_profiles_to_field_id
Definition: cs_atmo_chemistry.h:99
cs_real_t * conc_profiles
Definition: cs_atmo_chemistry.h:130
bool init_aero_with_lib
Definition: cs_atmo_chemistry.h:92
char * aero_conc_file_name
Definition: cs_atmo_chemistry.h:117
cs_real_t * z_conc_profiles
Definition: cs_atmo_chemistry.h:132
char * chem_conc_file_name
Definition: cs_atmo_chemistry.h:114
int nt_step_profiles
Definition: cs_atmo_chemistry.h:122
int n_layer
Definition: cs_atmo_chemistry.h:94
int n_z_profiles
Definition: cs_atmo_chemistry.h:124
int chemistry_sep_mode
Definition: cs_atmo_chemistry.h:77
int * chempoint
Definition: cs_atmo_chemistry.h:102
int n_size
Definition: cs_atmo_chemistry.h:96
cs_real_t * conv_factor_jac
Definition: cs_atmo_chemistry.h:104
char * spack_file_name
Definition: cs_atmo_chemistry.h:97
cs_real_t * reacnum
Definition: cs_atmo_chemistry.h:106
cs_real_t dt_chemistry_max
Definition: cs_atmo_chemistry.h:140