8.0
general documentation
Electric arcs boundary conditions examples

Initialization and finalization

Initialization and finalization is similar to that of the base examples

Example 1

For boundary faces of zone "1" assign an inlet and assign a cathode for "electric" variables.

{
const cs_zone_t *zone = cs_boundary_zone_by_name("1");
const cs_real_t *bfpro_rom = CS_F_(rho_b)->val;
cs_real_t *rcodcl1_vel = CS_F_(vel)->bc_coeffs->rcodcl1;
for (cs_lnum_t ilelt = 0; ilelt < zone->n_elts; ilelt++) {
const cs_lnum_t face_id = zone->elt_ids[ilelt];
bc_type[face_id] = CS_INLET;
/* Velocity */
rcodcl1_vel[n_b_faces*0 + face_id] = 0;
rcodcl1_vel[n_b_faces*1 + face_id] = 0;
rcodcl1_vel[n_b_faces*2 + face_id] = 0;
/* Turbulence */
cs_real_t uref2 = 0;
for(int ii = 0; ii < 3; ii++)
uref2 += cs_math_pow2(rcodcl1_vel[n_b_faces*ii +face_id]);
uref2 = cs_math_fmax(uref2, 1.e-12);
/* Turbulence example computed using equations valid for a pipe.
* We will be careful to specify a hydraulic diameter adapted
* to the current inlet.
* We will also be careful if necessary to use a more precise
* formula for the dynamic viscosity use in the calculation of
* the Reynolds number (especially if it is variable, it may be
* useful to take the law from 'cs_user_physical_properties'.
* Here, we use by default the 'viscl0" value.
* Regarding the density, we have access to its value at boundary
* faces (romb) so this value is the one used here (specifically,
* it is consistent with the processing in 'cs_user_physical_properties',
* in case of variable density)
* Hydraulic diameter */
const cs_real_t dhy = 0.075;
const cs_real_t rhomoy = bfpro_rom[face_id];
uref2,
dhy,
rhomoy,
/* Handle Scalars
* Enthalpy in J/kg
* On this example we impose the value of the enthalpy
* the arbitrary value of 1.d6 corresponds to a temperature
* of 2200 Kelvin for argon at atmospheric pressure (see dp_ELE) */
th_f->bc_coeffs->icodcl[face_id] = 1;
th_f->bc_coeffs->rcodcl1[face_id] = 1e6;
/* Specific model for Electric arc:
* Vector Potential: Zero flux by default beacuse we don't a lot about
* vector potential (what we know, is that A is equal to zero at
* and infinite distance)
* All the boundary conditions for A are zero flux, except on some
* selected faces where we need to impose a value in order to have
* a stable calculation (well defined problem).
* These faces are selected where we are sure that the electrical current
* density remains very low generally far from the center of the electric
* arc and from the electrodes (see above) */
if (potva != NULL) {
potva->bc_coeffs->icodcl[face_id] = 3;
potva->bc_coeffs->rcodcl3[face_id] = 0;
potva->bc_coeffs->icodcl[n_b_faces + face_id] = 3;
potva->bc_coeffs->rcodcl3[n_b_faces + face_id] = 0;
potva->bc_coeffs->icodcl[n_b_faces*2 + face_id] = 3;
potva->bc_coeffs->rcodcl3[n_b_faces*2 + face_id] = 0;
}
}
}
const cs_zone_t * cs_boundary_zone_by_name(const char *name)
Return a pointer to a boundary zone based on its name if present.
Definition: cs_boundary_zone.c:711
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
@ potva
Definition: cs_field_pointer.h:161
@ vel
Definition: cs_field_pointer.h:68
@ rho_b
Definition: cs_field_pointer.h:98
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
static cs_real_t cs_math_fmax(cs_real_t x, cs_real_t y)
Compute the max value of two real values.
Definition: cs_math.h:180
static cs_real_t cs_math_pow2(cs_real_t x)
Compute the square of a real value.
Definition: cs_math.h:238
@ CS_INLET
Definition: cs_parameters.h:83
const cs_fluid_properties_t * cs_glob_fluid_properties
Definition: cs_physical_constants.c:404
cs_field_t * cs_thermal_model_field(void)
Definition: cs_thermal_model.c:179
void cs_turbulence_bc_inlet_hyd_diam(cs_lnum_t face_id, double uref2, double dh, double rho, double mu)
Set inlet boundary condition values for turbulence variables based on a diameter and the reference v...
Definition: cs_turbulence_bc.c:871
const cs_turb_model_t * cs_glob_turb_model
@ CS_TURB_SPALART_ALLMARAS
Definition: cs_turbulence_model.h:69
@ CS_TURB_V2F_PHI
Definition: cs_turbulence_model.h:66
@ CS_TURB_K_OMEGA
Definition: cs_turbulence_model.h:68
real(c_double), pointer, save viscl0
reference molecular dynamic viscosity.
Definition: cstphy.f90:157
cs_real_t * rcodcl1
Definition: cs_field.h:109
int * icodcl
Definition: cs_field.h:108
Field descriptor.
Definition: cs_field.h:130
cs_field_bc_coeffs_t * bc_coeffs
Definition: cs_field.h:158
double viscl0
Definition: cs_physical_constants.h:73
int iturb
Definition: cs_turbulence_model.h:117
int itytur
Definition: cs_turbulence_model.h:139
Definition: cs_zone.h:55
const cs_lnum_t * elt_ids
Definition: cs_zone.h:65
cs_lnum_t n_elts
Definition: cs_zone.h:64

