9 scalar prsr, tmpt, alpha_f, g1_BA_val,
10 cc1_value, tmptrOld, timeStep, dTdt,
11 dXWdt, g1_CO2_val, XOH_val, rhoPolyS;
12 scalar henry_Coefficient, mZero_val, mOne_val,
13 bubble_radius, partialPressure_CO2, wCO2_g_val,
14 wBA_g_val, wCO2_Max,wBL_Max, partialPressure_BA;
23 forAll(mesh.C(), celli)
26 tmptrOld = TS.oldTime()[celli];
28 timeStep = runTime.deltaTValue();
31 alpha_f = alpha2[celli];
32 mZero_val = mZero[celli];
33 mOne_val = mOne[celli];
34 wCO2_g_val = wCO2_g[celli];
35 wBA_g_val = wBA_g[celli];
36 cc1_value = cc1[celli];
37 g1_BA_val = g1_BA[celli];
40 if (liquidMixtureDensitySurrogate)
43 modena_inputs_set(inputs_den, T_pos, tmpt);
44 modena_inputs_set(inputs_den, XOH_pos, XOH_val);
49 density_reaction_mixturemodel,
55 modena_inputs_destroy (inputs_den);
56 modena_outputs_destroy (outputs_den);
60 rhoPolyS = modena_outputs_get(outputs_den, 0);
72 wCO2_g_val, prsr, bubble_radius
74 if (blowingAgent ==
"n-pentane")
85 (
M_B/1000.0)*(1.0/rhoPolyS)
86 *(partialPressure_BA/(max((
RR*tmpt),ROOTVSMALL)))*(-g1_BA_val)
88 wBA_gSource[celli] = -wBA_lSource[celli];
98 wBA_lSource[celli] = 0.0;
99 wBA_gSource[celli] = 0.0;
103 if (blowingAgent ==
"R-11")
106 xBL_val =
xBL(tmpt, dxdT);
108 if (wBL_Max > 1.0e-4 && alpha_f > 0.5)
114 *(1.0/(Foam::pow((1.0 - xBL_val),2)))*(dxdT))*dTdt
119 *(1.0/(Foam::pow((1.0 - xBL_val),2)))*(dxdT))*dTdt
124 wBA_gSource[celli] = 0.0;
125 wBA_lSource[celli] = 0.0;
130 g1_CO2_val = g1_CO2[celli];
133 (mag(XW[celli] - XW.oldTime()[celli]))
134 /(max(runTime.deltaTValue(),ROOTVSMALL))
136 partialPressure_CO2 =
140 wCO2_g_val, wBA_g_val, prsr, bubble_radius
144 wCO2_lSource[celli] = 0.0;
148 if (XOH[celli] < XOH_Gel)
150 wCO2_lSource[celli] =
152 (CW_0*dXWdt*(
M_CO2/1000.0)*(1.0/rhoPolyS)
153 - g1_CO2_val*(partialPressure_CO2/(
RR*tmpt))*(
M_CO2/1000.0)*(1.0/rhoPolyS))
160 wCO2_Max =
wCO2Max(
M_CO2, M_liq, partialPressure_CO2, henry_Coefficient);
162 if (wCO2_l[celli] < wCO2_Max || CW_0 == 0.0 || XOH[celli] > XOH_Gel)
164 wCO2_gSource[celli] = 0.0;
169 wCO2_gSource[celli] =
172 *(partialPressure_CO2/(
RR*tmpt))*(
M_CO2/1000.0)*(1.0/rhoPolyS)
178 wCO2_gSource[celli] = 0.0;
179 wCO2_lSource[celli] = 0.0;
185 scalar prsr, tmpt, alpha_f,
186 QBA, tmptrOld, timeStep, dTdt;
188 scalar henry_Coefficient,
189 bubble_radius, partialPressure_CO2, wCO2_g_val,
190 wBA_g_val, wCO2_Max, wBL_Max, XOH_val, rhoPolyS;
192 scalar m0_val, m1_val;
193 m0_val = m1_val = 0.0;
203 forAll(mesh.C(), celli)
206 tmptrOld = TS.oldTime()[celli];
208 timeStep = runTime.deltaTValue();
211 alpha_f = alpha2[celli];
212 wCO2_g_val = wCO2_g[celli];
213 wBA_g_val = wBA_g[celli];
215 XOH_val = XOH[celli];
217 if (liquidMixtureDensitySurrogate)
220 modena_inputs_set(inputs_den, T_pos, tmpt);
221 modena_inputs_set(inputs_den, XOH_pos, XOH_val);
226 density_reaction_mixturemodel,
232 modena_inputs_destroy (inputs_den);
233 modena_outputs_destroy (outputs_den);
237 rhoPolyS = modena_outputs_get(outputs_den, 0);
244 if (blowingAgent ==
"n-pentane")
253 wBA_gSource[celli] = QBA;
258 wBA_gSource[celli] = 0.0;
259 wBA_lSource[celli] = 0.0;
264 wBA_lSource[celli] = 0.0;
265 wBA_gSource[celli] = 0.0;
269 if (blowingAgent ==
"R-11")
271 xBL_val =
xBL(tmpt, dxdT);
273 if (wBL_Max > 1.0e-4 && alpha_f > 0.5)
279 *(1.0/(Foam::pow((1.0 - xBL_val),2)))*(dxdT))*dTdt
284 *(1.0/(Foam::pow((1.0 - xBL_val),2)))*(dxdT))*dTdt
289 wBA_lSource[celli] = 0.0;
290 wBA_gSource[celli] = 0.0;
294 wCO2_lSource[celli] = scalar(0.0);
298 partialPressure_CO2 =
302 wCO2_g_val, wBA_g_val, prsr, bubble_radius
304 wCO2_Max =
wCO2Max(
M_CO2, M_liq, partialPressure_CO2, henry_Coefficient);
306 if (alpha_f > 0.5 && XOH[celli] <= XOH_Gel && CW_0 != 0.0)
308 wCO2_gSource[celli] =
310 ((CW_0*XW[celli]*(
M_CO2/1000.0)*(1.0/rhoPolyS)) - wCO2_Max)
315 wCO2_gSource[celli] = 0.0;
318 if (wCO2_gSource[celli] < 0.0)
320 wCO2_gSource[celli] = scalar(0.0);
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.
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 ddT_LliqMax(double &)
derivative of LliqMax with respect to temperature
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
void modena_model_destroy(modena_model_t *self)
Function deallocating the memory allocated for the surrogate model.
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 modena_model_argPos_check(const modena_model_t *self)
Function checking that the user has queried all input positions.
double dTdtFirstOrder(double &Tc, double &To, double &timeStep)
first order accurate dTdt