nonlinear_material.py 1.58 KB
Newer Older
1 2 3
import mgis.behaviour as mgis_bv

mgis_hypothesis = {"plane_strain": mgis_bv.Hypothesis.PlaneStrain,
Jeremy BLEYER's avatar
Jeremy BLEYER committed
4 5 6
                   "plane_stress": mgis_bv.Hypothesis.PlaneStress,
                   "3d": mgis_bv.Hypothesis.Tridimensional,
                   "axisymmetric": mgis_bv.Hypothesis.Axisymmetrical}
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33


class MFrontNonlinearMaterial:
    def __init__(self, path, name, hypothesis="3d",
                 material_properties={}, external_state_variables={"Temperature": 293.15}):
        self.path = path
        self.name = name
        # Defining the modelling hypothesis
        self.hypothesis = mgis_hypothesis[hypothesis]
        self.material_properties = material_properties
        self.external_state_variables = external_state_variables
        # Loading the behaviour
        self.behaviour = mgis_bv.load(self.path, self.name, self.hypothesis)

    def set_data_manager(self, ngauss):
        # Setting the material data manager
        self.data_manager = mgis_bv.MaterialDataManager(self.behaviour, ngauss)
        for s in [self.data_manager.s0, self.data_manager.s1]:
            for (key, value) in self.material_properties.items():
                mgis_bv.setMaterialProperty(s, key, value)
            for (key, value) in self.external_state_variables.items():
                mgis_bv.setExternalStateVariable(s, key, value)

    def get_state_variable_names(self):
        return [svar.name for svar in self.behaviour.internal_state_variables]
    def get_state_variable_sizes(self):
        return [mgis_bv.getVariableSize(svar, self.hypothesis) for svar in self.behaviour.internal_state_variables]