My Project
programmer's documentation
Electric arcs Joule examples

Local variables to be added

const cs_mesh_t *m = cs_glob_mesh;
const cs_lnum_t *b_face_cells = cs_glob_mesh->b_face_cells;
const cs_lnum_t n_b_faces = cs_glob_mesh->n_b_faces;
const cs_real_3_t *b_face_normal
const int keyvar = cs_field_key_id("variable_id");

Initialization and finalization

Initialization and finalization is similar to that of the base examples

int nbelec = cs_glob_transformer->nbelec;
int nbtrf = cs_glob_transformer->nbtrf;
cs_real_t *sir, *sii, *sirt, *siit;
cs_real_6_t *sirb, *siib, *ur, *ui;
int *nborne;
char name[8];
BFT_MALLOC(sir, nbelec, cs_real_t);
BFT_MALLOC(sii, nbelec, cs_real_t);
BFT_MALLOC(sirt, nbtrf, cs_real_t);
BFT_MALLOC(siit, nbtrf, cs_real_t);
BFT_MALLOC(siib, nbtrf, cs_real_6_t);
BFT_MALLOC(sirb, nbtrf, cs_real_6_t);
BFT_MALLOC(ui, nbtrf, cs_real_6_t);
BFT_MALLOC(ur, nbtrf, cs_real_6_t);
BFT_MALLOC(nborne, nbtrf, int);

Computation of intensity (A/m2) for each electrode

Pre initialisation

for (int i = 0; i < nbelec; i++) {
sir[i] = 0.;
sii[i] = 0.;
}
for (int i = 0; i < nbtrf; i++) {
sirt[i] = 0.;
siit[i] = 0.;
nborne[i] = 0;
}
for (int i = 0; i < nbtrf; i++) {
transfo->uroff[i] = 0.;
transfo->uioff[i] = 0.;
}
}
for (int i = 0; i < nbelec; i++) {
cs_lnum_t nelts;
cs_lnum_t *lstelt = NULL;
sprintf(name, "%07d", transfo->ielecc[i]);
cs_real_3_t *cpro_curre = (cs_real_3_t *)(CS_F_(curre)->val);
cs_real_3_t *cpro_curim = NULL;
if (ieljou == 4)
cpro_curim = (cs_real_3_t *)(CS_F_(curim)->val);
for (cs_lnum_t ilelt = 0; ilelt < nelts; ilelt++) {
cs_lnum_t face_id = lstelt[ilelt];
cs_lnum_t cell_id = b_face_cells[face_id];
for (cs_lnum_t id = 0; id < 3; id++)
sir[i] += cpro_curre[cell_id][id] * b_face_normal[id][face_id];
if (ieljou == 4)
for (cs_lnum_t id = 0; id < 3; id++)
sii[i] += cpro_curim[cell_id][id] * b_face_normal[id][face_id];
}
}

Definition of Voltage on each termin of transformers

Computation of Intensity on each termin of transformers:

for (int i = 0; i < nbelec; i++) {
sirb[transfo->ielect[i]][transfo->ielecb[i]] = 0.;
if (ieljou == 4)
siib[transfo->ielect[i]][transfo->ielecb[i]] = 0.;
}
for (int i = 0; i < nbelec; i++) {
if (transfo->ielect[i] != 0) {
sirb[transfo->ielect[i]][transfo->ielecb[i]] += sir[i];
if (ieljou == 4)
siib[transfo->ielect[i]][transfo->ielecb[i]] += sii[i];
}
}

RVoltage on each termin:

for (int ntf = 0; ntf < nbtrf; ntf++) {
/* Primary and Secondary in Triangle */
if (transfo->ibrpr[ntf] == 0 &&
transfo->ibrsec[ntf] == 0) {
nborne[ntf] = 3;
double rnbs2 = 3. * transfo->rnbs[ntf]
* transfo->rnbs[ntf];
ur[ntf][0] = 1.154675 * transfo->tenspr[ntf]
/ transfo->rnbs[ntf]
+ (transfo->zr[ntf] * sirb[ntf][0]
- transfo->zi[ntf] * siib[ntf][0]) / rnbs2;
ur[ntf][1] = -0.5773 * transfo->tenspr[ntf]
/ transfo->rnbs[ntf]
+ (transfo->zr[ntf] * sirb[ntf][1]
- transfo->zi[ntf] * siib[ntf][1]) / rnbs2;
ur[ntf][2] =-0.5773 * transfo->tenspr[ntf]
/ transfo->rnbs[ntf]
+ (transfo->zr[ntf] * sirb[ntf][2]
- transfo->zi[ntf] * siib[ntf][2]) / rnbs2;
ui[ntf][0] = (transfo->zi[ntf] * sirb[ntf][0]
- transfo->zr[ntf] * siib[ntf][0]) / rnbs2;
ui[ntf][1] = (transfo->zi[ntf] * sirb[ntf][1]
- transfo->zr[ntf] * siib[ntf][1]) / rnbs2;
ui[ntf][2] = (transfo->zi[ntf] * sirb[ntf][2]
- transfo->zr[ntf] * siib[ntf][2]) / rnbs2;
}
else
bft_error(__FILE__, __LINE__, 0,
_("electric module : \n"
"transformer matrix not defined\n"));
}

