Example #1
0
    def test_A(self):
        cid0 = CORD2R()
        Lx = 2.
        Ly = 0.
        Lz = 3.
        Fy = 1.
        origin = array([-Lx, 0., -Lz])
        z_axis = origin + array([0., 0., 1.])
        xz_plane = origin + array([1., 0., 1.])
        rid = 0
        data = [1, rid] + list(origin) + list(z_axis) + list(xz_plane)

        Fxyz = [0., -Fy, 0.]
        Mxyz = [0., 0., 0.]
        cid_new = CORD2R(data=data)
        model = None

        Fxyz_local, Mxyz_local = TransformLoadWRT(Fxyz, Mxyz, cid0, cid_new,
                                                  model, is_cid_int=False)

        r = array([Lx, Ly, Lz])
        F = array([0., -Fy, 0.])
        M = cross(r, F)
        self.assertTrue(array_equal(Fxyz_local,           F)), "expected=%s actual=%s" % (F, Fxyz_local)
        self.assertTrue(array_equal(Mxyz_local, cross(r, F))), "expected=%s actual=%s" % (M, Mxyz_local)
Example #2
0
    def test_coord_xform_b(self):
        origin = array([0., 0., 0.])
        zaxis = array([0., 0., 1.])
        xzplane = array([1., 0., 0.])
        cid0 = CORD2R(cid=0, rid=0, origin=origin, zaxis=zaxis, xzplane=xzplane)

        Lx = 2.
        Ly = 3.
        Lz = 5.
        Fy = 1.5
        origin = array([-Lx, -Ly, -Lz])
        z_axis = origin + array([0., 0., 1.])
        xz_plane = origin + array([1., 0., 1.])
        rid = 0
        data = [1, rid] + list(origin) + list(z_axis) + list(xz_plane)

        fxyz = [0., -Fy, 0.]
        mxyz = [0., 0., 0.]
        cid_new = CORD2R.add_op2_data(data=data)
        model = None

        fxyz_local, mxyz_local = TransformLoadWRT(fxyz, mxyz, cid0, cid_new,
                                                  model, is_cid_int=False)
        r = array([Lx, Ly, Lz])
        F = array([0., -Fy, 0.])
        M = cross(r, F)
        self.assertTrue(array_equal(fxyz_local, F), 'expected=%s actual=%s' % (F, fxyz_local))
        self.assertTrue(array_equal(mxyz_local, M), 'expected=%s actual=%s' % (M, mxyz_local))
Example #3
0
    def test_caero3_1(self):
        """checks the CAERO3/PAERO3"""
        eid = 100
        pid = 200
        cp = 4
        list_w = 5
        list_c1 = 6
        list_c2 = 7
        p1 = [0., 0., 0.]
        x12 = 10.
        p4 = [5., 10., 0.]
        x43 = 3.

        nbox = 10
        ncontrol_surfaces = 0
        x = None
        y = None

        log = SimpleLogger(level='warning')
        model = BDF(log=log)
        coord = CORD2R.add_card(BDFCard(['CORD2R', cp, 0,
                                         0., 0., 0.,
                                         0., 0., 1.,
                                         1., 0., 0.]))
        coord = CORD2R(cp, rid=0, origin=None, zaxis=None, xzplane=None,
                       comment='')
        coord.validate()
        model.coords[cp] = coord

        paero = PAERO3(pid, nbox, ncontrol_surfaces, x, y)
        model.paeros[pid] = paero

        card = ['CAERO3', 2000, 20001, 0, 22, 33, None, None, None,
                1.0, 0.0, 0., 100., 17., 130., 0., 100.]
        bdf_card = BDFCard(card, has_none=True)
        caero3a = CAERO3.add_card(bdf_card, comment='msg')
        caero3a.validate()
        caero3a.write_card()
        caero3a.raw_fields()

        caero3b = CAERO3(eid, pid, cp, list_w, list_c1, list_c2, p1, x12, p4,
                         x43, comment='caero3')
        model.caeros[pid] = caero3b

        caero3b.write_card()
        caero3b.cross_reference(model)
        caero3b.write_card()
        caero3a.raw_fields()
        caero3b.uncross_reference()
        caero3b.write_card()
        caero3a.raw_fields()
Example #4
0
    def test_cut_shell_model_face_1(self):
        """
        tests:
         - cut_edge_model_by_coord
         - cut_face_model_by_coord
        """
        tol = 2.
        coord = CORD2R(1, rid=0, origin=[0.5, 0., 0.], zaxis=[0.5, 0., 1], xzplane=[1.5, 0., 0.],
                       comment='')
        model, nodal_result = _cut_shell_model_quads()
        #-------------------------------------------------------------------------
        # triangles
        split_to_trias(model)
        model.coords[1] = coord
        model.write_bdf('tris.bdf')

        #print('----------------------------')
        title = 'result'
        p1 = None
        p2 = None
        zaxis = None
        #print(nodal_result)
        with self.assertRaises(TypeError):
            cut_and_plot_model(title, p1, p2, zaxis,
                               model, coord, nodal_result, model.log, tol,
                               plane_atol=1e-5,
                               csv_filename=None,
                               invert_yaxis=False,
                               cut_type='face', plot=IS_MATPLOTLIB, show=False)
        os.remove('tris.bdf')
