当前位置: 首页>>代码示例>>Python>>正文


Python BDF.sum_forces_moments_elements方法代码示例

本文整理汇总了Python中pyNastran.bdf.bdf.BDF.sum_forces_moments_elements方法的典型用法代码示例。如果您正苦于以下问题:Python BDF.sum_forces_moments_elements方法的具体用法?Python BDF.sum_forces_moments_elements怎么用?Python BDF.sum_forces_moments_elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyNastran.bdf.bdf.BDF的用法示例。


在下文中一共展示了BDF.sum_forces_moments_elements方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_loads_sum_02

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def test_loads_sum_02(self):
        model = BDF(log=log)
        bdf_filename = os.path.join(model_path, 'sol_101_elements', 'static_solid_shell_bar.bdf')
        model.read_bdf(bdf_filename)
        loadcase_id = 10000
        #print("keys2", model.loads.keys())

        p0 = array([0., 0., 0.])
        F_expected = array([0., 0., 10000.])
        M_expected = array([5000., -5000., 0.])
        eids = None
        nids = None
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)

        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))

        loadcase_id = 123458
        p0 = array([0., 0., 0.])
        F_expected = array([0., 0., 10000.])
        M_expected = array([5000., -5000., 0.])
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)

        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:33,代码来源:test_sum_loads.py

示例2: test_loads_sum_radial_01

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def test_loads_sum_radial_01(self):
        model = BDF()
        from pyNastran.bdf.bdf import CORD2C, GRID, FORCE
        model.nodes[1] = GRID(1, cp=1, xyz=[0., 0., 0.], cd=0, ps='', seid=0,
                              comment='')
        cid = 1
        origin = [0., 0., 0.]
        zaxis = [0., 0., 1.]
        xaxis = [1., 0., 0.]
        model.coords[1] = CORD2C(cid, rid=0, origin=origin, zaxis=zaxis,
                                 xzplane=xaxis, comment='')
        sid = 1
        node = 1
        cid = 1
        mag = 1.1
        xyz = [1., 0., 0.]
        radial_force = FORCE(sid, node, cid, mag, xyz, comment='')
        model.add_card_class(radial_force)

        sid = 2
        xyz = [1., 90., 0.]
        mag = 2.2
        theta_force = FORCE(sid, node, cid, mag, xyz, comment='')
        model.add_card_class(theta_force)
        model.cross_reference()

        p0 = 1
        eids = None
        nids = None

        loadcase_id = 1
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False,
                                        xyz_cid0=None)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids,
                                                   include_grav=False,
                                                   xyz_cid0=None)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)

        F1_expected = np.array([1.1, 0., 0.])
        M1_expected = np.array([0., 0., 0.])
        self.assertTrue(allclose(F1_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F1_expected, F))
        self.assertTrue(allclose(M1_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M1_expected, M))

        loadcase_id = 2
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False,
                                        xyz_cid0=None)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids,
                                                   include_grav=False,
                                                   xyz_cid0=None)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        F2_expected = np.array([0., 2.2, 0.])
        M2_expected = np.array([0., 0., 0.])
        self.assertTrue(allclose(F2_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F2_expected, F))
        self.assertTrue(allclose(M2_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M2_expected, M))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:58,代码来源:test_sum_loads.py

示例3: _test_loads_sum_06

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def _test_loads_sum_06(self):
        model = BDF(log=log)
        bdf_filename = os.path.join(model_path, 'real', 'loads', 'bars.bdf')
        model.read_bdf(bdf_filename)
        p0 = array([0., 0., 0.])

        loadcase_id = 1
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        if 0:
            r = array([0., 0., 0.])
            F1_expected = array([0., 0., 1.])
            M1_expected = cross(r, F1_expected)

            F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
            F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
            assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
            assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
            self.assertTrue(allclose(F1_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F1_expected, F))
            self.assertTrue(allclose(M1_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M1_expected, M))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:24,代码来源:test_sum_loads.py