Total intensity for a transformer (zero valued WHEN Offset established):

for (int ntf = 0; ntf < nbtrf; ntf++) {
sirt[ntf] = 0.;
if (ieljou == 4)
siit[ntf] = 0.;
}
for (int i = 0; i < nbelec; i++) {
if (transfo->ielect[i] != 0) {
sirt[i] += sir[i];
if (ieljou == 4)
siit[i] += sii[i];
}
}

Take in account of Offset:

double capaeq = 3.;
for (int ntf = 0; ntf < nbtrf; ntf++) {
transfo->uroff[ntf] += sirt[ntf] / capaeq;
if (ieljou == 4)
transfo->uioff[ntf] += siit[ntf] / capaeq;
}
/* A reference transformer is assumed to have an Offset zero valued */
if (transfo->ntfref > 0) {
transfo->uroff[transfo->ntfref] = 0.;
transfo->uioff[transfo->ntfref] = 0.;
}
for (int ntf = 0; ntf < nbtrf; ntf++) {
for (int nb = 0; nb < nborne[ntf]; nb++) {
ur[ntf][nb] += transfo->uroff[ntf];
if (ieljou == 4)
ui[ntf][nb] += transfo->uioff[ntf];
}
}
/* Print of UROFF (real part of offset potential) */
bft_printf(" ** INFORMATIONS ON TRANSFOMERS\n");
bft_printf(" ---------------------------------------\n");
bft_printf(" ---------------------------------\n");
bft_printf(" Number of Transfo UROFF\n");
bft_printf(" ---------------------------------\n");
for (int ntf = 0; ntf < nbtrf; ntf++)
bft_printf(" %6i %12.5E\n", ntf, transfo->uroff[ntf]);
bft_printf(" ---------------------------------------\n");

Take in account of Boundary Conditions

for (int i = 0; i < nbelec; i++) {
cs_lnum_t nelts;
cs_lnum_t *lstelt = NULL;
sprintf(name, "%07d", transfo->ielecc[i]);
for (cs_lnum_t ilelt = 0; ilelt < nelts; ilelt++) {
cs_lnum_t face_id = lstelt[ilelt];
bc_type[face_id] = CS_SMOOTHWALL;
if (transfo->ielect[i] != 0) {
const cs_field_t *f = CS_F_(potr);
int ivar = cs_field_get_key_int(f, keyvar) - 1;
icodcl[ivar * n_b_faces + face_id] = 1;
rcodcl[ivar * n_b_faces + face_id] = ur[transfo->ielect[i]][transfo->ielecb[i]];
if (ieljou == 4) {
f = CS_F_(poti);
ivar = cs_field_get_key_int(f, keyvar) - 1;
icodcl[ivar * n_b_faces + face_id] = 1;
rcodcl[ivar * n_b_faces + face_id] = ur[transfo->ielect[i]][transfo->ielecb[i]];
}
}
else {
const cs_field_t *f = CS_F_(potr);
int ivar = cs_field_get_key_int(f, keyvar) - 1;
icodcl[ivar * n_b_faces + face_id] = 3;
rcodcl[2 * n_b_faces * nvar + ivar * n_b_faces + face_id] = 0.;
if (ieljou == 4) {
f = CS_F_(poti);
ivar = cs_field_get_key_int(f, keyvar) - 1;
icodcl[ivar * n_b_faces + face_id] = 3;
rcodcl[2 * n_b_faces * nvar + ivar * n_b_faces + face_id] = 0.;
}
}
}
}
/* Test, if not any reference transformer
* a piece of wall may be at ground. */
if (transfo->ntfref == 0) {
bool found = false;
for (cs_lnum_t face_id = 0; face_id < n_b_faces; face_id++) {
if (bc_type[face_id] == CS_SMOOTHWALL) {
const cs_field_t *f = CS_F_(potr);
int ivar = cs_field_get_key_int(f, keyvar) - 1;
if (icodcl[ivar * n_b_faces + face_id] == 1) {
if (ieljou == 3) {
if (fabs(rcodcl[ivar * n_b_faces + face_id]) < 1.e-20)
found = true;
}
else if (ieljou == 4) {
double val = fabs(rcodcl[ivar * n_b_faces + face_id]);
f = CS_F_(poti);
ivar = cs_field_get_key_int(f, keyvar) - 1;
if (fabs(rcodcl[ivar * n_b_faces + face_id]) < 1.e-20 &&
val < 1.e-20)
found = true;
}
}
}
}
if (!found)
bft_error(__FILE__, __LINE__, 0,
_("ERROR in JOULE : \n"
"Lack of reference : choose a transformer for wich\n"
"offset is assumed zero or a face at ground on the\n"
"boundary\n"));
}

Finalization step

Test, if not any reference transformer a piece of wall may be at ground:

