MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
Rheology_Arrhenius.py
1 
31 
32 
41 
42 import os
43 import modena
44 import SurfaceTension, polymerViscosity
45 import Rheology
46 from modena import ForwardMappingModel, BackwardMappingModel, SurrogateModel, CFunction, ModenaFireTask
47 import modena.Strategy as Strategy
48 from fireworks.user_objects.firetasks.script_task import FireTaskBase, ScriptTask
49 from fireworks import Firework, Workflow, FWAction
50 from fireworks.utilities.fw_utilities import explicit_serialize
51 from jinja2 import Template
52 
53 f = CFunction(
54  Ccode= '''
55 #include "modena.h"
56 #include "math.h"
57 #include <stdio.h>
58 
59 void Arrhenius
60 (
61  const modena_model_t* model,
62  const double* inputs,
63  double *outputs
64 )
65 {
66  {% block variables %}{% endblock %}
67 
68  const double A_mu = 0.0387; // could be loaded from some library for consistence
69  const double E_mu = 10000;
70  const double R_rh = 8.314;
71 
72  double f_t, mu_ap;
73 
74  f_t = A_mu * exp(E_mu / R_rh / T );
75 
76  mu_ap = mu_car * f_t;
77  // printf("apparent viscosity %f", mu_ap);
78  outputs[0] = mu_ap;
79 }
80 ''',
81  inputs={
82  'T': {'min': 0, 'max': 9e99 },
83  'shear': {'min': 0, 'max': 9e99 },
84  'X': {'min': 0, 'max': 1 },
85  'm0' : {'min': 0, 'max' : 9e99},
86  'm1' : {'min': 0, 'max' : 9e99},
87  'mu' : {'min': 0, 'max' : 9e99},
88  'ST' : {'min': 0, 'max' : 9e99},
89  'mu_car' : {'min': 0, 'max' : 9e99},
90  },
91  outputs={
92  'mu_ap': { 'min': 0, 'max': 9e99, 'argPos': 0 },
93  },
94  parameters={
95  'Rgas' : {'min': 8.31, 'max': 8.32, 'argPos': 0},
96  }
97 )
98 
99 
100 m = ForwardMappingModel(
101  _id='Rheology_Arrhenius',
102  surrogateFunction=f,
103  substituteModels=[ Rheology.m ],
104  parameters=[ 8.314 ],
105 )