MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
densityEqns.H
Go to the documentation of this file.
1 
14 dimensionedScalar oneTwo
16 (
17  "oneTwo",
18  dimDensity,
19  1.0
20 );
21 rho_gas = 1.2*oneTwo;
22 
23 // MoDeNa interface to get the liquid mixture density
24 volScalarField rhoPolySM
25 (
26  IOobject
27  (
28  "rhoPolySM",
29  runTime.timeName(),
30  mesh,
31  IOobject::READ_IF_PRESENT,
32  IOobject::AUTO_WRITE
33  ),
34  mesh,
35  dimensionedScalar("rhoPolySM", dimless, 1100.0)
36 );
37  // Calling the model for density reaction mixture
38  size_t Td_pos =
39  modena_model_inputs_argPos(density_reaction_mixturemodel, "T");
40  size_t XOHd_pos =
41  modena_model_inputs_argPos(density_reaction_mixturemodel, "XOH");
42  modena_model_argPos_check(density_reaction_mixturemodel);
43 forAll(mesh.C(), celli)
44 {
45  if (liquidMixtureDensitySurrogate)
46  {
47  // set input vector
48  modena_inputs_set(inputs_den, Td_pos, TS[celli]);
49  modena_inputs_set(inputs_den, XOHd_pos, XOH[celli]);
50  int ret_den =
52  (
53  density_reaction_mixturemodel,
54  inputs_den,
55  outputs_den
56  );
57  if (ret_den != 0)
58  {
59  modena_inputs_destroy (inputs_den);
60  modena_outputs_destroy (outputs_den);
61  modena_model_destroy (density_reaction_mixturemodel);
62  exit(ret_den);
63  }
64  rhoPolySM[celli] = modena_outputs_get(outputs_den, 0);
65  }
66  else
67  {
68  rhoPolySM[celli] = rhoPoly;
69  }
70 }
71 rhoPolySM.correctBoundaryConditions();
72 
73 if (PBESwitch)
74 {
75  dimensionedScalar dumVar1 ("dumVar1",dimensionSet(1,-1,-2,-1,0,0,0), 1.0);
76  dimensionedScalar dumVar2 ("dumVar2",dimensionSet(0,-2,2,1,0,0,0), 1.0);
77 
78  forAll(mesh.C(), celli)
79  {
80  if (wCO2_g[celli] < 0.0)
81  {
82  wCO2_g[celli] = ROOTVSMALL;
83  }
84  if (wBA_g[celli] < 0.0)
85  {
86  wBA_g[celli] = ROOTVSMALL;
87  }
88  if (TS[celli] < 0.0)
89  {
90  TS[celli] = 298.0;
91  }
92  }
93 
94  volScalarField rho_bubble
95  (
96  (p/(RR*TS))*((wCO2_g*M_CO2 + wBA_g*M_B)
97  /max((scalar(1000.0)*(wCO2_g + wBA_g)),ROOTVSMALL))
98  );
99 
100  rho_foam =
101  (
102  dumVar2*(rho_bubble*(mOne/(scalar(1.0) + mOne))
103  + dumVar1*((scalar(1.0) + L0)*rhoPolySM
104  *(scalar(1.0) - (mOne/(scalar(1.0) + mOne)))))
105  );
106 }
107 else
108 {
109  dimensionedScalar dumVar1 ("dumVar1",dimensionSet(0,2,-2,-1,0,0,0), 1.0);
110  dimensionedScalar dumVar2 ("dumVar2",dimensionSet(-1,3,0,0,0,0,0), 1.0);
111 
112  forAll(mesh.C(), celli)
113  {
114  scalar temp, henry_coeff;
115  temp = TS[celli];
116  henry_coeff = henryCoefficient(temp);
117 
118  scalar wCO2_g_val, wBA_g_val, pr, bubble_radius, mZero_val, mOne_val;
119 
120  mZero_val = mOne_val = 0.0;
121  bubble_radius = bubbleRadius(mZero_val, mOne_val);
122 
123  wCO2_g_val = wCO2_g[celli];
124  wBA_g_val = wBA_g[celli];
125  pr = p[celli];
126 
127  scalar partialPressure_CO2;
128  partialPressure_CO2 =
130  (
131  M_CO2, M_B, surfaceTension,
132  wCO2_g_val, wBA_g_val, pr, bubble_radius
133  );
134 
135  scalar wCO2_Max;
136  wCO2_Max = wCO2Max (M_CO2, M_liq, partialPressure_CO2, henry_coeff);
137 
138  CO2[celli] =
139  (
140  ((CW_0*XW[celli]*M_CO2)/(scalar(1000.0)*rhoPolySM[celli])) - wCO2_Max
141  );
142 
143  if (CO2[celli] < 0.0)
144  {
145  CO2[celli] = 0.0;
146  }
147  }
148  rho_foam =
149  (
150  (scalar(1.0) + L0)/
151  (((CO2*scalar(1000.0)*RR*TS)/(p*M_CO2))*dumVar1
152  + ((wBA_g*scalar(1000.0)*RR*TS)/(p*M_B))*dumVar1
153  + ((wBA_l)/(rhoBL))*dumVar2
154  + (scalar(1.0)/rhoPolySM)*dumVar2)
155  );
156 }
157 ///@endcond
size_t modena_model_inputs_argPos(const modena_model_t *self, const char *name)
Function determining position of an argument in the input vector.
Definition: model.c:366
double henryCoefficient(double &T)
Henry coefficient for CO2.
real(dp) temp
temperature (K)
Definition: globals.f90:49
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.
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.
Definition: model.c:553
double RR
ideal gas constant, J/mol K
double bubbleRadius(const double m0, const double m1)
radius of bubbles based on the moments
Definition: bubbleRadius.h:28
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.
Definition: model.c:665
double rhoBL
density of the blowing agent, kg/m3
double M_B
Molecular mass of blowing agent, kg/kmol.
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.
Definition: model.c:408