Example 2

For boundary faces of zone "2" assign an free outlet and example of electrode for Joule Effect by direct conduction.

{
const cs_zone_t *zone = cs_boundary_zone_by_name("2");
for (cs_lnum_t ilelt = 0; ilelt < zone->n_elts; ilelt++) {
const cs_lnum_t face_id = zone->elt_ids[ilelt];
bc_type[face_id] = CS_OUTLET;
/* Handle Scalars
* Enthalpy in J/kg (By default zero flux with CS_OUTLET)
* Nothing to do
* Mass fraction of the (n-1) gas mixture components
* (Zero flux by defaut with ISOLIB)
* Nothing to do
* Specific model for Joule Effect by direct conduction:
* If you want to make a simulation with an imposed Power PUISIM
* (you want to get PUISIM imposed in cs_user_parameters.c and
* PUISIM = Amp x Volt) you need to impose IELCOR=1 in cs_user_parameters.c
* The boundary conditions will be scaled by COEJOU coefficient
* for example the electrical potential will be multiplied bu COEJOU
* (both real and imaginary part of the electrical potential if needed)
* COEJOU is automatically defined in order that the calculated dissipated
* power by Joule effect (both real and imaginary part if needed) is equal
* to PUISIM
* At the beginning of the calculation, COEJOU ie equal to 1;
* COEJOU is writing and reading in the result files.
* If you don't want to calculate with by scaling,
* you can impose directly the value. */
potr->bc_coeffs->icodcl[face_id] = 1;
if (ielcor == 1) {
potr->bc_coeffs->rcodcl1[face_id] = 500*coejou;
}
else {
potr->bc_coeffs->rcodcl1[face_id] = 500.;
}
}
poti->bc_coeffs->icodcl[face_id] = 1;
if (ielcor == 1) {
poti->bc_coeffs->rcodcl1[face_id] = sqrt(3)*500*coejou;
}
else {
poti->bc_coeffs->rcodcl1[face_id] = sqrt(3)*500.;
}
}
}
const cs_elec_option_t * cs_glob_elec_option
@ poti
Definition: cs_field_pointer.h:160
@ potr
Definition: cs_field_pointer.h:159
@ CS_OUTLET
Definition: cs_parameters.h:84
int cs_glob_physical_model_flag[CS_N_PHYSICAL_MODEL_TYPES]
Definition: cs_physical_model.c:108
@ CS_JOULE_EFFECT
Definition: cs_physical_model.h:70
integer(c_int), pointer, save ielcor
ielcor : 0 : electric arc scaling desactivate 1 : electric arc scaling activate
Definition: optcal.f90:1003
real(c_double), pointer, save coejou
coejou : scaling coefficient
Definition: optcal.f90:1009
cs_real_t coejou
Definition: cs_elec_model.h:112

Example 3

For boundary faces of zone "2" assign a free outlet and example of anode for electric arc.