示例4: test_pload4_cquad4

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def test_pload4_cquad4(self):
        bdf_filename = os.path.join(test_path, '..', 'models', 'pload4', 'cquad4.bdf')
        op2_filename = os.path.join(test_path, '..', 'models', 'pload4', 'cquad4.op2')
        op2 = OP2(debug=False)
        op2.read_op2(op2_filename)

        model_b = BDF(debug=False)
        model_b.read_bdf(bdf_filename)
        # p0 = (model_b.nodes[21].xyz + model_b.nodes[22].xyz + model_b.nodes[23].xyz) / 3.
        p0 = model_b.nodes[21].xyz

        eids = None
        nids = None
        for isubcase, subcase in sorted(iteritems(model_b.subcases)):
            if isubcase == 0:
                continue
            #if isubcase != 17:
                #continue
            loadcase_id = subcase.get_parameter('LOAD')[0]
            load = model_b.loads[loadcase_id]
            loadi = load[0]
            if loadi.type == 'PLOAD4':
                elem = loadi.eids[0]
                area = 1.0
                centroid = elem.Centroid()
                normal = elem.Normal()
                msg = '%s%s%s\n' % (elem.nodes[0], elem.nodes[1], elem.nodes[2])

                assert array_equal(centroid, array([0.5, 0.5, 0.])), 'centroid=%s\n%s' % (centroid, msg)
                assert array_equal(normal, array([0., 0., 1.])), 'normal=%s\n%s' % (normal, msg)

            f, m = model_b.sum_forces_moments(p0, loadcase_id, include_grav=False)
            f2, m2 = model_b.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
            assert allclose(f, f2), 'f=%s f2=%s' % (f, f2)
            assert allclose(m, m2), 'm=%s m2=%s' % (m, m2)

            case = op2.spc_forces[isubcase]
            fm = -case.data[0, :, :].sum(axis=0)
            assert len(fm) == 6, fm
            if not allclose(f[0], fm[0]):
                print('%-2i Fx f=%s fexpected=%s' % (isubcase, f, fm))
            if not allclose(f[1], fm[1]):
                print('%-2i Fy f=%s fexpected=%s' % (isubcase, f, fm))
            if not allclose(f[2], fm[2]):
                print('%-2i Fz f=%s fexpected=%s' % (isubcase, f, fm))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:47,代码来源:test_loads.py

示例5: test_loads_sum_01

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def test_loads_sum_01(self):
        model = BDF(log=log)
        bdf_filename = os.path.join(model_path, 'solid_bending', 'solid_bending.bdf')
        model.read_bdf(bdf_filename)
        loadcase_id = 1
        #print("keys1", model.loads.keys())

        p0 = array([0., 0., 0.])
        F_expected = array([23000., 0., 0.])
        M_expected = array([0., 33209.869, -22803.951])
        eids = None
        nids = None
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)

        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:21,代码来源:test_sum_loads.py

示例6: test_loads_sum_03

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def test_loads_sum_03(self):
        if 0:
            model = BDF(log=log)
            bdf_filename = os.path.join(model_path, 'iSat', 'ISat_Launch_Sm_4pt.dat')
            model.read_bdf(bdf_filename)
            loadcase_id = 1
            #print("keys3", model.loads.keys())

            p0 = array([0., 0., 0.])
            F_expected = array([0., 0., 1.])
            M_expected = array([0., 0., 0.])
            eids = None
            nids = None
            F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
            F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
            assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
            assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)

            self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
            self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:22,代码来源:test_sum_loads.py

