MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
density_reaction_mixture.py
Go to the documentation of this file.
1 
31 
32 
45 
46 import os
47 import modena
48 from modena import CFunction, IndexSet, \
49  ForwardMappingModel, BackwardMappingModel, SurrogateModel
50 import modena.Strategy as Strategy
51 from fireworks.user_objects.firetasks.script_task import FireTaskBase, ScriptTask
52 from fireworks import Firework, Workflow, FWAction
53 from fireworks.utilities.fw_utilities import explicit_serialize
54 from blessings import Terminal
55 from jinja2 import Template
56 
57 
58 term = Terminal()
59 
62 f = CFunction(
63  Ccode='''
64 #include "modena.h"
65 #include "math.h"
66 void densityreactionmixture
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_L0 = parameters[0];
76  const double b_L0 = parameters[1];
77  const double a_P0 = parameters[2];
78  const double b_P0 = parameters[3];
79 
80  outputs[0] = ((a_L0*T + b_L0) + ((a_P0*T + b_P0) - (a_L0*T + b_L0))*XOH);
81 }
82 ''',
83  # These are global bounds for the function
84  inputs={
85  'T': { 'min': 273, 'max': 550},
86  'XOH': { 'min': 0, 'max': 1},
87  },
88  outputs={
89  'density_polymer': { 'min': 0, 'max': 8000, 'argPos': 0 },
90  },
91  parameters={
92  'param0': { 'min': -9e99, 'max': +9e99, 'argPos': 0 },
93  'param1': { 'min': 0.0, 'max': +9e99, 'argPos': 1 },
94  'param2': { 'min': -9e99, 'max': +9e99, 'argPos': 2 },
95  'param3': { 'min': 0.0, 'max': +9e99, 'argPos': 3 },
96  },
97 )
98 
101 m = ForwardMappingModel(
102  _id='density_reaction_mixture',
103  surrogateFunction=f,
104  substituteModels= [ ],
105  parameters=[-0.0006, 1287.8, -0.000048, 992.8],
106 )