51 from os
import getcwd, system
52 from os.path
import abspath, dirname, join
53 from jinja2
import Template
56 from modena
import ForwardMappingModel,BackwardMappingModel, CFunction, ModenaFireTask, Strategy
59 from fireworks.utilities.fw_utilities
import explicit_serialize
62 MODULE_DIR = dirname(abspath(__file__))
63 EXECUTION_DIR = getcwd()
65 TEMPLATE_FoamElasticModulus = Template(\
67 {{ s['point']['Mu'] }} 68 {{ s['point']['Sigma'] }} 69 {{ s['point']['strut_content'] }} 70 {{ s['point']['rho'] }} 71 """, trim_blocks=
True, lstrip_blocks=
True)
80 INPUT_FILE =
"Inputs.in" 81 OUTPUT_FILE =
"Outputs.in" 83 def task(self, fw_spec):
86 TEMPLATE_FoamElasticModulus.stream(s=self).dump(self.INPUT_FILE)
89 run_command = join(MODULE_DIR,
"AbaqusSimulation.py")
91 ret = subprocess.check_call(run_command, shell=
True)
93 self.handleReturnCode(ret)
96 with open(self.OUTPUT_FILE,
'r') as FILE: self['point'][
'E'] = float(FILE.readline())
101 f_backward = CFunction(
105 void two_tank_flowRate 107 const modena_model_t* model, 108 const double* inputs, 112 {% block variables %}{% endblock %} 115 const double C1 = parameters[0]; 116 const double C2 = parameters[1]; 118 const double E_PU = 2400; 119 const double rho_PU = 1200; 121 outputs[0] = E_PU*(C1*pow(strut_content*rho/rho_PU,2) + C2*(1-strut_content)*(rho/rho_PU)); 126 'rho': {
'min': 0,
'max': 1e5},
127 'strut_content': {
'min': 0,
'max': 1e5},
128 'Mu': {
'min': 0,
'max': 1e5},
129 'Sigma': {
'min': 0,
'max': 1e5},
132 'E': {
'min': 9e99,
'max': -9e99,
'argPos': 0 },
135 'C1': {
'min': 0.0,
'max': 10.0,
'argPos': 0 },
136 'C2': {
'min': 0.0,
'max': 10.0,
'argPos': 1 },
142 f_ludwigshafen = CFunction(
148 const modena_model_t* model, 149 const double* inputs, 153 {% block variables %}{% endblock %} 155 const double C1 = parameters[0]; 156 const double C2 = parameters[1]; 157 const double E_PU = 2400; 158 const double rho_PU = 1200; 160 outputs[0] = E_PU*(C1*pow(strut_content*rho/rho_PU,2) + C2*(1-strut_content)*(rho/rho_PU)); 165 'rho': {
'min': 0,
'max': 1e5},
166 'strut_content': {
'min': 0,
'max': 1e5},
167 'Mu': {
'min': 0,
'max': 1e5},
168 'Sigma': {
'min': 0,
'max': 1e5},
171 'E': {
'min': 0,
'max': 1,
'argPos': 0 },
174 'C1': {
'min': -9e99,
'max': +9e99,
'argPos': 0 },
175 'C2': {
'min': -9e99,
'max': +9e99,
'argPos': 1 },
181 m_forward = ForwardMappingModel(
182 _id=
'FoamElasticModulus',
183 surrogateFunction=f_ludwigshafen,
184 substituteModels= [ ],
189 m_backward = BackwardMappingModel(
190 _id=
'FoamElasticModulus_TEST',
191 surrogateFunction= f_backward,
193 substituteModels= [],
194 initialisationStrategy= Strategy.InitialData(
196 'rho': [30.2,60,120,240,30.2,60,120,240,30.2,30.2,30.2,30.2,30.2,30.2,30.2],
197 'strut_content': [0.4,0.4,0.4,0.4,0.8,0.8,0.8,0.8,0.85,0.85,0.85,0.85,0.85,0.85,0.85],
198 'Mu': [0.39,0.39,0.39,0.39,0.39,0.39,0.39,0.39,0.39,0.39,0.39,0.39,0.39,0.39,0.39],
199 'Sigma': [0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.01,0.05,0.1,0.15,0.2,0.25,0.30],
200 'E': [8.16,22.85,52.89,124.73,6.53,13.06,30.36,65.63,4.97,5.48,5.42,4.52,4.61,4.42,4.79],
203 outOfBoundsStrategy= Strategy.ExtendSpaceStochasticSampling(
206 parameterFittingStrategy= Strategy.NonLinFitWithErrorContol(
207 testDataPercentage= 0.2,
209 improveErrorStrategy= Strategy.StochasticSampling(