1 #ifndef __CS_ELEC_MODEL_H__
2 #define __CS_ELEC_MODEL_H__
3 
4 /*============================================================================
5  * General parameters management.
6  *============================================================================*/
7 
8 /*
9   This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11   Copyright (C) 1998-2021 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 "cs_defs.h"
35 
36 #include "cs_domain.h"
37 #include "cs_mesh.h"
38 #include "cs_mesh_quantities.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
42 BEGIN_C_DECLS
43 
44 /*=============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 /*============================================================================
49  * Type definitions
50  *============================================================================*/
51 
52 /*----------------------------------------------------------------------------
53  * Structure to read properties in dp_ELE
54  *----------------------------------------------------------------------------*/
55 
56 typedef struct {
57 
58   int         ngaz;
59   int         npoint;
60   cs_real_t  *th;
61   cs_real_t  *ehgaz;
62   cs_real_t  *rhoel;
63   cs_real_t  *cpel;
64   cs_real_t  *sigel;
65   cs_real_t  *visel;
66   cs_real_t  *xlabel;
67   cs_real_t  *xkabel;
68 
69 } cs_data_elec_t;
70 
71 /*----------------------------------------------------------------------------
72  * Structure to read transformer parameters in dp_ELE
73  *----------------------------------------------------------------------------*/
74 
75 typedef struct {
76 
77   int         nbelec;
78   int        *ielecc;
79   int        *ielect;
80   int        *ielecb;
81   int         nbtrf;
82   int         ntfref;
83   int        *ibrpr;
84   int        *ibrsec;
85   cs_real_t  *tenspr;
86   cs_real_t  *rnbs;
87   cs_real_t  *zr;
88   cs_real_t  *zi;
89   cs_real_t  *uroff;
90   cs_real_t  *uioff;
91 
92 } cs_data_joule_effect_t;
93 
94 /*----------------------------------------------------------------------------
95  * Electrical model options descriptor
96  *----------------------------------------------------------------------------*/
97 
98 typedef struct {
99 
100   int         ixkabe;
101   int         ntdcla;
102   int         irestrike;
103   cs_real_t   restrike_point[3];
104   cs_real_t   crit_reca[5];
105   int         ielcor;
106   int         modrec;
107   int         idreca;
108   int        *izreca;
109   cs_real_t   couimp;
110   cs_real_t   pot_diff;
111   cs_real_t   puisim;
112   cs_real_t   coejou;
113   cs_real_t   elcou;
114   cs_real_t   srrom;
115 
116 } cs_elec_option_t;
117 
118 /*============================================================================
119  * Static global variables
120  *============================================================================*/
121 
122 /* Pointer to electrical model options structure */
123 
124 extern const cs_elec_option_t        *cs_glob_elec_option;
125 extern const cs_data_elec_t          *cs_glob_elec_properties;
126 extern const cs_data_joule_effect_t  *cs_glob_transformer;
127 
128 /* Constant for electrical models */
129 
130 extern const cs_real_t cs_elec_permvi;
131 extern const cs_real_t cs_elec_epszer;
132 
133 /*=============================================================================
134  * Public function prototypes for Fortran API
135  *============================================================================*/
136 
137 void
138 CS_PROCF (elini1, ELINI1) (cs_real_t  *diftl0);
139 
140 void
141 CS_PROCF (elflux, ELFLUX) (int      *iappel);
142 
143 void
144 CS_PROCF (elthht, ELTHHT) (int       *mode,
145                            cs_real_t *ym,
146                            cs_real_t *enthal,
147                            cs_real_t *temp);
148 
149 void
150 CS_PROCF (ellecd, ELLECD) (void);
151 
152 void
153 CS_PROCF (elphyv, ELPHYV) (void);
154 
155 void
156 CS_PROCF (eltssc, ELTSSC) (const int       *isca,
157                            cs_real_t       *smbrs);
158 
159 void
160 CS_PROCF (eltsvv, ELTSVV) (const int       *f_id,
161                            cs_real_t       *smbrv);
162 
163 void
164 CS_PROCF (eliniv, ELINIV) (int      *isuite);
165 
166 void
167 CS_PROCF (elreca, ELRECA) (cs_real_t *dt);
168 
169 /*=============================================================================
170  * Public function prototypes
171  *============================================================================*/
172 
173 /*----------------------------------------------------------------------------
174  * Provide access to cs_elec_option
175  *----------------------------------------------------------------------------*/
176 
177 cs_elec_option_t *
178 cs_get_glob_elec_option(void);
179 
180 /*----------------------------------------------------------------------------
181  * Provide access to cs_glob_transformer
182  *----------------------------------------------------------------------------*/
183 
184 cs_data_joule_effect_t *
185 cs_get_glob_transformer(void);
186 
187 /*----------------------------------------------------------------------------
188  * Initialize structures for electrical model
189  *----------------------------------------------------------------------------*/
190 
191 void
192 cs_electrical_model_initialize(void);
193 
194 /*----------------------------------------------------------------------------
195  * Destroy structures for electrical model
196  *----------------------------------------------------------------------------*/
197 
198 void
199 cs_electrical_model_finalize(void);
200 
201 /*----------------------------------------------------------------------------
202  * Specific initialization for electric arc
203  *----------------------------------------------------------------------------*/
204 
205 void
206 cs_electrical_model_specific_initialization(cs_real_t  *diftl0);
207 
208 /*----------------------------------------------------------------------------
209  * Read properties file
210  *----------------------------------------------------------------------------*/
211 
212 void
213 cs_electrical_properties_read(void);
214 
215 /*----------------------------------------------------------------------------
216  * compute specific electric arc fields
217  *----------------------------------------------------------------------------*/
218 
219 void
220 cs_elec_compute_fields(const cs_mesh_t  *mesh,
221                        int               call_id);
222 
223 /*----------------------------------------------------------------------------
224  * compute physical properties
225  *----------------------------------------------------------------------------*/
226 
227 void
228 cs_elec_physical_properties(cs_domain_t             *domain);
229 
230 /*----------------------------------------------------------------------------
231  * compute source terms for energy
232  *----------------------------------------------------------------------------*/
233 
234 void
235 cs_elec_source_terms(const cs_mesh_t             *mesh,
236                      const cs_mesh_quantities_t  *mesh_quantities,
237                      int                          f_id,
238                      cs_real_t                   *smbrs);
239 
240 /*----------------------------------------------------------------------------
241  * compute source terms for vector potential
242  *----------------------------------------------------------------------------*/
243 
244 void
245 cs_elec_source_terms_v(const cs_mesh_t             *mesh,
246                        const cs_mesh_quantities_t  *mesh_quantities,
247                        int                          f_id,
248                        cs_real_3_t                 *smbrv);
249 
250 /*----------------------------------------------------------------------------
251  * add variables fields
252  *----------------------------------------------------------------------------*/
253 
254 void
255 cs_elec_add_variable_fields(void);
256 
257 /*----------------------------------------------------------------------------
258  * add properties fields
259  *----------------------------------------------------------------------------*/
260 
261 void
262 cs_elec_add_property_fields(void);
263 
264 /*----------------------------------------------------------------------------
265  * initialize electric fields
266  *----------------------------------------------------------------------------*/
267 
268 void
269 cs_elec_fields_initialize(const cs_mesh_t  *mesh,
270                           int               isuite);
271 
272 /*----------------------------------------------------------------------------
273  * scaling electric quantities
274  *----------------------------------------------------------------------------*/
275 
276 void
277 cs_elec_scaling_function(const cs_mesh_t             *mesh,
278                          const cs_mesh_quantities_t  *mesh_quantities,
279                          cs_real_t                   *dt);
280 
281 /*----------------------------------------------------------------------------*/
282 /*!
283  * \brief Convert enthalpy to temperature at all boundary faces.
284  *
285  * This handles both user and model enthalpy conversions, so can be used
286  * safely whenever conversion is needed.
287  *
288  * \param[in]   h   enthalpy values
289  * \param[out]  t   temperature values
290  */
291 /*----------------------------------------------------------------------------*/
292 
293 void
294 cs_elec_convert_h_to_t_faces(const cs_real_t  h[],
295                              cs_real_t        t[]);
296 
297 /*----------------------------------------------------------------------------*/
298 /*!
299  * \brief Convert temperature to enthalpy at all cells
300  *
301  * This handles both user and model temperature conversions, so can be used
302  * safely whenever conversion is needed.
303  *
304  * \param[in]   t   temperature values
305  * \param[out]  h   enthalpy values
306  */
307 /*----------------------------------------------------------------------------*/
308 
309 void
310 cs_elec_convert_t_to_h_cells(const cs_real_t  t[],
311                              cs_real_t        h[]);
312 
313 /*----------------------------------------------------------------------------*/
314 /*!
315  * \brief Convert temperature to enthalpy at selected boundary faces.
316  *
317  * This handles both user and model temperature conversions, so can be used
318  * safely whenever conversion is needed.
319  *
320  * \param[in]   n_faces   number of selected faces
321  * \param[in]   face_ids  ids of selected faces
322  * \param[in]   t         temperature values (defined on all boundary faces)
323  * \param[out]  h         enthalpy values (defined on all boundary faces)
324  */
325 /*----------------------------------------------------------------------------*/
326 
327 void
328 cs_elec_convert_t_to_h_faces(const cs_lnum_t  n_faces,
329                              const cs_lnum_t  face_ids[],
330                              const cs_real_t  t[],
331                              cs_real_t        h[]);
332 
333 /*----------------------------------------------------------------------------*/
334 
335 END_C_DECLS
336 
337 #endif /* __CS_ELEC_MODEL_H__ */
338