MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
rheologyModel.H
Go to the documentation of this file.
1 
6 // Constant viscosity (Newtonian)
8 if (viscosityModel == "constant")
9 {
10  forAll(mesh.C(), celli)
11  {
12  muFoamCorr[celli] = 1.0e-3;
13  }
14 }
15 
16 // Castro-Macosko model (Newtonian)
17 if (viscosityModel == "castro-macosko")
18 {
19  double muTemp,alphacell,CXOH,CXW;
20  double muinf = 10.3*1e-8;
21  double XNCOGel = 1.0;
22  double EnuR = 4970.0;
23  double nua = 1.5;
24  double nub = 1.0;
25  double nuc = 0.0;
26 
27  forAll(mesh.C(), celli)
28  {
29  muTemp = TS[celli];
30  alphacell = alpha2[celli];
31  CXOH = XOH[celli];
32  CXW = XW[celli];
33 
34  if (alphacell > 0.5)
35  {
36  XNCO[celli] = (CNCO_0 - (CNCO_0 - CXOH*COH_0 - 2*CXW*CW_0))/CNCO_0;
37  muFoamCorr[celli] =
38  (
39  (muinf*Foam::exp(EnuR/(muTemp)) *
40  Foam::pow((XNCOGel/max((XNCOGel - XNCO[celli]),ROOTVSMALL)),
41  (nua + nub*XNCO[celli] + nuc*XNCO[celli]*XNCO[celli])))
42  );
43  }
44  }
45 }
46 
47 // Modified Bird-Carreau model (non-Newtonian)
48 if (viscosityModel == "bird-carreau")
49 {
50 
51  double coeffalpha,coeffn,muTemp,lambdaBC,XOHC,alphacell,a,b,c,d,mu0l,muinfl;
52  scalar Amu = 0.0387;
53  scalar EmuR = 10000.0;
54  // model constant
55  a = 1.5;
56  b = 1.0;
57  c = 0.0;
58  d = 0.001;
59  mu0l = 0.195;
60  muinfl = 0.266;
61  coeffalpha = 2.0;
62  lambdaBC = 11.35;
63  coeffn = 0.2;
64 
65  forAll(mesh.C(), celli)
66  {
67  alphacell = alpha2[celli];
68  if (alphacell > 0.5)
69  {
70  muTemp = TS[celli];
71  XOHC = XOH[celli];
72 
73  volScalarField shearRate = Foam::mag(fvc::grad(U));
74 
75  mu0[celli] =
76  (
77  (Foam::log(XOHC+d) - Foam::log(d) +
78  Foam::pow((XOH_Gel/max((XOH_Gel - XOHC),0.00001)),
79  ((a+b*XOHC+c*XOHC*XOHC))))*mu0l
80  );
81  muinf[celli] =
82  (
83  (Foam::log(XOHC + d) - Foam::log(d) +
84  Foam::pow((XOH_Gel/max((XOH_Gel - XOHC),0.00001)),
85  ((a + b*XOHC + c*XOHC*XOHC))))*muinfl
86  );
87 
88  muFoam[celli] =
89  (
90  ((muinf[celli] + (mag((mu0[celli] - muinf[celli]))*
91  Foam::pow((1.0 + Foam::pow((shearRate[celli]*lambdaBC),coeffalpha)),
92  ((coeffn - 1)/coeffalpha)))))
93  );
94  muFoamCorr[celli] = (muFoam[celli]*(Amu*Foam::exp(EmuR/RR/muTemp)));
95  }
96  else
97  {
98  muFoamCorr[celli] = 1.0e-5;
99  }
100  }
101 }
102 
103 if (viscosityModel == "MoDeNaRheology")
104 {
105  forAll(mesh.C(), celli)
106  {
107  if (alpha2[celli] > 0.5)
108  {
109  volScalarField shearRate = Foam::mag(fvc::grad(U));
110  // set input vector
111  modena_inputs_set(inputs_rheo, temp_rheopos, TS[celli]);
112  modena_inputs_set(inputs_rheo, conv_rheopos, XOH[celli]);
113  modena_inputs_set(inputs_rheo, shear_rheopos, shearRate[celli]);
114  modena_inputs_set(inputs_rheo, m0_rheopos, mZero[celli]);
115  modena_inputs_set(inputs_rheo, m1_rheopos, mOne[celli]);
116  // call the model
117  int ret_rheo = modena_model_call (rheologymodel, inputs_rheo, outputs_rheo);
118  if (modena_error_occurred())
119  {
120  modena_inputs_destroy (inputs_rheo);
121  modena_outputs_destroy (outputs_rheo);
122  modena_model_destroy (rheologymodel);
123  Info<< "MoDeNa Error: " << (modena_error()) << endl;
124  // exit(modena_error());
125  }
126  muFoamCorr[celli] = modena_outputs_get(outputs_rheo, 0);
127  }
128  }
129 }
130 muMixture = alpha1*muAir + alpha2*muFoamCorr;
131 muMixture.correctBoundaryConditions();
132 
133 ///@endcond
size_t m0_rheopos
memory allocation for the moment of order zero as the input of rheology surrogate model ...
Definition: modenaData.H:220
size_t temp_rheopos
memory allocation for the temperature as the input of rheology surrogate model
Definition: modenaData.H:211
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
size_t m1_rheopos
memory allocation for the moment of order one as the input of rheology surrogate model ...
Definition: modenaData.H:223
real(dp), dimension(:), allocatable d
diffusion coefficients (for each dissolved gas)
Definition: globals.f90:106
size_t conv_rheopos
memory allocation for the conversion as the input of rheology surrogate model
Definition: modenaData.H:217
void modena_model_destroy(modena_model_t *self)
Function deallocating the memory allocated for the surrogate model.
Definition: model.c:665
size_t shear_rheopos
memory allocation for the shear rate as the input of rheology surrogate model
Definition: modenaData.H:214