7.1
general documentation
SDE within the Lagrangian model

Introduction

User integration of the SDE for the user-defined variables.

The variables are constant by default. The SDE must be of the form:

\[ \frac{dT}{dt}=\frac{T - PIP}{Tca} \]

T: particle attribute representing the variable

Tca: characteristic time for the sde to be prescribed in the array auxl1

PIP: coefficient of the SDE (pseudo RHS) to be prescribed in the array auxl2.

If the chosen scheme is first order (nordre=1) then, at the first and only call pip is expressed as a function of the quantities of the previous time step (contained in the particle data).

If the chosen scheme is second order (nordre=2) then, at the first call (nor=1) pip is expressed as a function of the quantities of the previous time step, and at the second passage (nor=2) pip is expressed as a function of the quantities of the current time step.

Example

Example of the integration of the SDE (Stochastic Differential Equation).

void
cs_real_t taup[],
cs_real_3_t tlag[],
cs_real_t tempct[])
{
/* Initializations
--------------- */
const cs_lagr_attribute_map_t *p_am = p_set->p_am;
cs_real_t *tcarac, *pip;
BFT_MALLOC(tcarac, p_set->n_particles, cs_real_t);
/* Characteristic time of the current SDE
-------------------------------------- */
/* Loop on the additional variables */
for (int i = 0;
i++) {
for (cs_lnum_t npt = 0; npt < p_set->n_particles; npt++) {
unsigned char *part = p_set->p_buffer + p_am->extents * npt;
cs_real_t *usr_var
= cs_lagr_particle_attr_n(part, p_am, 0, CS_LAGR_USER);
cs_real_t *prev_usr_var
= cs_lagr_particle_attr_n(part, p_am, 1, CS_LAGR_USER);
/* Characteristic time tca of the differential equation,
This example must be adapted to the case */
tcarac[npt] = 1.0;
/* Prediction at the first substep;
This example must be adapted to the case */
pip[npt] = prev_usr_var[i];
/* Correction at the second substep;
This example must be adapted to the case */
else
pip[npt] = usr_var[i];
}
/* Integration of the variable ipl
------------------------------- */
}
BFT_FREE(tcarac);
BFT_FREE(pip);
}