8.0
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_real_t *prev_usr_var
/* 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);
}
#define BFT_MALLOC(_ptr, _ni, _type)
Allocate memory for _ni elements of type _type.
Definition: bft_mem.h:62
#define BFT_FREE(_ptr)
Free allocated memory.
Definition: bft_mem.h:101
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
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
@ 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.c:1153
@ CS_LAGR_USER
Definition: cs_lagr_particle.h:177
static void * cs_lagr_particle_attr_n(void *particle, const cs_lagr_attribute_map_t *attr_map, int time_id, cs_lagr_attribute_t attr)
Get pointer to attribute data of a particle at a given time.
Definition: cs_lagr_particle.h:997
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.c:340
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.c:2958
Definition: cs_lagr_particle.h:188
size_t extents
Definition: cs_lagr_particle.h:190
int n_user_variables
Definition: cs_lagr.h:337
Definition: cs_lagr_particle.h:222
cs_lnum_t n_particles
Definition: cs_lagr_particle.h:224
unsigned char * p_buffer
Definition: cs_lagr_particle.h:246
const cs_lagr_attribute_map_t * p_am
Definition: cs_lagr_particle.h:244
int nor
Definition: cs_lagr.h:547