21 out[0].open(
"./XW1.txt", std::ios::app);
22 out[1].open(
"./XOH1.txt", std::ios::app);
23 out[2].open(
"./T1.txt", std::ios::app);
24 out[3].open(
"./L_l1.txt", std::ios::app);
25 out[4].open(
"./L_g1.txt", std::ios::app);
26 out[5].open(
"./CO2_l1.txt", std::ios::app);
27 out[6].open(
"./CO2_g1.txt", std::ios::app);
28 out[7].open(
"./m01.txt", std::ios::app);
29 out[8].open(
"./m11.txt", std::ios::app);
30 out[9].open(
"./m21.txt", std::ios::app);
31 out[10].open(
"./m31.txt", std::ios::app);
42 for (
int i = 0; i < n; i++)
46 out[i] << t <<
'\t' << (1.0-y[i]/5.0) <<
'\n';
50 out[i] << t <<
'\t' << (1.0-y[i]/5.0) <<
'\n';
54 out[i] << t <<
'\t' << (1.0-y[i]/0.2) <<
'\n';
58 out[i] << t <<
'\t' << y[i] <<
'\n';
63 double rhoPolySurrgate;
71 modena_inputs_set(inputs_den, T_denpos, y[2]);
72 modena_inputs_set(inputs_den, XOH_denpos, y[1]);
74 int ret_den =
modena_model_call (density_reaction_mixturemodel, inputs_den, outputs_den);
78 modena_inputs_destroy (inputs_den);
79 modena_outputs_destroy (outputs_den);
83 rhoPolySurrgate = modena_outputs_get(outputs_den, 0);
94 modena_inputs_set(inputs_den, T_denpos, y[2]);
96 int ret_den =
modena_model_call (density_reaction_mixturemodel, inputs_den, outputs_den);
99 modena_inputs_destroy (inputs_den);
100 modena_outputs_destroy (outputs_den);
104 rhoPolySurrgate = modena_outputs_get(outputs_den, 0);
108 cerr <<
"Invalid density model" << endl;
115 double rho_bubble = ((p1+p2)/(
RR*y[2]))*(y[6]*
M_CO2 + y[4]*
M_B)/(fmax((1000.0*(y[6] + y[4])),1.0e-8));
117 double rho_foam = (rho_bubble*(y[8]/(1.0+y[8])) + rhoPolySurrgate*(1.0 - (y[8]/(1.0+y[8]))));
121 modena_inputs_set(inputs_strutContent,
rho_foam_Pos, rho_foam);
124 int ret_strutContent =
modena_model_call (strutContentmodel, inputs_strutContent, outputs_strutContent);
127 cout <<
"final foam density: " << rho_foam << endl;
128 cout <<
"strut content: " << modena_outputs_get(outputs_strutContent, 0) << endl;
131 double thermalConductivity;
134 thermalConductivity = 8.7006e-8*rho_foam*rho_foam + 8.4674e-5*rho_foam
139 thermalConductivity = 9.3738e-6*rho_foam*rho_foam - 7.3511e-4*rho_foam
143 modena_inputs_set(inputs_thermalConductivity,
porosity_Pos, (1.0 - rho_foam/rhoPolySurrgate));
145 modena_inputs_set(inputs_thermalConductivity,
cell_size_Pos, (2.0*R));
146 modena_inputs_set(inputs_thermalConductivity,
temp_Pos, y[2]);
147 modena_inputs_set(inputs_thermalConductivity,
X_CO2_Pos, (p2/(p1+p2)));
148 modena_inputs_set(inputs_thermalConductivity,
X_O2_Pos, 0.0);
149 modena_inputs_set(inputs_thermalConductivity,
X_N2_Pos, 0.0);
150 modena_inputs_set(inputs_thermalConductivity,
X_Cyp_Pos, (p1/(p1+p2)));
152 st_c = modena_outputs_get(outputs_strutContent, 0);
153 modena_inputs_set(inputs_thermalConductivity,
strut_c_Pos, st_c);
155 if(modena_error_occurred())
157 exit(modena_error());
160 the_con = modena_outputs_get(outputs_thermalConductivity, 0);
162 thermalOut.open(
"./thermalConductivity.txt", std::ios::app);
163 thermalOut << the_con <<
'\t' << thermalConductivity <<
'\t' << rho_foam <<
'\n';
167 ofstream rho_bubbleout;
168 rho_bubbleout.open(
"./rho_bubble.txt", std::ios::app);
169 rho_bubbleout << t <<
'\t' << rho_bubble <<
'\n';
170 rho_bubbleout.close();
172 ofstream rho_foamout;
173 rho_foamout.open(
"./rho_foam.txt", std::ios::app);
174 rho_foamout << t <<
'\t' << rho_foam <<
'\n';
178 R_bubble.open(
"./R_bubble.txt", std::ios::app);
179 R_bubble << t <<
'\t' << R <<
'\n';
186 p1out.open(
"./p_1.txt", std::ios::app);
187 p1out << t <<
'\t' << p_1 <<
'\n';
192 p2out.open(
"./p_2.txt", std::ios::app);
193 p2out << t <<
'\t' << p_2 <<
'\n';
size_t modena_model_inputs_argPos(const modena_model_t *self, const char *name)
Function determining position of an argument in the input vector.
size_t X_CO2_Pos
memory allocation for the partial pressure of CO2 as the input of thermal conductivity surrogate mode...
real(dp), dimension(:), allocatable y
state variables
size_t temp_Pos
memory allocation for the temperature as the input of thermal conductivity surrogate model ...
size_t porosity_Pos
memory allocation for the gas volume fraction as the input of thermal conductivity surrogate model ...
size_t X_N2_Pos
memory allocation for the partial pressure of N2 as the input of thermal conductivity surrogate model...
size_t cell_size_Pos
memory allocation for the bubble size as the input of thermal conductivity surrogate model ...
modena_model_t * thermalConductivitymodel
pointer to the surrogate model for thermal conductivity
int denMod
density mode, 1 = modena, 2 = constant
size_t X_Cyp_Pos
memory allocation for the partial pressure of cyclo-pentane as the input of thermal conductivity surr...
double partialPressureCO2(const state_type &y)
partial pressure of CO2
double M_CO2
Molecular mass of carbon dioxide, kg/kmol.
int modena_model_call(modena_model_t *self, modena_inputs_t *inputs, modena_outputs_t *outputs)
Function calling the surrogate model and checking for errors.
double RR
ideal gas constant, J/mol K
double bubbleRadius(const double m0, const double m1)
radius of bubbles based on the moments
size_t rho_foam_Pos
memory allocation for the foam density as the input of thermal conductivity surrogate model ...
double rhoPoly
density of the liquid polymer, kg/m3
void modena_model_destroy(modena_model_t *self)
Function deallocating the memory allocated for the surrogate model.
void write_kinetics(const state_type &y, const double t)
double M_B
Molecular mass of blowing agent, kg/kmol.
void momentsConverter(const state_type &y, const double t)
double partialPressureBA(const state_type &y)
partial pressure of the physical blowing agent
size_t strut_c_Pos
memory allocation for the strut content as the input of thermal conductivity surrogate model ...
size_t X_O2_Pos
memory allocation for the partial pressure of O2 as the input of thermal conductivity surrogate model...
void modena_model_argPos_check(const modena_model_t *self)
Function checking that the user has queried all input positions.