def _apply_material_properties(self,mp,dim):
        #define properties
        mp.GetProperties()[1].SetValue(KratosMultiphysics.YOUNG_MODULUS, 21000)
        mp.GetProperties()[1].SetValue(KratosMultiphysics.POISSON_RATIO, 0.3)
        mp.GetProperties()[1].SetValue(KratosMultiphysics.YIELD_STRESS, 5.5)
        mp.GetProperties()[1].SetValue(KratosMultiphysics.REFERENCE_HARDENING_MODULUS, 1.0)
        mp.GetProperties()[1].SetValue(KratosMultiphysics.ISOTROPIC_HARDENING_MODULUS, 0.12924)
        mp.GetProperties()[1].SetValue(KratosMultiphysics.INFINITY_HARDENING_MODULUS, 0.0)
        mp.GetProperties()[1].SetValue(KratosMultiphysics.HARDENING_EXPONENT, 1.0)

        g = [0,0,0]
        mp.GetProperties()[1].SetValue(KratosMultiphysics.VOLUME_ACCELERATION,g)

        if(dim == 2):
            cl = StructuralMechanicsApplication.LinearJ2PlasticityPlaneStrain2DLaw()
        else:
            cl = StructuralMechanicsApplication.LinearJ2Plasticity3DLaw()
        mp.GetProperties()[1].SetValue(KratosMultiphysics.CONSTITUTIVE_LAW,cl)
 def create_constitutive_Law():
     return StructuralMechanicsApplication.LinearJ2Plasticity3DLaw()
Пример #3
0
    def test_J2_Plasticity_3D(self):
        nnodes = 8
        dim = 3

        # Define a model and geometry
        model_part = KratosMultiphysics.ModelPart("test")
        geom = self._create_geometry(model_part, dim, nnodes)

        # Material properties
        prop_id = 0
        properties = model_part.Properties[prop_id]
        properties.SetValue(KratosMultiphysics.YOUNG_MODULUS, 21000)
        properties.SetValue(KratosMultiphysics.POISSON_RATIO, 0.3)
        properties.SetValue(KratosMultiphysics.YIELD_STRESS, 5.5)
        properties.SetValue(KratosMultiphysics.REFERENCE_HARDENING_MODULUS,
                            1.0)
        properties.SetValue(KratosMultiphysics.ISOTROPIC_HARDENING_MODULUS,
                            0.12924)
        properties.SetValue(KratosMultiphysics.INFINITY_HARDENING_MODULUS, 0.0)
        properties.SetValue(KratosMultiphysics.HARDENING_EXPONENT, 1.0)

        N = KratosMultiphysics.Vector(nnodes)
        DN_DX = KratosMultiphysics.Matrix(nnodes, dim)

        # Construct a constitutive law
        cl = StructuralMechanicsApplication.LinearJ2Plasticity3DLaw()
        self._cl_check(cl, properties, geom, model_part, dim)

        # Set the parameters to be employed
        dict_options = {
            'USE_ELEMENT_PROVIDED_STRAIN': False,
            'COMPUTE_STRESS': True,
            'COMPUTE_CONSTITUTIVE_TENSOR': True,
        }
        cl_options = self._set_cl_options(dict_options)
        stress_vector = KratosMultiphysics.Vector(cl.GetStrainSize())
        strain_vector = KratosMultiphysics.Vector(cl.GetStrainSize())
        constitutive_matrix = KratosMultiphysics.Matrix(
            cl.GetStrainSize(), cl.GetStrainSize())

        # Setting the parameters - note that a constitutive law may not need them all!
        F = self._create_F()
        detF = 1.0
        cl_params = self._set_cl_parameters(cl_options, F, detF, strain_vector,
                                            stress_vector, constitutive_matrix,
                                            N, DN_DX, model_part, properties,
                                            geom)
        cl.InitializeMaterial(properties, geom, N)

        # Check the results
        nr_timesteps = 10
        rstress = []
        for i in range(nr_timesteps):
            rstress.append(KratosMultiphysics.Vector(cl.GetStrainSize()))
        rstress[0][0] = 4.03846
        rstress[0][1] = 4.03846
        rstress[0][2] = 2.42308
        rstress[0][3] = 0.80769
        rstress[0][4] = 0.0
        rstress[0][5] = 0.80769
        rstress[1][0] = 8.07692
        rstress[1][1] = 8.07692
        rstress[1][2] = 4.84615
        rstress[1][3] = 1.61538
        rstress[1][4] = 0.0
        rstress[1][5] = 1.61538
        rstress[2][0] = 11.6595
        rstress[2][1] = 11.6595
        rstress[2][2] = 8.18099
        rstress[2][3] = 1.73926
        rstress[2][4] = 0.0
        rstress[2][5] = 1.73926
        rstress[3][0] = 15.1595
        rstress[3][1] = 15.1595
        rstress[3][2] = 11.681
        rstress[3][3] = 1.73926
        rstress[3][4] = 0.0
        rstress[3][5] = 1.73926
        rstress[4][0] = 18.6595
        rstress[4][1] = 18.6595
        rstress[4][2] = 15.181
        rstress[4][3] = 1.73926
        rstress[4][4] = 0.0
        rstress[4][5] = 1.73926
        rstress[5][0] = 22.1595
        rstress[5][1] = 22.1595
        rstress[5][2] = 18.681
        rstress[5][3] = 1.73927
        rstress[5][4] = 0.0
        rstress[5][5] = 1.73927
        rstress[6][0] = 25.6595
        rstress[6][1] = 25.6595
        rstress[6][2] = 22.181
        rstress[6][3] = 1.73927
        rstress[6][4] = 0.0
        rstress[6][5] = 1.73927
        rstress[7][0] = 29.1595
        rstress[7][1] = 29.1595
        rstress[7][2] = 25.681
        rstress[7][3] = 1.73928
        rstress[7][4] = 0.0
        rstress[7][5] = 1.73928
        rstress[8][0] = 32.6595
        rstress[8][1] = 32.6595
        rstress[8][2] = 29.181
        rstress[8][3] = 1.73928
        rstress[8][4] = 0.0
        rstress[8][5] = 1.73928
        rstress[9][0] = 36.1595
        rstress[9][1] = 36.1595
        rstress[9][2] = 32.681
        rstress[9][3] = 1.73929
        rstress[9][4] = 0.0
        rstress[9][5] = 1.73929

        initial_strain = KratosMultiphysics.Vector(cl.GetStrainSize())
        initial_strain[0] = 0.001
        initial_strain[1] = 0.001
        initial_strain[2] = 0.0
        initial_strain[3] = 0.001
        initial_strain[4] = 0.0
        initial_strain[5] = 0.001

        t = dt = 1. / nr_timesteps
        c = 0
        while (t <= 1. + dt / 10.):
            strain = t * initial_strain
            cl_params.SetStrainVector(strain)

            # Chauchy
            cl.CalculateMaterialResponseCauchy(cl_params)
            cl.FinalizeMaterialResponseCauchy(cl_params)
            cl.FinalizeSolutionStep(properties, geom, N,
                                    model_part.ProcessInfo)
            stress = cl_params.GetStressVector()
            for j in range(cl.GetStrainSize()):
                self.assertAlmostEqual(rstress[c][j], stress[j], 4)
            t += dt
            c += 1