Introduction
This page provides examples of code snippets that may be used to define physical variable laws.
- Warning
It is forbidden to modify turbulent viscosity visct
here (a specific subroutine is dedicated to that: usvist)
- cs_glob_fluid_properties->icp = 1 must have been specified in cs_user_parameters if we wish to define a variable specific heat cpro_cp (otherwise: memory overwrite).
- the field's diffusivity_id integer key must have been specified in cs_user_parameters if we wish to define a variable dynamic viscosity
viscls
.
- Warning
- : if the scalar is the temperature, its associated dynamic diffusivity actually corresponds to its conductivity (Lambda) in W/(m K)
The types of boundary faces at the previous time step are available (except at the first time step, where arrays itypfb
and itrifb
have not been initialized yet)
It is recommended to keep only the minimum necessary in this file (i.e. remove all unused example code)
Accessing physical properties
Base physical properties (rho, viscl, cp, ...) may be accessed as in the following snippet (see Variables and structures reference (C) for additional information).
cs_user_physical_properties and are not to be modified here.
Molecular viscosity varying with temperature
The values of the molecular viscosity are provided as a function of the temperature. All variables are evaluated at the cell centers.
Here is the corresponding code:
for (
cs_lnum_t c_id = 0; c_id < n_cells; c_id++) {
cpro_viscl[c_id] = xvart*(xvart*(varam*xvart+varbm)+varcm)+vardm;
}
Molecular volumetric viscosity varying with temperature
The values of the molecular volumetric viscosity are provided as a function of the temperature. All variables are evaluated at the cell centers.
Here is the corresponding code:
if (cpro_viscv == nullptr)
"%s: cpro_viscv not available.", __func__);
for (
cs_lnum_t c_id =0; c_id < n_cells; c_id++) {
cpro_viscv[c_id] = xvart*(xvart*(varam*xvart+varbm)+varcm)+vardm;
}
Isobaric specific heat varying with temperature
The values of the isobaric specific heat values are provided as a function of the temperature. All variables are evaluated at the cell centers.
Here is the corresponding code:
if ((cpro_cp == nullptr) || (cpro_cv == nullptr))
"%s: cpro_cp or cpro_cv not available.", __func__);
for (
cs_lnum_t c_id = 0; c_id < n_cells; c_id++) {
cpro_cp[c_id] = varac*xvart + varbc;
}
Molecular thermal conductivity varying with temperature
The values of the molecular thermal conductivity are provided as a function of the temperature. All variables are evaluated at the cell centers.
Here is the corresponding code:
if (cpro_vtmpk == nullptr)
"%s: cpro_vtmpk not available.", __func__);
for (
cs_lnum_t c_id = 0; c_id < n_cells; c_id++) {
cpro_vtmpk[c_id] = (xvart*(xvart*(varal*xvart+varbl)+varcl)+vardl);
}
Molecular dynamic diffusivity of user-defined scalars varying with temperature
The molecular dynamic diffusivity can be set for all the user-defined scalars except:
- temperature and enthalpy (already dealt with above: for these variables, the 'diffusivity' is the thermal conductivity)
- variances of the fluctuations of another scalar variable (the diffusivity is assumed to be equal to that of the associated scalar) The values of the molecular dynamic diffusivity are provided as a function of the temperature. All variables are evaluated at the cell centers.
Here is the corresponding code:
for (int f_id = 0; f_id < n_fields; f_id++) {
continue;
int sc_id = -1;
if (sc_id < 0)
continue;
continue;
for (
cs_lnum_t c_id = 0; c_id < n_cells; c_id++) {
cpro_vscal[c_id] = (xvart*(xvart*(varal*xvart+varbl)+varcl)+vardl);
}
}