MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
conversionSources.H
Go to the documentation of this file.
1 
12 if (KineticsModel == "generic")
14 {
15  scalar temp_current,
16  temp_old,
17  Arhns_current,
18  Arhns_old,
19  XW_val,
20  XOH_valOld,
21  BA_dilution,
22  XOHSource_Old,
23  QW,
24  rhoPolyS;
25 
26  // call surrogate model for density reaction mixture
27  size_t T_pos =
28  modena_model_inputs_argPos(density_reaction_mixturemodel, "T");
29  size_t XOH_pos =
30  modena_model_inputs_argPos(density_reaction_mixturemodel, "XOH");
31  modena_model_argPos_check(density_reaction_mixturemodel);
32 
33  forAll(mesh.C(), celli)
34  {
35  temp_current = TS[celli];
36  temp_old = TS.oldTime()[celli];
37 
38  if (liquidMixtureDensitySurrogate)
39  {
40  // set input vector
41  modena_inputs_set(inputs_den, T_pos, temp_current);
42  modena_inputs_set(inputs_den, XOH_pos, XOH[celli]);
43  // call the model
44  int ret_den =
46  (
47  density_reaction_mixturemodel,
48  inputs_den,
49  outputs_den
50  );
51  if (ret_den != 0)
52  {
53  modena_inputs_destroy (inputs_den);
54  modena_outputs_destroy (outputs_den);
55  modena_model_destroy (density_reaction_mixturemodel);
56  exit(ret_den);
57  }
58  rhoPolyS = modena_outputs_get(outputs_den, 0);
59  }
60  else
61  {
62  rhoPolyS = rhoPoly;
63  }
64 
65  if (XW[celli] < 0.0)
66  {
67  XW[celli] = ROOTVSMALL;
68  }
69  if (XW[celli] > 1.0)
70  {
71  XW[celli] = ROOTVSMALL;
72  }
73  QW = QKinW (AW, EW, temp_current, L0, rhoPolyS, rhoBL);
74  if (QW < 0.0 || CW_0 == 0.0)
75  {
76  QW = ROOTVSMALL;
77  }
78 
79  if (XOH[celli] < XOH_Gel)
80  {
81  XWSource[celli] = QW;
82  }
83 
84  if (XW[celli] < 0.0)
85  {
86  XW_val = ROOTVSMALL;
87  }
88  else if (XW[celli] > 1.0)
89  {
90  XW_val = ROOTVSMALL;
91  }
92  else
93  {
94  XW_val = XW[celli];
95  }
96 
97  if (XOH[celli] < 0.0)
98  {
99  XOH[celli] = ROOTVSMALL;
100  }
101  if (XOH[celli] > 1.0)
102  {
103  XOH[celli] = ROOTVSMALL;
104  }
105 
106  if (XOH[celli] < XOH_Gel)
107  {
108  XOH_valOld = XOH[celli];
109  Arhns_current = arrhenius (AOH, EOH, temp_current);
110  Arhns_old = arrhenius (AOH, EOH, temp_old);
111  BA_dilution = BAdilution(L0,rhoPolyS,rhoBL);
112  XOHSource_Old =
113  (
114  (Arhns_old*COH_0*(1 - XOH_valOld)*
115  (CNCO_0/COH_0 - 2*XW_val*CW_0/COH_0 - XOH_valOld)*BA_dilution)
116  );
117  if (XOHSource_Old < 0.0)
118  {
119  ScNonXOH[celli] = ROOTVSMALL;
120  Coeff_1stOrd[celli] = ROOTVSMALL;
121  SuXOH[celli] = ROOTVSMALL;
122  SpXOH[celli] = ROOTVSMALL;
123  }
124  else
125  {
126  ScNonXOH[celli] =
127  (
128  BA_dilution*
129  (Arhns_current*CNCO_0 - 2.0*Arhns_current*CW_0*XW_val)
130  );
131  Coeff_1stOrd[celli] =
132  (
133  BA_dilution*
134  (Arhns_current*COH_0 + Arhns_current*CNCO_0
135  - 2.0*Arhns_current*CW_0*XW_val)
136  );
137 
138  SuXOH[celli] =
139  (
140  -1.0*BA_dilution*Arhns_old*
141  COH_0*Foam::pow(XOH_valOld,2.0)
142  );
143  SpXOH[celli] =
144  (
145  2.0*BA_dilution*Arhns_old*COH_0*XOH_valOld
146  );
147  }
148  }
149  }
150 }
151 if (KineticsModel == "RF-1")
152 {
153  forAll(mesh.C(), celli)
154  {
155  modena_inputs_set(inputs_kinetics, kineticTime_Pos, runTime.value());
156  modena_inputs_set(inputs_kinetics, Catalyst_1_Pos, (Catalyst_1[celli]));
157  modena_inputs_set(inputs_kinetics, CE_A0_Pos, (CE_A0[celli]));
158  modena_inputs_set(inputs_kinetics, CE_A1_Pos, (CE_A1[celli]));
159  modena_inputs_set(inputs_kinetics, CE_B_Pos, (CE_B[celli]));
160  modena_inputs_set(inputs_kinetics, CE_B2_Pos, (CE_B2[celli]));
161  modena_inputs_set(inputs_kinetics, CE_I0_Pos, (CE_I0[celli]));
162  modena_inputs_set(inputs_kinetics, CE_I1_Pos, (CE_I1[celli]));
163  modena_inputs_set(inputs_kinetics, CE_I2_Pos, (CE_I2[celli]));
164  modena_inputs_set(inputs_kinetics, CE_PBA_Pos, (CE_PBA[celli]));
165  modena_inputs_set(inputs_kinetics, CE_Breac_Pos, (CE_Breac[celli]));
166  modena_inputs_set(inputs_kinetics, CE_Areac0_Pos, (CE_Areac0[celli]));
167  modena_inputs_set(inputs_kinetics, CE_Areac1_Pos, (CE_Areac1[celli]));
168  modena_inputs_set(inputs_kinetics, CE_Ireac0_Pos, (CE_Ireac0[celli]));
169  modena_inputs_set(inputs_kinetics, CE_Ireac1_Pos, (CE_Ireac1[celli]));
170  modena_inputs_set(inputs_kinetics, CE_Ireac2_Pos, (CE_Ireac2[celli]));
171  modena_inputs_set(inputs_kinetics, Bulk_Pos, Bulk[celli]);
172  modena_inputs_set(inputs_kinetics, R_1_Pos, R_1[celli]);
173  modena_inputs_set(inputs_kinetics, R_1_mass_Pos, R_1_mass[celli]);
174  modena_inputs_set(inputs_kinetics, R_1_temp_RF1_Pos, (TS[celli] - 273.15));
175  modena_inputs_set(inputs_kinetics, R_1_vol_RF1_Pos, R_1_vol_RF1[celli]);
176 
177  // call the model
178  int ret_kinetics =
179  modena_model_call(kinetics, inputs_kinetics, outputs_kinetics);
180  if (ret_kinetics != 0)
181  {
182  modena_inputs_destroy (inputs_kinetics);
183  modena_outputs_destroy (outputs_kinetics);
184  modena_model_destroy (kinetics);
185  exit(ret_kinetics);
186  }
187  // source terms for RF-1
188  source_Catalyst_1[celli] =
189  modena_outputs_get(outputs_kinetics, source_Catalyst_1_Pos);
190  source_CE_A0[celli] =
191  modena_outputs_get(outputs_kinetics, source_CE_A0_Pos);
192  source_CE_A1[celli] =
193  modena_outputs_get(outputs_kinetics, source_CE_A1_Pos);
194  source_CE_B[celli] =
195  modena_outputs_get(outputs_kinetics, source_CE_B_Pos);
196  source_CE_B2[celli] =
197  modena_outputs_get(outputs_kinetics, source_CE_B2_Pos);
198  source_CE_I0[celli] =
199  modena_outputs_get(outputs_kinetics, source_CE_I0_Pos);
200  source_CE_I1[celli] =
201  modena_outputs_get(outputs_kinetics, source_CE_I1_Pos);
202  source_CE_I2[celli] =
203  modena_outputs_get(outputs_kinetics, source_CE_I2_Pos);
204  source_CE_PBA[celli] =
205  modena_outputs_get(outputs_kinetics, source_CE_PBA_Pos);
206  source_CE_Breac[celli] =
207  modena_outputs_get(outputs_kinetics, source_CE_Breac_Pos);
208  source_CE_Areac0[celli] =
209  modena_outputs_get(outputs_kinetics, source_CE_Areac0_Pos);
210  source_CE_Areac1[celli] =
211  modena_outputs_get(outputs_kinetics, source_CE_Areac1_Pos);
212  source_CE_Ireac0[celli] =
213  modena_outputs_get(outputs_kinetics, source_CE_Ireac0_Pos);
214  source_CE_Ireac1[celli] =
215  modena_outputs_get(outputs_kinetics, source_CE_Ireac1_Pos);
216  source_CE_Ireac2[celli] =
217  modena_outputs_get(outputs_kinetics, source_CE_Ireac2_Pos);
218  source_Bulk[celli] =
219  modena_outputs_get(outputs_kinetics, source_Bulk_Pos);
220  source_R_1[celli] =
221  modena_outputs_get(outputs_kinetics, source_R_1_Pos);
222  source_R_1_mass[celli] =
223  modena_outputs_get(outputs_kinetics, source_R_1_mass_Pos);
224  source_R_1_temp_RF1[celli] =
225  modena_outputs_get(outputs_kinetics, source_R_1_temp_RF1_Pos);
226  source_R_1_vol_RF1[celli] =
227  modena_outputs_get(outputs_kinetics, source_R_1_vol_RF1_Pos);
228 
229  if (CW_0 > scalar(1e-8)) {
230  XWSource[celli] = scalar(-1.0)*
231  source_CE_B2[celli]/(CW_0/scalar(1000.0));
232  } else {
233  XWSource[celli] = scalar(0.0);
234  }
235 
236  XOHSource[celli] = scalar(-1.0)*
237  (source_CE_A0[celli] + source_CE_A1[celli])/
238  ((COH_0))*scalar(1000.0);
239  }
240  source_Catalyst_1.correctBoundaryConditions();
241  source_CE_A0.correctBoundaryConditions();
242  source_CE_A1.correctBoundaryConditions();
243  source_CE_B.correctBoundaryConditions();
244  source_CE_B2.correctBoundaryConditions();
245  source_CE_I0.correctBoundaryConditions();
246  source_CE_I1.correctBoundaryConditions();
247  source_CE_I2.correctBoundaryConditions();
248  source_CE_PBA.correctBoundaryConditions();
249  source_CE_Breac.correctBoundaryConditions();
250  source_CE_Areac0.correctBoundaryConditions();
251  source_CE_Areac1.correctBoundaryConditions();
252  source_CE_Ireac0.correctBoundaryConditions();
253  source_CE_Ireac1.correctBoundaryConditions();
254  source_CE_Ireac2.correctBoundaryConditions();
255  source_Bulk.correctBoundaryConditions();
256  source_R_1.correctBoundaryConditions();
257  source_R_1_mass.correctBoundaryConditions();
258  source_R_1_temp_RF1.correctBoundaryConditions();
259  source_R_1_vol_RF1.correctBoundaryConditions();
260 }
261 ///@endcond
size_t source_CE_Ireac2_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:160
size_t source_CE_PBA_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:142
size_t source_CE_A1_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:124
size_t CE_I2_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:79
size_t source_CE_Breac_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:145
size_t source_Bulk_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:163
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
size_t source_CE_Areac0_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:148
size_t CE_Ireac0_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:94
size_t CE_PBA_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:82
size_t CE_Breac_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:85
size_t R_1_mass_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:112
size_t source_CE_I1_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:136
size_t Catalyst_1_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:58
size_t source_R_1_temp_RF1_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:172
size_t source_CE_B_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:127
size_t CE_Areac1_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:91
size_t CE_I1_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:76
size_t source_CE_Ireac1_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:157
size_t CE_Ireac2_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:100
size_t source_CE_A0_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:121
size_t CE_Areac0_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:88
size_t source_CE_I2_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:139
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
size_t R_1_vol_RF1_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:115
size_t source_CE_I0_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:133
size_t CE_I0_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:73
size_t source_R_1_mass_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:169
size_t source_CE_Ireac0_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:154
double rhoPoly
density of the liquid polymer, kg/m3
size_t source_R_1_vol_RF1_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:175
size_t source_Catalyst_1_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:118
void modena_model_destroy(modena_model_t *self)
Function deallocating the memory allocated for the surrogate model.
Definition: model.c:665
double arrhenius(double &, double &, double &)
Arrhenius function.
double BAdilution(double &, double &, double &)
dilution term for the blowing agent (n-pentane)
double rhoBL
density of the blowing agent, kg/m3
size_t R_1_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:106
double QKinW(double &AW, double &EW, double &tempi, double &Lliq, double &rhoPoly, double &rhoBL)
arrhenius term times by dilution term
size_t Bulk_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:103
size_t source_CE_Areac1_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:151
size_t kineticTime_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:55
double L0
Initial weight fraction of blowing agent in the liquid, -.
size_t CE_A1_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:64
size_t CE_B_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:67
size_t source_CE_B2_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:130
size_t CE_B2_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:70
void modena_model_argPos_check(const modena_model_t *self)
Function checking that the user has queried all input positions.
Definition: model.c:408
size_t CE_Ireac1_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:97
size_t R_1_temp_RF1_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:109
size_t CE_A0_Pos
memory allocation for inputs of kinetics surrogate model
Definition: modenaData.H:61
size_t source_R_1_Pos
memory allocation for outputs of kinetics surrogate model
Definition: modenaData.H:166