示例7: test_pload4_cpenta

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def test_pload4_cpenta(self):
        bdf_filename = os.path.join(test_path, '..', 'models', 'pload4', 'cpenta.bdf')
        op2_filename = os.path.join(test_path, '..', 'models', 'pload4', 'cpenta.op2')
        op2 = OP2(debug=False)
        op2.read_op2(op2_filename)

        model_b = BDF(debug=False)
        model_b.read_bdf(bdf_filename)
        # p0 = (model_b.nodes[21].xyz + model_b.nodes[22].xyz + model_b.nodes[23].xyz) / 3.
        p0 = model_b.nodes[21].xyz
        angles = [
            (23, 24), (24, 23),
            (21, 26), (26, 21),
        ]
        nx = [
            (23, 25), (25, 23),
            (22, 26), (26, 22),
        ]

        msg = ''
        for isubcase, subcase in sorted(iteritems(model_b.subcases)):
            if isubcase == 0:
                continue
            #if isubcase != 17:
                #continue
            loadcase_id = subcase.get_parameter('LOAD')[0]
            load = model_b.loads[loadcase_id][0]
            elem = load.eids[0]
            g1 = load.g1.nid
            if load.g34 is None:
                #print(load)
                face, area, centroid, normal = elem.getFaceAreaCentroidNormal(g1)
                assert area == 0.5, area
                if g1 in [21, 22, 23]:
                    assert face == (2, 1, 0), 'g1=%s face=%s' % (g1, face)
                    assert array_equal(centroid, array([2/3., 1/3., 0.])), 'fore g1=%s g34=%s face=%s centroid=%s\n%s' % (g1, g34, face, centroid, msg)
                    assert array_equal(normal, array([0., 0., 1.])), 'fore g1=%s g34=%s face=%s normal=%s\n%s' % (g1, g34, face, normal, msg)
                else:
                    assert face == (3, 4, 5), 'g1=%s face=%s' % (g1, face)
                    assert array_equal(centroid, array([2/3., 1/3., 2.])), 'aft g1=%s g34=%s face=%s centroid=%s\n%s' % (g1, g34, face, centroid, msg)
                    assert array_equal(normal, array([0., 0., -1.])), 'aft g1=%s g34=%s face=%s normal=%s\n%s' % (g1, g34, face, normal, msg)
            else:
                g34 = load.g34.nid
                face, area, centroid, normal = elem.getFaceAreaCentroidNormal(g1, g34)
                if (g1, g34) in angles:
                    self.assertAlmostEqual(area, 2 * 2**0.5, msg='g1=%s g34=%s face=%s area=%s' % (g1, g34, face, area))
                elif (g1, g34) in nx:
                    self.assertEqual(area, 2.0, 'area=%s' % area)
                    msg = '%s%s%s%s\n' % (
                        elem.nodes[face[0]], elem.nodes[face[1]], elem.nodes[face[2]], elem.nodes[face[3]])
                    assert array_equal(centroid, array([1., .5, 1.])), 'Nx g1=%s g34=%s face=%s centroid=%g\n%s' % (g1, g34, face, centroid, msg)
                    assert array_equal(normal, array([-1., 0., 0.])), 'Nx g1=%s g34=%s face=%s normal=%g\n%s' % (g1, g34, face, normal, msg)
                else:
                    msg = '%s%s%s%s\n' % (
                        elem.nodes[face[0]], elem.nodes[face[1]], elem.nodes[face[2]], elem.nodes[face[3]])

                    assert array_equal(centroid, array([0.5, .0, 1.])), 'Ny g1=%s g34=%s face=%s centroid=%s\n%s' % (g1, g34, face, centroid, msg)
                    assert array_equal(normal, array([0., 1., 0.])), 'Ny g1=%s g34=%s face=%s normal=%s\n%s' % (g1, g34, face, normal, msg)
                    self.assertEqual(area, 2.0, 'area=%s' % area)

            f, m = model_b.sum_forces_moments(p0, loadcase_id, include_grav=False)
            eids = None
            nids = None
            f2, m2 = model_b.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
            assert allclose(f, f2), 'f=%s f2=%s' % (f, f2)
            assert allclose(m, m2), 'm=%s m2=%s' % (m, m2)

            case = op2.spc_forces[isubcase]
            fm = -case.data[0, :3, :].sum(axis=0)
            assert len(fm) == 6, fm
            if not allclose(f[0], fm[0]):
                print('%-2i Fx f=%s fexpected=%s face=%s' % (isubcase, f, fm, face))
            if not allclose(f[1], fm[1]):
                print('%-2i Fy f=%s fexpected=%s face=%s' % (isubcase, f, fm, face))
            if not allclose(f[2], fm[2]):
                print('%-2i Fz f=%s fexpected=%s face=%s' % (isubcase, f, fm, face))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:78,代码来源:test_loads.py