BFT_FREE(sir);
BFT_FREE(sii);
BFT_FREE(sirb);
BFT_FREE(siib);
BFT_FREE(ur);
BFT_FREE(ui);
BFT_FREE(sirt);
BFT_FREE(siit);
BFT_FREE(nborne);
cs_glob_transformer
const cs_data_joule_effect_t * cs_glob_transformer
curim
Definition: cs_field_pointer.h:173
poti
Definition: cs_field_pointer.h:166
cs_glob_mesh_quantities
cs_mesh_quantities_t * cs_glob_mesh_quantities
cs_real_3_t
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:315
cs_data_joule_effect_t::zr
cs_real_t * zr
Definition: cs_elec_model.h:86
cs_mesh_quantities_t::b_face_normal
cs_real_t * b_face_normal
Definition: cs_mesh_quantities.h:98
_
#define _(String)
Definition: cs_defs.h:52
cs_data_joule_effect_t::tenspr
cs_real_t * tenspr
Definition: cs_elec_model.h:84
potr
Definition: cs_field_pointer.h:165
ppincl::ieljou
integer ieljou
pointer to specify Joule effect module (Laplace forces not taken into account) with indicator ippmod(...
Definition: ppincl.f90:167
icodcl
void const int const int const int const int int int int int int int int int int int int int int int * icodcl
Definition: cs_gui_boundary_conditions.h:64
cs_time_step_t::nt_cur
int nt_cur
Definition: cs_time_step.h:61
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
cs_data_joule_effect_t::ielect
int * ielect
Definition: cs_elec_model.h:78
cs_mesh_t::b_face_cells
cs_lnum_t * b_face_cells
Definition: cs_mesh.h:88
cs_data_joule_effect_t::rnbs
cs_real_t * rnbs
Definition: cs_elec_model.h:85
cs_get_glob_transformer
cs_data_joule_effect_t * cs_get_glob_transformer(void)
Definition: cs_elec_model.c:562
cs_mesh_t::n_b_faces
cs_lnum_t n_b_faces
Definition: cs_mesh.h:75
nvar
void const cs_int_t const cs_int_t * nvar
Definition: cs_prototypes.h:104
cs_glob_physical_model_flag
int cs_glob_physical_model_flag[CS_N_PHYSICAL_MODEL_TYPES]
Definition: cs_physical_model.c:109
bft_error
void bft_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by bft_error_handler_set() or default).
Definition: bft_error.c:193
cs_glob_mesh
cs_mesh_t * cs_glob_mesh
cs_data_joule_effect_t::ielecc
int * ielecc
Definition: cs_elec_model.h:77
CS_JOULE_EFFECT
Definition: cs_physical_model.h:69
cs_field_get_key_int
int cs_field_get_key_int(const cs_field_t *f, int key_id)
Return a integer value for a given key associated with a field.
Definition: cs_field.c:2976
BFT_MALLOC
#define BFT_MALLOC(_ptr, _ni, _type)
Allocate memory for _ni elements of type _type.
Definition: bft_mem.h:62
BFT_FREE
#define BFT_FREE(_ptr)
Free allocated memory.
Definition: bft_mem.h:101
CS_F_
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
CS_SMOOTHWALL
Definition: cs_parameters.h:137
cs_data_joule_effect_t::ibrsec
int * ibrsec
Definition: cs_elec_model.h:83
cs_real_6_t
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:317
curre
Definition: cs_field_pointer.h:172
cs_data_joule_effect_t::ibrpr
int * ibrpr
Definition: cs_elec_model.h:82
cs_data_joule_effect_t::ielecb
int * ielecb
Definition: cs_elec_model.h:79
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_time_step_t::nt_prev
int nt_prev
Definition: cs_time_step.h:59
cs_data_joule_effect_t::nbtrf
int nbtrf
Definition: cs_elec_model.h:80
cs_data_joule_effect_t::uroff
cs_real_t * uroff
Definition: cs_elec_model.h:88
cs_data_joule_effect_t::uioff
cs_real_t * uioff
Definition: cs_elec_model.h:89
cs_field_key_id
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2490
cs_data_joule_effect_t::zi
cs_real_t * zi
Definition: cs_elec_model.h:87
cs_selector_get_b_face_list
void cs_selector_get_b_face_list(const char *criteria, cs_lnum_t *n_b_faces, cs_lnum_t b_face_list[])
Fill a list of boundary faces verifying a given selection criteria.
Definition: cs_selector.c:213
cs_data_joule_effect_t::nbelec
int nbelec
Definition: cs_elec_model.h:76
cs_data_joule_effect_t::ntfref
int ntfref
Definition: cs_elec_model.h:81
cs_glob_time_step
const cs_time_step_t * cs_glob_time_step
lstelt
void cs_int_t cs_int_t * lstelt
Definition: cs_syr_coupling.h:194
cs_field_t
Field descriptor.
Definition: cs_field.h:124
cs_mesh_t
Definition: cs_mesh.h:63
rcodcl
void const int const int const int const int int int int int int int int int int int int int int int double double double double double double double double double double int double * rcodcl
Definition: cs_gui_boundary_conditions.h:64
bft_printf
int bft_printf(const char *const format,...)
Replacement for printf() with modifiable behavior.
Definition: bft_printf.c:140
cs_data_joule_effect_t
Structure to read transformer parameters in dp_ELE.
Definition: cs_elec_model.h:75