foaming_ini = json.load(fl) ## Surrogate model for foam conductivity. # # Backward mapping model is used. Gas and polymer conductivity are taken # from substitute models. m_foamConductivity = BackwardMappingModel( _id='foamConductivity', surrogateFunction=f_foamConductivity, exactTask=FoamConductivityExactTask(), substituteModels=[ gasMixtureConductivity.m_gasMixtureConductivity,\ polymerConductivity.m_polymer_thermal_conductivity\ ], initialisationStrategy=Strategy.InitialPoints( initialPoints=foaming_ini, ), outOfBoundsStrategy=Strategy.ExtendSpaceStochasticSampling( nNewPoints=4 ), parameterFittingStrategy=Strategy.NonLinFitWithErrorContol( testDataPercentage=0.2, maxError=0.02, improveErrorStrategy=Strategy.StochasticSampling( nNewPoints=2 ), maxIterations=5 # Currently not used ), ) ## Foam conductivity simulation.
'max': 2, 'argPos': 2 }, }, ) # --------------------------------------------------------------------------- # m = BackwardMappingModel( _id='Rheology', surrogateFunction=f_dummy, exactTask=RheologyExactTask_dummy(), # surrogateFunction= f_tFEM, # exactTask= RheologyExactTask_tFEM(), substituteModels=[polymerViscosity.m_polymerViscosity, SurfaceTension.m], initialisationStrategy=Strategy.InitialPoints(initialPoints={ 'T': [270.0, 330.0], 'shear': [0, 10000], 'X': [0, 0.3], 'm0': [2.5e10, 1.1e10], 'm1': [0.1, 0.1], }, ), outOfBoundsStrategy=Strategy.ExtendSpaceStochasticSampling(nNewPoints=4), parameterFittingStrategy=Strategy.NonLinFitWithErrorContol( testDataPercentage=0.2, maxError=0.5, improveErrorStrategy=Strategy.StochasticSampling(nNewPoints=2), maxIterations=5 # Currently not used ), )
parameters={ 'param0': { 'min': 0.0, 'max': 10.0, 'argPos': 0 }, 'param1': { 'min': 0.0, 'max': 10.0, 'argPos': 1 }, }, ) m = BackwardMappingModel( _id= 'flowRate', surrogateFunction= f, exactTask= FlowRateExactSim(), substituteModels= [ idealGas.m ], initialisationStrategy= Strategy.InitialPoints( initialPoints= { 'D': [0.01, 0.01, 0.01, 0.01], 'T0': [300, 300, 300, 300], 'p0': [2.8e5, 3.2e5, 2.8e5, 3.2e5], 'p1Byp0': [0.03, 0.03, 0.04, 0.04], }, ), outOfBoundsStrategy= Strategy.ExtendSpaceStochasticSampling( nNewPoints= 4 ), parameterFittingStrategy= Strategy.NonLinFitWithErrorContol( testDataPercentage= 0.2, maxError= 0.05, improveErrorStrategy= Strategy.StochasticSampling( nNewPoints= 2 ), maxIterations= 5 # Currently not used ),
'max': 1E10, 'argPos': 1 }, 'param2': { 'min': -1E10, 'max': 1E10, 'argPos': 2 }, }, species={ 'A': blowing_agents, 'B': monomers }) m = BackwardMappingModel( _id='SurfaceTension[A=AIR,B=THF]', surrogateFunction=f, exactTask=SurfaceTensionExactSim(), substituteModels=[], initialisationStrategy=Strategy.InitialPoints(initialPoints={ 'T': [270.0, 290.0, 300.0], }, ), outOfBoundsStrategy=Strategy.ExtendSpaceStochasticSampling(nNewPoints=4), parameterFittingStrategy=Strategy.NonLinFitWithErrorContol( testDataPercentage=0.2, maxError=30.0, improveErrorStrategy=Strategy.StochasticSampling(nNewPoints=2), maxIterations=5 # Currently not used ), )
'lamdba': { 'min': 1.35, 'max': 21.35, 'argPos': 0 }, 'alpha': { 'min': 0, 'max': 2, 'argPos': 1 }, 'n_rh': { 'min': 0, 'max': 2, 'argPos': 2 }, }, ) m = BackwardMappingModel( _id= 'Rheology', surrogateFunction= f, exactTask= RheologyExactTask(), substituteModels= [ polymerViscosity.m_polymerViscosity, SurfaceTension.m], # substituteModels= [ ], initialisationStrategy= Strategy.InitialPoints( initialPoints= { 'T': [300.0, 310.0], # 310 is the maximum that is supported by Surface Tension Model 'shear': [0.01, 0.1], 'X': [0.1, 0.3], }, ), outOfBoundsStrategy= Strategy.ExtendSpaceStochasticSampling( nNewPoints= 4 ), parameterFittingStrategy= Strategy.NonLinFitWithErrorContol( testDataPercentage= 0.2, maxError= 0.5, improveErrorStrategy= Strategy.StochasticSampling( nNewPoints= 2 ), maxIterations= 5 # Currently not used ), )
_id='FoamElasticModulus_TEST', surrogateFunction=f_backward, exactTask=MechanicalPropertiesExactSim(), substituteModels=[], initialisationStrategy=Strategy.InitialData( initialData={ '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 ], '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 ], '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 ], '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 ], '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 ], }), outOfBoundsStrategy=Strategy.ExtendSpaceStochasticSampling(nNewPoints=4), parameterFittingStrategy=Strategy.NonLinFitWithErrorContol( testDataPercentage=0.2, maxError=9e99,
'min': 0.0, 'max': 1.0 }, } f2 = CFunction(Ccode=Ccode2, inputs=inputs2, outputs=outputs, parameters=parameters, indices=indices) f3 = CFunction(Ccode=Ccode3, inputs=inputs3, outputs=outputs, parameters=parameters4, indices=indices) outOfBoundsStrategy = Strategy.ExtendSpaceStochasticSampling(nNewPoints=4) parameterFittingStrategy = Strategy.NonLinFitWithErrorContol( testDataPercentage=0.2, maxError=0.1, improveErrorStrategy=Strategy.StochasticSampling(nNewPoints=2), maxIterations=5 # Currently not used ) m_solubilityCO2PU = BackwardMappingModel( _id='Solubility[A=CO2,B=2]', surrogateFunction=f2, exactTask=SolubilityExactSim(), substituteModels=[], initialisationStrategy=Strategy.InitialPoints(initialPoints={ 'T': [270, 320, 370, 420], 'xl1': [1.1e-3, 1.0e-3, 1.0e-3, 1.0e-4], 'xl2': [0.9989, 0.999, 0.999, 0.9999],
@namespace wallDrainage.wallDrainage @ingroup mod_wallDrainage @brief Backward mapping Firetask for Wall drainage model. @author Pavel Ferkl @copyright 2014-2016, MoDeNa Project. GNU Public License. @details # Wall drainage python module Contains a FireTask, which runs the detailed model and copies the results into the results folder. The relative path and name of the detailed model executable are hard coded. The FireTask is BackwardMapping, which means that if one of the lower scale backward mapping models will get out of validity range that model will be re-fitted to larger range and the detailed model will be re-run. This is repeated until the detailed model succesfully finishes (or possibly crashes for other reason, in which case an error is printed out). """ import os from modena import Strategy from modena.Strategy import BackwardMappingScriptTask ## Wall drainage application recipe # # Runs the detailed model and saves the results. m_simulation = Strategy.BackwardMappingScriptTask( script=os.path.dirname(os.path.abspath(__file__)) + '/wallDrainage' + ' && cp filmthickness.csv ../results/wallDrainage/' + ' && cp results_1d.csv ../results/wallDrainage/')
return { key: [ sr[key]['min'] + (sr[key]['min'] - sr[key]['min']) * points[j][i] for j in xrange(nPoints) ] for (i, key) in enumerate(sr) } m = BackwardMappingModel( _id='flowRate', surrogateFunction=f, exactTask=FlowRateExactSim(), substituteModels=[], initialisationStrategy=Strategy.InitialPoints(initialPoints={ 'D': [0.01, 0.01, 0.01, 0.01], 'rho0': [3.4, 3.5, 3.4, 3.5], 'p0': [2.8e5, 3.2e5, 2.8e5, 3.2e5], 'p1Byp0': [0.03, 0.03, 0.04, 0.04], }, ), outOfBoundsStrategy=Strategy.ExtendSpaceStochasticSampling(nNewPoints=4), parameterFittingStrategy=Strategy.Test( testDataPercentage=0.2, maxError=0.5, improveErrorStrategy=TemporaryClass(nNewPoints=2, constraints="p0 / p1 > 0"), maxIterations=5 # Currently not used ), )
import os import modena from modena import ForwardMappingModel, BackwardMappingModel, SurrogateModel, \ CFunction import modena.Strategy as Strategy from fireworks.user_objects.firetasks.script_task import FireTaskBase, ScriptTask from fireworks import Firework, Workflow, FWAction from fireworks.utilities.fw_utilities import explicit_serialize from blessings import Terminal from jinja2 import Template import Rheology ## Create terminal for colour output term = Terminal() # For the case, when only foam conductivity and no aging is needed. m = Strategy.BackwardMappingScriptTask( script=os.path.dirname(os.path.abspath(__file__)) + '/src_dummy/workflowdummy')
_id= 'idealGas', #exactTask= Strategy.InitialDataPoints(), surrogateFunction= f2, substituteModels= [ ], parameters= [ 287.0 ], inputs={ 'p0': { 'min': 0, 'max': 9e99 }, 'T0': { 'min': 0, 'max': 9e99 }, }, outputs={ 'rho0': {'min': 0, 'max': 9e99 }, }, initialisationStrategy= Strategy.InitialData( initialData={ 'p0' : [1,2,3,4,5], 'T0' : [296,297,298,299,300], 'rho0' : [0.000011771353234, 0.00002346343809758, 0.00003507705259219, 0.00004661298404, 0.0000580720092915], }, ), ) m2 = BackwardMappingModel( _id= 'idealGasBackward', exactTask= Strategy.InitialDataPoints(), surrogateFunction= f1, substituteModels= [ ], parameters= [ 287.0 ], inputs={ 'p0': { 'min': 0, 'max': 9e99 }, 'T0': { 'min': 0, 'max': 9e99 }, },
'x[CyP]': setIP(xCyP0), } ## Surrogate model for foam conductivity # # Backward mapping model is used. m_foamConductivity = BackwardMappingModel( _id='foamConductivity', surrogateFunction=f_foamConductivity, exactTask=FoamConductivityExactTask(), substituteModels=[ gasMixtureConductivity.m_gasMixtureConductivity,\ polymerConductivity.m_polymer_thermal_conductivity\ ], initialisationStrategy=Strategy.InitialPoints( initialPoints=initialPoints_foamConductivity_auto, ), outOfBoundsStrategy=Strategy.ExtendSpaceStochasticSampling( nNewPoints=4 ), parameterFittingStrategy=Strategy.NonLinFitWithErrorContol( testDataPercentage=0.2, maxError=0.01, improveErrorStrategy=Strategy.StochasticSampling( nNewPoints=2 ), maxIterations=5 # Currently not used ), ) ## Foam conductivity simulation