Boundary conditions
Lagrangian boundary conditions are based on boundary zone (cs_boundary_zone_t) definitions. Additional information may be provided for Lagrangian boundary types and injections.
As usual, definitions may be created using the GUI and extended with user functions.
Access to the Lagrangian boundary conditions structure, which is necessary to most of the following examples, may be done as follows:
Boundary zones
In this example, we assign rebound conditions to all boundary zones, except for an inlet and outlet type to specified zones. The type assigned is an integer based on the cs_lagr_bc_type_t enumerator type.
{
for (int z_id = 0; z_id < n_zones; z_id++) {
}
}
Injection sets
In the following example, a first injection set for an inlet zone is defined. Note that newly injected particles may also be modified using the cs_user_lagr_in function.
In the next example, a profile is assigned to the second injection set of an inlet zone (it is assumed this et was previously defined either through the GUI or user function).
This requires first defining a profile definition function, matching the profile of cs_lagr_injection_profile_compute_t. An example based on experimental profiles is given here:
static void
_injection_profile(int zone_id,
int location_id,
const void *input,
{
const int itmx = 8;
cs_real_t zi[] = {0.e-3, 1.e-3, 1.5e-3, 2.0e-3, 2.5e-3, 3.0e-3, 3.5e-3,
4.0e-3, 4.5e-3, 5.0e-3};
cs_real_t lvf[] = {0.377e-4, 2.236e-4, 3.014e-4, 4.306e-4, 5.689e-4,
8.567e-4, 7.099e-4, 4.520e-4, 2.184e-4, 0.377e-4};
cs_real_t ui[] = {5.544, 8.827, 9.068, 9.169, 8.923, 8.295, 7.151, 6.048,
4.785, 5.544};
const cs_real_t z = b_face_coords[face_id][2];
int i = 0;
if (z > zi[0]) {
for (i = 0; i < itmx; i++) {
if (z >= zi[i] && z < zi[i+1])
break;
}
}
cs_real_t up = ui[i] +(z-zi[i])*(ui[i+1]-ui[i])/(zi[i+1]-zi[i]);
cs_real_t lvfp = lvf[i] + (z-zi[i])*(lvf[i+1]-lvf[i])/(zi[i+1]-zi[i]);
profile[ei] = lvfp * up;
}
}
Assigning the profile to the injection set simply requires assigning the function to the pointer in the injection set structure:
An optional user-defined input function may also be associated.
Boundary-particle interactions
It is also possible to decide of the behavior of particle when they encounter a boundary (this boundary has to be of type CS_LAGR_BC_USER).
In the following example, the particle is simply deposited and marked for elimination:
# pragma omp atomic
particles->n_part_dep += 1;
# pragma omp atomic
particles->weight_dep += cs_lagr_particles_get_real(particles,
p_id,
for (int k = 0; k < 3; k++)
particle_coord[k] = c_intersect[k];
Volume conditions
Lagrangian volume conditions are based on volume zone (cs_volume_zone_t) definitions. Additional information may be provided for Lagrangian injections.
As usual, definitions may be created using the GUI and extended with user functions.
Access to the Lagrangian volume conditions structure, which is necessary to most of the following examples, may be done as follows:
Injection sets
In the following example, we inject 1 particle set at each time step:
{
for (int set_id = 0; set_id < 2; set_id++) {
}
}
In the following example, we inject 2 particle sets at computation initialization (i.e. at the first time step of a computation sequence in which the Lagrangian module is activated). Note that newly injected particles may also be modified using the cs_user_lagr_in function.
{
for (int set_id = 0; set_id < 2; set_id++) {
}
}
External force
User definition of an external force field acting on the particles.
It must be prescribed in every cell and be homogeneous to gravity (m/s^2) By default gravity and drag force are the only forces acting on the particles (the gravity components gx gy gz are assigned in the GUI or in usipsu)
void
{
fextla[ip][0] = 0;
fextla[ip][1] = 0;
fextla[ip][2] = 0;
}
}
Impose motion on a particle
Impose the motion of a particle flagged CS_LAGR_PART_IMPOSED_MOTION by modifying the particle position and its velocity.
void
{
disp[0] = 0.;
disp[1] = rcost * (cos(omega*dt) - 1.0 ) - rsint * sin(omega*dt);
disp[2] = rsint * (cos(omega*dt) - 1.0 ) + rcost * sin(omega*dt);
}
Modification of newly injected particles
User modification of newly injected particles.
This function is called after the initialization of the new particles in order to modify them according to new particle profiles (injection profiles, position of the injection point, statistical weights, correction of the diameter if the standard-deviation option is activated).
This function is called for each injection zone and set. Particles with ids between pset->n_particles and n_elts are initialized but may be modidied by this function.
void
{
for (
cs_lnum_t p_id = particle_range[0]; p_id < particle_range[1]; p_id++) {
part_vel[0] = 1.0;
part_vel[1] = 0.0;
part_vel[2] = 0.0;
attr_id++) {
cs_real_t *user_var = cs_lagr_particles_attr(particles, p_id, attr_id);
*user_var = 0.;
}
}
if (particle_range[1] <= particle_range[0])
return;
for (
cs_lnum_t ip = particle_range[0]; ip < particle_range[1]; ip++) {
_inlet2(particles, ip);
}
}
{
int time_id = 1;
time_id = 0;
time_id,
visc_length);
}
}
Here is another example of the modification of newly injected particles:
int coal_id = 0;
cs_real_t initial_diameter = 0, shrinking_diameter = 0;
for (int l_id = 0; l_id < n_layers; l_id++) {
temperature[l_id] = 0;
coal_mass_fraction[l_id] = 0;
coke_density[l_id] = 0;
coke_mass_fraction[l_id] = 0;
}
coal_id = 0;
density
+ (1.0 - lagr_cc->
xwatch[coal_id] - lagr_cc->
xashch[coal_id])
* (1.0 - (lagr_cc->
y1ch[coal_id] + lagr_cc->
y2ch[coal_id]) / 2.0);
cp = lagr_cc->
cp2ch[coal_id];
water_mass_f = 0.0;
for (int l_id = 0; l_id < n_layers; l_id++) {
temperature[l_id] = 800 - 273.15;
coal_mass_fraction[l_id] = 0.;
coke_density[l_id]
= (1.0 - lagr_cc->
xwatch[coal_id] - lagr_cc->
xashch[coal_id])
* (1.0 - (lagr_cc->
y1ch[coal_id] + lagr_cc->
y2ch[coal_id]) / 2.0);
coke_mass_fraction[l_id] = coke_density[l_id] /
density;
}
}
for (
cs_lnum_t p_id = particle_range[0]; p_id < particle_range[1]; p_id++) {
cs_lagr_particles_set_real(particles, p_id,
CS_LAGR_CP, cp);
cs_lagr_particles_set_real(particles, p_id,
CS_LAGR_MASS, mass);
water_mass_f * mass);
for (int l_id = 0; l_id < n_layers; l_id++) {
particle_temperature[l_id] = temperature[l_id];
particle_coal_mass[l_id] = coal_mass_fraction[l_id] * mass / n_layers;
particle_coke_mass[l_id] = coke_mass_fraction[l_id] * mass / n_layers;
particle_coal_density[l_id] = coke_density[l_id];
}
shrinking_diameter);
initial_diameter);
}