コード例 #1
0
    def test_multiple_materials(self):
        """tests multiple materials"""
        model = BDF(debug=False)
        E = 3.0e7
        G = None
        nu = 0.3
        model.add_mat1(1, E, G, nu)
        e11 = e22 = 3.0e7
        nu12 = 0.3
        model.add_mat8(8, e11, e22, nu12)

        model.add_mat4(4, 10.0)
        model.add_mat5(5)

        bulk = 0.3
        rho = 0.2
        c = None
        model.add_mat10(10, bulk, rho, c)

        structural_material_ids = model.get_structural_material_ids()
        assert len(structural_material_ids) == 3, structural_material_ids

        thermal_material_ids = model.get_thermal_material_ids()
        assert len(thermal_material_ids) == 2, thermal_material_ids

        mats = model.Materials(1)
        assert len(mats) == 1, mats
        mats = model.Materials([1, 4, 5])
        assert len(mats) == 3, mats

        with self.assertRaises(KeyError):
            model.Material(-1)
        with self.assertRaises(KeyError):
            model.StructuralMaterial(-1)
        with self.assertRaises(KeyError):
            model.ThermalMaterial(-1)
コード例 #2
0
ファイル: test_materials.py プロジェクト: mnekkach/pyNastran
    def test_multiple_materials(self):
        """tests multiple materials"""
        model = BDF(debug=False)
        E = 3.0e7
        G = None
        nu = 0.3
        mat1 = model.add_mat1(1, E, G, nu)
        e11 = e22 = 3.0e7
        nu12 = 0.3
        model.add_mat8(8, e11, e22, nu12)

        model.add_mat4(4, 10.0)
        mat5 = model.add_mat5(5)
        mat9 = model.add_mat9(9,
                              G11=0.,
                              G12=0.,
                              G13=0.,
                              G14=0.,
                              G15=0.,
                              G16=0.,
                              G22=0.,
                              G23=0.,
                              G24=0.,
                              G25=0.,
                              G26=0.,
                              G33=0.,
                              G34=0.,
                              G35=0.,
                              G36=0.,
                              G44=0.,
                              G45=0.,
                              G46=0.,
                              G55=0.,
                              G56=0.,
                              G66=0.,
                              rho=0.,
                              A=None,
                              tref=0.,
                              ge=0.,
                              comment='mat9')

        bulk = 0.3
        rho = 0.2
        c = None
        model.add_mat10(10, bulk, rho, c)

        e1 = 1.
        e2 = 2.
        e3 = 3.
        nu13 = 0.3
        nu23 = 0.3
        g12 = 12.
        g13 = 13.
        g23 = 23.
        mat11 = model.add_mat11(11,
                                e1,
                                e2,
                                e3,
                                nu12,
                                nu13,
                                nu23,
                                g12,
                                g13,
                                g23,
                                rho=0.0,
                                a1=0.0,
                                a2=0.0,
                                a3=0.0,
                                tref=0.0,
                                ge=0.0,
                                comment='mat11')

        mat1.raw_fields()
        mat5.raw_fields()
        mat9.raw_fields()
        mat11.raw_fields()

        structural_material_ids = model.get_structural_material_ids()
        assert len(structural_material_ids) == 5, structural_material_ids

        thermal_material_ids = model.get_thermal_material_ids()
        assert len(thermal_material_ids) == 2, thermal_material_ids

        mats = model.Materials(1)
        assert len(mats) == 1, mats
        mats = model.Materials([1, 4, 5])
        assert len(mats) == 3, mats

        with self.assertRaises(KeyError):
            model.Material(-1)
        with self.assertRaises(KeyError):
            model.StructuralMaterial(-1)
        with self.assertRaises(KeyError):
            model.ThermalMaterial(-1)