Example #5
0
    def test_cord2c_01(self):
        lines = [
            'CORD2C*                3               0              0.              0.',
            '*                     0.              0.              0.              1.*',
            '*                     1.              0.              1.'
        ]
        model = BDF(debug=False)
        card = model.process_card(lines)
        card = BDFCard(card)
        card = CORD2C(card)
        model.add_coord(card)

        lines = [
            'CORD2R         4       3     10.      0.      5.     10.     90.      5.',
            '             10.      0.      6.'
        ]
        card = model.process_card(lines)
        card = BDFCard(card)
        card = CORD2R(card)
        model.add_coord(card)
        model.cross_reference()

        cord2r = model.Coord(3)
        self.assertEquals(cord2r.Cid(), 3)
        self.assertEquals(cord2r.Rid(), 0)

        cord2r = model.Coord(4)
        self.assertEquals(cord2r.Cid(), 4)
        self.assertEquals(cord2r.Rid(), 3)

        self.assertTrue(allclose(cord2r.i, array([0., 0., 1.])))
        delta = cord2r.j - array([1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(cord2r.j, array([1., 1., 0.]) / 2**0.5), str(delta))
        delta = cord2r.k - array([-1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(cord2r.k, array([-1., 1., 0.]) / 2**0.5), str(delta))
    def test_B(self):
        origin = array([0., 0., 0.])
        zaxis = array([0., 0., 1.])
        xzplane = array([1., 0., 0.])
        cid0 = CORD2R(cid=0, rid=0, origin=origin, zaxis=zaxis, xzplane=xzplane)

        Lx = 2.
        Ly = 3.
        Lz = 5.
        Fy = 1.5
        origin = array([-Lx, -Ly, -Lz])
        z_axis = origin + array([0., 0., 1.])
        xz_plane = origin + array([1., 0., 1.])
        rid = 0
        data = [1, rid] + list(origin) + list(z_axis) + list(xz_plane)

        Fxyz = [0., -Fy, 0.]
        Mxyz = [0., 0., 0.]
        cid_new = CORD2R.add_op2_data(data=data)
        model = None

        Fxyz_local, Mxyz_local = TransformLoadWRT(Fxyz, Mxyz, cid0, cid_new,
                                                  model, is_cid_int=False)
        r = array([Lx, Ly, Lz])
        F = array([0., -Fy, 0.])
        M = cross(r, F)
        self.assertTrue(array_equal(Fxyz_local, F)), "expected=%s actual=%s" % (F, Fxyz_local)
        self.assertTrue(array_equal(Mxyz_local, cross(r, F))), "expected=%s actual=%s" % (M, Mxyz_local)
Example #7
0
def plot_shear_moment_torque(model,
                             gpforce,
                             coord: CORD2R,
                             idir: int = 0,
                             itime: int = 0,
                             nplanes: int = 11,
                             show: bool = True):
    nids, nid_cd, xyz_cid0, icd_transform, eids, element_centroids_cid0 = smt_setup(
        model)
    element_centroids_cid = coord.transform_node_to_local_array(
        element_centroids_cid0)
    x = element_centroids_cid[idir]
    xmin = x.min()
    xmax = x.max()
    dx = xmax - xmin
    assert abs(dx) > 0., f'dx={dx} xmin={xmin} xmax={xmax}'
    stations = np.linspace(0., dx, num=nplanes, endpoint=True)
    force_sum, moment_sum = gpforce.shear_moment_diagram(
        xyz_cid0,
        eids,
        nids,
        icd_transform,
        element_centroids_cid0,
        model.coords,
        nid_cd,
        stations,
        coord,
        idir=idir,
        itime=itime,
        debug=False,
        log=model.log)
    plot_smt(stations, force_sum, moment_sum, show=show)
Example #8
0
    def test_cut_plate(self):
        """mode 10 is a sine wave"""
        log = SimpleLogger(level='warning', encoding='utf-8', log_func=None)
        bdf_filename = os.path.join(MODEL_PATH, 'plate_py', 'plate_py.dat')
        op2_filename = os.path.join(MODEL_PATH, 'plate_py', 'plate_py.op2')
        model = read_bdf(bdf_filename, log=log)
        op2_model = read_op2_geom(op2_filename, log=log)

        title = 'Mode 10 Eigenvector'
        p1 = None
        p2 = None
        zaxis = None
        coord = CORD2R(1,
                       rid=0,
                       origin=[0., 0., 0.],
                       zaxis=[0., 0., 1],
                       xzplane=[1., 0., 0.],
                       comment='')
        model.coords[1] = coord
        ytol = 2.

        # real
        nodal_result = op2_model.eigenvectors[1].data[9, :, 2]

        cut_and_plot_model(title,
                           p1,
                           p2,
                           zaxis,
                           model,
                           coord,
                           nodal_result,
                           model.log,
                           ytol,
                           plane_atol=1e-5,
                           csv_filename='real_result.csv',
                           invert_yaxis=False,
                           cut_type='edge',
                           plot=IS_MATPLOTLIB,
                           show=False)

        # complex
        nodal_result2 = np.asarray(nodal_result, dtype='complex64')
        nodal_result2.imag = -nodal_result.real
        cut_and_plot_model(title,
                           p1,
                           p2,
                           zaxis,
                           model,
                           coord,
                           nodal_result2,
                           model.log,
                           ytol,
                           plane_atol=1e-5,
                           csv_filename='complex_result.csv',
                           invert_yaxis=True,
                           cut_type='edge',
                           plot=IS_MATPLOTLIB,
                           show=False)
        os.remove('real_result.csv')
        os.remove('complex_result.csv')
Example #9
0
    def test_cut_plate_eids(self):
        """recover element ids"""
        log = SimpleLogger(level='warning', encoding='utf-8', log_func=None)
        bdf_filename = os.path.join(MODEL_PATH, 'plate_py', 'plate_py.dat')
        model = read_bdf(bdf_filename, log=log)
        nnodes = len(model.nodes)
        nodal_result = np.ones(nnodes)

        coord = CORD2R(1, rid=0, origin=[0., 0., 0.], zaxis=[0., 0., 1], xzplane=[1., 0., 0.],
                       comment='')
        model.coords[1] = coord
        ytol = 2.

        unique_geometry_array, unique_results_array, unused_rods = cut_face_model_by_coord(
            bdf_filename, coord, ytol,
            nodal_result, plane_atol=1e-5, skip_cleanup=True,
            csv_filename='cut_face.csv')
        #print(unique_geometry_array)
        #print(unique_results_array)
        unique_geometry_array = np.array(unique_geometry_array)
        unique_results_array = np.array(unique_results_array)
        assert unique_geometry_array.shape == (1, 40, 4), unique_geometry_array.shape
        assert unique_results_array.shape == (1, 40, 7), unique_results_array.shape
        unique_geometry_array = unique_geometry_array[0, :, :]
        unique_results_array = unique_results_array[0, :, :]

        assert unique_geometry_array.shape == (40, 4), unique_geometry_array.shape
        assert unique_results_array.shape == (40, 7), unique_results_array.shape
    def test_cord2c_01(self):
        lines = [
            'CORD2C*                3               0              0.              0.',
            '*                     0.              0.              0.              1.*',
            '*                     1.              0.              1.'
        ]
        model = BDF(debug=False)
        card = model.process_card(lines)
        cardi = BDFCard(card)
        coord = CORD2C.add_card(cardi)
        model.add_coord(coord)

        lines = [
            'CORD2R         4       3     10.      0.      5.     10.     90.      5.',
            '             10.      0.      6.'
        ]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        coord = CORD2R.add_card(cardi)
        model.add_coord(coord)
        model.cross_reference()

        cord2r = model.Coord(3)
        self.assertEqual(cord2r.Cid(), 3)
        self.assertEqual(cord2r.Rid(), 0)

        cord2r = model.Coord(4)
        self.assertEqual(cord2r.Cid(), 4)
        self.assertEqual(cord2r.Rid(), 3)

        self.assertTrue(allclose(cord2r.i, array([0., 0., 1.])))
        delta = cord2r.j - array([1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(cord2r.j, array([1., 1., 0.]) / 2**0.5), str(delta))
        delta = cord2r.k - array([-1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(cord2r.k, array([-1., 1., 0.]) / 2**0.5), str(delta))
Example #11
0
def get_coords_crm(ncuts=2000):  # pragma: no cover
    dys = []
    coords = []
    for i in range(ncuts):
        dy = 4. * i + 1.  #  CRM
        coord = CORD2R(1, rid=0, origin=[0., dy, 0.], zaxis=[0., dy, 1], xzplane=[1., dy, 0.])
        dys.append(dy)
        coords.append(coord)
    return dys, coords
Example #12
0
def get_coords_bwb(ncuts=2000):
    dys = []
    coords = []
    for i in range(ncuts):
        dy = 100. * i + 1.  #  bwb
        coord = CORD2R(1, rid=0, origin=[0., dy, 0.], zaxis=[0., dy, 1], xzplane=[1., dy, 0.])
        dys.append(dy)
        coords.append(coord)
    return dys, coords
Example #13
0
    def test_caero3_1(self):
        """checks the CAERO3/PAERO3"""
        eid = 100
        pid = 200
        cp = 4
        list_w = 5
        list_c1 = 6
        list_c2 = 7
        p1 = [0., 0., 0.]
        x12 = 10.
        p4 = [5., 10., 0.]
        x43 = 3.

        nbox = 10
        ncontrol_surfaces = 0
        x = None
        y = None

        log = SimpleLogger(level='warning')
        model = BDF(log=log)
        coord = CORD2R.add_card(BDFCard(['CORD2R', cp, 0,
                                         0., 0., 0.,
                                         0., 0., 1.,
                                         1., 0., 0.]))
        coord = CORD2R(cp, rid=0, origin=None, zaxis=None, xzplane=None,
                       comment='')
        coord.validate()
        model.coords[cp] = coord

        paero = PAERO3(pid, nbox, ncontrol_surfaces, x, y)
        model.paeros[pid] = paero

        card = ['CAERO3', 2000, 20001, 0, 22, 33, None, None, None,
                1.0, 0.0, 0., 100., 17., 130., 0., 100.]
        bdf_card = BDFCard(card, has_none=True)
        caero3a = CAERO3.add_card(bdf_card, comment='msg')
        caero3a.validate()
        caero3a.write_card()
        caero3a.raw_fields()

        caero3b = CAERO3(eid, pid, cp, list_w, list_c1, list_c2, p1, x12, p4,
                         x43, comment='caero3')
        model.caeros[pid] = caero3b

        caero3b.write_card()
        caero3b.cross_reference(model)
        caero3b.write_card()
        caero3a.raw_fields()
        caero3b.uncross_reference()
        caero3b.write_card()
        caero3a.raw_fields()
Example #14
0
    def test_coord_adding(self):
        origin = [0., 0., 0.]
        zaxis = [0., 0., 1.]
        xzplane = [1., 0., 0.]
        cid1 = CORD2R(cid=1, rid=0, origin=origin, zaxis=zaxis, xzplane=xzplane,
                      comment='cord2r')

        xaxis = [1., 0., 0.]
        yaxis = [0., 1., 0.]
        zaxis = [0., 0., 1.]
        xz_plane = [1., 0., 1.]
        yz_plane = [0., 1., 1.]
        xy_plane = [1., 1., 0.]
        # x-axis
        cid2 = CORD2R.add_axes(cid=2, rid=0, origin=origin, xaxis=xaxis, yaxis=None, zaxis=None,
                               xyplane=None, yzplane=None, xzplane=xz_plane)

        cid3 = CORD2R.add_axes(cid=2, rid=0, origin=origin, xaxis=xaxis, yaxis=None, zaxis=None,
                               xyplane=xy_plane, yzplane=None, xzplane=None)

        # y-axis
        cid4 = CORD2R.add_axes(cid=4, rid=0, origin=origin, xaxis=None, yaxis=yaxis, zaxis=None,
                               xyplane=xy_plane, yzplane=None, xzplane=None)

        cid5 = CORD2R.add_axes(cid=5, rid=0, origin=origin, xaxis=None, yaxis=yaxis, zaxis=None,
                               xyplane=None, yzplane=yz_plane, xzplane=None)

        # z-axis
        cid4 = CORD2R.add_axes(cid=4, rid=0, origin=origin, xaxis=None, yaxis=None, zaxis=zaxis,
                               xyplane=None, yzplane=None, xzplane=xz_plane)

        cid5 = CORD2R.add_axes(cid=5, rid=0, origin=origin, xaxis=None, yaxis=None, zaxis=zaxis,
                               xyplane=None, yzplane=yz_plane, xzplane=None)

        # ijk
        cid6 = CORD2R.add_ijk(cid=6, rid=0, origin=origin, i=xaxis, j=yaxis, k=None)
        cid7 = CORD2R.add_ijk(cid=7, rid=0, origin=origin, i=xaxis, j=None, k=zaxis)
        cid8 = CORD2R.add_ijk(cid=8, rid=0, origin=origin, i=None, j=yaxis, k=zaxis)
Example #15
0
    def test_cut_shell_model_1(self):
        """
        tests:
         - cut_edge_model_by_coord
         - cut_face_model_by_coord
        """
        model, nodal_result = _cut_shell_model_quads()
        coord = CORD2R(1,
                       rid=0,
                       origin=[0.5, 0., 0.],
                       zaxis=[0.5, 0., 1],
                       xzplane=[1.5, 0., 0.],
                       comment='')
        model.coords[1] = coord
        tol = 2.
        #-------------------------------------------------------------------------
        title = 'result'
        p1 = None
        p2 = None
        zaxis = None
        cut_and_plot_model(title,
                           p1,
                           p2,
                           zaxis,
                           model,
                           coord,
                           nodal_result,
                           model.log,
                           tol,
                           plane_atol=1e-5,
                           csv_filename=None,
                           invert_yaxis=False,
                           cut_type='edge',
                           plot=IS_MATPLOTLIB,
                           show=False)
        #=========================================================================
        out = cut_edge_model_by_coord(model,
                                      coord,
                                      tol,
                                      nodal_result,
                                      plane_atol=1e-5)
        unused_local_points_array, unused_global_points_array, result_array = out
        assert len(result_array) == 16, len(result_array)

        unused_geometry_array, result_array, unused_rods = cut_face_model_by_coord(
            model, coord, tol, nodal_result, plane_atol=1e-5)
        result_array = np.array(result_array)
        assert result_array.shape == (1, 8, 7), result_array.shape
        os.remove('plane_edge.bdf')
        os.remove('plane_face.bdf')
Example #16
0
    def test_cut_shell_model_1(self):
        """
        tests:
         - cut_edge_model_by_coord
         - cut_face_model_by_coord
        """
        model, nodal_result = _cut_shell_model_quads()
        coord = CORD2R(1,
                       rid=0,
                       origin=[0.5, 0., 0.],
                       zaxis=[0.5, 0., 1],
                       xzplane=[1.5, 0., 0.],
                       comment='')
        model.coords[1] = coord
        tol = 2.
        #-------------------------------------------------------------------------
        title = 'result'
        p1 = None
        p2 = None
        zaxis = None
        cut_and_plot_model(title,
                           p1,
                           p2,
                           zaxis,
                           model,
                           coord,
                           nodal_result,
                           model.log,
                           tol,
                           plane_atol=1e-5,
                           csv_filename=None,
                           invert_yaxis=False,
                           cut_type='edge',
                           show=False)
        #=========================================================================
        local_points_array, global_points_array, result_array = cut_edge_model_by_coord(
            model, coord, tol, nodal_result, plane_atol=1e-5)
        assert len(result_array) == 16, len(result_array)

        geometry_array, result_array = cut_face_model_by_coord(model,
                                                               coord,
                                                               tol,
                                                               nodal_result,
                                                               plane_atol=1e-5)
        assert result_array is None, len(result_array)  # no quad support
        os.remove('plane_edge.bdf')
        os.remove('plane_face.bdf')
    def test_coord_adding(self):
        origin = [0., 0., 0.]
        zaxis = [0., 0., 1.]
        xzplane = [1., 0., 0.]
        cid1 =CORD2R(cid=1, rid=0, origin=origin, zaxis=zaxis, xzplane=xzplane,
                     comment='')

        xaxis = [1., 0., 0.]
        yaxis = [0., 1., 0.]
        zaxis = [0., 0., 1.]
        xz_plane = [1., 0., 1.]
        yz_plane = [0., 1., 1.]
        xy_plane = [1., 1., 0.]
        # x-axis
        cid2 = CORD2R.add_axes(cid=2, rid=0, origin=origin, xaxis=xaxis, yaxis=None, zaxis=None,
                               xyplane=None, yzplane=None, xzplane=xz_plane)

        cid3 = CORD2R.add_axes(cid=2, rid=0, origin=origin, xaxis=xaxis, yaxis=None, zaxis=None,
                               xyplane=xy_plane, yzplane=None, xzplane=None)

        # y-axis
        cid4 = CORD2R.add_axes(cid=4, rid=0, origin=origin, xaxis=None, yaxis=yaxis, zaxis=None,
                               xyplane=xy_plane, yzplane=None, xzplane=None)

        cid5 = CORD2R.add_axes(cid=5, rid=0, origin=origin, xaxis=None, yaxis=yaxis, zaxis=None,
                               xyplane=None, yzplane=yz_plane, xzplane=None)

        # z-axis
        cid4 = CORD2R.add_axes(cid=4, rid=0, origin=origin, xaxis=None, yaxis=None, zaxis=zaxis,
                               xyplane=None, yzplane=None, xzplane=xz_plane)

        cid5 = CORD2R.add_axes(cid=5, rid=0, origin=origin, xaxis=None, yaxis=None, zaxis=zaxis,
                               xyplane=None, yzplane=yz_plane, xzplane=None)

        # ijk
        cid6 = CORD2R.add_ijk(cid=6, rid=0, origin=origin, i=xaxis, j=yaxis, k=None)
        cid7 = CORD2R.add_ijk(cid=7, rid=0, origin=origin, i=xaxis, j=None, k=zaxis)
        cid8 = CORD2R.add_ijk(cid=8, rid=0, origin=origin, i=None, j=yaxis, k=zaxis)
Example #18
0
    def test_cut_shell_model_2(self):
        """
        tests:
         - cut_edge_model_by_coord
         - cut_face_model_by_coord
        """
        tol = 2.
        coord = CORD2R(1, rid=0, origin=[0.5, 0., 0.], zaxis=[0.5, 0., 1], xzplane=[1.5, 0., 0.],
                       comment='')
        model, nodal_result = _cut_shell_model_quads()
        #-------------------------------------------------------------------------
        # triangles
        split_to_trias(model)
        model.coords[1] = coord
        model.write_bdf('tris.bdf')

        #print('----------------------------')
        title = 'result'
        p1 = None
        p2 = None
        zaxis = None
        cut_and_plot_model(title, p1, p2, zaxis,
                           model, coord, nodal_result, model.log, tol,
                           plane_atol=1e-5,
                           csv_filename=None,
                           invert_yaxis=False,
                           cut_type='edge', plot=IS_MATPLOTLIB, show=False)

        out = cut_edge_model_by_coord(
            model, coord, tol, nodal_result,
            plane_atol=1e-5, csv_filename='cut_edge_2.csv')
        unused_local_points_array, unused_global_points_array, result_array = out
        assert len(result_array) == 20, len(result_array)

        unused_geometry_arrays, result_arrays, unused_rods = cut_face_model_by_coord(
            model, coord, tol, nodal_result,
            plane_atol=1e-5, csv_filename='cut_face_2.csv')
        assert len(result_arrays[0]) == 8, len(result_arrays)
        os.remove('tris.bdf')
        os.remove('cut_edge_2.csv')
        os.remove('cut_face_2.csv')
        os.remove('plane_edge.bdf')
        os.remove('plane_face.bdf')
Example #19
0
    def test_cut_shell_model_2(self):
        """tests pierce_shell_model"""
        tol = 2.
        coord = CORD2R(1,
                       rid=0,
                       origin=[0.5, 0., 0.],
                       zaxis=[0.5, 0., 1],
                       xzplane=[1.5, 0., 0.],
                       comment='')
        model, nodal_result = _cut_shell_model_quads()
        #-------------------------------------------------------------------------
        # triangles
        elements2 = {}
        neids = len(model.elements)
        for eid, elem in iteritems(model.elements):
            elem_a, elem_b = elem.split_to_ctria3(eid, eid + neids)
            elements2[elem_a.eid] = elem_a
            elements2[elem_b.eid] = elem_b
        model.elements = elements2
        print(elements2)
        model.coords[1] = coord
        model.write_bdf('tris.bdf')

        print('----------------------------')
        local_points_array, global_points_array, result_array = cut_edge_model_by_coord(
            model,
            coord,
            tol,
            nodal_result,
            plane_atol=1e-5,
            csv_filename='cut_edge_2.csv')
        assert len(result_array) == 20, len(result_array)

        geometry_arrays, result_arrays = cut_face_model_by_coord(
            model,
            coord,
            tol,
            nodal_result,
            plane_atol=1e-5,
            csv_filename='cut_face_2.csv')
        assert len(result_arrays[0]) == 8, len(result_arrays)
Example #20
0
def plot_shear_moment_torque(model: OP2Geom,
                             gpforce: RealGridPointForcesArray,
                             coord: CORD2R,
                             itime: int=0,
                             nplanes: int=11, show: bool=True):
    nids, nid_cd, xyz_cid0, icd_transform, eids, element_centroids_cid0 = smt_setup(model)
    element_centroids_coord = coord.transform_node_to_local_array(element_centroids_cid0)
    idir = 0
    x = element_centroids_coord[idir]
    xmin = x.min()
    xmax = x.max()
    dx = xmax - xmin
    assert abs(dx) > 0., f'dx={dx} xmin={xmin} xmax={xmax}'
    stations = np.linspace(0., dx, num=nplanes, endpoint=True)
    force_sum, moment_sum, new_coords, nelems, nnodes = gpforce.shear_moment_diagram(
        nids, xyz_cid0, nid_cd, icd_transform,
        eids, element_centroids_cid0, stations,
        model.coords, coord,
        iaxis_march=None,
        itime=itime, debug=False, log=model.log)
    plot_smt(stations, force_sum, moment_sum, nelems, nnodes, show=show)
Example #21
0
def get_coords_box(ncuts):  # pragma: no cover
    dys = []
    coords = []
    for i in range(ncuts):
        dy = -0.1 * i - 0.1  #  box
        #coord = CORD2R(1, rid=0, origin=[0., dy, 0.], zaxis=[0., dy, 1], xzplane=[1., dy, 0.])
        coord = CORD2R(1, rid=0, origin=[0., dy, 0.], zaxis=[0., dy, 1], xzplane=[1., dy, 0.])

        #if dy < -5:
            #print('break', dy)
            #break

        #origin = np.array([0., dy, 0.])
        #xzplane = origin + dx
        #xzplane = np.array([1., dy, 0.])
        #coord = CORD2R.add_axes(cid, rid=0, origin=p1, xaxis=p2-p1, yaxis=None, zaxis=None,
                                 #xyplane=None, yzplane=None, xzplane=None, comment='')
        #print(coord)
        dys.append(dy)
        coords.append(coord)
    return dys, coords
Example #22
0
    def test_cut_shell_model_1(self):
        """tests pierce_shell_model"""
        model, nodal_result = _cut_shell_model_quads()
        coord = CORD2R(1,
                       rid=0,
                       origin=[0.5, 0., 0.],
                       zaxis=[0.5, 0., 1],
                       xzplane=[1.5, 0., 0.],
                       comment='')
        model.coords[1] = coord
        tol = 2.
        #-------------------------------------------------------------------------
        local_points_array, global_points_array, result_array = cut_edge_model_by_coord(
            model, coord, tol, nodal_result, plane_atol=1e-5)
        assert len(result_array) == 16, len(result_array)

        geometry_array, result_array = cut_face_model_by_coord(model,
                                                               coord,
                                                               tol,
                                                               nodal_result,
                                                               plane_atol=1e-5)
        assert result_array is None, len(result_array)  # no quad support
Example #23
0
    def test_cord2c_01(self):
        """simple CORD2R/CORD2C input/output test"""
        lines = [
            'CORD2C*                3               0              0.              0.',
            '*                     0.              0.              0.              1.*',
            '*                     1.              0.              1.'
        ]
        model = BDF(debug=False)
        card = model.process_card(lines)
        cardi = BDFCard(card)
        cord2c = CORD2C.add_card(cardi)
        model._add_coord_object(cord2c)

        lines = [
            'CORD2R         4       3     10.      0.      5.     10.     90.      5.',
            '             10.      0.      6.'
        ]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        cord2r = CORD2R.add_card(cardi)
        model._add_coord_object(cord2r)
        model.cross_reference()

        cord2r_b = model.Coord(3)
        self.assertEqual(cord2r_b.Cid(), 3)
        self.assertEqual(cord2r_b.Rid(), 0)

        cord2r_c = model.Coord(4)
        self.assertEqual(cord2r_c.Cid(), 4)
        self.assertEqual(cord2r_c.Rid(), 3)

        self.assertTrue(allclose(cord2r_c.i, array([0., 0., 1.])))
        delta = cord2r_c.j - array([1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(cord2r_c.j,
                                 array([1., 1., 0.]) / 2**0.5), str(delta))
        delta = cord2r_c.k - array([-1., 1., 0.]) / 2**0.5
        self.assertTrue(allclose(cord2r_c.k,
                                 array([-1., 1., 0.]) / 2**0.5), str(delta))
Example #24
0
    def test_spline2(self):
        """checks the SPLINE2 card"""
        #| SPLINE2 | EID  | CAERO |  ID1  |  ID2  | SETG | DZ | DTOR | CID |
        #|         | DTHX | DTHY  | None  | USAGE |      |    |      |     |
        #+---------+------+-------+-------+-------+------+----+------+-----+
        #| SPLINE2 |   5  |   8   |  12   | 24    | 60   | 0. | 1.0  |  3  |
        #|         |  1.  |       |       |       |      |    |      |     |

        cid = 3
        origin = [0., 0., 0.]
        xaxis = [1., 0., 0.]
        xyplane = [0., 1., 0.]
        coord = CORD2R.add_axes(cid, rid=0, origin=origin,
                                xaxis=xaxis, yaxis=None, zaxis=None,
                                xyplane=xyplane, yzplane=None, xzplane=None,
                                comment='comment')
        eid = 8
        pid = 10
        cp = 0
        nsb = 4
        nint = 2
        lsb = None
        lint = None
        p1 = [0., 0., 0.]
        x12 = 42.
        igid = None
        caero2 = CAERO2(eid, pid, igid, p1, x12,
                        cp=cp, nsb=nsb, nint=nint, lsb=lsb, lint=lint,
                        comment='this is a caero')
        #caero = CAERO2(eid, pid, cp, nsb, nint, lsb, lint, igid, p1, x12)

        sid = 60
        ids = [7, 13]
        set_obj = SET1(sid, ids, is_skin=False, comment='set card')
        grid7 = GRID(nid=7, cp=0, xyz=[7., 0., 0.], cd=0, ps='', seid=0, comment='')
        grid13 = GRID(nid=13, cp=0, xyz=[13., 0., 0.], cd=0, ps='', seid=0, comment='')

        model = BDF(log=None)
        model._add_coord_object(coord)
        model._add_caero_object(caero2)
        model._add_set_object(set_obj)
        model._add_node_object(grid7)
        model._add_node_object(grid13)

        eid = 5
        caero = 8
        id1 = 12
        id2 = 24
        setg = 60
        dz = 0.
        dtor = 1.0
        cid = 3
        dthx = 1.
        dthy = None
        usage = None
        card = ['SPLINE2', eid, caero, id1, id2, setg, dz, dtor, cid,
                dthx, dthy, None, usage]

        bdf_card = BDFCard(card, has_none=True)
        spline_a = SPLINE2.add_card(bdf_card, comment='spline2_a')
        spline_a.write_card()

        spline_b = SPLINE2(eid, caero, id1, id2, setg, dz, dtor, cid, dthx,
                           dthy, usage, comment='spline2_b')
        spline_b.validate()
        spline_b.write_card()
        spline_b.cross_reference(model)
        spline_b.write_card()
Example #25
0
    def test_spline2(self):
        """checks the SPLINE2 card"""
        #| SPLINE2 | EID  | CAERO |  ID1  |  ID2  | SETG | DZ | DTOR | CID |
        #|         | DTHX | DTHY  | None  | USAGE |      |    |      |     |
        #+---------+------+-------+-------+-------+------+----+------+-----+
        #| SPLINE2 |   5  |   8   |  12   | 24    | 60   | 0. | 1.0  |  3  |
        #|         |  1.  |       |       |       |      |    |      |     |

        cid = 3
        origin = [0., 0., 0.]
        xaxis = [1., 0., 0.]
        xyplane = [0., 1., 0.]
        coord = CORD2R.add_axes(cid, rid=0, origin=origin,
                                xaxis=xaxis, yaxis=None, zaxis=None,
                                xyplane=xyplane, yzplane=None, xzplane=None,
                                comment='comment')
        eid = 8
        pid = 10
        cp = 0
        nsb = 4
        nint = 2
        lsb = None
        lint = None
        p1 = [0., 0., 0.]
        x12 = 42.
        igid = None
        caero2 = CAERO2(eid, pid, igid, p1, x12,
                        cp=cp, nsb=nsb, nint=nint, lsb=lsb, lint=lint,
                        comment='this is a caero')
        #caero = CAERO2(eid, pid, cp, nsb, nint, lsb, lint, igid, p1, x12)

        sid = 60
        ids = [7, 13]
        set_obj = SET1(sid, ids, is_skin=False, comment='set card')
        grid7 = GRID(nid=7, cp=0, xyz=[7., 0., 0.], cd=0, ps='', seid=0, comment='')
        grid13 = GRID(nid=13, cp=0, xyz=[13., 0., 0.], cd=0, ps='', seid=0, comment='')

        model = BDF(log=None)
        model.add_coord(coord)
        model.add_caero(caero2)
        model.add_set(set_obj)
        model.add_node(grid7)
        model.add_node(grid13)

        eid = 5
        caero = 8
        id1 = 12
        id2 = 24
        setg = 60
        dz = 0.
        dtor = 1.0
        cid = 3
        dthx = 1.
        dthy = None
        usage = None
        card = ['SPLINE2', eid, caero, id1, id2, setg, dz, dtor, cid,
                dthx, dthy, None, usage]

        bdf_card = BDFCard(card, has_none=True)
        spline_a = SPLINE2.add_card(bdf_card, comment='spline2_a')
        spline_a.write_card()

        spline_b = SPLINE2(eid, caero, id1, id2, setg, dz, dtor, cid, dthx,
                           dthy, usage, comment='spline2_b')
        spline_b.validate()
        spline_b.write_card()
        spline_b.cross_reference(model)
        spline_b.write_card()
Example #26
0
    def test_cut_bwb(self):
        """recover element ids"""
        log = SimpleLogger(level='warning', encoding='utf-8', log_func=None)
        is_bwb = True
        if is_bwb:
            bdf_filename = os.path.join(MODEL_PATH, 'bwb',
                                        'bwb_saero.bdf')  # ymax~=1262.0
        else:  #  pragma: no cover
            bdf_filename = r'C:\NASA\asm\all_modes_mach_0.85\flutter.bdf'  # ymax=1160.601
        normal_plane = np.array([0., 1., 0.])

        model = read_bdf(bdf_filename, log=log)
        model2 = read_bdf(bdf_filename, log=log)

        # initialize theta
        thetas = {}
        for eid in model.elements:
            #  theta, Ex, Ey, Gxy
            thetas[eid] = (0., 0., 0., 0.)

        #p1 = np.array([466.78845, 735.9053, 0.0])
        #p2 = np.array([624.91345, 639.68896, -0.99763656])
        #dx = p2 - p1
        ytol = 2.
        nodal_result = None
        plane_bdf_filenames = []
        y = []
        A = []
        I = []
        EI = []
        avg_centroid = []

        for i in range(2000):
            if is_bwb:
                dy = 100. * i + 1.  #  bwb
                coord = CORD2R(1,
                               rid=0,
                               origin=[0., dy, 0.],
                               zaxis=[0., dy, 1],
                               xzplane=[1., dy, 0.])
            else:  #  pragma: no cover
                dy = 4. * i + 1.  #  CRM
                coord = CORD2R(1,
                               rid=0,
                               origin=[0., dy, 0.],
                               zaxis=[0., dy, 1],
                               xzplane=[1., dy, 0.])
                #origin = np.array([0., dy, 0.])
                #xzplane = origin + dx
                #xzplane = np.array([1., dy, 0.])
                #coord = CORD2R.add_axes(cid, rid=0, origin=p1, xaxis=p2-p1, yaxis=None, zaxis=None,
                #xyplane=None, yzplane=None, xzplane=None, comment='')
                print(coord)
            model.coords[1] = coord
            plane_bdf_filename = 'plane_face_%i.bdf' % i
            cut_face_filename = 'cut_face_%i.csv' % i
            if os.path.exists(cut_face_filename):
                os.remove(cut_face_filename)
            try:
                out = cut_face_model_by_coord(
                    model2,
                    coord,
                    ytol,
                    nodal_result,
                    plane_atol=1e-5,
                    skip_cleanup=True,
                    #csv_filename=cut_face_filename,
                    csv_filename=None,
                    #plane_bdf_filename=None)
                    plane_bdf_filename=plane_bdf_filename,
                    plane_bdf_offset=dy)
            except RuntimeError:
                # incorrect ivalues=[0, 1, 2]; dy=771. for CRM
                continue
            unused_unique_geometry_array, unused_unique_results_array, rods = out

            if not os.path.exists(plane_bdf_filename):
                break
            plane_bdf_filenames.append(plane_bdf_filename)
            # eid, nid, inid1, inid2
            #print(unique_geometry_array)
            #moi_filename = 'amoi_%i.bdf' % i
            moi_filename = None
            out = calculate_area_moi(model,
                                     rods,
                                     normal_plane,
                                     thetas,
                                     moi_filename=moi_filename)
            #print(out)
            Ai, Ii, EIi, avg_centroidi = out
            y.append(dy)
            A.append(Ai)
            I.append(Ii)
            EI.append(EIi)
            avg_centroid.append(avg_centroidi)
            #break

        with open('thetas.csv', 'w') as csv_filename:
            csv_filename.write('# eid(%i),theta,Ex,Ey,Gxy\n')
            for eid, (theta, Ex, Ey, Gxy) in sorted(thetas.items()):
                csv_filename.write('%i,%f,%f,%f,%f\n' %
                                   (eid, theta, Ex, Ey, Gxy))

        y = np.array(y, dtype='float64')
        A = np.array(A, dtype='float64')
        I = np.array(I, dtype='float64')
        EI = np.array(EI, dtype='float64')
        avg_centroid = np.array(avg_centroid, dtype='float64')

        inid = 1
        beam_model = BDF(debug=False)
        avg_centroid[:, 1] = y

        # wrong
        mid = 1
        E = 3.0e7
        G = None
        nu = 0.3
        model.add_mat1(mid, E, G, nu, rho=0.1)

        Ix = I[:, 0]
        Iy = I[:, 1]
        Ixy = I[:, 2]
        J = Ix + Iy
        #i1, i2, i12 = Ix, Iy, Ixy
        for inid, xyz in enumerate(avg_centroid):
            beam_model.add_grid(inid + 1, xyz)
        for eid in range(1, len(A)):
            pid = eid
            nids = [eid, eid + 1]
            x = [1., 0., 0.]
            g0 = None
            beam_model.add_cbeam(eid,
                                 pid,
                                 nids,
                                 x,
                                 g0,
                                 offt='GGG',
                                 bit=None,
                                 pa=0,
                                 pb=0,
                                 wa=None,
                                 wb=None,
                                 sa=0,
                                 sb=0,
                                 comment='')

            # j = i1 + i2
            so = ['YES', 'YES']
            xxb = [0., 1.]
            area = [A[eid - 1], A[eid]]
            i1 = [Ix[eid - 1], Ix[eid]]
            i2 = [Iy[eid - 1], Iy[eid]]
            i12 = [Ixy[eid - 1], Ixy[eid]]
            j = [J[eid - 1], J[eid]]
            beam_model.add_pbeam(pid,
                                 mid,
                                 xxb,
                                 so,
                                 area,
                                 i1,
                                 i2,
                                 i12,
                                 j,
                                 nsm=None,
                                 c1=None,
                                 c2=None,
                                 d1=None,
                                 d2=None,
                                 e1=None,
                                 e2=None,
                                 f1=None,
                                 f2=None,
                                 k1=1.,
                                 k2=1.,
                                 s1=0.,
                                 s2=0.,
                                 nsia=0.,
                                 nsib=None,
                                 cwa=0.,
                                 cwb=None,
                                 m1a=0.,
                                 m2a=None,
                                 m1b=0.,
                                 m2b=None,
                                 n1a=0.,
                                 n2a=None,
                                 n1b=0.,
                                 n2b=None,
                                 comment='')
        beam_model.write_bdf('equivalent_beam_model.bdf')

        X = np.vstack([y, A]).T
        Y = np.hstack([X, I, EI, avg_centroid])
        header = 'y, A, Ix, Iz, Ixz, Ex*Ix, Ex*Iz, Ex*Ixz, xcentroid, ycentroid, zcentroid'
        np.savetxt('cut_data_vs_span.csv', Y, header=header, delimiter=',')

        show = True
        #show = False
        if IS_MATPLOTLIB:
            plot_inertia(y, A, I, EI, avg_centroid, show=show)
Example #27
0
    def test_caero2_1(self):
        """checks the CAERO2/PAERO2/AERO/AEFACT card"""
        log = SimpleLogger(level='warning')
        model = BDF(log=log)
        eid = 1
        pid = 10
        cp = 4
        nsb = 0
        nint = 0

        lsb = 3
        lint = 6
        igid = 0
        p1 = [0., 1., 2.]
        x12 = 10.
        caero = CAERO2.add_card(BDFCard(['CAERO2', eid, pid, cp, nsb, nint,
                                         lsb, lint, igid, ] + p1 + [x12]))

        #---------------
        caero = CAERO2(eid, pid, igid, p1, x12,
                       cp=cp, nsb=0, nint=nint, lsb=0, lint=lint,
                       comment='this is a caero')
        with self.assertRaises(ValueError):
            caero.validate()

        caero = CAERO2(eid, pid, igid, p1, x12,
                       cp=cp, nsb=lsb, nint=0, lsb=lsb, lint=0,
                       comment='this is a caero')
        with self.assertRaises(ValueError):
            caero.validate()

        #---------------
        caero = CAERO2(eid, pid, igid, p1, x12,
                       cp=cp, nsb=nsb, nint=nint, lsb=lsb, lint=lint,
                       comment='this is a caero')
        caero.validate()
        caero.write_card()

        aefact = AEFACT.add_card(BDFCard(['AEFACT', lint, 0., 1., 2., 3., 4., 5.]))
        aefact = AEFACT(lint, [0., 1., 2., 3., 4., 5.])
        aefact.validate()
        aefact.write_card()
        model.aefacts[lint] = aefact

        orient = 'Z'
        width = 10.
        AR = 2.
        lrsb = 0
        lrib = 3
        lth1 = 0
        lth2 = 0
        thi = [0]
        thn = [0]
        paero = PAERO2.add_card(BDFCard(['PAERO2', pid, orient, width, AR,
                                         lrsb, lrib, lth1, lth2] + thi + thn),
                                comment='paero')
        paero = PAERO2(pid, orient, width, AR, lrsb, lrib, lth1, lth2, thi, thn)
        paero.validate()
        paero.write_card()
        model.paeros[pid] = paero

        coord = CORD2R.add_card(BDFCard(['CORD2R', cp, 0,
                                         0., 0., 0.,
                                         0., 0., 1.,
                                         1., 0., 0.]))
        coord = CORD2R(cp, rid=0, origin=None, zaxis=None, xzplane=None,
                       comment='')
        coord.validate()
        model.coords[cp] = coord

        aefact = AEFACT(lrib, [0., 1., 2., 3., 4., 5.])
        aefact.validate()
        model.aefacts[lrib] = aefact

        acsid = 0
        velocity = None
        cref = 1.0
        rho_ref = 1.0

        aero = AERO.add_card(BDFCard(['AERO', acsid, velocity, cref, rho_ref]))
        aero = AERO(velocity, cref, rho_ref, acsid=acsid,
                    comment='')
        aero.validate()
        aero.write_card()
        model.aero = aero

        paero.cross_reference(model)
        caero.cross_reference(model)
        paero.raw_fields()
        caero.raw_fields()
        caero.uncross_reference()
        caero.raw_fields()
        caero.cross_reference(model)
        caero.get_points_elements_3d()

        caero.get_points()
        #caero.get_points_elements_3d()
        xyz, elems = caero.get_points_elements_3d()
        model.uncross_reference()
        model.safe_cross_reference()
        model.uncross_reference()
        model.write_bdf('aero.temp')
        os.remove('aero.temp')

        model.cross_reference()
        model.write_bdf('aero.temp')
        os.remove('aero.temp')

        nsb = 4
        nint = 2
        lsb = None
        lint = None
        caero2 = CAERO2(eid, pid, igid, p1, x12,
                        cp=cp, nsb=nsb, nint=nint, lsb=lsb, lint=lint,
                        comment='this is a caero')
        caero2.validate()
        caero2.cross_reference(model)
        caero2.write_card()
Example #28
0
    def test_cut_shell_model_2(self):
        """
        tests:
         - cut_edge_model_by_coord
         - cut_face_model_by_coord
        """
        tol = 2.
        coord = CORD2R(1,
                       rid=0,
                       origin=[0.5, 0., 0.],
                       zaxis=[0.5, 0., 1],
                       xzplane=[1.5, 0., 0.],
                       comment='')
        model, nodal_result = _cut_shell_model_quads()
        #-------------------------------------------------------------------------
        # triangles
        elements2 = {}
        neids = len(model.elements)
        for eid, elem in model.elements.items():
            elem_a, elem_b = elem.split_to_ctria3(eid, eid + neids)
            elements2[elem_a.eid] = elem_a
            elements2[elem_b.eid] = elem_b
        model.elements = elements2
        model.coords[1] = coord
        model.write_bdf('tris.bdf')

        #print('----------------------------')
        title = 'result'
        p1 = None
        p2 = None
        zaxis = None
        cut_and_plot_model(title,
                           p1,
                           p2,
                           zaxis,
                           model,
                           coord,
                           nodal_result,
                           model.log,
                           tol,
                           plane_atol=1e-5,
                           csv_filename=None,
                           invert_yaxis=False,
                           cut_type='edge',
                           show=False)

        local_points_array, global_points_array, result_array = cut_edge_model_by_coord(
            model,
            coord,
            tol,
            nodal_result,
            plane_atol=1e-5,
            csv_filename='cut_edge_2.csv')
        assert len(result_array) == 20, len(result_array)

        geometry_arrays, result_arrays = cut_face_model_by_coord(
            model,
            coord,
            tol,
            nodal_result,
            plane_atol=1e-5,
            csv_filename='cut_face_2.csv')
        assert len(result_arrays[0]) == 8, len(result_arrays)
        os.remove('tris.bdf')
        os.remove('cut_edge_2.csv')
        os.remove('cut_face_2.csv')
        os.remove('plane_edge.bdf')
        os.remove('plane_face.bdf')
Example #29
0
    def test_cut_shell_model(self):
        """tests pierce_shell_model"""
        pid = 10
        mid1 = 100
        model = BDF(log=log)

        # intersects (min)
        model.add_grid(1, [0., 0., 0.])
        model.add_grid(2, [1., 0., 0.])
        model.add_grid(3, [1., 1., 0.])
        model.add_grid(4, [0., 1., 0.])
        model.add_cquad4(1, pid, [1, 2, 3, 4])

        # intersects (max)
        model.add_grid(5, [0., 0., 1.])
        model.add_grid(6, [1., 0., 1.])
        model.add_grid(7, [1., 1., 1.])
        model.add_grid(8, [0., 1., 1.])
        model.add_cquad4(2, pid, [5, 6, 7, 8])

        # intersects (mid)
        model.add_grid(9, [0., 0., 0.5])
        model.add_grid(10, [1., 0., 0.5])
        model.add_grid(11, [1., 1., 0.5])
        model.add_grid(12, [0., 1., 0.5])
        model.add_cquad4(3, pid, [9, 10, 11, 12])

        # doesn't intersect
        model.add_grid(13, [10., 0., 0.])
        model.add_grid(14, [11., 0., 0.])
        model.add_grid(15, [11., 1., 0.])
        model.add_grid(16, [10., 1., 0.])
        model.add_cquad4(4, pid, [13, 14, 15, 16])

        model.add_pshell(pid, mid1=mid1, t=2.)

        E = 1.0
        G = None
        nu = 0.3
        model.add_mat1(mid1, E, G, nu, rho=1.0)
        model.validate()

        model.cross_reference()

        xyz_points = [
            [0.4, 0.6, 0.],
            [-1., -1, 0.],
        ]

        tol = 2.
        coord = CORD2R(1,
                       rid=0,
                       origin=[0.5, 0., 0.],
                       zaxis=[0.5, 0., 1],
                       xzplane=[1.5, 0., 0.],
                       comment='')
        nodal_result = np.linspace(0., 1., num=16)
        local_points_array, global_points_array, result_array = cut_edge_model_by_coord(
            model, coord, tol, nodal_result, plane_atol=1e-5)
        assert len(result_array) == 16, len(result_array)

        local_points_array, global_points_array, result_array = cut_face_model_by_coord(
            model, coord, tol, nodal_result, plane_atol=1e-5)
        assert len(result_array) == 0, len(result_array)  # no quad support
Example #30
0
    def test_caero1_1(self):
        """checks the CAERO1/PAERO1/AEROS/AEFACT card"""
        eid = 1
        pid = 10
        cp = 4
        nspan = None
        lspan = 3
        nchord = None
        lchord = 4
        igid = 0
        p1 = [0., 0., 0.]
        x12 = 5.
        p4 = [2., 3., 4.]
        x43 = 1.

        log = SimpleLogger(level='warning')
        model = BDF(log=log)
        caero = CAERO1.add_card(BDFCard(['CAERO1', eid, pid, cp, nspan, nchord, lspan, lchord,
                                         igid, ] + p1 + [x12] + p4 + [x43]))
        caero.validate()
        caero = CAERO1.add_card(BDFCard(['CAERO1', eid, pid, None, nspan, nchord, lspan, lchord,
                                         igid, ] + p1 + [x12] + p4 + [x43]))
        caero.validate()
        caero = CAERO1(eid, pid, cp, nspan, lspan, nchord, lchord, igid, p1,
                       x12, p4, x43, comment='caero1')
        caero.raw_fields()
        caero.validate()
        caero.write_card()
        model.caeros[eid] = caero

        p1 = [0., 0., 0.]
        p2 = [1., 0., 0.]
        p3 = [0.2, 1., 0.]
        p4 = [0.1, 1., 0.]
        nspan = 5
        nchord = 10
        igid = -1
        caeroq = CAERO1.add_quad(eid, pid, cp, nspan, nchord, igid, p1, p2, p3, p4,
                                 spanwise='y', comment='')
        caeroq.validate()

        span = 0.1
        chord = 0.05
        igid = -1
        caeroq = CAERO1.add_quad(eid, pid, cp, span, chord, igid, p1, p2, p3, p4,
                                 spanwise='y', comment='')
        caeroq.validate()


        p1 = [0., 0., 0.]
        p2 = [1., 0., 0.]
        p3 = [0.2, 0., 1.]
        p4 = [0.1, 0., 1.]
        span = 0.1
        chord = 0.05
        igid = -1
        caeroq = CAERO1.add_quad(eid, pid, cp, span, chord, igid, p1, p2, p3, p4,
                                 spanwise='z', comment='')
        caeroq.validate()

        paero = PAERO1(pid, Bi=None, comment='')
        paero.validate()
        paero.write_card()
        model.paeros[pid] = paero

        coord = CORD2R(cp, rid=0, origin=None, zaxis=None, xzplane=None,
                       comment='')
        coord.validate()
        model.coords[cp] = coord

        #acsid = 0.
        #velocity = None
        cref = 1.0
        bref = 2.0
        sref = 100.
        acsid = 0
        rcsid = 0
        aeros = AEROS(cref, bref, sref, acsid, rcsid, sym_xz=0, sym_xy=0,
                      comment='')
        aeros.validate()
        aeros.write_card()
        model.aeros = aeros

        aefact = AEFACT(lspan, [0., 1., 2., 3., 4., 5.])
        aefact.validate()
        model.aefacts[lspan] = aefact

        aefact = AEFACT(lchord, [2., 3., 4., 5., 6., 7.])
        aefact.validate()
        model.aefacts[lchord] = aefact

        paero.cross_reference(model)
        caero.cross_reference(model)
        caero.get_npanel_points_elements()
        caero.get_points()
        caero.panel_points_elements()

        caero.write_card()
        model.uncross_reference()
        model.cross_reference()
        model.uncross_reference()
        #model.safe_cross_reference()
        caero.safe_cross_reference(model)
        caero.panel_points_elements()
        caero.raw_fields()
        min_max_eid = caero.min_max_eid
        self.assertEqual(min_max_eid, [1, 26])
        #print('min_eid, max_eid', min_eid, max_eid)

        points = [
            [0., 0., 0.], # p1
            [10., 0., 0.],
            [10., 20., 0.],
            [5., 20., 0.],
        ]
        caero.set_points(points)
        caero.get_points()
        str(caero.write_card())

        nspan = None
        lspan = None
        caero = CAERO1(eid, pid, cp, nspan, lspan, nchord, lchord, igid, p1,
                       x12, p4, x43, comment='caero1')
        with self.assertRaises(ValueError):
            caero.validate()

        nspan = 5
        lspan = 5
        caero = CAERO1(eid, pid, cp, nspan, lspan, nchord, lchord, igid, p1,
                       x12, p4, x43, comment='caero1')
        with self.assertRaises(ValueError):
            caero.validate()

        nspan = 5
        nchord = None
        lchord = None
        caero = CAERO1(eid, pid, cp, nspan, lspan, nchord, lchord, igid, p1,
                       x12, p4, x43, comment='caero1')
        with self.assertRaises(ValueError):
            caero.validate()

        nchord = 10
        lchord = 10
        caero = CAERO1(eid, pid, cp, nspan, lspan, nchord, lchord, igid, p1,
                       x12, p4, x43, comment='caero1')
        with self.assertRaises(ValueError):
            caero.validate()

        lspan = None
        lchord = None
        nspan = 10
        nchord = 10
        p1 = [0., 0., 0., 0.]
        caero = CAERO1(eid, pid, cp, nspan, lspan, nchord, lchord, igid, p1,
                       x12, p4, x43, comment='caero1')
        with self.assertRaises(AssertionError):
            caero.validate()

        p1 = [0., 0., 0.]
        p4 = [1., 2., 3., 4.]
        caero = CAERO1(eid, pid, cp, nspan, lspan, nchord, lchord, igid, p1,
                       x12, p4, x43, comment='caero1')
        with self.assertRaises(AssertionError):
            caero.validate()
Example #31
0
    def test_aesurf_1(self):
        """checks the AESURF/AELIST cards"""
        aesid = 10
        label = 'FLAP'
        cid1 = 0
        aelist_id1 = 10
        cid2 = None
        alid2 = None
        aesurf1 = AESURF(aesid, label, cid1, aelist_id1, cid2, alid2,
                         #eff, ldw,
                         #crefc, crefs, pllim, pulim,
                         #hmllim, hmulim, tqllim, tqulim,
                         comment='aesurf comment')
        aesurf2 = AESURF.add_card(BDFCard(
            [
                'AESURF', aesid, label, cid1, aelist_id1, cid2, alid2,
                #eff, ldw,
                #crefc, crefs, pllim, pulim,
                #hmllim, hmulim, tqllim, tqulim,
            ]), comment='aesurf comment')
        #assert aesurf1 == aesurf2

        cid2 = 1
        coord = CORD2R(cid2, rid=0, origin=[0., 0., 0.],
                       zaxis=[1., 0., 0.], xzplane=[0., 1., 1.], comment='')

        aelist_id1 = 10
        aelist_id2 = 20
        aesurf2 = AESURF.add_card(BDFCard(
            [
                'AESURF', aesid, label, cid1, aelist_id1, cid2, aelist_id2,
                #eff, ldw,
                #crefc, crefs, pllim, pulim,
                #hmllim, hmulim, tqllim, tqulim,
            ]), comment='aesurf comment')

        aesurf1.validate()
        aesurf2.validate()
        log = SimpleLogger(level='warning')

        model = BDF()
        model._add_coord_object(coord)
        model._add_aesurf_object(aesurf1)

        elements = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
        aelist = AELIST(aelist_id1, elements)
        model._add_aelist_object(aelist)

        elements = [11, 22, 33, 44, 55, 66, 77, 88, 99]
        aelist = AELIST(aelist_id2, elements)
        model._add_aelist_object(aelist)

        aesurf1.cross_reference(model)
        aesurf1.write_card()
        aesurf1.raw_fields()
        aesurf1.uncross_reference()
        aesurf1.write_card()
        aesurf1.cross_reference(model)
        aesurf1.raw_fields()

        aesurf2.cross_reference(model)
        aesurf2.write_card()
        aesurf2.raw_fields()
        aesurf2.uncross_reference()
        aesurf2.write_card()
        aesurf2.cross_reference(model)
        aesurf2.raw_fields()
    def test_gpforce_01(self):
        nids = np.array([1, 2, 3])
        xyz_cid0 = np.array([
            [1., 1., 1.],
            [4., 2., 5.],
            [3., 3., 3.],
        ])
        data_code = {
            'nonlinear_factor': None,
            'sort_bits': [0, 0, 0],
            'analysis_code': 1,
            'is_msc': True,
            'format_code': 1,
            'table_code': 1,
            'data_names': 'cat',
            'device_code': 1,
            #'tcode' : 1,
        }
        is_sort1 = True
        isubcase = 1
        dt = 0.0
        gpforce = RealGridPointForcesArray(data_code, is_sort1, isubcase, dt)
        gpforce.ntimes = 1
        gpforce.ntotal = 3
        gpforce._ntotals = [3]

        gpforce.build()
        gpforce.data[0, :, :] = np.array([
            [
                3.,
                7.,
                11.,
                0.,
                0.,
                0.,
            ],  # fx, fy, fz, mx, my, mz
            [
                3.,
                7.,
                11.,
                0.,
                0.,
                0.,
            ],
            [
                3.,
                7.,
                11.,
                0.,
                0.,
                0.,
            ],
        ])
        gpforce.node_element[0, :, :] = np.array([
            [1, 1],
            [2, 1],
            [3, 1],
        ])
        op2 = OP2()
        summation_point = [0., 0., 0.]
        i_transform = None
        nid_cd = np.array([
            [1, 0],
            [2, 0],
            [3, 0],
        ])
        coord_out = CORD2R(cid=0)
        coords = {0: coord_out}

        #eids = [1]
        #nids = [1]
        #gpforce.extract_interface_loads(
        #nids, eids, coord_out, coords, nid_cd,
        #i_transform,
        #xyz_cid0,
        #summation_point,
        #itime=0,
        #debug=True,
        #logger=op2.log)

        #print('------------')
        #eids = [1]
        #nids = [2]
        #gpforce.extract_interface_loads(
        #nids, eids, coord_out, coords, nid_cd,
        #i_transform,
        #xyz_cid0,
        #summation_point,
        #itime=0,
        #debug=True,
        #logger=op2.log)
        #print('------------')

        eids = [1]
        nids = [1, 2]
        gpforce.extract_interface_loads(nids,
                                        eids,
                                        coord_out,
                                        coords,
                                        nid_cd,
                                        i_transform,
                                        xyz_cid0,
                                        summation_point,
                                        itime=0,
                                        debug=True,
                                        logger=op2.log)
Example #33
0
    def test_caero2_1(self):
        """checks the CAERO2/PAERO2/AERO/AEFACT card"""
        log = SimpleLogger(level='warning')
        model = BDF(log=log)
        eid = 1
        pid = 10
        cp = 4
        nsb = 0
        nint = 0

        lsb = 3
        lint = 6
        igid = 0
        p1 = [0., 1., 2.]
        x12 = 10.
        caero = CAERO2.add_card(BDFCard(['CAERO2', eid, pid, cp, nsb, nint,
                                         lsb, lint, igid, ] + p1 + [x12]))

        #---------------
        caero = CAERO2(eid, pid, igid, p1, x12,
                       cp=cp, nsb=0, nint=nint, lsb=0, lint=lint,
                       comment='this is a caero')
        with self.assertRaises(ValueError):
            caero.validate()

        caero = CAERO2(eid, pid, igid, p1, x12,
                       cp=cp, nsb=lsb, nint=0, lsb=lsb, lint=0,
                       comment='this is a caero')
        with self.assertRaises(ValueError):
            caero.validate()

        #---------------
        caero = CAERO2(eid, pid, igid, p1, x12,
                       cp=cp, nsb=nsb, nint=nint, lsb=lsb, lint=lint,
                       comment='this is a caero')
        caero.validate()
        caero.write_card()

        aefact = AEFACT.add_card(BDFCard(['AEFACT', lint, 0., 1., 2., 3., 4., 5.]))
        aefact = AEFACT(lint, [0., 1., 2., 3., 4., 5.])
        aefact.validate()
        aefact.write_card()
        model.aefacts[lint] = aefact

        orient = 'Z'
        width = 10.
        AR = 2.
        lrsb = 0
        lrib = 3
        lth1 = 0
        lth2 = 0
        thi = [0]
        thn = [0]
        paero = PAERO2.add_card(BDFCard(['PAERO2', pid, orient, width, AR,
                                         lrsb, lrib, lth1, lth2] + thi + thn),
                                comment='paero')
        paero = PAERO2(pid, orient, width, AR, lrsb, lrib, lth1, lth2, thi, thn)
        paero.validate()
        paero.write_card()
        model.paeros[pid] = paero

        coord = CORD2R.add_card(BDFCard(['CORD2R', cp, 0,
                                         0., 0., 0.,
                                         0., 0., 1.,
                                         1., 0., 0.]))
        coord = CORD2R(cp, rid=0, origin=None, zaxis=None, xzplane=None,
                       comment='')
        coord.validate()
        model.coords[cp] = coord

        aefact = AEFACT(lrib, [0., 1., 2., 3., 4., 5.])
        aefact.validate()
        model.aefacts[lrib] = aefact

        acsid = 0
        velocity = None
        cref = 1.0
        rho_ref = 1.0

        aero = AERO.add_card(BDFCard(['AERO', acsid, velocity, cref, rho_ref]))
        aero = AERO(velocity, cref, rho_ref, acsid=acsid,
                    comment='')
        aero.validate()
        aero.write_card()
        model.aero = aero

        paero.cross_reference(model)
        caero.cross_reference(model)
        paero.raw_fields()
        caero.raw_fields()
        caero.uncross_reference()
        caero.raw_fields()
        caero.cross_reference(model)
        caero.get_points_elements_3d()

        caero.get_points()
        #caero.get_points_elements_3d()
        xyz, elems = caero.get_points_elements_3d()
        model.uncross_reference()
        model.safe_cross_reference()
        model.uncross_reference()
        model.write_bdf('aero.temp')
        os.remove('aero.temp')

        model.cross_reference()
        model.write_bdf('aero.temp')
        os.remove('aero.temp')

        nsb = 4
        nint = 2
        lsb = None
        lint = None
        caero2 = CAERO2(eid, pid, igid, p1, x12,
                        cp=cp, nsb=nsb, nint=nint, lsb=lsb, lint=lint,
                        comment='this is a caero')
        caero2.validate()
        caero2.cross_reference(model)
        caero2.write_card()