{
const cs_zone_t *zone = cs_boundary_zone_by_name("2");
for (cs_lnum_t ilelt = 0; ilelt < zone->n_elts; ilelt++) {
const cs_lnum_t face_id = zone->elt_ids[ilelt];
bc_type[face_id] = CS_OUTLET;
/* Handle scalars
* Enthalpy in J/kg (Zero flux by default with ISOLIB)
* Nothing to do
* Real component of the electrical potential */
/* For electric arc model,
* ======================
* We generally calculate the "electric variables" assuming that the total
* intensity of the electrical current is imposed (COUIMP is the value of
* the imposed total current).
* In that case, you need to impose IELCOR=1 in cs_user_parameters.c
* The "electrical variables" will be scaled by COEPOT coefficient :
* for example the electrical potential will be multiplied by COEPOT,
* Joule effect will be multipied by COEPOT * COEPOT and so on (see
* cs_user_electric_scaling.c).
* COEJOU is defined in cs_user_electric_scaling.c: different possibilities
* are described in cs_user_electric_scaling.c, depending on the different
* physics you want to simulate (scaling from current, from power, special
* model for restriking ...).
* The variable DPOT is defined: it corresponds to the electrical potential
* difference between the electrodes (Anode potential - cathode Potential).
* DPOT is calculated in cs_user_electric_scaling.c. DPOT is saved at each
* time step, and for a following calculation
* DPOT is the value of the boundary condition on anode assuming that
* the cathode potential is equel to zero.
* It is also possible to fix the value of the potential on the anode.
* (for example, 1000 Volts).*/
potr->bc_coeffs->icodcl[face_id] = 1;
potr->bc_coeffs->rcodcl1[face_id] = cs_glob_elec_option->pot_diff;
else
potr->bc_coeffs->rcodcl1[face_id] = 1000.;
/* Mass fraction of the (n-1) gas mixture components
* zero flux by default with CS_OUTLET
* nothing to do
* vector Potential
* zero flux by default with CS_OUTLET
* nothing to do */
}
@ CS_ELECTRIC_ARCS
Definition: cs_physical_model.h:71
cs_real_t pot_diff
Definition: cs_elec_model.h:110

Example 4

For boundary faces of zone "2" assign a wall and example of potential vector Dirichlet condition

{
const cs_real_3_t *cvara_potva
= (const cs_real_3_t *)cs_field_by_name("vec_potential")->val_pre;
const cs_zone_t *zone = cs_boundary_zone_by_name("2");
for (cs_lnum_t ilelt = 0; ilelt < zone->n_elts; ilelt++) {
const cs_lnum_t face_id = zone->elt_ids[ilelt];
bc_type[face_id] = CS_SMOOTHWALL;
/* Wall: zero flow (zero flux for pressure)
* friction for velocities (+ turbulent variables)
* zero flux for scalars
* Handle scalars
* Enthalpy in J/kg (Zero flux by default)
* Nothing to do
* Real component of the electrical potential
* Zero flux by default
* Nothing to do
* Specific model for Electric arc:
* ===============================
* Vector potential A (Ax, Ay, Az)
* Zero flux by default because we don't a lot about vector potential
* (what we know, is that A is equal to zero at the infinite)
* All the boundary conditions for A are zero flux, except on some chosen
* faces where we need to impose a value in order to have a stable
* calculation. These faces are chosen where we are sure that the
* electrical current density remains very low generally far from the
* center of the electric arc and from the electrodes:
* On the following example, we choose to impose a "dirichlet" value for
* the 3 components of A on a small zone of the boundary located near the
* vertical free outlet of the computation domain.
* In this example, the electric arc is at the center of the computational
* domain, located on z axis (near x = 0 and y = 0).
* The x (1st) and y (the 3rd) coordinates are contained between
* -2.5 cm nd 2.5 cm:
* Ax(t, x,y,z) = Ax(t-dt, x=2.5cm, y=2.5cm, z)
* Ay(t, x,y,z) = Ay(t-dt, x=2.5cm, y=2.5cm, z)
* Az(t, x,y,z) = Az(t-dt, x=2.5cm, y=2.5cm, z) */
if ( (cdgfbo[face_id][0] <= 249e-2)
|| (cdgfbo[face_id][0] >= 249e-2)
|| (cdgfbo[face_id][2] <= 249e-2)
|| (cdgfbo[face_id][2] >= 249e-2)) {
const cs_lnum_t c_id = b_face_cells[face_id];
potva->bc_coeffs->icodcl[face_id] = 1;
potva->bc_coeffs->rcodcl1[face_id] = cvara_potva[c_id][0];
potva->bc_coeffs->icodcl[n_b_faces + face_id] = 1;
potva->bc_coeffs->rcodcl1[n_b_faces + face_id] = cvara_potva[c_id][1];
potva->bc_coeffs->icodcl[n_b_faces*2 + face_id] = 1;
potva->bc_coeffs->rcodcl1[n_b_faces*2 + face_id]
= cvara_potva[c_id][2];
}
}
}
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:332
cs_field_t * cs_field_by_name(const char *name)
Return a pointer to a field based on its name.
Definition: cs_field.c:2340
@ CS_SMOOTHWALL
Definition: cs_parameters.h:87
double precision, dimension(:,:), pointer cdgfbo
coordinates of the centers of the boundary faces
Definition: mesh.f90:144
cs_real_t * val_pre
Definition: cs_field.h:154

Example 5

For boundary faces of zone "51" assign a wall and restriking model for electric arc (anode boundaray condition).

{
const cs_zone_t *zone = cs_boundary_zone_by_name("51");
for (cs_lnum_t ilelt = 0; ilelt < zone->n_elts; ilelt++) {
const cs_lnum_t face_id = zone->elt_ids[ilelt];
bc_type[face_id] = CS_SMOOTHWALL;
/* Enthalpy (J/kg) :
* imposed heat transfer coefficient */
th_f->bc_coeffs->icodcl[face_id] = 1;
th_f->bc_coeffs->rcodcl1[face_id] = 2.e4;
th_f->bc_coeffs->rcodcl2[face_id] = 1.e5;
/* Real electrical potential: anode boundary condition;
* pot_diff calculated in cs_user_electric_scaling.c */
potr->bc_coeffs->icodcl[face_id] = 1;
if (z1 <= 0.0)
z1 = 0.0;
if (z2 >= 2e-2)
z2 = 2e-2;
if ((cdgfbo[face_id][2] >= z1) && (cdgfbo[face_id][2] <= z2)) {
th_f->bc_coeffs->icodcl[face_id] = 1;
}
else {
th_f->bc_coeffs->icodcl[face_id] = 3;
th_f->bc_coeffs->rcodcl3[face_id] = 0;
}
}
}
/* Vector potential : Zero flux */
if (potva != NULL) {
potva->bc_coeffs->icodcl[n_b_faces*0 + face_id] = 3;
potva->bc_coeffs->icodcl[n_b_faces*1 + face_id] = 3;
potva->bc_coeffs->icodcl[n_b_faces*2 + face_id] = 3;
potva->bc_coeffs->rcodcl3[n_b_faces*0 + face_id] = 0;
potva->bc_coeffs->rcodcl3[n_b_faces*1 + face_id] = 0;
potva->bc_coeffs->rcodcl3[n_b_faces*2 + face_id] = 0;
}
}
const cs_time_step_t * cs_glob_time_step
int irestrike
Definition: cs_elec_model.h:102
cs_real_t restrike_point[3]
Definition: cs_elec_model.h:103
int ntdcla
Definition: cs_elec_model.h:101
cs_real_t * rcodcl2
Definition: cs_field.h:110
cs_real_t * rcodcl3
Definition: cs_field.h:111
int nt_cur
Definition: cs_time_step.h:74

Example 6

For boundary faces of zone "4" assign a symmetry.

{
const cs_zone_t *zone = cs_boundary_zone_by_name("4");
for (cs_lnum_t ilelt = 0; ilelt < zone->n_elts; ilelt++) {
const cs_lnum_t face_id = zone->elt_ids[ilelt];
bc_type[face_id] = CS_SYMMETRY;
/* For all scalars, by default a zero flux condition is assumed
* (for potentials also)
* In Joule effect direct conduction,
* we can use an anti-symetry condition for the imaginary component of the
* electrical potential depending on the electrode configuration: */
if (poti != NULL) {
poti->bc_coeffs->icodcl[face_id] = 1;
poti->bc_coeffs->rcodcl1[face_id] = 0.;
}
}
@ CS_SYMMETRY
Definition: cs_parameters.h:85