示例8: test_pload1_cbar

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def test_pload1_cbar(self):
        bdf_filename = os.path.join(test_path, '..', 'models', 'pload4', 'pload1.bdf')
        op2_filename = os.path.join(test_path, '..', 'models', 'pload4', 'pload1.op2')
        op2 = OP2(debug=False)
        op2.read_op2(op2_filename)

        model_b = BDF(debug=False)
        model_b.read_bdf(bdf_filename)
        # p0 = (model_b.nodes[21].xyz + model_b.nodes[22].xyz + model_b.nodes[23].xyz) / 3.
        p0 = model_b.nodes[1].xyz

        fail = False
        dashes = '-' * 80
        for isubcase, subcase in sorted(iteritems(model_b.subcases)):
            if isubcase == 0:
                continue
            #if isubcase != 17:
                #continue
            loadcase_id = subcase.get_parameter('LOAD')[0]
            load = model_b.loads[loadcase_id][0]
            elem = load.eid

            msg = '%s%s\n' % (elem.nodes[0], elem.nodes[1])

            f, m = model_b.sum_forces_moments(p0, loadcase_id, include_grav=False)
            eids = None
            nids = None
            f2, m2 = model_b.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
            assert allclose(f, f2), 'f=%s f2=%s' % (f, f2)
            assert allclose(m, m2), 'm=%s m2=%s' % (m, m2)

            case = op2.spc_forces[isubcase]
            fm = -case.data[0, :, :].sum(axis=0)
            assert len(fm) == 6, fm
            if not allclose(f[0], fm[0]):
                print('%-2i Fx f=%s fexpected=%s' % (isubcase, f, fm))
                print(dashes)
                fail = True
            if not allclose(f[1], fm[1]):
                print('%-2i Fy f=%s fexpected=%s' % (isubcase, f, fm))
                print(dashes)
                fail = True
            if not allclose(f[2], fm[2]):
                print('%-2i Fz f=%s fexpected=%s' % (isubcase, f, fm))
                print(dashes)
                fail = True

            if not allclose(m[0], fm[3]):
                print('%-2i Mx m=%s fexpected=%s' % (isubcase, m, fm))
                print(dashes)
                fail = True
            if not allclose(m[1], fm[4]):
                print('%-2i My m=%s fexpected=%s' % (isubcase, m, fm))
                print(dashes)
                fail = True
            if not allclose(m[2], fm[5]):
                print('%-2i Mz m=%s fexpected=%s' % (isubcase, m, fm))
                print(dashes)
                fail = True
        if fail:
            raise RuntimeError('incorrect loads')
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:63,代码来源:test_loads.py

