MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
diffusivity.py
1 
31 
32 
42 
43 import os
44 from modena import *
45 from fireworks.utilities.fw_utilities import explicit_serialize
46 from jinja2 import Template
47 
48 
49 
50 species = IndexSet(
51  name= 'diffusivity_pol_species',
52  names= [ 'CO2', 'CyP', 'N2', 'O2' ]
53 )
54 
57 f_diffusivity = CFunction(
58  Ccode='''
59 #include "modena.h"
60 #include "math.h"
61 
62 void diffusivityPol
63 (
64  const modena_model_t* model,
65  const double* inputs,
66  double *outputs
67 )
68 {
69  {% block variables %}{% endblock %}
70 
71  const double a = parameters[0];
72  const double b = parameters[1];
73 
74  outputs[0] = a*exp(-(b*(1/T)));
75 }
76 ''',
77  # These are global bounds for the function
78  inputs={
79  'T': {'min': 273, 'max': 550},
80  },
81  outputs={
82  'diffusivity': {'min': 0, 'max': +9e99, 'argPos': 0},
83  },
84  parameters={
85  'param0[A]': {'min': 0.0, 'max': +9e99, 'argPos': 0},
86  'param1[A]': {'min': 0.0, 'max': +9e99, 'argPos': 1},
87  },
88  indices={
89  'A': species,
90  },
91 )
92 
95 m_CO2_diffusivity = ForwardMappingModel(
96  _id='diffusivityPol[A=CO2]',
97  surrogateFunction=f_diffusivity,
98  substituteModels=[],
99  parameters=[0.00123, 6156],
100 )
101 
104 m_CyP_diffusivity = ForwardMappingModel(
105  _id='diffusivityPol[A=CyP]',
106  surrogateFunction=f_diffusivity,
107  substituteModels=[],
108  parameters=[1.7e-7, 4236],
109 )
110 
113 m_N2_diffusivity = ForwardMappingModel(
114  _id='diffusivityPol[A=N2]',
115  surrogateFunction=f_diffusivity,
116  substituteModels=[],
117  parameters=[0.003235, 6927],
118 )
119 
122 m_O2_diffusivity = ForwardMappingModel(
123  _id='diffusivityPol[A=O2]',
124  surrogateFunction=f_diffusivity,
125  substituteModels=[],
126  parameters=[0.00085, 6411],
127 )