def no_refitting():
    """
    initialize with dummy data that should ensure that foamConductivity
    does not go out of range
    """
    # this can fail when we change species in gas conductivity importing gas
    # conductivity surrogate model and running this script again should work
    try:
        indxs = list(IndexSet.load("gas_thermal_conductivity_species").names)
    except:
        indxs = ['CO2', 'CyP', 'O2', 'N2', 'Opt', 'Sol']
    ini = {
        "eps": [0.9, 0.0, 0.96, 0.99, 0.7, 0.5],
        "dcell": [200e-6, 0.0, 300e-6, 100e-6, 1e-2, 200e-6],
        "fstrut": [0.0, 1.0, 0.7, 0.6, 0.0, 0.9],
        "T": [280, 549, 300, 350, 330, 300]
    }
    mat = eye(6)
    for i, indx in enumerate(indxs):
        ini["x[" + indx + "]"] = mat[i % 6, :].tolist()
    with open("./inputs/init_foamConductivity.json", "w") as fl:
        json.dump(ini, fl, indent=4, sort_keys=True)
    return
Пример #2
0
@endcond'''

"""
@file
Python library of FireTasks

@author    Henrik Rusche
@copyright 2014-2015, MoDeNa Project. GNU Public License.
@ingroup   twoTank
"""

from modena import CFunction, IndexSet, ForwardMappingModel
import modena.Strategy as Strategy

species = IndexSet(
    name= 'species',
    names= [ 'H2O', 'N2', 'SO2' ]
)


f = CFunction(
    inputs={
        'T': { 'min': 0, 'max': 9e99 },
        'p': { 'min': 0, 'max': 9e99 },
    },
    outputs={
        'D[A]': { 'min': 0, 'max': 9e99, 'argPos': 0 },
    },
    parameters={
        'W[A]': { 'min': 0, 'max': 9e99, 'argPos': 0 },
        'V[A]': { 'min': 0, 'max': 9e99, 'argPos': 1 },
        'W[B]': { 'min': 0, 'max': 9e99, 'argPos': 2 },
Пример #3
0
"""
@file
@ingroup   mod_gasConductivity
@namespace gasConductivity.gasConductivity
@brief     Surrogate function and model definitions for thermal conductivity of
           blowing agents.
@author    Erik Laurini
@author    Pavel Ferkl
@copyright 2014-2016, MoDeNa Project. GNU Public License.
@ingroup   app_aging
"""

from modena import CFunction, ForwardMappingModel, IndexSet

## List of components, for which surrogate model is provided
species = IndexSet(name='gas_thermal_conductivity_species',
                   names=['CO2', 'CyP', 'O2', 'N2'])

## Surrogate function for thermal conductivity of blowing agents.
#
# Thermal conductivity of blowing agents is a function of temperature.
f_gas_thermal_conductivity = CFunction(
    Ccode='''
#include "modena.h"
#include "math.h"

void gas_thermal_conductivity
(
    const modena_model_t* model,
    const double* inputs,
    double *outputs
)
Пример #4
0
import os
import modena
from modena import ForwardMappingModel, BackwardMappingModel, SurrogateModel, CFunction, IndexSet, ModenaFireTask
import modena.Strategy as Strategy
from fireworks import Firework, Workflow, FWAction
from fireworks.utilities.fw_utilities import explicit_serialize
from jinja2 import Template

__author__ = 'Henrik Rusche'
__copyright__ = 'Copyright 2014, MoDeNa Project'
__version__ = '0.2'
__maintainer__ = 'Henrik Rusche'
__email__ = '[email protected].'
__date__ = 'Sep 4, 2014'

blowing_agents = IndexSet(name='blowing_agents', names=['air', 'CO2'])

monomers = IndexSet(name='monomers', names=['PU', 'THF', 'hexane'])


# ********************************* Class ********************************** #
@explicit_serialize
class SurfaceTensionExactSim(ModenaFireTask):
    """
    This FireTask controls the execution of the detailed model of the Surface Tension model.
    The detailed model is a density functional theory implementation based on PC-SAFT. A 
    detailed description of this model can be found in Deliverable 1.3 on the MoDeNa website.
    
    In order to start the detailed model, the input values for the model are first written to the
    file "in.txt". The detailed model code picks them up from this file and performs the according
    calculation. Once it is done, the output value is written to the file "out.txt". This FireTask
Пример #5
0
strategy determines, how many new points and where to place these new points,
once the Solubility model is called for input values outside of the fitted
range. The parameter fitting strategy defines tolerances and maximal iterations
which are passed to the numerical solver which performs the actual fitting of
the surrogate model parameters.

@author    Jonas Mairhofer, Pavel Ferkl
@copyright 2014-2016, MoDeNa Project. GNU Public License.
"""

import os
from fireworks.utilities.fw_utilities import explicit_serialize
from modena import CFunction, BackwardMappingModel, IndexSet, ModenaFireTask
from modena import Strategy, ForwardMappingModel

species = IndexSet(name='solubility_pol_species',
                   names=['Air', 'CO2', 'CyP', 'O2', 'N2', 'Opt', 'Sol'])
system = IndexSet(name='solubility_num_of_components', names=['2', '3'])


@explicit_serialize
class SolubilityExactSim(ModenaFireTask):
    """
    This FireTask controls the execution of the detailed model of the Solubility
    model. The detailed model uses the PC-SAFT equation of state. A detailed
    description of PC-SAFT model can be found in Deliverable 1.3 on the MoDeNa
    website.

    In order to start the detailed model, the input values for the model are
    first written to the file "in.txt". The detailed model code picks them up
    from this file and performs the according calculation. Once it is done, the
    output value is written to the file "out.txt". This FireTask then reads in
Пример #6
0
import os
import modena
from modena import CFunction, IndexSet, Workflow2, \
    ForwardMappingModel, BackwardMappingModel, SurrogateModel
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

## Create terminal for colour output
term = Terminal()
## List of components, for which surrogate model is provided
species = IndexSet(
    name= 'diffusivity_pol_species',
    names= [ 'CO2', 'CyP', 'N2', 'O2' ]
)
## Surrogate function for diffusivity of blowing agents in polymer.
#
# Diffusivity is a function of temperature.
f_diffusivity = CFunction(
    Ccode='''
#include "modena.h"
#include "math.h"

void diffusivityPol
(
    const modena_model_t* model,
    const double* inputs,
    double *outputs
)
Пример #7
0
from jinja2 import Template
from fireworks.utilities.fw_utilities import explicit_serialize
from modena import CFunction, BackwardMappingModel, IndexSet, ModenaFireTask
from modena import Strategy

## @var blowing_agents
# @brief (MoDeNa) Index Set for the Blowing Agents that are valid for the model
# @details
#
# The index set contains two elements:
#
# @f[
#     \mathbb{A} = \left\{ \text{Air}, \text{CO2} \right\}
# @f]
#
blowing_agents = IndexSet(name='blowing_agents', names=['AIR', 'CO2'])

## @var monomers
# @brief (MoDeNa) Index Set for the Monomers that are valid for the model
# @details
#
# The index set contains four elements:
#
# @f[
#   \mathbb{B} = \left\{ \text{PU}, \text{THF}, \text{HEXANE} \right\}
# @f]
#
monomers = IndexSet(name='monomers', names=['PU', 'THF', 'HEXANE'])

## @var surfactant
# @brief (MoDeNa) Index Set for the Surfactants that are valid for the model