示例9: test_pload4_chexa

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def test_pload4_chexa(self):
        bdf_filename = os.path.join(test_path, '..', 'models', 'pload4', 'chexa.bdf')
        op2_filename = os.path.join(test_path, '..', 'models', 'pload4', 'chexa.op2')
        op2 = OP2(debug=False)
        op2.read_op2(op2_filename)

        model_b = BDF(debug=False)
        model_b.read_bdf(bdf_filename)
        p0 = model_b.nodes[21].xyz
        nx_minus = [
            (22, 27), (27, 22),
            (23, 26), (26, 23),
        ]
        nx_plus = [
            (24, 25), (25, 24),
            (21, 28), (28, 21),
            #(23, 25), (25, 23),
            #(22, 26), (26, 22),
        ]

        ny_minus = [
            (24, 27), (27, 24),
            (23, 28), (28, 23),
        ]
        ny_plus = [
            (21, 26), (26, 21),
            (22, 25), (25, 22),
        ]

        nz_minus = [
            (25, 27), (27, 25),
            (26, 28), (28, 26),
        ]
        nz_plus = [
            (21, 23), (23, 21),
            (24, 22), (22, 24),
        ]

        for isubcase, subcase in sorted(iteritems(model_b.subcases)):
            if isubcase == 0:
                continue
            loadcase_id = subcase.get_parameter('LOAD')[0]
            load = model_b.loads[loadcase_id][0]
            elem = load.eids[0]
            g1 = load.g1.nid

            # f, m = model_b.sum_forces_moments(p0, loadcase_id, include_grav=False)
            # case = op2.spc_forces[isubcase]
            # fm = case.data[0, 0, :]#.ravel()
            # if f[0] != fm[0]:
                # print('%i f=%s fexpected=%s' % (isubcase, f, fm))

            g34 = load.g34.nid
            face, area, centroid, normal = elem.getFaceAreaCentroidNormal(g1, g34)
            msg = '%s%s%s%s\n' % (
                elem.nodes[face[0]], elem.nodes[face[1]],
                elem.nodes[face[2]], elem.nodes[face[3]])

            if (g1, g34) in nx_plus:
                self.assertEqual(area, 2.0, '+Nx area=%s' % area)
                #assert array_equal(centroid, array([1., .5, 1.])), '+Nx g1=%s g34=%s face=%s centroid=%g\n%s' % (g1, g34, face, centroid, msg)
                assert array_equal(normal, array([1., 0., 0.])), '+Nx g1=%s g34=%s face=%s normal=%g\n%s' % (g1, g34, face, normal, msg)
            elif (g1, g34) in nx_minus:
                self.assertEqual(area, 2.0, '-Nx area=%s' % area)
                #assert array_equal(centroid, array([1., .5, 1.])), '-Nx g1=%s g34=%s face=%s centroid=%g\n%s' % (g1, g34, face, centroid, msg)
                assert array_equal(normal, array([-1., 0., 0.])), '-Nx g1=%s g34=%s face=%s normal=%g\n%s' % (g1, g34, face, normal, msg)

            elif (g1, g34) in ny_plus:
                self.assertEqual(area, 2.0, '+Ny area=%s' % area)
                #assert array_equal(centroid, array([1., .5, 1.])), '+Nz g1=%s g34=%s face=%s centroid=%g\n%s' % (g1, g34, face, centroid, msg)
                assert array_equal(normal, array([0., 1., 0.])), '+Ny g1=%s g34=%s face=%s normal=%s\n%s' % (g1, g34, face, normal, msg)
            elif (g1, g34) in ny_minus:
                self.assertEqual(area, 2.0, '-Ny area=%s' % area)
                #assert array_equal(centroid, array([1., .5, 1.])), '-Nz g1=%s g34=%s face=%s centroid=%g\n%s' % (g1, g34, face, centroid, msg)
                assert array_equal(normal, array([0., -1., 0.])), '-Ny g1=%s g34=%s face=%s normal=%s\n%s' % (g1, g34, face, normal, msg)

            elif (g1, g34) in nz_plus:
                self.assertEqual(area, 1.0, '+Nz area=%s' % area)
                #assert array_equal(centroid, array([1., .5, 1.])), '+Nz g1=%s g34=%s face=%s centroid=%g\n%s' % (g1, g34, face, centroid, msg)
                assert array_equal(normal, array([0., 0., 1.])), '+Nz g1=%s g34=%s face=%s normal=%s\n%s' % (g1, g34, face, normal, msg)
            elif (g1, g34) in nz_minus:
                self.assertEqual(area, 1.0, '-Nz area=%s' % area)
                #assert array_equal(centroid, array([1., .5, 1.])), '-Nz g1=%s g34=%s face=%s centroid=%g\n%s' % (g1, g34, face, centroid, msg)
                assert array_equal(normal, array([0., 0., -1.])), '-Nz g1=%s g34=%s face=%s normal=%s\n%s' % (g1, g34, face, normal, msg)
                #assert array_equal(centroid, array([1., .5, 1.])),  'Nx g1=%s g34=%s face=%s centroid=%s\n%s' % (g1, g34, face, centroid, msg)
                #assert array_equal(normal, array([-1., 0., 0.])),  'Nx g1=%s g34=%s face=%s normal=%s\n%s' % (g1, g34, face, normal, msg)
            else:
                raise RuntimeError('??? g1=%s g34=%s face=%s normal=%s\n%s' % (g1, g34, face, normal, msg))
            #self.assertEqual(f[0], fm[0], 'f=%s fexpected=%s' % (f, fm[:3]))
            #self.assertEqual(f[1], fm[1], 'f=%s fexpected=%s' % (f, fm[:3]))
            #self.assertEqual(f[2], fm[2], 'f=%s fexpected=%s' % (f, fm[:3]))
            #self.assertEqual(m[0], fm[3], 'm=%s mexpected=%s' % (m, fm[3:]))
            #self.assertEqual(m[1], fm[4], 'm=%s mexpected=%s' % (m, fm[3:]))
            #self.assertEqual(m[2], fm[5], 'm=%s mexpected=%s' % (m, fm[3:]))
            f, m = model_b.sum_forces_moments(p0, loadcase_id, include_grav=False)
            eids = None
            nids = None
            f2, m2 = model_b.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
            assert allclose(f, f2), 'f=%s f2=%s' % (f, f2)
            assert allclose(m, m2), 'm=%s m2=%s' % (m, m2)
