Adding new particle parameters
Posted: Thu Apr 02, 2020 3:06 pm
Hello,
I shall try to make a brief summary of my consultation and the process that I am doing.
1.- I am working on Code_Saturne V 5.0.10
2.- I am developing a new fouling model for my PhD Thesis about biomass boilers.
3.- My intention is to create a new fouling model independent from the existing one linked to the coal combustion.
Although I write the code for self explanation, I attach all the subroutines files.
in file .xml
<particles_models model="thermal">
<coal_fouling status="off"/> ( Note: the former fouling model is off)
<evaporation status="off"/>
<thermal status="on"/>
<depox_fouling status="on"/> ( I have added a new one with status on)
</particles_models>
and in the boundary conditions:
<wall field_id="none" label="BC_10">
<particles choice="foulwall"/> ( Note:foulwall instead of the former "fouling")
<velocity_pressure choice="off"/>
</wall>
These new parameters are declared in cs_lagr.h :
typedef enum {
CS_LAGR_INLET = 1,
CS_LAGR_OUTLET = 2,
CS_LAGR_REBOUND = 3,
CS_LAGR_DEPO1 = 4,
CS_LAGR_DEPO2 = 5,
CS_LAGR_DEPOX = 25, (new bc type)
CS_LAGR_FOULING = 7,
CS_LAGR_JBORD1 = 8,
CS_LAGR_JBORD2 = 9,
CS_LAGR_JBORD3 = 10,
CS_LAGR_JBORD4 = 11,
CS_LAGR_JBORD5 = 12,
CS_LAGR_DEPO_DLVO = 13,
CS_LAGR_SYM = 14
} cs_lagr_bc_type_t;
...............................and:
static cs_lagr_model_t _lagr_model
= {.physical_model = 0,
.n_temperature_layers = 1,
.deposition = 0,
.dlvo = 0,
.roughness = 0,
.resuspension = 0,
.clogging = 0,
.consolidation = 0,
.precipitation = 0,
.fouling = 0,
.depox = 0, (Note: this is the new model name)
.n_stat_classes = 0,
.n_user_variables = 0};
and in cs_gui_particles.c:
else if( cs_gui_strcmp(interaction, "foulwall"))//mdt incluido un nuevo tipo
{
bdy_cond->b_zone_natures[izone] = CS_LAGR_DEPOX;
printf("L887 cs_gui La zona nº:%d es faulwall\n", izone); // for tracking
}
4.- So, the chemical ash composition will be data implemented into the xml file in DATA folder.
5.- This chemical information is placed into the particle data, between the <class> marks.
<class>
<density>1000</density>
<diameter choice="prescribed">0.0001</diameter>
<diameter_standard_deviation>1e-05</diameter_standard_deviation>
<emissivity>0.9</emissivity>
<fouling_index>1.2</fouling_index>
<frequency>1</frequency>
<mass_flow_rate>0</mass_flow_rate>
<number>2</number>
<specific_heat>1400</specific_heat>
<statistical_groups>0</statistical_groups>
<statistical_weight choice="prescribed">12</statistical_weight>
<temperature choice="prescribed">1200</temperature>
<velocity choice="fluid"/>
<ashclk>0.45</ashclk>
<ashna2o>0.18</ashna2o>
<ashsio2>0.31</ashsio2>
<ashal2o3>0.195</ashal2o3>
<ashfe2o3>0.0485</ashfe2o3>
<ashcao>0.12</ashcao>
<ashmgo>0.1</ashmgo>
</class>
6.- The new parameters added are recovered quite well by modifying the subroutine cs_gui_particles.c
_get_status(&(cs_glob_lagr_model->depox), 3, "lagrangian", "particles_models", "depox_fouling");
printf("L1083 gui_part particles_Depox model :%d\n ", cs_glob_lagr_model->depox); // for tracking
if ( cs_glob_lagr_model->depox == 1) {
cs_real_t ashclk;
cs_real_t ashna2o;
cs_real_t ashal2o3;
cs_real_t ashfe2o3;
cs_real_t ashcao;
cs_real_t ashmgo;
cs_real_t ashsio2;
cs_real_t ashenc1=0.0;
cs_real_t ashenc2=0.0;
_get_double(&ashclk, 2, path2, "ashclk"); // ClK in ash mdt
_get_double(&ashna2o, 2, path2, "ashna2o"); // etc..
_get_double(&ashsio2, 2, path2, "ashsio2");
_get_double(&ashal2o3, 2, path2, "ashal2o3");
_get_double(&ashfe2o3, 2, path2, "ashfe2o3");
_get_double(&ashcao, 2, path2, "ashcao");
_get_double(&ashmgo, 2, path2, "ashmgo");
ashenc1 = 0.00835*ashsio2*100.0+0.00601*ashal2o3*100.0-0.109;
ashenc2 = 0.0415*ashsio2*100.0+0.0192*ashal2o3*100.0+0.0276*ashfe2o3*100.0+0.016*ashcao*100.0-3.92;
cs_lagr_set_zone_class_ash(iclas,
izone,
ashclk,
ashna2o,
ashal2o3,
ashfe2o3,
ashcao,
ashmgo,
ashsio2,
ashenc1,
ashenc2);
printf("\n L1100 gui_particles:\n"); // for tracking: everything is ok
printf("ashclk: %2.2f\n", ashclk);
printf("ashna2o: %2.2f\n", ashna2o);
printf("ashsio2: %2.2f\n", ashsio2);
printf("ashal2o3: %2.2f\n", ashal2o3);
printf("ashfe2o3: %2.2f\n", ashfe2o3);
printf("ashcao: %2.2f\n", ashcao);
printf("ashmgo: %2.2f\n", ashmgo);
printf("ashenc1: %2.3f\n", ashenc1);
printf("ashenc2: %2.3f\n", ashenc2);
}
7. Afterwards, I think it is necessary to pass this information to the cs_lagr_injection.c subroutine
Declaring and asigning:
double clk = userdata->ashclk;
double na2o = userdata->ashna2o;
double al2o3 = userdata->ashal2o3;
double fe2o3 = userdata->ashfe2o3;
double cao = userdata->ashcao;
double mgo = userdata->ashmgo;
double sio2 = userdata->ashsio2;
double enc1 = userdata->ashenc1;
double enc2 = userdata->ashenc2;
previously, we have built in cs_lagr.c the void function:
void
cs_lagr_set_zone_class_ash(int iclas,
int izone,
cs_real_t ashclk,
cs_real_t ashna2o,
cs_real_t ashal2o3,
cs_real_t ashfe2o3,
cs_real_t ashcao,
cs_real_t ashmgo,
cs_real_t ashsio2,
cs_real_t ashenc1,
cs_real_t ashenc2)
{
cs_lagr_zone_class_data_t *zonedata = cs_lagr_get_zone_class_data(iclas, izone);
zonedata->ashclk = ashclk;
zonedata->ashna2o = ashna2o;
zonedata->ashal2o3 = ashal2o3;
zonedata->ashfe2o3 = ashfe2o3;
zonedata->ashcao = ashcao;
zonedata->ashmgo = ashmgo;
zonedata->ashsio2 = ashsio2;
zonedata->ashenc1 = ashenc1;
zonedata->ashenc2 = ashenc2;
}
Coefficients enc1 and enc2 calculated are properly recovered in cs_lagr_injection.c
We have to include the new variables declaration in former typdef struct: " cs_lagr_zone_class_data_t" into cs_lagr.h
typedef struct {
/*! ashclk */
cs_real_t ashclk;
/*! ashna2o */
cs_real_t ashna2o;
/*! ashnsio2 */
cs_real_t ashsio2;
/*! ashal2o3 */
cs_real_t ashal2o3;
/*! ashfe2o3 */
cs_real_t ashfe2o3;
/*! ashcao */
cs_real_t ashcao;
/*! ashmgo */
cs_real_t ashmgo;
/*! enc1 calculated */
cs_real_t ashenc1;
/*! enc2 calculated */
cs_real_t ashenc2;
} cs_lagr_zone_class_data_t;
So far, so good.
8.- The problem comes when I try to work with parameters enc1 and enc2 in cs_lagr:tracking,c. Once a particle arrives at a BC zone, a model should be applied (clogging, fouling, dvlo, and my new one "depox").
For calculating the viscosity of the particle, I need to get previously enc1, enc2 and particle temperature.
Particle temperature is read easily by:
cs_real_t particle_temp = cs_lagr_particle_get_real(particle, p_am, CS_LAGR_TEMPERATURE);
however, if I try to get in the same way enc1 by:
cs_real_t particle_enc1 = cs_lagr_particle_get_real(particle, p_am, CS_LAGR_ENC1);
it faults.
Previously, I have includded in cs_particle.h:
typedef enum {
.....................
/* depox fouling additional parameters */
CS_LAGR_ASHENC1,
CS_LAGR_ASHENC2,
...................
} cs_lagr_attribute_t;
and in cs_particle.c:
void
cs_lagr_particle_attr_initialize(void)
{
.................................................
attr_keys[CS_LAGR_ASHENC1][1] = ++loc_count;
attr_keys[CS_LAGR_ASHENC2][1] = ++loc_count;
.........................................................
I have followed same structure of syntax like other similar parameters for example specific heat:
attr_keys[CS_LAGR_CP][1] = ++loc_count;
It does not work with these modifications. I have made a massive search of other similar parameter (CS_LAGR_CP) along all the subroutines included in SCR folder.
I think that I have modified all what i saw.
Sure that I forgot to declare / define fuction / etc., but i can not see it.
Please, if you miss any information, let me know.
Please could you help me in this topic. I think once I solve it, only writting and post process will remain.
I enclose whole the collection of related subroutines.
Thanks in advance.
Miguel Diaz
I shall try to make a brief summary of my consultation and the process that I am doing.
1.- I am working on Code_Saturne V 5.0.10
2.- I am developing a new fouling model for my PhD Thesis about biomass boilers.
3.- My intention is to create a new fouling model independent from the existing one linked to the coal combustion.
Although I write the code for self explanation, I attach all the subroutines files.
in file .xml
<particles_models model="thermal">
<coal_fouling status="off"/> ( Note: the former fouling model is off)
<evaporation status="off"/>
<thermal status="on"/>
<depox_fouling status="on"/> ( I have added a new one with status on)
</particles_models>
and in the boundary conditions:
<wall field_id="none" label="BC_10">
<particles choice="foulwall"/> ( Note:foulwall instead of the former "fouling")
<velocity_pressure choice="off"/>
</wall>
These new parameters are declared in cs_lagr.h :
typedef enum {
CS_LAGR_INLET = 1,
CS_LAGR_OUTLET = 2,
CS_LAGR_REBOUND = 3,
CS_LAGR_DEPO1 = 4,
CS_LAGR_DEPO2 = 5,
CS_LAGR_DEPOX = 25, (new bc type)
CS_LAGR_FOULING = 7,
CS_LAGR_JBORD1 = 8,
CS_LAGR_JBORD2 = 9,
CS_LAGR_JBORD3 = 10,
CS_LAGR_JBORD4 = 11,
CS_LAGR_JBORD5 = 12,
CS_LAGR_DEPO_DLVO = 13,
CS_LAGR_SYM = 14
} cs_lagr_bc_type_t;
...............................and:
static cs_lagr_model_t _lagr_model
= {.physical_model = 0,
.n_temperature_layers = 1,
.deposition = 0,
.dlvo = 0,
.roughness = 0,
.resuspension = 0,
.clogging = 0,
.consolidation = 0,
.precipitation = 0,
.fouling = 0,
.depox = 0, (Note: this is the new model name)
.n_stat_classes = 0,
.n_user_variables = 0};
and in cs_gui_particles.c:
else if( cs_gui_strcmp(interaction, "foulwall"))//mdt incluido un nuevo tipo
{
bdy_cond->b_zone_natures[izone] = CS_LAGR_DEPOX;
printf("L887 cs_gui La zona nº:%d es faulwall\n", izone); // for tracking
}
4.- So, the chemical ash composition will be data implemented into the xml file in DATA folder.
5.- This chemical information is placed into the particle data, between the <class> marks.
<class>
<density>1000</density>
<diameter choice="prescribed">0.0001</diameter>
<diameter_standard_deviation>1e-05</diameter_standard_deviation>
<emissivity>0.9</emissivity>
<fouling_index>1.2</fouling_index>
<frequency>1</frequency>
<mass_flow_rate>0</mass_flow_rate>
<number>2</number>
<specific_heat>1400</specific_heat>
<statistical_groups>0</statistical_groups>
<statistical_weight choice="prescribed">12</statistical_weight>
<temperature choice="prescribed">1200</temperature>
<velocity choice="fluid"/>
<ashclk>0.45</ashclk>
<ashna2o>0.18</ashna2o>
<ashsio2>0.31</ashsio2>
<ashal2o3>0.195</ashal2o3>
<ashfe2o3>0.0485</ashfe2o3>
<ashcao>0.12</ashcao>
<ashmgo>0.1</ashmgo>
</class>
6.- The new parameters added are recovered quite well by modifying the subroutine cs_gui_particles.c
_get_status(&(cs_glob_lagr_model->depox), 3, "lagrangian", "particles_models", "depox_fouling");
printf("L1083 gui_part particles_Depox model :%d\n ", cs_glob_lagr_model->depox); // for tracking
if ( cs_glob_lagr_model->depox == 1) {
cs_real_t ashclk;
cs_real_t ashna2o;
cs_real_t ashal2o3;
cs_real_t ashfe2o3;
cs_real_t ashcao;
cs_real_t ashmgo;
cs_real_t ashsio2;
cs_real_t ashenc1=0.0;
cs_real_t ashenc2=0.0;
_get_double(&ashclk, 2, path2, "ashclk"); // ClK in ash mdt
_get_double(&ashna2o, 2, path2, "ashna2o"); // etc..
_get_double(&ashsio2, 2, path2, "ashsio2");
_get_double(&ashal2o3, 2, path2, "ashal2o3");
_get_double(&ashfe2o3, 2, path2, "ashfe2o3");
_get_double(&ashcao, 2, path2, "ashcao");
_get_double(&ashmgo, 2, path2, "ashmgo");
ashenc1 = 0.00835*ashsio2*100.0+0.00601*ashal2o3*100.0-0.109;
ashenc2 = 0.0415*ashsio2*100.0+0.0192*ashal2o3*100.0+0.0276*ashfe2o3*100.0+0.016*ashcao*100.0-3.92;
cs_lagr_set_zone_class_ash(iclas,
izone,
ashclk,
ashna2o,
ashal2o3,
ashfe2o3,
ashcao,
ashmgo,
ashsio2,
ashenc1,
ashenc2);
printf("\n L1100 gui_particles:\n"); // for tracking: everything is ok
printf("ashclk: %2.2f\n", ashclk);
printf("ashna2o: %2.2f\n", ashna2o);
printf("ashsio2: %2.2f\n", ashsio2);
printf("ashal2o3: %2.2f\n", ashal2o3);
printf("ashfe2o3: %2.2f\n", ashfe2o3);
printf("ashcao: %2.2f\n", ashcao);
printf("ashmgo: %2.2f\n", ashmgo);
printf("ashenc1: %2.3f\n", ashenc1);
printf("ashenc2: %2.3f\n", ashenc2);
}
7. Afterwards, I think it is necessary to pass this information to the cs_lagr_injection.c subroutine
Declaring and asigning:
double clk = userdata->ashclk;
double na2o = userdata->ashna2o;
double al2o3 = userdata->ashal2o3;
double fe2o3 = userdata->ashfe2o3;
double cao = userdata->ashcao;
double mgo = userdata->ashmgo;
double sio2 = userdata->ashsio2;
double enc1 = userdata->ashenc1;
double enc2 = userdata->ashenc2;
previously, we have built in cs_lagr.c the void function:
void
cs_lagr_set_zone_class_ash(int iclas,
int izone,
cs_real_t ashclk,
cs_real_t ashna2o,
cs_real_t ashal2o3,
cs_real_t ashfe2o3,
cs_real_t ashcao,
cs_real_t ashmgo,
cs_real_t ashsio2,
cs_real_t ashenc1,
cs_real_t ashenc2)
{
cs_lagr_zone_class_data_t *zonedata = cs_lagr_get_zone_class_data(iclas, izone);
zonedata->ashclk = ashclk;
zonedata->ashna2o = ashna2o;
zonedata->ashal2o3 = ashal2o3;
zonedata->ashfe2o3 = ashfe2o3;
zonedata->ashcao = ashcao;
zonedata->ashmgo = ashmgo;
zonedata->ashsio2 = ashsio2;
zonedata->ashenc1 = ashenc1;
zonedata->ashenc2 = ashenc2;
}
Coefficients enc1 and enc2 calculated are properly recovered in cs_lagr_injection.c
We have to include the new variables declaration in former typdef struct: " cs_lagr_zone_class_data_t" into cs_lagr.h
typedef struct {
/*! ashclk */
cs_real_t ashclk;
/*! ashna2o */
cs_real_t ashna2o;
/*! ashnsio2 */
cs_real_t ashsio2;
/*! ashal2o3 */
cs_real_t ashal2o3;
/*! ashfe2o3 */
cs_real_t ashfe2o3;
/*! ashcao */
cs_real_t ashcao;
/*! ashmgo */
cs_real_t ashmgo;
/*! enc1 calculated */
cs_real_t ashenc1;
/*! enc2 calculated */
cs_real_t ashenc2;
} cs_lagr_zone_class_data_t;
So far, so good.
8.- The problem comes when I try to work with parameters enc1 and enc2 in cs_lagr:tracking,c. Once a particle arrives at a BC zone, a model should be applied (clogging, fouling, dvlo, and my new one "depox").
For calculating the viscosity of the particle, I need to get previously enc1, enc2 and particle temperature.
Particle temperature is read easily by:
cs_real_t particle_temp = cs_lagr_particle_get_real(particle, p_am, CS_LAGR_TEMPERATURE);
however, if I try to get in the same way enc1 by:
cs_real_t particle_enc1 = cs_lagr_particle_get_real(particle, p_am, CS_LAGR_ENC1);
it faults.
Previously, I have includded in cs_particle.h:
typedef enum {
.....................
/* depox fouling additional parameters */
CS_LAGR_ASHENC1,
CS_LAGR_ASHENC2,
...................
} cs_lagr_attribute_t;
and in cs_particle.c:
void
cs_lagr_particle_attr_initialize(void)
{
.................................................
attr_keys[CS_LAGR_ASHENC1][1] = ++loc_count;
attr_keys[CS_LAGR_ASHENC2][1] = ++loc_count;
.........................................................
I have followed same structure of syntax like other similar parameters for example specific heat:
attr_keys[CS_LAGR_CP][1] = ++loc_count;
It does not work with these modifications. I have made a massive search of other similar parameter (CS_LAGR_CP) along all the subroutines included in SCR folder.
I think that I have modified all what i saw.
Sure that I forgot to declare / define fuction / etc., but i can not see it.
Please, if you miss any information, let me know.
Please could you help me in this topic. I think once I solve it, only writting and post process will remain.
I enclose whole the collection of related subroutines.
Thanks in advance.
Miguel Diaz