MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
polymerConductivity.py
1 
31 
32 
44 
45 import os
46 import modena
47 from modena import ForwardMappingModel, BackwardMappingModel, SurrogateModel, CFunction
48 import modena.Strategy as Strategy
49 from fireworks.user_objects.firetasks.script_task import FireTaskBase, ScriptTask
50 from fireworks import Firework, Workflow, FWAction
51 from fireworks.utilities.fw_utilities import explicit_serialize
52 from blessings import Terminal
53 from jinja2 import Template
54 
55 
56 term = Terminal()
57 
58 
61 f_polymer_thermal_conductivity = CFunction(
62  Ccode='''
63 #include "modena.h"
64 #include "math.h"
65 
66 void thermal_conductivity
67 (
68  const modena_model_t* model,
69  const double* inputs,
70  double *outputs
71 )
72 {
73  {% block variables %}{% endblock %}
74 
75  const double a = parameters[0];
76  const double b = parameters[1];
77 
78  outputs[0] = (a*T)+b;
79 }
80 ''',
81  # These are global bounds for the function
82  inputs={
83  'T': {'min': 273, 'max': 550},
84  },
85  outputs={
86  'polymer_thermal_conductivity': {
87  'min': 0, 'max': +9e99, 'argPos': 0
88  },
89  },
90  parameters={
91  'param0': {'min': -9e99, 'max': +9e99, 'argPos': 0},
92  'param1': {'min': -9e99, 'max': +9e99, 'argPos': 1},
93  },
94 )
95 
96 
99 m_polymer_thermal_conductivity = ForwardMappingModel(
100  _id='polymer_thermal_conductivity',
101  surrogateFunction=f_polymer_thermal_conductivity,
102  substituteModels=[],
103  parameters=[0.198e-3, 151.08e-3],
104  inputs={
105  'T': {'min': 273, 'max': 450},
106  },
107  outputs={
108  'polymer_thermal_conductivity': {'min': 0, 'max': +9e99},
109  },
110 )