#.........这里部分代码省略.........
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:103,代码来源:test_loads.py

示例10: test_loads_sum_04

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def test_loads_sum_04(self):
        p0 = array([0., 0., 0.])
        model = BDF(log=log)
        bdf_filename = os.path.join(model_path, 'plate', 'plate.bdf')
        print(bdf_filename)
        model.read_bdf(bdf_filename)
        #print("keys4", model.loads.keys())

        loadcase_id = 1
        F_expected = array([600., 0., 0.])
        M_expected = array([0., 0., -3000.])
        eids = None
        nids = None
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))

        loadcase_id = 2
        F_expected = array([600., 0., 0.])
        M_expected = array([0., 0., -3000.])
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))

        #---------
        loadcase_id = 3
        A = 0.
        for e, element in iteritems(model.elements):
            A += element.Area()
        A_expected = 100.
        self.assertTrue(allclose(A, A_expected), 'loadcase_id=%s A_expected=%s A=%s' % (loadcase_id, A_expected, A))
        p = 3.
        Fi = p * A

        eids = None
        nids = None
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)

        self.assertTrue(allclose(p*A, F[2]), 'loadcase_id=%s p*A=%s F=%s' % (loadcase_id, p*A, F))

        F_expected = array([0., 0., 300.])
        M_expected = array([1500., -1500., 0.])
        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))

        #---
        loadcase_id = 10
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))

        #---
        loadcase_id = 4
        F_expected = array([0., 0., 300.])
        M_expected = array([1500., -1500., 0.])
        F_expected *= 5.
        M_expected *= 5.
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        #print('F =', F)
        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))

        loadcase_id = 5
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        F_expected = array([0., 0., 300.])
        M_expected = array([1500., -1500., 0.])
        F_expected *= 7.
        M_expected *= 7.
        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))

        loadcase_id = 6
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        F_expected = array([0., 0., 300.])
        M_expected = array([1500., -1500., 0.])
        F_expected *= 7. * 5.
        M_expected *= 7. * 5.
        self.assertTrue(allclose(F_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F_expected, F))
        self.assertTrue(allclose(M_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M_expected, M))

        #---------
        loadcase_id = 11
