MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
polymerViscosity.py
1 
31 
32 
51 
52 import os
53 import json
54 from modena import *
55 
56 
59 f_polymerViscosity = CFunction(
60  Ccode='''
61 #include "modena.h"
62 #include "math.h"
63 
64 void viscosity_SM
65 (
66  const modena_model_t* model,
67  const double* inputs,
68  double *outputs
69 )
70 {
71  {% block variables %}{% endblock %}
72 
73  const double Aeta = parameters[0];
74  const double Eeta = parameters[1];
75  const double AA = parameters[2];
76  const double B = parameters[3];
77  const double Xg = parameters[4];
78 
79  const double Rg = 8.31446218;
80 
81  if (X<Xg) {
82  outputs[0] = Aeta*exp(Eeta/(Rg*T))*pow(Xg/(Xg-X),AA+B*X);
83  } else {
84  outputs[0] = 1e10;
85  }
86 }
87 ''',
88  # These are global bounds for the function
89  inputs={
90  'T': {'min': 200, 'max': 550 },
91  'X': {'min': 0, 'max': 1 },
92  },
93  outputs={
94  'mu': {'min': 0, 'max': +9e99, 'argPos': 0},
95  },
96  parameters={
97  'param1': {'min': -1e9, 'max': 1e9, 'argPos': 0},
98  'param2': {'min': -1e9, 'max': 1e9, 'argPos': 1},
99  'param3': {'min': -1e9, 'max': 1e9, 'argPos': 2},
100  'param4': {'min': -1e9, 'max': 1e9, 'argPos': 3},
101  'param5': {'min': -1e9, 'max': 1e9, 'argPos': 4},
102  },
103 )
104 with open(os.getcwd()+'/inputs/unifiedInput.json') as jsonfile:
105 
106  inputs=json.load(jsonfile)
107 
108  X_gel=inputs['kinetics']['gelPoint']
109 
111 par = [4.1e-8, 38.3e3, 4.0, -2.0, X_gel]
112 
114 par2 = [10.3e-8, 41.3e3, 1.5, 1.0, X_gel]
115 
116 
118 par3 = [3.32e-8, 42.9e3, 2.32, 1.4, X_gel]
119 
120 
122 par4 = [4.1e-8, 38.3e3, 4.0, -2.0, X_gel]
123 
125 par5 = [3.1e0, 2.24e3, 3.5, -2.0, X_gel]
126 
128 par6 = [1.6e-7, 44.9e3, 1.29, 1.86, X_gel]
129 
131 par7 = [2.49707805e-13, 6.88758966e+04, 1.03553549e+01, -1.46554648e+01, 0.5]
132 
134 par8 = [7.03759789e-17, 8.91382466e+04, 1.32209736e+01, -1.82153953e+01, 0.5]
135 
136 
139 m_polymerViscosity = ForwardMappingModel(
140  _id='polymerViscosity',
141  surrogateFunction=f_polymerViscosity,
142  substituteModels=[],
143  parameters=par,
144 )