8.0
general documentation
Electric arcs Joule examples

Local variables to be added

const cs_lnum_t *b_face_cells = domain->mesh->b_face_cells;
const cs_lnum_t n_b_faces = domain->mesh->n_b_faces;
const cs_real_3_t *b_face_normal
= (const cs_real_3_t *)domain->mesh_quantities->b_face_normal;
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:332
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313

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);
#define BFT_MALLOC(_ptr, _ni, _type)
Allocate memory for _ni elements of type _type.
Definition: bft_mem.h:62
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:334
cs_data_joule_effect_t * cs_get_glob_transformer(void)
Definition: cs_elec_model.c:898
const cs_data_joule_effect_t * cs_glob_transformer
Structure to read transformer parameters in dp_ELE.
Definition: cs_elec_model.h:75
int nbtrf
Definition: cs_elec_model.h:81
int nbelec
Definition: cs_elec_model.h:77

Computation of intensity (A/m2) for each electrode

Pre initialization

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.;
}
}
const cs_time_step_t * cs_glob_time_step
cs_real_t * uioff
Definition: cs_elec_model.h:90
cs_real_t * uroff
Definition: cs_elec_model.h:89
int nt_prev
Definition: cs_time_step.h:72
int nt_cur
Definition: cs_time_step.h:74
for (int i = 0; i < nbelec; i++) {
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 < z->n_elts; ilelt++) {
cs_lnum_t face_id = z->elt_ids[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];
}
}
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
@ curre
Definition: cs_field_pointer.h:166
@ curim
Definition: cs_field_pointer.h:167
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
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 ieljou
pointer to specify Joule effect module (Laplace forces not taken into account) with indicator ippmod(...
Definition: ppincl.f90:192
int * ielecc
Definition: cs_elec_model.h:78
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

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];
}
}
int * ielect
Definition: cs_elec_model.h:79
int * ielecb
Definition: cs_elec_model.h:80

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;
cs_real_t 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"));
}
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
#define _(String)
Definition: cs_defs.h:63
cs_real_t * zi
Definition: cs_elec_model.h:88
cs_real_t * rnbs
Definition: cs_elec_model.h:86
int * ibrpr
Definition: cs_elec_model.h:83
cs_real_t * tenspr
Definition: cs_elec_model.h:85
cs_real_t * zr
Definition: cs_elec_model.h:87
int * ibrsec
Definition: cs_elec_model.h:84

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:

cs_real_t 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(" ** INFORMATION ON TRANSFORMERS\n"
" ---------------------------------------\n"
"\n"
" ---------------------------------\n"
" Number of Transformers UROFF\n"
" ---------------------------------\n");
for (int ntf = 0; ntf < nbtrf; ntf++)
bft_printf(" %6i %12.5E\n", ntf, transfo->uroff[ntf]);
bft_printf(" ---------------------------------------\n");
int bft_printf(const char *const format,...)
Replacement for printf() with modifiable behavior.
Definition: bft_printf.c:140
int ntfref
Definition: cs_elec_model.h:82

Take in account of Boundary Conditions

int *potr_icodcl = CS_F_(potr)->bc_coeffs->icodcl;
cs_real_t *potr_rcodcl1 = CS_F_(potr)->bc_coeffs->rcodcl1;
cs_real_t *potr_rcodcl3 = CS_F_(potr)->bc_coeffs->rcodcl3;
int *poti_icodcl = NULL;
cs_real_t *poti_rcodcl1 = NULL;
cs_real_t *poti_rcodcl3 = NULL;
if (ieljou == 4) {
poti_icodcl = CS_F_(potr)->bc_coeffs->icodcl;
poti_rcodcl1 = CS_F_(potr)->bc_coeffs->rcodcl1;
poti_rcodcl3 = CS_F_(potr)->bc_coeffs->rcodcl3;
}
for (int i = 0; i < nbelec; i++) {
sprintf(name, "%07d", transfo->ielecc[i]);
for (cs_lnum_t ilelt = 0; ilelt < z->n_elts; ilelt++) {
cs_lnum_t face_id = z->elt_ids[ilelt];
bc_type[face_id] = CS_SMOOTHWALL;
if (transfo->ielect[i] != 0) {
potr_icodcl[face_id] = 1;
potr_rcodcl1[face_id] = ur[transfo->ielect[i]][transfo->ielecb[i]];
if (ieljou == 4) {
poti_icodcl[face_id] = 1;
poti_rcodcl1[face_id] = ur[transfo->ielect[i]][transfo->ielecb[i]];
}
}
else {
potr_icodcl[face_id] = 3;
potr_rcodcl3[face_id] = 0.;
if (ieljou == 4) {
poti_icodcl[face_id] = 3;
poti_rcodcl3[face_id] = 0.;
}
}
}
}
/* Test, if not any reference transformer
* a piece of wall may be at ground. */
if (transfo->ntfref == 0) {
int found = 0;
for (cs_lnum_t face_id = 0; face_id < n_b_faces; face_id++) {
if (bc_type[face_id] == CS_SMOOTHWALL) {
if (potr_icodcl[face_id] == 1) {
if (ieljou == 3) {
if (fabs(potr_rcodcl1[face_id]) < 1.e-20)
found = 1;
}
else if (ieljou == 4) {
cs_real_t val = fabs(potr_rcodcl1[face_id]);
if (fabs(poti_rcodcl1[face_id]) < 1.e-20 && val < 1.e-20)
found = 1;
}
}
}
}
if (!found)
bft_error(__FILE__, __LINE__, 0,
_("ERROR in JOULE : \n"
"Lack of reference: choose a transformer for which\n"
"offset is assumed zero or a face at ground on the\n"
"boundary."));
}
#define CS_INT_TYPE
Definition: cs_defs.h:442
@ potr
Definition: cs_field_pointer.h:159
static void cs_parall_max(int n, cs_datatype_t datatype, void *val)
Maximum values of a given datatype on all default communicator processes.
Definition: cs_parall.h:197
@ CS_SMOOTHWALL
Definition: cs_parameters.h:87

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);
#define BFT_FREE(_ptr)
Free allocated memory.
Definition: bft_mem.h:101