def test_pass(self):

        stress_options = mgis_bv.FiniteStrainBehaviourOptionsStressMeasure
        to_options = mgis_bv.FiniteStrainBehaviourOptionsTangentOperator
        # path to the test library
        lib = os.environ['MGIS_TEST_BEHAVIOURS_LIBRARY']
        version = os.environ['MGIS_TEST_TFEL_VERSION']
        h = mgis_bv.Hypothesis.Tridimensional
        o = mgis_bv.FiniteStrainBehaviourOptions()
        o.stress_measure = stress_options.PK1
        o.tangent_operator = to_options.DPK1_DF
        b = mgis_bv.load(o, lib, 'FiniteStrainSingleCrystal', h)
        self.assertTrue(b.tfel_version == version, "invalid TFEL version")
        self.assertTrue(len(b.gradients) == 1, 'invalid number of gradients')
        self.assertTrue(b.gradients[0].name == 'DeformationGradient',
                        'invalid gradient name')
        self.assertTrue(b.gradients[0].getType() == 'Tensor',
                        'invalid gradient type')
        self.assertTrue(b.gradients[0].type == mgis_bv.VariableType.TENSOR,
                        'invalid gradient type')
        self.assertTrue(b.gradients[0].type == mgis_bv.VariableType.Tensor,
                        'invalid gradient type')
        self.assertTrue(
            len(b.thermodynamic_forces) == 1,
            'invalid number of thermodynamic_forces')
        pk1 = b.thermodynamic_forces[0]
        self.assertTrue(pk1.name == 'FirstPiolaKirchhoffStress',
                        'invalid thermodynamic force  name')
        self.assertTrue(pk1.getType() == 'Tensor',
                        'invalid thermodynamic force  type')
        self.assertTrue(pk1.type == mgis_bv.VariableType.TENSOR,
                        'invalid thermodynamic force  type')
 def load_behaviour(self):
     self.is_finite_strain = mgis_bv.isStandardFiniteStrainBehaviour(self.path, self.name)
     if self.is_finite_strain:
         # finite strain options
         bopts = mgis_bv.FiniteStrainBehaviourOptions()
         bopts.stress_measure = mgis_bv.FiniteStrainBehaviourOptionsStressMeasure.PK1
         bopts.tangent_operator = mgis_bv.FiniteStrainBehaviourOptionsTangentOperator.DPK1_DF
         self.behaviour = mgis_bv.load(bopts, self.path,
                                       self.name, self.hypothesis)
     else:
         self.behaviour = mgis_bv.load(self.path, self.name, self.hypothesis)
Пример #3
0
    def __init__(
        self,
        nq: int,
        library_path: str,
        library_name: str,
        hypothesis: Hypothesis,
        stabilization_parameter: float,
        lagrange_parameter: float,
        field: Field,
        parameters: Dict[str, float] = None,
        integration_type: IntegrationType = IntegrationType.
        IntegrationWithConsistentTangentOperator,
        storage_mode:
        MaterialStateManagerStorageMode = MaterialStateManagerStorageMode.
        ExternalStorage,
        temperature: float = 293.15,
    ):
        """

        Args:
            nq:
            library_path:
            library_name:
            hypothesis:
            stabilization_parameter:
            field:
            parameters:
            integration_type:
            storage_mode:
            temperature:
        """
        self.nq = nq
        self.behaviour_name = library_name
        if field.grad_type in [GradType.DISPLACEMENT_SMALL_STRAIN]:
            if field.flux_type == FluxType.STRESS_CAUCHY:
                self.behaviour = mgis_bv.load(library_path, library_name,
                                              hypothesis)
        elif field.grad_type == GradType.DISPLACEMENT_TRANSFORMATION_GRADIENT:
            if field.flux_type == FluxType.STRESS_PK1:
                opt = mgis_bv.FiniteStrainBehaviourOptions()
                opt.stress_measure = mgis_bv.FiniteStrainBehaviourOptionsStressMeasure.PK1
                opt.tangent_operator = mgis_bv.FiniteStrainBehaviourOptionsTangentOperator.DPK1_DF
                self.behaviour = mgis_bv.load(opt, library_path, library_name,
                                              hypothesis)
        self.mat_data = mgis_bv.MaterialDataManager(self.behaviour, self.nq)
        self.stabilization_parameter = stabilization_parameter
        self.lagrange_parameter = lagrange_parameter
        if not parameters is None:
            for key, val in parameters.items():
                mgis_bv.setParameter(self.behaviour, key, val)
        self.integration_type = integration_type
        self.storage_mode = storage_mode
        self.temperature = temperature
