29 static int nodes = nNodes;
31 for (
int i = 0; i < 2*nNodes; i++){mOrder[i] = i;}
32 double mom[2*nodes], we[nodes], vi[nodes],
33 sgBA[2*nodes], sgCO2[2*nodes], sc[2*nodes];
34 double sources[2*nodes];
36 double radiusGrowthBA[nodes],
37 radiusGrowthCO2[nodes],
38 volumeGrowthBA[nodes],
39 volumeGrowthCO2[nodes],
41 int ret_bblgr1[nodes], ret_bblgr2[nodes];
43 double CO2_l_val, L_l_val, tmp_val, alphafoam;
45 double LMAX, xBL_val, rhoPolyS;
68 forAll(mesh.C(), celli)
70 CO2_l_val = wCO2_l[celli];
71 L_l_val = wBA_l[celli];
73 alphafoam = alpha2[celli];
74 double wCO2_g_val, wBA_g_val,prsr;
75 wCO2_g_val= wCO2_g[celli];
76 wBA_g_val = wBA_g[celli];
79 if (liquidMixtureDensitySurrogate)
82 modena_inputs_set(inputs_den, Td_pos, TS[celli]);
83 modena_inputs_set(inputs_den, XOHd_pos, XOH[celli]);
87 density_reaction_mixturemodel,
93 modena_inputs_destroy (inputs_den);
94 modena_outputs_destroy (outputs_den);
98 rhoPolyS = modena_outputs_get(outputs_den, 0);
108 mom[0] = mZero[celli];
109 mom[1] = mOne[celli];
110 mom[2] = mTwo[celli];
111 mom[3] = mThree[celli];
114 PDA(we, vi, mom, nodes);
115 weight0[celli] = we[0];
116 weight1[celli] = we[1];
117 node0[celli] = vi[0];
118 node1[celli] = vi[1];
121 double henry_Coefficient, bubble_radius,
122 partialPressure_CO2, wCO2_Max;
125 partialPressure_CO2 =
129 wBA_g_val, prsr, bubble_radius
134 M_CO2, M_liq, partialPressure_CO2, henry_Coefficient
137 if (blowingAgent ==
"n-pentane")
141 if (blowingAgent ==
"R-11")
143 xBL_val =
xBL(tmp_val, dxdT);
146 if (blowingAgent ==
"no")
151 if (bubbleGrowthSurrogateSwitch)
160 double p_2 = partialPressure_CO2;
161 double c_1 = wBA_l[celli]*rhoPolyS*1000.0/
M_B;
162 double c_2 = wCO2_l[celli]*rhoPolyS*1000.0/
M_CO2;
163 if (bubbleGrowthMode ==
"twoNodes")
171 for (
int i = 0; i < nodes; i++)
175 modena_inputs_set(inputs_bblgr1, Tbblgr1pos, TS[celli]);
176 modena_inputs_set(inputs_bblgr1, Rbblgr1pos, nodeRadii[i]);
178 modena_inputs_set(inputs_bblgr1, c_1bblgr1pos, c_1);
179 modena_inputs_set(inputs_bblgr1, p_1bblgr1pos, p_1);
183 if (ret_bblgr1[i] != 0)
185 modena_inputs_destroy (inputs_bblgr1);
186 modena_outputs_destroy (outputs_bblgr1);
191 modena_outputs_get(outputs_bblgr1, 0);
194 modena_inputs_set(inputs_bblgr2, Tbblgr2pos, TS[celli]);
195 modena_inputs_set(inputs_bblgr2, Rbblgr2pos, nodeRadii[i]);
197 modena_inputs_set(inputs_bblgr2, c_2bblgr2pos, c_2);
198 modena_inputs_set(inputs_bblgr2, p_2bblgr2pos, p_2);
202 if (ret_bblgr2[i] != 0)
204 modena_inputs_destroy (inputs_bblgr2);
205 modena_outputs_destroy (outputs_bblgr2);
210 modena_outputs_get(outputs_bblgr2, 0);
213 (radiusGrowthBA[i]*
RR*TS[celli])/(p_1);
215 (radiusGrowthCO2[i]*
RR*TS[celli])/(p_2);
222 volumeGrowthBA[i] < 0.0
223 || radiusGrowthBA[i] < 0.0
225 || wBA_l[celli] < 1.0e-8
228 volumeGrowthBA[i] = 0.0;
232 volumeGrowthCO2[i] < 0.0
233 || radiusGrowthCO2[i] < 0.0
235 || wCO2_l[celli] < 1.0e-8
238 volumeGrowthCO2[i] = 0.0;
242 else if (bubbleGrowthMode ==
"meanRadius")
252 modena_inputs_set(inputs_bblgr1, Tbblgr1pos, TS[celli]);
253 modena_inputs_set(inputs_bblgr1, Rbblgr1pos, bubble_radius);
254 modena_inputs_set(inputs_bblgr1, c_1bblgr1pos, c_1);
255 modena_inputs_set(inputs_bblgr1, p_1bblgr1pos, p_1);
257 modena_inputs_set(inputs_bblgr2, Tbblgr2pos, TS[celli]);
258 modena_inputs_set(inputs_bblgr2, Rbblgr2pos, bubble_radius);
259 modena_inputs_set(inputs_bblgr2, c_2bblgr2pos, c_2);
260 modena_inputs_set(inputs_bblgr2, p_2bblgr2pos, p_2);
263 if (ret_bblgr_1 != 0)
265 modena_inputs_destroy (inputs_bblgr1);
266 modena_outputs_destroy (outputs_bblgr1);
272 if (ret_bblgr_2 != 0)
274 modena_inputs_destroy (inputs_bblgr2);
275 modena_outputs_destroy (outputs_bblgr2);
280 for (
int i = 0; i < nNodes; i++)
282 volumeGrowthBA[i] = 0.0;
283 volumeGrowthCO2[i] = 0.0;
285 G1 = modena_outputs_get(outputs_bblgr1, 0);
286 G2 = modena_outputs_get(outputs_bblgr2, 0);
290 volumeGrowthBA[0] = (G1*
RR*TS[celli])/(p_1);
291 volumeGrowthCO2[0] = (G2*
RR*TS[celli])/(p_2);
296 volumeGrowthBA[0] < 0.0
299 || wBA_l[celli] < 1.0e-8
302 volumeGrowthBA[0] = 0.0;
306 volumeGrowthCO2[0] < 0.0
309 || wCO2_l[celli] < 1.0e-8
312 volumeGrowthCO2[0] = 0.0;
314 volumeGrowthBA[1] = volumeGrowthBA[0];
315 volumeGrowthCO2[1] = volumeGrowthCO2[0];
319 FatalErrorIn(args.executable())
320 <<
"Invalid bubble growth mode " << bubbleGrowthMode
321 <<
"\nValid modes are: " 329 for (
int i = 0; i < nodes; i++)
338 sgBA, sgCO2, we, vi, nodes, mOrder, CO2_l_val, L_l_val,
339 tmp_val, wCO2_Max, cc1_val, LMAX,
340 volumeGrowthBA, volumeGrowthCO2
343 g1_CO2[celli] = sgCO2[1];
344 g1_BA[celli] = sgBA[1];
345 cc1[celli] = cc1_val;
347 if (XOH[celli] > XOH_Gel)
349 for (
int j = 0; j < 2*nodes; j++)
359 for (
int j = 0; j < 2*nodes; j++)
361 sources[j] = sgBA[j] + sgCO2[j] + 0.5*sc[j];
363 mZeroSource[celli] = sources[0];
364 mOneSource[celli] = sources[1];
365 mTwoSource[celli] = sources[2];
366 mThreeSource[celli] = sources[3];
370 mZeroSource[celli] = ROOTVSMALL;
371 mOneSource[celli] = ROOTVSMALL;
372 mTwoSource[celli] = ROOTVSMALL;
373 mThreeSource[celli] = ROOTVSMALL;
384 static int nodes = nNodes;
386 for (
int i = 0; i < 2*nNodes; i++){mOrder[i] = i;}
387 double mom[2*nodes], we[nodes], vi[nodes], sgBA[2*nodes],
388 sgCO2[2*nodes], sc[2*nodes];
389 double sources[2*nodes];
391 double CO2_l_val, L_l_val, tmp_val, alphafoam;
392 double LMAX, xBL_val, rhoPolyS;
393 double cc1_val = 0.0;
395 double radiusGrowthBA[nodes],
396 radiusGrowthCO2[nodes],
397 volumeGrowthBA[nodes],
398 volumeGrowthCO2[nodes],
400 int ret_bblgr1[nodes], ret_bblgr2[nodes];
421 forAll(mesh.C(), celli)
423 CO2_l_val = wCO2_l[celli];
424 L_l_val = wBA_l[celli];
426 alphafoam = alpha2[celli];
429 double wCO2_g_val, wBA_g_val,prsr;
430 wCO2_g_val= wCO2_g[celli];
431 wBA_g_val = wBA_g[celli];
434 if (liquidMixtureDensitySurrogate)
437 modena_inputs_set(inputs_den, Td_pos, TS[celli]);
438 modena_inputs_set(inputs_den, XOHd_pos, XOH[celli]);
442 density_reaction_mixturemodel,
448 modena_inputs_destroy (inputs_den);
449 modena_outputs_destroy (outputs_den);
453 rhoPolyS = modena_outputs_get(outputs_den, 0);
462 mom[0] = mZero[celli];
463 mom[1] = mOne[celli];
464 mom[2] = mTwo[celli];
465 mom[3] = mThree[celli];
466 mom[4] = mFour[celli];
467 mom[5] = mFive[celli];
470 PDA(we, vi, mom, nodes);
471 weight0[celli] = we[0];
472 weight1[celli] = we[1];
473 weight2[celli] = we[2];
474 node0[celli] = vi[0];
475 node1[celli] = vi[1];
476 node2[celli] = vi[2];
479 double henry_Coefficient, bubble_radius,
480 partialPressure_CO2, wCO2_Max;
483 partialPressure_CO2 =
492 M_CO2, M_liq, partialPressure_CO2, henry_Coefficient
495 if (blowingAgent ==
"n-pentane")
499 if (blowingAgent ==
"R-11")
501 xBL_val =
xBL(tmp_val, dxdT);
504 if (blowingAgent ==
"no")
509 if (bubbleGrowthSurrogateSwitch)
516 wCO2_g_val, prsr, bubble_radius
518 double p_2 = partialPressure_CO2;
519 double c_1 = wBA_l[celli]*rhoPolyS*1000.0/
M_B;
520 double c_2 = wCO2_l[celli]*rhoPolyS*1000.0/
M_CO2;
522 for (
int i = 0; i < nodes; i++)
526 modena_inputs_set(inputs_bblgr1, Tbblgr1pos, TS[celli]);
527 modena_inputs_set(inputs_bblgr1, Rbblgr1pos, nodeRadii[i]);
529 modena_inputs_set(inputs_bblgr1, c_1bblgr1pos, c_1);
530 modena_inputs_set(inputs_bblgr1, p_1bblgr1pos, p_1);
534 if (ret_bblgr1[i] != 0)
536 modena_inputs_destroy (inputs_bblgr1);
537 modena_outputs_destroy (outputs_bblgr1);
542 modena_outputs_get(outputs_bblgr1, 0);
545 modena_inputs_set(inputs_bblgr2, Tbblgr2pos, TS[celli]);
546 modena_inputs_set(inputs_bblgr2, Rbblgr2pos, nodeRadii[i]);
548 modena_inputs_set(inputs_bblgr2, c_2bblgr2pos, c_2);
549 modena_inputs_set(inputs_bblgr2, p_2bblgr2pos, p_2);
553 if (ret_bblgr2[i] != 0)
555 modena_inputs_destroy (inputs_bblgr2);
556 modena_outputs_destroy (outputs_bblgr2);
561 modena_outputs_get (outputs_bblgr2, 0);
564 (radiusGrowthBA[i]*
RR*TS[celli])/(p_1);
566 (radiusGrowthCO2[i]*
RR*TS[celli])/(p_2);
569 volumeGrowthBA[i] < 0.0
570 || radiusGrowthBA[i] < 0.0
572 || wBA_l[celli] < 1.0e-8
575 volumeGrowthBA[i] = 0.0;
579 volumeGrowthCO2[i] < 0.0
580 || radiusGrowthCO2[i] < 0.0
582 || wCO2_l[celli] < 1.0e-8
585 volumeGrowthCO2[i] = 0.0;
591 for (
int i = 0; i < nodes; i++)
599 sgBA, sgCO2, we, vi, nodes, mOrder, CO2_l_val, L_l_val,
600 tmp_val, wCO2_Max, cc1_val, LMAX,
601 volumeGrowthBA, volumeGrowthCO2
604 g1_CO2[celli] = sgCO2[1];
605 g1_BA[celli] = sgBA[1];
606 cc1[celli] = cc1_val;
608 if (XOH[celli] > XOH_Gel)
610 for (
int j = 0; j < 2*nodes; j++)
620 for (
int j = 0; j < 2*nodes; j++)
622 sources[j] = sgBA[j] + sgCO2[j] + 0.5*sc[j];
624 mZeroSource[celli] = sources[0];
625 mOneSource[celli] = sources[1];
626 mTwoSource[celli] = sources[2];
627 mThreeSource[celli] = sources[3];
628 mFourSource[celli] = sources[4];
629 mFiveSource[celli] = sources[5];
633 mZeroSource[celli] = ROOTVSMALL;
634 mOneSource[celli] = ROOTVSMALL;
635 mTwoSource[celli] = ROOTVSMALL;
636 mThreeSource[celli] = ROOTVSMALL;
637 mFourSource[celli] = ROOTVSMALL;
638 mFiveSource[celli] = ROOTVSMALL;
size_t modena_model_inputs_argPos(const modena_model_t *self, const char *name)
Function determining position of an argument in the input vector.
double henryCoefficient(double &T)
Henry coefficient for CO2.
void growthSource(double *, double *, double *, double *, int &, int *, double &, double &, double &, double *, double *)
void coalescenceSource(double *, double *, double *, int &, int *, double &)
double partialPressureCO2(const state_type &y)
partial pressure of CO2
double surfaceTension
required for the computation of partial pressure
double M_CO2
Molecular mass of carbon dioxide, kg/kmol.
double M_NCO
Molecular weight of NCO, 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
double LliqMax(double &)
maximum allowable amount of liquid blowing agent (n-pentane) in liquid
double wBL_D(double &xBL, double &M_B, double &M_NCO, double &L0)
weight fraction of maximum allowable blowing agent (R-11) in liquid
double rhoPoly
density of the liquid polymer, kg/m3
double growthRateBA(double &, double &)
growth rate due to evaporation of blowing agents
void modena_model_destroy(modena_model_t *self)
Function deallocating the memory allocated for the surrogate model.
double nodeRadius(const double &v)
radius of bubbles at each node
double M_B
Molecular mass of blowing agent, kg/kmol.
double xBL(double &T, double &dxdT)
mole fraction of blowing agent (R-11) in liquid polymer
double partialPressureBA(const state_type &y)
partial pressure of the physical blowing agent
double L0
Initial weight fraction of blowing agent in the liquid, -.
double wCO2Max(double &M_CO2, double &M_liq, double &pCO2, double &henryCoeff)
dissolved amount of CO2 in liquid
void PDA(double *, double *, double *, int &)
void modena_model_argPos_check(const modena_model_t *self)
Function checking that the user has queried all input positions.
double growthRateCO2(double &, double &)
growth rate due to production of CO2