#.........这里部分代码省略.........
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:103,代码来源:test_sum_loads.py

示例11: test_loads_sum_05

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import sum_forces_moments_elements [as 别名]
    def test_loads_sum_05(self):
        model = BDF(log=log)
        bdf_filename = os.path.join(model_path, 'real', 'loads', 'loads.bdf')
        model.read_bdf(bdf_filename)

        p = 3.
        A = 1.
        n = array([0., 0., 1.])
        F1001_expected = p * A * n
        r = array([0.5, 1.5, 0.])
        p0 = array([0., 0., 0.])
        M1001_expected = cross(r, F1001_expected)

        loadcase_id = 1001
        eids = None
        nids = None
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        self.assertTrue(allclose(F1001_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F1001_expected, F))
        self.assertTrue(allclose(M1001_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M1001_expected, M))

        loadcase_id = 1002
        r = array([4., 2., 0.])
        F1002_expected = array([0., 0., 1.])
        M1002_expected = cross(r, F1002_expected)
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        self.assertTrue(allclose(F1002_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F1002_expected, F))
        self.assertTrue(allclose(M1002_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M1002_expected, M))

        loadcase_id = 1
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        self.assertTrue(allclose(F1001_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F1001_expected, F))
        self.assertTrue(allclose(M1001_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M1001_expected, M))

        loadcase_id = 2
        F2_expected = F1001_expected + F1002_expected
        M2_expected = M1001_expected + M1002_expected
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        self.assertTrue(allclose(F2_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F2_expected, F))
        self.assertTrue(allclose(M2_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M2_expected, M))


        F6_expected = 2. * (3. * F1001_expected + 13. * F1002_expected)
        M6_expected = 2. * (3. * M1001_expected + 13. * M1002_expected)

        F7_expected = 7. * 11. * F6_expected
        M7_expected = 7. * 11. * M6_expected
        if 0:
            loadcase_id = 6
            F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
            F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
            assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
            assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
            self.assertTrue(allclose(F6_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F6_expected, F))
            self.assertTrue(allclose(M6_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M6_expected, M))

            loadcase_id = 7
            F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
            F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
            assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
            assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
            self.assertTrue(allclose(F7_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F7_expected, F))
            self.assertTrue(allclose(M7_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M7_expected, M))


        loadcase_id = 1003
        p = 9.
        A = 1.
        n = array([0., 0., 1.])
        F1003_expected = p * A * n
        r = array([0.5, 0.5, 0.])
        M1003_expected = cross(r, F1003_expected)
        F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
        F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
        assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
        assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
        self.assertTrue(allclose(F1003_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F1003_expected, F))
        self.assertTrue(allclose(M1003_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M1003_expected, M))

        loadcase_id = 8
        F8_expected = 2. * (3. * F7_expected + 2. * F1003_expected)
        M8_expected = 2. * (3. * M7_expected + 2. * M1003_expected)
        if 0:
            F, M = model.sum_forces_moments(p0, loadcase_id, include_grav=False)
            F2, M2 = model.sum_forces_moments_elements(p0, loadcase_id, eids, nids, include_grav=False)
            assert np.allclose(F, F2), 'F=%s F2=%s' % (F, F2)
            assert np.allclose(M, M2), 'M=%s M2=%s' % (M, M2)
            self.assertTrue(allclose(F8_expected, F), 'loadcase_id=%s F_expected=%s F=%s' % (loadcase_id, F8_expected, F))
            self.assertTrue(allclose(M8_expected, M), 'loadcase_id=%s M_expected=%s M=%s' % (loadcase_id, M8_expected, M))

        loadcase_id = 800
#.........这里部分代码省略.........
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:103,代码来源:test_sum_loads.py


注:本文中的pyNastran.bdf.bdf.BDF.sum_forces_moments_elements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。