9.0
general documentation
Loading...
Searching...
No Matches
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
--------------- */
cs_real_t *tcarac, *pip;
CS_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 < cs_glob_lagr_model->n_user_variables;
i++) {
for (cs_lnum_t p_id = 0; p_id < p_set->n_particles; p_id++) {
cs_real_t *usr_var
cs_real_t *prev_usr_var
/* Characteristic time tca of the differential equation,
This example must be adapted to the case */
tcarac[p_id] = 1.0;
/* Prediction at the first substep;
This example must be adapted to the case */
if (cs_glob_lagr_time_step->nor == 1)
pip[p_id] = prev_usr_var[i];
/* Correction at the second substep;
This example must be adapted to the case */
else
pip[p_id] = usr_var[i];
}
/* Integration of the variable ipl
------------------------------- */
}
CS_FREE(tcarac);
CS_FREE(pip);
}