8.3
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
--------------- */
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 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 */
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
------------------------------- */
}
BFT_FREE(tcarac);
BFT_FREE(pip);
}
#define BFT_FREE(_ptr)
Definition: bft_mem.h:90
#define BFT_MALLOC(_ptr, _ni, _type)
Definition: bft_mem.h:58
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:359
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
@ dt
Definition: cs_field_pointer.h:65
cs_lagr_model_t * cs_glob_lagr_model
cs_lagr_time_step_t * cs_glob_lagr_time_step
cs_lagr_particle_set_t * cs_lagr_get_particle_set(void)
Return pointer to the main cs_lagr_particle_set_t structure.
Definition: cs_lagr_particle.cpp:1194
@ CS_LAGR_USER
Definition: cs_lagr_particle.h:178
static void * cs_lagr_particles_attr_n(cs_lagr_particle_set_t *particle_set, cs_lnum_t particle_id, int time_id, cs_lagr_attribute_t attr)
Get pointer to attribute data of a given particle in a set at a given time.
Definition: cs_lagr_particle.h:464
void cs_user_lagr_sde(const cs_real_t dt[], cs_real_t taup[], cs_real_3_t tlag[], cs_real_t tempct[])
User integration of the SDE for the user-defined variables.
Definition: cs_user_lagr_particle.cpp:386
void cs_lagr_sde_attr(cs_lagr_attribute_t attr, cs_real_t *tcarac, cs_real_t *pip)
Integration of a stochastic differential equation (SDE) for a user particle variable (attribute).
Definition: cs_lagr_sde.cpp:3043
int n_user_variables
Definition: cs_lagr.h:340
Definition: cs_lagr_particle.h:223
cs_lnum_t n_particles
Definition: cs_lagr_particle.h:225
int nor
Definition: cs_lagr.h:553