Пример #4
0
    def test_pass(self):

        btype = mgis_bv.BehaviourType
        bkinematic = mgis_bv.BehaviourKinematic
        bsyme = mgis_bv.BehaviourSymmetry
        stress_options = mgis_bv.FiniteStrainBehaviourOptionsStressMeasure
        to_options = mgis_bv.FiniteStrainBehaviourOptionsTangentOperator
        # path to the test library
        lib = os.environ['MGIS_TEST_BEHAVIOURS_LIBRARY']
        version = os.environ['MGIS_TEST_TFEL_VERSION']
        h = mgis_bv.Hypothesis.Tridimensional
        o = mgis_bv.FiniteStrainBehaviourOptions()
        o.stress_measure = stress_options.PK1
        o.tangent_operator = to_options.DPK1_DF
        b = mgis_bv.load(o, lib, 'FiniteStrainSingleCrystal', h)
        self.assertTrue(b.behaviour == 'FiniteStrainSingleCrystal',
                        'invalid behaviour name')
        self.assertTrue(b.hypothesis == h, 'invalid hypothesis')
        self.assertTrue(b.source == 'FiniteStrainSingleCrystal.mfront',
                        'invalid source')
        self.assertTrue(b.tfel_version == version, 'invalid TFEL version')
        self.assertTrue(
            b.getBehaviourType() == 'StandardFiniteStrainBehaviour',
            'invalid behaviour type')
        self.assertTrue(b.btype == btype.STANDARDFINITESTRAINBEHAVIOUR,
                        'invalid behaviour type')
        self.assertTrue(b.btype == btype.StandardFiniteStrainBehaviour,
                        'invalid behaviour type')
        self.assertTrue(b.getKinematic() == 'F_CAUCHY',
                        'invalid kinematic value')
        self.assertTrue(
            b.kinematic == bkinematic.FINITESTRAINKINEMATIC_F_CAUCHY,
            'invalid kinematic value')
        self.assertTrue(
            b.kinematic == bkinematic.FiniteStrainKinematic_F_Cauchy,
            'invalid kinematic value')
        self.assertTrue(b.getSymmetry() == 'Orthotropic',
                        'invalid behaviour symmetry')
        self.assertTrue(b.symmetry == bsyme.ORTHOTROPIC,
                        'invalid behaviour symmetry')
        self.assertTrue(b.symmetry == bsyme.Orthotropic,
                        'invalid behaviour symmetry')
        self.assertTrue(len(b.gradients) == 1, 'invalid number of gradients')
        F = b.gradients[0]
        self.assertTrue(F.name == 'DeformationGradient',
                        'invalid gradient name')
        self.assertTrue(F.getType() == 'Tensor', 'invalid gradient type')
        self.assertTrue(F.type == mgis_bv.VariableType.TENSOR,
                        'invalid gradient type')
        self.assertTrue(F.type == mgis_bv.VariableType.Tensor,
                        'invalid gradient type')
        self.assertTrue(
            len(b.thermodynamic_forces) == 1,
            'invalid number of thermodynamic_forces')
        pk1 = b.thermodynamic_forces[0]
        self.assertTrue(pk1.name == 'FirstPiolaKirchhoffStress',
                        'invalid flux name')
        self.assertTrue(pk1.getType() == 'Tensor', 'invalid flux type')
        self.assertTrue(pk1.type == mgis_bv.VariableType.TENSOR,
                        'invalid flux type')
        self.assertTrue(pk1.type == mgis_bv.VariableType.Tensor,
                        'invalid flux type')
        self.assertTrue(
            len(b.mps) == 16, 'invalid number of material properties')

        def check_mp_name(mp, n):
            self.assertTrue(
                mp.name == n, "invalid material property name, "
                "expected '" + n + "'")

        for mp in b.mps:
            self.assertTrue(mp.getType() == 'Scalar',
                            "invalid material property type '" + mp.name + "'")
            self.assertTrue(mp.type == mgis_bv.VariableType.SCALAR,
                            "invalid material property type '" + mp.name + "'")
            self.assertTrue(mp.type == mgis_bv.VariableType.Scalar,
                            "invalid material property type '" + mp.name + "'")
        check_mp_name(b.mps[0], 'YoungModulus1')
        check_mp_name(b.mps[1], 'YoungModulus2')
        check_mp_name(b.mps[2], 'YoungModulus3')
        check_mp_name(b.mps[3], 'PoissonRatio12')
        check_mp_name(b.mps[4], 'PoissonRatio23')
        check_mp_name(b.mps[5], 'PoissonRatio13')
        check_mp_name(b.mps[6], 'ShearModulus12')
        check_mp_name(b.mps[7], 'ShearModulus23')
        check_mp_name(b.mps[8], 'ShearModulus13')
        check_mp_name(b.mps[9], 'm')
        check_mp_name(b.mps[10], 'K')
        check_mp_name(b.mps[11], 'C')
        check_mp_name(b.mps[12], 'R0')
        check_mp_name(b.mps[13], 'Q')
        check_mp_name(b.mps[14], 'b')
        check_mp_name(b.mps[15], 'd1')
        self.assertTrue(
            len(b.isvs) == 37, 'invalid number of internal state variables')

        def check_iv_name(iv, n, i):
            vn = n + '[' + str(i) + ']'
            self.assertTrue(
                iv.name == vn, "invalid internal state variable name, "
                "expected '" + vn + "'")
            self.assertTrue(
                iv.getType() == 'Scalar',
                'invalid type for internal ' + 'state variable \'' + vn + '\'')
            self.assertTrue(
                iv.type == mgis_bv.VariableType.SCALAR,
                'invalid type for internal ' + 'state variable \'' + vn + '\'')
            self.assertTrue(
                iv.type == mgis_bv.VariableType.Scalar,
                'invalid type for internal ' + 'state variable \'' + vn + '\'')

        for i in range(0, 12):
            check_iv_name(b.isvs[i], 'g', i)
            check_iv_name(b.isvs[13 + i], 'p', i)
            check_iv_name(b.isvs[25 + i], 'a', i)
        self.assertTrue(b.isvs[12].name == 'Fe',
                        "invalid name for internal state variable 'Fe'")
        self.assertTrue(b.isvs[12].getType() == "Tensor",
                        "invalid type for internal state variable 'Fe'")
        self.assertTrue(b.isvs[12].type == mgis_bv.VariableType.TENSOR,
                        "invalid type for internal state variable 'Fe'")
        self.assertTrue(b.isvs[12].type == mgis_bv.VariableType.Tensor,
                        "invalid type for internal state variable 'Fe'")
        self.assertTrue(
            len(b.esvs) == 1, 'invalid number of external state variables')
        self.assertTrue(b.esvs[0].name == 'Temperature',
                        'invalid name for the first external state variable')
        self.assertTrue(b.esvs[0].getType() == 'Scalar',
                        'invalid type for the first external state variable')
        self.assertTrue(b.esvs[0].type == mgis_bv.VariableType.SCALAR,
                        'invalid type for the first external state variable')
        self.assertTrue(b.esvs[0].type == mgis_bv.VariableType.Scalar,
                        'invalid type for the first external state variable')