Example #1
0
    def test_conrod_01(self):
        model = BDF(debug=debug)
        model.allocate({'CONROD': 1})
        eid = 10
        nid1 = 2
        nid2 = 3
        mid = 5
        A = 27.0
        lines = ['conrod,%i, %i, %i, %i, %f' % (eid, nid1, nid2, mid, A)]
        model.add_card(lines, 'CONROD', is_list=False)

        size = 8
        card = model.conrod[eid]
        f = StringIO()
        card.write_bdf(f, size)
        #card.rawFields()
        self.assertEquals(card.get_element_id_by_element_index(), eid)
        self.assertEquals(card.get_material_id_by_element_index(), mid)
Example #2
0
    def test_cord2_rcs_03(self):
        """
        all points are located at <30,40,50>
        """
        model = BDF(debug=False)
        card_count = {
            'GRID' : 3,
            'CORD2R' : 1,
            'CORD2C' : 1,
            'CORD2S' : 2,
        }
        model.allocate(card_count)

        cards = [
            ['CORD2S*                2               0              0.              0.',
            '*                     0.              0.              0.              1.*       ',
            '*                     1.              0.              1.',],
            [#'$ Femap with NX Nastran Coordinate System 30 : rectangular in spherical',
            'CORD2R*               30               2             14.             30.',
            '*                    70.    13.431863852   32.1458443949   75.2107442927*       ',
            '*          14.4583462334   33.4569982885   68.2297989286',],
            [#'$ Femap with NX Nastran Coordinate System 31 : cylindrical in spherical',
            'CORD2C*               31               2              3.             42.',
            '*                  -173.   2.86526881213   45.5425615252   159.180363517*       ',
            '*          3.65222385965   29.2536614627  -178.631312271',],
            [#'$ Femap with NX Nastran Coordinate System 32 : spherical in spherical',
            'CORD2S*               32               2             22.             14.',
            '*                    85.   22.1243073983   11.9537753718   77.9978191005*       ',
            '*          21.0997242967   13.1806120497   88.4824763008',],
            ['GRID*                 30              30   40.7437952957  -23.6254877994',
            '*           -33.09784854               0',],
            ['GRID*                 31              31   62.9378078196   15.9774797923',
            '*          31.0484428362               0',],
            ['GRID*                 32              32   53.8270847449   95.8215692632',
            '*          159.097767463               0',],
        ]
        for lines in cards:
            card = model.process_card(lines)
            model.add_card(card, card[0])
        model.cross_reference()
        for nid in model.nodes:
            a = array([30.,40.,50.])
            b = model.Node(nid).Position()
            self.assertTrue(allclose(array([30.,40.,50.]), model.Node(nid).Position()), str(a-b))
Example #3
0
 def test_cord2_rcs_01(self):
     """
     all points are located at <30,40,50>
     """
     model = BDF(debug=False)
     cards = [
         [  #'$ Femap with NX Nastran Coordinate System 10 : rectangular defined in a rectangular',
             'CORD2R*               10               0             10.              5.',
             '*                     3.   10.3420201433   4.53015368961   3.81379768136*       ',
             '*          10.7198463104   5.68767171433   3.09449287122',
         ],
         [  #'$ Femap with NX Nastran Coordinate System 11 : cylindrical defined in rectangular',
             'CORD2C*               11               0              7.              3.',
             '*                     9.   7.64278760969   2.73799736977   9.71984631039*       ',
             '*          7.75440650673   3.37968226211   8.46454486422',
         ],
         [  #'$ Femap with NX Nastran Coordinate System 12 : spherical defined in rectangular',
             'CORD2S*               12               0             12.              8.',
             '*                     5.   12.6427876097   7.86697777844   5.75440650673*       ',
             '*          12.6634139482   8.58906867688   4.53861076379',
         ],
         [
             'GRID*                 10              10   42.9066011565   34.2422137135',
             '*          28.6442730262               0',
         ],
         [
             'GRID*                 11              11   48.8014631871   78.8394787869',
             '*          34.6037164304               0',
         ],
         [
             'GRID*                 12              12   58.0775343829   44.7276544324',
             '*          75.7955331161               0',
         ],
     ]
     for lines in cards:
         card = model.process_card(lines)
         model.add_card(card, card[0])
     model.cross_reference()
     for nid in model.nodes:
         a = array([30., 40., 50.])
         b = model.Node(nid).Position()
         self.assertTrue(
             allclose(array([30., 40., 50.]),
                      model.Node(nid).Position()), str(a - b))
Example #4
0
 def test_cord2_rcs_02(self):
     """
     all points are located at <30,40,50>
     """
     model = BDF(debug=False)
     card_count = {
         'GRID' : 3,
         'CORD2R' : 1,
         'CORD2C' : 2,
         'CORD2S' : 1,
     }
     model.allocate(card_count)
     cards = [
         ['CORD2C*                1               0              0.              0.',
         '*                     0.              0.              0.              1.*       ',
         '*                     1.              0.              1.',],
         [#'$ Femap with NX Nastran Coordinate System 20 : rectangular defined in cylindrical',
         'CORD2R*               20               1              7.             20.',
         '*                    -6.   7.07106781187   28.1301023542             -6.*       ',
         '*          7.70710678119             20.  -5.29289321881',],
         [#'$ Femap with NX Nastran Coordinate System 21 : cylindrical defined in cylindrical',
         'CORD2C*               21               1             15.            -30.',
         '*                    12.   14.6565766735  -30.3177805524   12.9355733712*       ',
         '*          14.6234241583  -26.4257323272   11.9304419665',],
         [#'$ Femap with NX Nastran Coordinate System 22 : spherical defined in cylindrical',
         'CORD2S*               22               1              5.            -75.',
         '*                    20.   5.66032384035  -82.9319986389   19.8502545865*       ',
         '*          4.88876051026  -73.8006653677   19.0116094889',],
         ['GRID*                 20              20   64.2559135157  -14.9400459772',
         '*          27.3271005317               0',],
         ['GRID*                 21              21   52.8328862418  -28.8729017195',
         '*           34.615939507               0',],
         ['GRID*                 22              22   61.1042111232   158.773483595',
         '*           -167.4951724               0',],
     ]
     for lines in cards:
         card = model.process_card(lines)
         model.add_card(card, card[0])
     model.cross_reference()
     for nid in model.nodes:
         a = array([30.,40.,50.])
         b = model.Node(nid).Position()
         self.assertTrue(allclose(array([30.,40.,50.]), model.Node(nid).Position()), str(a-b))
Example #5
0
def run_fem2(bdfModel, outModel, xref, punch, debug=False, log=None):
    assert os.path.exists(bdfModel), bdfModel
    assert os.path.exists(outModel), outModel
    fem2 = BDF(debug=debug, log=log)
    fem2.log.info('starting fem2')
    sys.stdout.flush()
    try:
        fem2.read_bdf(outModel, xref=xref, punch=punch)
    except:
        print("failed reading |%s|" % (outModel))
        raise

    #fem2.sumForces()
    #fem2.sumMoments()
    outModel2 = bdfModel + '_out2'
    fem2.write_bdf(outModel2, interspersed=True)
    #fem2.writeAsCTRIA3(outModel2)
    os.remove(outModel2)
    return (fem2)
Example #6
0
 def test_grid_01(self):
     model = BDF(debug=False)
     cards = [
         #['CORD1R', 1, 1, 2, 3],  # fails on self.k
         ['GRID', 1, 0, 0., 0., 0.],
         ['GRID', 2, 0, 1., 0., 0.],
         ['GRID', 4, 0, 1., 2., 3.],
     ]
     card_count = {
         'GRID': 3,
     }
     model.allocate(card_count)
     for card in cards:
         model.add_card(card, card[0], comment='comment', is_list=True)
     #+------+-----+----+----+----+----+----+----+------+
     #|   0  |  1  | 2  | 3  | 4  | 5  |  6 | 7  |  8   |
     #+======+=====+====+====+====+====+====+====+======+
     #| GRID | NID | CP | X1 | X2 | X3 | CD | PS | SEID |
     #+------+-----+----+----+----+----+----+----+------+
     node = model.Node(4)
Example #7
0
    def test_cord1_01(self):
        model = BDF(debug=False)
        cards = [
            ['CORD1R', 1, 1, 2, 3],  # fails on self.k
            ['GRID', 1, 0, 0., 0., 0.],
            ['GRID', 2, 0, 1., 0., 0.],
            ['GRID', 3, 0, 1., 1., 0.],
        ]
        for card in cards:
            model.add_card(card, card[0], comment='comment', is_list=True)
        c1 = model.Coord(1)
        self.assertEquals(c1.G1(), 1)
        self.assertEquals(c1.G2(), 2)
        self.assertEquals(c1.G3(), 3)

        model.cross_reference()
        self.assertEquals(c1.G1(), 1)
        self.assertEquals(c1.G2(), 2)
        self.assertEquals(c1.G3(), 3)

        self.assertEquals(c1.NodeIDs(), [1, 2, 3])
Example #8
0
def run_fem2(bdf_model,
             out_model,
             xref,
             punch,
             sum_load,
             size,
             is_double,
             reject,
             debug=False,
             log=None):
    """
    Reads/writes the BDF to verify nothing has been lost

    Parameters
    ----------
    bdf_model : str
        the filename to run
    xref : bool
       xrefs
    punch : bool
       punches
    """
    assert os.path.exists(bdf_model), bdf_model
    assert os.path.exists(out_model), out_model
    fem2 = BDF(debug=debug, log=log)
    fem2.log.info('starting fem2')
    sys.stdout.flush()
    try:
        fem2.read_bdf(out_model, xref=xref, punch=punch)
    except:
        print("failed reading %r" % out_model)
        raise

    #fem2.sumForces()
    #fem2.sumMoments()
    out_model2 = bdf_model + '_out2'
    fem2.write_bdf(out_model2, interspersed=True)
    #fem2.writeAsCTRIA3(out_model_2)
    os.remove(out_model2)
    return fem2
Example #9
0
 def test_grid_01(self):
     model = BDF(debug=False)
     card_lines = [
         #['CORD1R', 1, 1, 2, 3],  # fails on self.k
         ['GRID', 1, 0, 0., 0., 0.],
         ['GRID', 2, 0, 1., 0., 0.],
         ['GRID', 4, 0, 1., 2., 3.],
     ]
     #card_count = {
     #'GRID': 3,
     #}
     cards, card_count = model.add_cards_lines(card_lines)
     model.allocate(card_count, cards)
     for card in cards:
         model.add_card(card, card[0], comment='comment', is_list=True)
     model.build()
     #+------+-----+----+----+----+----+----+----+------+
     #|   0  |  1  | 2  | 3  | 4  | 5  |  6 | 7  |  8   |
     #+======+=====+====+====+====+====+====+====+======+
     #| GRID | NID | CP | X1 | X2 | X3 | CD | PS | SEID |
     #+------+-----+----+----+----+----+----+----+------+
     node = model.grid.slice_by_node_id(4)
Example #10
0
    def test_grid_01(self):
        model = BDF(debug=False)
        cards = [
            #['CORD1R', 1, 1, 2, 3],  # fails on self.k
            ['GRID', 1, 0, 0., 0., 0.],
            ['GRID', 2, 0, 1., 0., 0.],
            ['GRID', 4, 0, 1., 2., 3.],
        ]
        for card in cards:
            model.add_card(card, card[0], comment='comment', is_list=True)

        #+------+-----+----+----+----+----+----+----+------+
        #|   0  |  1  | 2  | 3  | 4  | 5  |  6 | 7  |  8   |
        #+======+=====+====+====+====+====+====+====+======+
        #| GRID | NID | CP | X1 | X2 | X3 | CD | PS | SEID |
        #+------+-----+----+----+----+----+----+----+------+
        node = model.Node(4)
        self.assertEqual(node.get_field(1), 4)
        self.assertEqual(node.get_field(2), 0)
        self.assertEqual(node.get_field(3), 1.)
        self.assertEqual(node.get_field(4), 2.)
        self.assertEqual(node.get_field(5), 3.)

        node.update_field(1, 5)
        node.update_field(2, 6)
        node.update_field(3, 7.)
        node.update_field(4, 8.)
        node.update_field(5, 9.)
        with self.assertRaises(KeyError):
            node.update_field(9, 'dummy')

        self.assertEqual(node.get_field(1), 5)
        self.assertEqual(node.get_field(2), 6)
        self.assertEqual(node.get_field(3), 7.)
        self.assertEqual(node.get_field(4), 8.)
        self.assertEqual(node.get_field(5), 9.)
        with self.assertRaises(KeyError):
            node.get_field(9)
Example #11
0
    def test_grid_01(self):
        nid = 1
        cp = 2
        cd = 0
        ps = ''
        seid = 0
        card_count = {
            'GRID': 1,
        }

        model = BDF()
        model.allocate(card_count)
        data1 = BDFCard(['GRID', nid, cp, 0., 0., 0., cd, ps, seid])

        nodes = model.grid
        nodes.add(data1)

        #print n1
        f = StringIO()
        nodes.write_bdf(f, size=8, write_header=False)
        nodes.write_bdf(f, size=16, write_header=False)
        nodes.write_bdf(f, size=16, is_double=True, write_header=False)

        # small field
        f = StringIO()
        nodes.write_bdf(f, size=8, write_header=False)
        msg = f.getvalue()
        card = 'GRID           1       2      0.      0.      0.\n'
        self.assertCardEqual(msg, card)

        # large field
        f = StringIO()
        nodes.write_bdf(f, size=16, write_header=False)
        card = (
            'GRID*                  1               2              0.              0.\n'
            '*                     0.\n')
        msg = f.getvalue()
        self.assertCardEqual(msg, card)
Example #12
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))
Example #13
0
    def test_cord2_bad_01(self):
        model = BDF(debug=False)
        cards = [
            ['CORD2R', 1, 0, 0., 0., 0.,
                             0., 0., 0.,
                             0., 0., 0.],  # fails on self.k
            ['CORD2R', 2, 0, 0., 0., 0.,
                             1., 0., 0.,
                             0., 0., 0.],  # fails on normalize self.j
            ['CORD2R', 3, 0, 0., 0., 0.,
                             1., 0., 0.,
                             1., 1., 0.],  # passes
            ['CORD2R', 4, 0, 0., 1., 0.,
                             1., 0., 0.,
                             1., 1., 0.],  # passes
            ['CORD2R', 5, 4, 0., 1., 0.,
                             1., 0., 0.,
                             1., 1., 0.],  # passes
        ]
        for card in cards:
            cid = card[1]
            if cid in [1, 2]:
                with self.assertRaises(RuntimeError):
                    model.add_card(card, card[0], is_list=True)
            else:
                model.add_card(card, card[0], is_list=True)

        # this runs because it's got rid=0
        cord4 = model.Coord(4)
        cord4.transformToGlobal([0., 0., 0.])

        # this doesn't run because rid != 0
        cord5 = model.Coord(5)
        with self.assertRaises(RuntimeError):
            cord5.transformToGlobal([0., 0., 0.])
        model.cross_reference()
Example #14
0
    def test_pcomp_02(self):
        """
        symmetrical, nsm=0.0 and nsm=1.0
        """
        model = BDF()
        pid = 1
        z0 = 0.
        nsm = 0.
        sb = 0.
        ft = 'HOFF'
        TRef = 0.
        ge = 0.
        lam = 'SYM'  # isSymmetrical SYM
        Mid = [1, 2, 3]
        Theta = [0., 10., 20.]
        T = [.1, .2, .3]
        Sout = ['YES', 'YES', 'NO']  # 0-NO, 1-YES
        card = [
            'PCOMP', pid, z0, nsm, sb, ft, TRef, ge, lam, Mid[0], T[0],
            Theta[0], Sout[0], Mid[1], T[1], Theta[1], Sout[1], Mid[2], T[2],
            Theta[2], Sout[2]
        ]
        card = BDFCard(card)
        p = PCOMP(model)
        p.add(card)
        p.build()
        self.assertTrue(p.is_symmetrical_by_property_id())
        self.assertTrue(p.is_symmetrical_by_property_index())
        self.assertEqual(p.get_nplies_by_property_id(), 6)

        self.assertAlmostEqual(p.get_thickness_by_property_id(), 1.2)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 0), 0.1)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 1), 0.2)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 2), 0.3)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 3), 0.1)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 4), 0.2)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 5), 0.3)
        with self.assertRaises(IndexError):
            p.Thickness(6)

        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 0), 0.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 1), 10.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 2), 20.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 3), 0.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 4), 10.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 5), 20.)
        with self.assertRaises(IndexError):
            p.get_theta_by_property_id_ply(pid, 6)

        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 0), 1)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 1), 2)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 2), 3)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 3), 1)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 4), 2)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 5), 3)
        with self.assertRaises(IndexError):
            p.get_material_id_by_property_id_ply(pid, 6)

        self.assertEqual(p.get_material_ids_by_property_id(),
                         [1, 2, 3, 1, 2, 3])

        self.assertEqual(p.get_sout_by_property_id_ply(pid, 0), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 1), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 2), 'NO')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 3), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 4), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 5), 'NO')
        with self.assertRaises(IndexError):
            p.get_sout_by_property_id_ply(pid, 6)

        mid = 1
        E = None
        G = None
        nu = None
        rho = 1.0
        a = None
        St = None
        Sc = None
        Ss = None
        Mcsid = None
        mat1 = [mid, E, G, nu, rho, a, TRef, ge, St, Sc, Ss, Mcsid]
        m = MAT1(data=mat1)
        for iply in range(len(p.plies)):
            mid = p.plies[iply][0]
            p.plies[iply][0] = m  # MAT1

        #Rho
        self.assertAlmostEqual(p.Rho(0), 1.0)
        self.assertAlmostEqual(p.Rho(1), 1.0)
        self.assertAlmostEqual(p.Rho(2), 1.0)
        self.assertAlmostEqual(p.Rho(3), 1.0)
        self.assertAlmostEqual(p.Rho(4), 1.0)
        self.assertAlmostEqual(p.Rho(5), 1.0)
        with self.assertRaises(IndexError):
            p.Rho(6)

        # MassPerArea
        self.assertAlmostEqual(p.MassPerArea(), 1.2)
        self.assertAlmostEqual(p.MassPerArea(0), 0.1)
        self.assertAlmostEqual(p.MassPerArea(1), 0.2)
        self.assertAlmostEqual(p.MassPerArea(2), 0.3)
        self.assertAlmostEqual(p.MassPerArea(3), 0.1)
        self.assertAlmostEqual(p.MassPerArea(4), 0.2)
        self.assertAlmostEqual(p.MassPerArea(5), 0.3)
        with self.assertRaises(IndexError):
            p.MassPerArea(6)

        self.assertEqual(p.Nsm(), 0.0)
        #----------------------
        # change the nsm to 1.0
        p.nsm = 1.0

        self.assertEqual(p.Nsm(), 1.0)
        # MassPerArea
        self.assertAlmostEqual(p.MassPerArea(), 2.2)
        self.assertAlmostEqual(p.MassPerArea(0, method='nplies'), 0.1 + 1 / 6.)
        self.assertAlmostEqual(p.MassPerArea(1, method='nplies'), 0.2 + 1 / 6.)
        self.assertAlmostEqual(p.MassPerArea(2, method='nplies'), 0.3 + 1 / 6.)
        self.assertAlmostEqual(p.MassPerArea(3, method='nplies'), 0.1 + 1 / 6.)
        self.assertAlmostEqual(p.MassPerArea(4, method='nplies'), 0.2 + 1 / 6.)
        self.assertAlmostEqual(p.MassPerArea(5, method='nplies'), 0.3 + 1 / 6.)
        with self.assertRaises(IndexError):
            p.MassPerArea(6)
Example #15
0
    def test_solid_01(self):
        """checks linear static solid material"""
        mid = 2
        pid = 4
        rho = 0.1
        cards = [
            #$ Solid Nodes
            ['GRID', 11, 0, 0., 0., 0., 0],
            ['GRID', 12, 0, 1., 0., 0., 0],
            ['GRID', 13, 0, 1., 1., 0., 0],
            ['GRID', 14, 0, 0., 1., 0., 0],
            ['GRID', 15, 0, 0., 0., 2., 0],
            ['GRID', 16, 0, 1., 0., 2., 0],
            ['GRID', 17, 0, 1., 1., 2., 0],
            ['GRID', 18, 0, 0., 1., 2., 0],

            # Solids
            ['CHEXA', 7, pid, 11, 12, 13, 14, 15, 16, 17, 18],
            ['CTETRA', 8, pid, 11, 12, 13, 15],

            # Solid Nodes
            [
                'GRID',
                21,
                0,
                0.,
                0.,
                0.,
                0,
            ],
            [
                'GRID',
                22,
                0,
                1.,
                0.,
                0.,
                0,
            ],
            [
                'GRID',
                23,
                0,
                1.,
                1.,
                0.,
                0,
            ],
            [
                'GRID',
                24,
                0,
                0.,
                0.,
                2.,
                0,
            ],
            [
                'GRID',
                25,
                0,
                1.,
                0.,
                2.,
                0,
            ],
            [
                'GRID',
                26,
                0,
                1.,
                1.,
                2.,
                0,
            ],
            ['CPENTA', 9, pid, 21, 22, 23, 24, 25, 26],

            # static
            ['PSOLID', pid, mid, 0],
            ['MAT1', mid, 1.0, 2.0, 3.0, rho]
        ]
        card_count = {
            'GRID': 14,
            'CTETRA4': 1,
            'CPENTA6': 1,
            'CHEXA8': 1,
            'PSOLID': 1,
            'MAT1': 1,
        }
        model = BDF(debug=True)
        model.allocate(card_count)
        for fields in cards:
            model.add_card(fields, fields[0], is_list=True)
        model.cross_reference()

        # CTETRA
        eid = 8
        mid = 2
        pid = 4
        nsm = 0.
        V = 1. / 3.
        rho = 0.1
        self.check_solid(model, eid, 'CTETRA4', pid, 'PSOLID', mid, 'MAT1',
                         nsm, rho, V)

        eid = 9
        V = 1.0
        self.check_solid(model, eid, 'CPENTA6', pid, 'PSOLID', mid, 'MAT1',
                         nsm, rho, V)

        eid = 7
        V = 2.0
        self.check_solid(model, eid, 'CHEXA8', pid, 'PSOLID', mid, 'MAT1', nsm,
                         rho, V)
Example #16
0
    def get_mass(self, nid1, nid2, xyz1, xyz2, eid, pid, mid, A, J, c, nsm, E,
                 G, nu, rho, L):
        """tests a CROD and a CONROD"""
        card_count = {
            'CONROD': 1,
            'CTUBE': 1,
            'PTUBE': 1,
            'CROD': 1,
            'PROD': 1,
            'GRID': 2,
            'MAT1': 1,
        }
        model = BDF(debug=debug)
        model.allocate(card_count)
        lines = [
            'conrod,%i, %i, %i, %i, %f, %f, %f, %f' %
            (eid, nid1, nid2, mid, A, J, c, nsm)
        ]
        model.add_card(lines, 'conrod', is_list=False)

        lines = ['crod,%i, %i, %i, %i' % (eid + 1, pid, nid1, nid2)]
        model.add_card(lines, 'crod', is_list=False)

        lines = ['ctube,%i, %i, %i, %i' % (eid + 2, pid + 1, nid1, nid2)]
        model.add_card(lines, 'ctube', is_list=False)

        lines = ['prod,%i, %i, %f, %f, %f, %f' % (pid, mid, A, J, c, nsm)]
        model.add_card(lines, 'prod', is_list=False)

        OD1 = sqrt(4 * A / pi)
        t = 0.
        OD2 = OD1
        lines = [
            'ptube,%i, %i, %f, %f, %f, %f' % (pid + 1, mid, OD1, t, nsm, OD2)
        ]
        model.add_card(lines, 'ptube', is_list=False)

        lines = ['mat1,%i, %.2e, %.2e, %f, %f' % (mid, E, G, nu, rho)]
        model.add_card(lines, 'mat1', is_list=False)

        lines = [
            'grid,%i, %i, %f, %f, %f' % (nid1, 0, xyz1[0], xyz1[1], xyz1[2])
        ]
        model.add_card(lines, 'grid', is_list=False)

        lines = [
            'grid,%i, %i, %f, %f, %f' % (nid2, 0, xyz2[0], xyz2[1], xyz2[2])
        ]
        model.add_card(lines, 'grid', is_list=False)

        model.build()
        mass = L * (rho * A + nsm)

        f = StringIO()
        model.write_bdf(out_filename=f,
                        interspersed=True,
                        size=8,
                        precision='single',
                        enddata=None)
        print(f.getvalue())
        #positions = model.get_positions()
        grid_cid0 = None

        # conrod
        conrod = model.conrod.slice_by_element_id(eid)
        self.assertEquals(conrod.get_element_id_by_element_index(), eid)
        #self.assertEquals(conrod.get_property_id_by_element_id(), None)
        self.assertEquals(conrod.get_material_id_by_element_id(eid), mid)
        self.assertEquals(
            conrod.get_length_by_element_index(i=None, grid_cid0=grid_cid0), L)
        #self.assertEquals(conrod.Nsm(), nsm)

        rhoi = conrod.get_density_by_element_id(eid)
        Ai = conrod.get_area_by_element_id(eid)
        Li = conrod.get_length_by_element_id(eid, grid_cid0=grid_cid0)
        nsmi = conrod.get_non_structural_mass_by_element_id(eid)
        massa = conrod.get_mass_by_element_index()
        mass_msg_conrod = 'mass = L * (rho * A + nsm)\n'
        mass_msg_conrod += 'L=%s expected=%s\n' % (Li, L)
        mass_msg_conrod += 'rho=%s expected=%s\n' % (rhoi, rho)
        mass_msg_conrod += 'A=%s expected=%s\n' % (Ai, A)
        mass_msg_conrod += 'nsm=%s expected=%s\n' % (nsmi, nsm)
        mass_msg_conrod += 'mass=%s actual=%s expected=%s\n' % (
            Li * (rhoi * Ai + nsmi), massa, mass)
        #mass_msg_conrod += 'mass=%s expected=%s\n' % (Li * (rhoi*Ai + nsmi), mass)

        self.assertEquals(massa, mass, mass_msg_conrod)
        #self.assertEquals(conrod.E(), E)
        #self.assertEquals(conrod.G(), G)
        #self.assertEquals(conrod.area(), A)
        #self.assertEquals(conrod.J(), J)
        #self.assertEquals(conrod.C(), c)
        #self.assertEquals(conrod.Rho(), rho)

        # crod
        crod_eid = eid + 1
        crod = model.crod.slice_by_element_id([crod_eid])
        self.assertEquals(crod.get_element_id_by_element_index(), crod_eid)
        self.assertEquals(crod.get_property_id_by_element_id(crod_eid), pid)
        self.assertEquals(crod.get_material_id_by_element_id(crod_eid), mid)
        rhoi = crod.get_density_by_element_id(crod_eid)
        Ai = crod.get_area_by_element_id(crod_eid)
        Li = crod.get_length_by_element_id(crod_eid, grid_cid0=grid_cid0)
        nsmi = crod.get_non_structural_mass_by_element_id(crod_eid)
        self.assertEquals(Li, L)
        #self.assertEquals(crod.Nsm(), nsm)

        massa = crod.get_mass_by_element_id(crod_eid)
        mass_msg_crod = 'mass = L * (rho * A + nsm)\n'
        mass_msg_crod += 'L=%s expected=%s\n' % (Li, L)
        mass_msg_crod += 'rho=%s expected=%s\n' % (rhoi, rho)
        mass_msg_crod += 'A=%s expected=%s\n' % (Ai, A)
        mass_msg_crod += 'nsm=%s expected=%s\n' % (nsmi, nsm)
        mass_msg_crod += 'mass=%s actual=%s expected=%s\n' % (
            Li * (rhoi * Ai + nsmi), massa, mass)
        self.assertEquals(massa, mass, mass_msg_crod)
        #self.assertEquals(crod.E(), E)
        #self.assertEquals(crod.G(), G)
        #self.assertEquals(crod.area(), A)
        #self.assertEquals(crod.J(), J)
        #self.assertEquals(crod.C(), c)
        #self.assertEquals(crod.Rho(), rho)
        #self.assertEquals(crod.Nu(), nu)

        # prod
        prod = model.prod.slice_by_property_id([pid])
        self.assertEquals(prod.property_id[0], pid)
        self.assertEquals(prod.get_material_id_by_property_id(pid), mid)
        self.assertEquals(prod.get_non_structural_mass_by_property_id(pid),
                          nsm)
        self.assertEquals(prod.get_E_by_property_id(pid), E)
        self.assertEquals(prod.get_G_by_property_id(pid), G)
        self.assertEquals(prod.get_area_by_property_id(pid), A)
        self.assertEquals(prod.get_J_by_property_id(pid), J)
        self.assertEquals(prod.get_c_by_property_id(pid), c)
        self.assertEquals(prod.get_density_by_property_id(pid), rho)

        # ctube
        if 1:
            ctube_eid = eid + 2
            ptube_pid = pid + 1
            assert ctube_eid == 12, ctube_eid
            assert ptube_pid == 68, ptube_pid
            ctube = model.ctube.slice_by_element_id(ctube_eid)
            self.assertEquals(ctube.get_element_id_by_element_index(),
                              ctube_eid)
            self.assertEquals(ctube.get_property_id_by_element_id(ctube_eid),
                              ptube_pid)
            self.assertEquals(ctube.get_material_id_by_element_id(ctube_eid),
                              mid)
            self.assertEquals(
                ctube.get_length_by_element_id(ctube_eid, grid_cid0), L)
            self.assertEquals(
                ctube.get_non_structural_mass_by_element_id(ctube_eid), nsm)
            self.assertAlmostEquals(ctube.get_mass_by_element_id(ctube_eid),
                                    mass, 5)
            self.assertEquals(ctube.get_E_by_element_id(ctube_eid), E)
            self.assertEquals(ctube.get_G_by_element_id(ctube_eid), G)
            self.assertAlmostEquals(ctube.get_area_by_element_id(ctube_eid), A,
                                    5)
            ctube.get_J_by_element_id(ctube_eid)
            self.assertEquals(ctube.get_density_by_element_id(), rho)

            # ptube
            ptube = model.ptube.slice_by_property_id(pid + 1)
            self.assertEquals(ptube.get_property_id_by_property_index(),
                              pid + 1)
            self.assertEquals(ptube.get_material_id_by_property_id(), mid)
            self.assertEquals(ptube.get_non_structural_mass_by_property_id(),
                              nsm)
            self.assertEquals(ptube.get_E_by_property_id(), E)
            self.assertEquals(ptube.get_G_by_property_id(), G)
            self.assertAlmostEquals(ptube.get_area_by_property_id(), A, 5)
            ptube.get_J_by_property_id()
            self.assertEquals(ptube.get_density_by_property_id(), rho)
Example #17
0
from __future__ import print_function
from six.moves import StringIO
from numpy import array, allclose, array_equal
import unittest

from pyNastran.bdf.dev_vectorized.bdf import BDF, BDFCard, CORD1R, CORD1C, CORD1S, CORD2R, CORD2C, CORD2S

bdf = BDF(debug=False)  # don't load this up with stuff
class TestCoords(unittest.TestCase):
    def test_same(self):  # passes
        grids = [
            [1, 0, 0., 0., 1.],
            [2, 0, 0., 1., 0.],
            [3, 0, 1., 0., 0.],
            [4, 0, 1., 1., 1.],
            [5, 0, 1., 1., 0.],
        ]
        grids_expected = grids
        coords = []
        self.getNodes(grids, grids_expected, coords)

    def test_shift(self):  # passes
        grids = [
            [1, 1, 0., 0., 1.],
            [2, 1, 0., 1., 0.],
            [3, 1, 1., 0., 0.],
            [4, 1, 1., 1., 1.],
            [5, 1, 1., 1., 0.],
        ]
        grids_expected = [
            [1, 1, 1., 1., 2.],
Example #18
0
    def test_solid_02(self):
        mid = 2
        pid = 4
        rho = 0.1
        cards = [
            #$ Solid Nodes
            ['GRID', 11, 0, 0., 0., 0., 0],
            ['GRID', 12, 0, 1., 0., 0., 0],
            ['GRID', 13, 0, 1., 1., 0., 0],
            ['GRID', 14, 0, 0., 1., 0., 0],
            ['GRID', 15, 0, 0., 0., 2., 0],
            ['GRID', 16, 0, 1., 0., 2., 0],
            ['GRID', 17, 0, 1., 1., 2., 0],
            ['GRID', 18, 0, 0., 1., 2., 0],

            # Solids
            ['CHEXA', 7, pid, 11, 12, 13, 14, 15, 16, 17, 18],
            ['CTETRA', 8, pid, 11, 12, 13, 15],

            # Solid Nodes
            [
                'GRID',
                21,
                0,
                0.,
                0.,
                0.,
                0,
            ],
            [
                'GRID',
                22,
                0,
                1.,
                0.,
                0.,
                0,
            ],
            [
                'GRID',
                23,
                0,
                1.,
                1.,
                0.,
                0,
            ],
            [
                'GRID',
                24,
                0,
                0.,
                0.,
                2.,
                0,
            ],
            [
                'GRID',
                25,
                0,
                1.,
                0.,
                2.,
                0,
            ],
            [
                'GRID',
                26,
                0,
                1.,
                1.,
                2.,
                0,
            ],
            ['CPENTA', 9, pid, 21, 22, 23, 24, 25, 26],

            # hyperelastic
            ['PLSOLID', pid, mid, 'GRID'],
            ['MATHP', mid, None, None, None, rho],
        ]
        card_count = {
            'GRID': 14,
            'CTETRA4': 1,
            'CPENTA6': 1,
            'CHEXA8': 1,
            'PLSOLID': 1,
            'MATHP': 1,
        }
        model = BDF(debug=True)
        model.allocate(card_count)
        for fields in cards:
            model.add_card(fields, fields[0], is_list=True)
        model.cross_reference()

        # CTETRA
        eid = 8
        nsm = 0.
        V = 1. / 3.
        self.check_solid(model, eid, 'CTETRA4', pid, 'PLSOLID', mid, 'MATHP',
                         nsm, rho, V)

        eid = 9
        V = 1.0
        self.check_solid(model, eid, 'CPENTA6', pid, 'PLSOLID', mid, 'MATHP',
                         nsm, rho, V)

        eid = 7
        V = 2.0
        self.check_solid(model, eid, 'CHEXA8', pid, 'PLSOLID', mid, 'MATHP',
                         nsm, rho, V)
Example #19
0
def run_bdf(folder, bdf_filename, debug=False, xref=True, check=True, punch=False,
            cid=None, mesh_form='combined', is_folder=False, print_stats=False,
            sum_load=False, size=8, precision='single',
            quiet=False,
            reject=False, dynamic_vars=None):
    """
    Runs a single BDF

    Parameters
    ----------
    folder : str
        the folder where the bdf_filename is
    bdf_filename : str
        the bdf file to analyze
    debug : bool, optional
        run with debug logging (default=False)
    xref : bool / str, optional
        True : cross reference the model
        False  : don't cross reference the model
        'safe' : do safe cross referencing
    check : bool, optional
        validate cards for things like mass, area, etc.
    punch : bool, optional
        this is a PUNCH file (no executive/case control decks)
    cid : int / None, optional
        convert the model grids to an alternate coordinate system (default=None; no conversion)
    mesh_form : str, optional, {'combined', 'separate'}
        'combined' : interspersed=True
        'separate' : interspersed=False
    is_folder : bool, optional
        attach the test path and the folder to the bdf_filename
    print_stats : bool, optional
        get a nicely formatted message of all the cards in the model
    sum_load : bool, optional
        Sum the static loads (doesn't work for frequency-based loads)
    size : int, optional, {8, 16}
        The field width of the model
    is_double : bool, optional
        Is this a double precision model?
            True : size = 16
            False : six = {8, 16}
    reject : bool, optional
        True : all the cards are rejected
        False : the model is read
    nastran : str, optional
        the path to nastran (default=''; no analysis)
    post : int, optional
        the PARAM,POST,value to run
    dynamic vars : dict[str]=int / float / str / None
        support OpenMDAO syntax  %myvar; max variable length=7
    quiet : bool; default=False
        suppresses print messages
    dumplines: bool; default=False
        writes pyNastran_dump.bdf
    dictsort : bool; default=False
        writes pyNastran_dict.bdf
    dev : bool; default=False
        True : crashes if an Exception occurs
        False : doesn't crash; useful for running many tests
    """
    if not quiet:
        print('debug = %s' % debug)
    if dynamic_vars is None:
        dynamic_vars = {}

    # TODO: why do we need this?
    bdf_model = str(bdf_filename)
    if not quiet:
        print("bdf_model = %s" % bdf_model)
    if is_folder:
        bdf_model = os.path.join(test_path, folder, bdf_filename)

    assert os.path.exists(bdf_model), '%r doesnt exist' % bdf_model

    print("before read bdf, Memory usage: %s (Mb) " % memory_usage_psutil())
    #print('before read bdf, Memory usage: %s (kb)' % resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
    fem1 = BDF(debug=debug, log=None)
    if dynamic_vars:
        fem1.set_dynamic_syntax(dynamic_vars)

    fem1.log.info('starting fem1')
    sys.stdout.flush()
    fem2 = None
    diff_cards = []
    try:
        out_model = run_fem1(fem1, bdf_model, mesh_form, xref, punch, sum_load, size, precision, cid)
        fem2 = run_fem2(bdf_model, out_model, xref, punch, sum_load, size, precision, reject,
                        debug=debug, log=None)
        diff_cards = compare(fem1, fem2, xref=xref, check=check, print_stats=print_stats)

    except KeyboardInterrupt:
        sys.exit('KeyboardInterrupt...sys.exit()')
    #except IOError:
        #pass
    #except AttributeError:  # only temporarily uncomment this when running lots of tests
        #pass
    #except SyntaxError:  # only temporarily uncomment this when running lots of tests
        #pass
    #except AssertionError:  # only temporarily uncomment this when running lots of tests
        #pass
    except SystemExit:
        sys.exit('sys.exit...')
    except:
        #exc_type, exc_value, exc_traceback = sys.exc_info()
        #print("\n")
        traceback.print_exc(file=sys.stdout)
        #print msg
        print("-" * 80)
        raise

    print("-" * 80)
    return (fem1, fem2, diff_cards)
Example #20
0
    def test_pcomp_02(self):
        """
        symmetrical, nsm=0.0 and nsm=1.0
        """
        model = BDF(debug=False)
        pid = 1
        z0 = 0.
        nsm = 0.
        sb = 0.
        ft = 'HOFF'
        TRef = 0.
        ge = 0.
        lam = 'SYM'  # isSymmetrical SYM
        Mid = [1, 2, 3]
        Theta = [0., 10., 20.]
        T = [.1, .2, .3]
        Sout = ['YES', 'YES', 'NO']  # 0-NO, 1-YES
        pcomp = [
            'PCOMP', pid, z0, nsm, sb, ft, TRef, ge, lam, Mid[0], T[0],
            Theta[0], Sout[0], Mid[1], T[1], Theta[1], Sout[1], Mid[2], T[2],
            Theta[2], Sout[2]
        ]

        #----

        mid = 1
        E = 3.0e7
        G = None
        nu = None
        rho = 1.0
        a = None
        St = None
        Sc = None
        Ss = None
        Mcsid = None
        mat1_a = ['MAT1', mid, E, G, nu, rho, a, TRef, ge, St, Sc, Ss, Mcsid]
        mat1_b = [
            'MAT1', mid + 1, E, G, nu, rho, a, TRef, ge, St, Sc, Ss, Mcsid
        ]
        mat1_c = [
            'MAT1', mid + 2, E, G, nu, rho, a, TRef, ge, St, Sc, Ss, Mcsid
        ]

        card_count = {
            'PCOMP': 1,
            'MAT1': 3,
        }
        model.allocate(card_count)
        model.add_card(pcomp, pcomp[0], is_list=True)
        model.add_card(mat1_a, 'MAT1', is_list=True)
        model.add_card(mat1_b, 'MAT1', is_list=True)
        model.add_card(mat1_c, 'MAT1', is_list=True)
        model.build()

        p = model.properties.properties_shell.pcomp[0]
        self.assertTrue(p.is_symmetrical_by_property_id())
        self.assertTrue(p.is_symmetrical_by_property_index())
        self.assertEqual(p.get_nplies_by_property_id(), 6)

        self.assertAlmostEqual(p.get_thickness_by_property_id()[0], 1.2)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 0), 0.1)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 1), 0.2)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 2), 0.3)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 3), 0.1)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 4), 0.2)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 5), 0.3)
        with self.assertRaises(IndexError):
            p.get_thickness_by_property_id_ply(pid, 6)

        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 0), 0.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 1), 10.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 2), 20.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 3), 0.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 4), 10.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 5), 20.)
        with self.assertRaises(IndexError):
            p.get_theta_by_property_id_ply(pid, 6)

        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 0), 1)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 1), 2)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 2), 3)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 3), 1)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 4), 2)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 5), 3)
        with self.assertRaises(IndexError):
            p.get_material_id_by_property_id_ply(pid, 6)

        self.assertTrue(
            allclose(p.get_material_ids_by_property_id(pid),
                     [1, 2, 3, 1, 2, 3]))

        self.assertEqual(p.get_sout_by_property_id_ply(pid, 0), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 1), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 2), 'NO')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 3), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 4), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 5), 'NO')
        with self.assertRaises(IndexError):
            p.get_sout_by_property_id_ply(pid, 6)

        #---------------

        #Rho
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 0), 1.0)
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 1), 1.0)
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 2), 1.0)
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 3), 1.0)
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 4), 1.0)
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 5), 1.0)
        with self.assertRaises(IndexError):
            p.get_density_by_property_id_ply(pid, 6)

        # MassPerArea
        #self.assertAlmostEqual(p.get_mass_per_area_by_property_id(), 1.2)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id(pid), 1.2)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_ply(pid, 0),
                               0.1)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_ply(pid, 1),
                               0.2)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_ply(pid, 2),
                               0.3)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_ply(pid, 3),
                               0.1)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_ply(pid, 4),
                               0.2)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_ply(pid, 5),
                               0.3)
        with self.assertRaises(IndexError):
            p.get_mass_per_area_by_property_id_ply(pid, 6)

        self.assertEqual(p.get_nonstructural_mass_by_property_id(pid), 0.0)
        #----------------------
        # change the nsm to 1.0
        p.set_nonstructural_mass_by_property_id(pid, 1.0)

        self.assertEqual(p.get_nonstructural_mass_by_property_id(pid), 1.0)
        # MassPerArea
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id(pid), 2.2)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 0, method='nplies'),
            0.1 + 1 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 1, method='nplies'),
            0.2 + 1 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 2, method='nplies'),
            0.3 + 1 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 3, method='nplies'),
            0.1 + 1 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 4, method='nplies'),
            0.2 + 1 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 5, method='nplies'),
            0.3 + 1 / 6.)
        with self.assertRaises(IndexError):
            p.get_mass_per_area_by_property_id_ply(pid, 6)
Example #21
0
    def test_spoint_01(self):
        model = BDF()
        card_count = {
            'SPOINT': 2,
        }

        model = BDF()
        model.allocate(card_count)

        spoints = model.spoint
        data1 = BDFCard(['SPOINT', 1, 2])
        data2 = BDFCard(['SPOINT', 4, 5])
        data3 = BDFCard(['SPOINT', 10, 20])
        data4 = BDFCard(['SPOINT', 30, 'THRU', 40])
        spoints.add(data1)
        spoints.add(data2)

        f = StringIO()
        spoints.write_bdf(f, size=8)
        #print('spoints %s' % f.getvalue())
        self.assertEqual(len(spoints), 4)
        self.assertEqual(spoints.n, 4)

        spoints.add(data3)
        f = StringIO()
        spoints.write_bdf(f, size=8)
        #print('spoints %s' % f.getvalue())
        self.assertEqual(len(spoints), 6)
        self.assertEqual(spoints.n, 6)

        spoints.add(data4)
        f = StringIO()
        spoints.write_bdf(f, size=16)
        #print('spoints %s' % f.getvalue())
        self.assertEqual(len(spoints), 17)
        self.assertEqual(spoints.n, 17)

        spoints.add(data4)
        f = StringIO()
        spoints.write_bdf(f, size=16)
        #print('spoints %s' % f.getvalue())
        self.assertEqual(spoints.max(), 40)
        self.assertEqual(spoints.min(), 1)
        self.assertEqual(spoints.n, 17)

        if 1 in spoints:
            pass
        else:
            raise RuntimeError('invalid catch')

        if 29 in spoints:
            raise RuntimeError('invalid catch')

        data5 = BDFCard(['SPOINT', 50, 'THRU', 55, 59, '61', 'THRU', '64'])
        spoints.add(data5)
        f = StringIO()
        spoints.write_bdf(f, size=16)
        #print('spoints %s' % f.getvalue())
        self.assertEqual(spoints.max(), 64)
        self.assertEqual(spoints.min(), 1)
        self.assertEqual(spoints.n, 28)

        spoints.remove([1, 2, 64])
        #self.assertRaises(KeyError, spoints.remove([1, 2]))
        f = StringIO()
        spoints.write_bdf(f, size=16)
        #print('spoints %s' % f.getvalue())
        self.assertEqual(spoints.n, 25)
Example #22
0
    def test_pcomp_01(self):
        """
        asymmetrical, nsm=0.0 and nsm=1.0
        """
        #self.pid = data[0]
        #self.z0 = data[1]
        #self.nsm = data[2]
        #self.sb = data[3]
        #self.ft = data[4]
        #self.TRef = data[5]
        #self.ge = data[6]
        #self.lam = data[7]
        #Mid = data[8]
        #T = data[9]
        #Theta = data[10]
        #Sout = data[11]

        pid = 1
        z0 = 0.
        nsm = 0.
        sb = 0.
        ft = 'HILL'
        TRef = 0.
        ge = 0.
        #lam = 'NO'  # isSymmetrical YES/NO
        lam = 'BEND'  # isSymmetrical YES/NO
        Mid = [1, 2, 3]
        Theta = [0., 10., 20.]
        T = [.1, .2, .3]
        Sout = ['YES', 'YES', 'NO']  # 0-NO, 1-YES
        card_lines = [
            'PCOMP',
            pid,
            z0,
            nsm,
            sb,
            ft,
            TRef,
            ge,
            lam,
            Mid[0],
            T[0],
            Theta[0],
            Sout[0],
            Mid[1],
            T[1],
            Theta[1],
            Sout[1],
            Mid[2],
            T[2],
            Theta[2],
            Sout[2],
        ]
        model = BDF(debug=False)
        card_count = {
            'PCOMP': 1,
            'MAT1': 3,
        }
        model.allocate(card_count)

        model.add_card(card_lines, 'PCOMP', comment='', is_list=True)

        # material...
        mid = 1
        E = 1e7
        G = None
        nu = None
        rho = 1.0
        a = None
        St = None
        Sc = None
        Ss = None
        Mcsid = None
        mat1_a = ['MAT1', mid, E, G, nu, rho, a, TRef, ge, St, Sc, Ss, Mcsid]
        mat1_b = [
            'MAT1', mid + 1, E, G, nu, rho, a, TRef, ge, St, Sc, Ss, Mcsid
        ]
        mat1_c = [
            'MAT1', mid + 2, E, G, nu, rho, a, TRef, ge, St, Sc, Ss, Mcsid
        ]
        model.add_card(mat1_a, 'MAT1', comment='', is_list=True)
        model.add_card(mat1_b, 'MAT1', comment='', is_list=True)
        model.add_card(mat1_c, 'MAT1', comment='', is_list=True)
        #card = BDFCard(mat1)
        #m = MAT1(model)
        #m.allocate(1)
        #m.add(card)
        #m.build()

        model.build()
        #card = BDFCard(data)
        #p = PCOMP(model)
        #p = model.properties.pcomp
        #p.add(card)
        #p.build()
        p = model.properties_shell.pcomp
        m = model.materials.mat1
        #self.assertFalse(p.is_symmetrical())
        self.assertEqual(p.get_nplies_by_property_id(), 3)

        self.assertAlmostEqual(p.get_thickness_by_property_id(pid), 0.6)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 0), 0.1)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 1), 0.2)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 2), 0.3)
        with self.assertRaises(IndexError):
            p.get_thickness_by_property_id_ply(pid, 3)

        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 0), 0.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 1), 10.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 2), 20.)
        with self.assertRaises(IndexError):
            p.get_theta_by_property_id_ply(pid, 3)

        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 0), 1)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 1), 2)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 2), 3)
        with self.assertRaises(IndexError):
            p.get_material_id_by_property_id_ply(pid, 3)

        #print('get_material_id_by_property_id = ', p.get_material_id_by_property_id(pid))
        self.assertEqual(p.get_material_ids_by_property_id(pid)[0], 1)
        self.assertEqual(p.get_material_ids_by_property_id(pid)[0], 1)
        self.assertEqual(p.get_material_ids_by_property_id(pid)[1], 2)
        self.assertEqual(p.get_material_ids_by_property_id(pid)[2], 3)

        self.assertEqual(p.get_sout_by_property_id_ply(pid, 0), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 1), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 2), 'NO')
        with self.assertRaises(IndexError):
            p.get_sout_by_property_id_ply(pid, 3)

        #for iply in range(len(p.plies)):
        #mid = p.plies[iply][0]
        #p.plies[iply][0] = m # MAT1
        ##p.mids = [m, m, m]

        from StringIO import StringIO
        f = StringIO()

        #print(m.write_card(f, size=8, material_id=None))
        p.write_card(f)
        m.write_card(f)
        print(f.getvalue())

        #Mid
        self.assertAlmostEqual(p.get_material_id_by_property_id_ply(pid, 0), 1)
        self.assertAlmostEqual(p.get_material_id_by_property_id_ply(pid, 1), 2)
        self.assertAlmostEqual(p.get_material_id_by_property_id_ply(pid, 2), 3)
        with self.assertRaises(IndexError):
            p.get_density_by_property_id_ply(pid, 3)

        #Rho
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 0), 1.0)
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 1), 1.0)
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 2), 1.0)
        with self.assertRaises(IndexError):
            p.get_density_by_property_id_ply(pid, 3)

        # MassPerArea
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id(), 0.6)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id(pid), 0.6)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id([pid]), 0.6)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_ply(pid, 0),
                               0.1)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_ply(pid, 1),
                               0.2)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_ply(pid, 2),
                               0.3)
        #with self.assertRaises(IndexError):
        #p.MassPerArea(3)

        #----------------------
        # change the nsm to 1.0
        p.set_nonstructural_mass_by_property_id(pid, 1.0)

        self.assertEqual(p.get_nonstructural_mass_by_property_id(), 1.0)
        # MassPerArea
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id(), 1.6)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 0, method='nplies'),
            0.1 + 1 / 3.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 1, method='nplies'),
            0.2 + 1 / 3.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 2, method='nplies'),
            0.3 + 1 / 3.)

        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 0, method='t'),
            0.1 + 1 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 1, method='t'),
            0.2 + 2 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 2, method='t'),
            0.3 + 3 / 6.)

        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 0, method='rho*t'),
            0.1 + 1 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 1, method='rho*t'),
            0.2 + 2 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 2, method='rho*t'),
            0.3 + 3 / 6.)

        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 0, method='t'),
            0.1 + 1 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 1, method='t'),
            0.2 + 2 / 6.)
        self.assertAlmostEqual(
            p.get_mass_per_area_by_property_id_ply(pid, 2, method='t'),
            0.3 + 3 / 6.)
        with self.assertRaises(IndexError):
            p.get_mass_per_area_by_property_id_ply(pid, 3, method='nplies')

        z0 = p.get_z0_by_property_id(pid)

        z = p.get_z_locations_by_property_id(pid)
        z_expected = array([0., T[0], T[0] + T[1], T[0] + T[1] + T[2]])
        for za, ze in zip(z, z_expected):
            self.assertAlmostEqual(za, ze)

        #z0  =
        p.z0[0] = 1.0
        z_expected = 1.0 + z_expected
        z = p.get_z_locations_by_property_id(pid)
        for za, ze in zip(z, z_expected):
            self.assertAlmostEqual(za, ze)
Example #23
0
    def test_solid_03(self):
        """checks linear static solid material"""
        mid = 2
        pid = 4
        rho = 0.1
        cards = [
            #$ Solid Nodes
            ['GRID', 11, 0, 0., 0., 0., 0],
            ['GRID', 12, 0, 1., 0., 0., 0],
            ['GRID', 13, 0, 1., 1., 0., 0],
            ['GRID', 14, 0, 0., 1., 0., 0],
            ['GRID', 15, 0, 0., 0., 2., 0],
            ['GRID', 16, 0, 1., 0., 2., 0],
            ['GRID', 17, 0, 1., 1., 2., 0],
            ['GRID', 18, 0, 0., 1., 2., 0],

            # Solids
            ['CHEXA', 7, pid, 11, 12, 13, 14, 15, 16, 17, 18],
            ['CTETRA', 8, pid, 11, 12, 13, 15],

            # Solid Nodes
            [
                'GRID',
                21,
                0,
                0.,
                0.,
                0.,
                0,
            ],
            [
                'GRID',
                22,
                0,
                1.,
                0.,
                0.,
                0,
            ],
            [
                'GRID',
                23,
                0,
                1.,
                1.,
                0.,
                0,
            ],
            [
                'GRID',
                24,
                0,
                0.,
                0.,
                2.,
                0,
            ],
            [
                'GRID',
                25,
                0,
                1.,
                0.,
                2.,
                0,
            ],
            [
                'GRID',
                26,
                0,
                1.,
                1.,
                2.,
                0,
            ],
            ['CPENTA', 9, pid, 21, 22, 23, 24, 25, 26],

            # static
            ['PSOLID', pid, mid, 0],
            ['MAT1', mid, 1.0, 2.0, 3.0, rho],
            [
                'MATS1',
                mid,
                None,
                'PLASTIC',
                0.0,
                1,
                1,
                100000.,
            ],
        ]
        card_count = {
            'GRID': 14,
            'CTETRA4': 1,
            'CPENTA6': 1,
            'CHEXA8': 1,
            'PSOLID': 1,
            'MAT1': 1,
            'MATS1': 1,
        }
        model = BDF(debug=True)
        model.allocate(card_count)
        for fields in cards:
            model.add_card(fields, fields[0], is_list=True)
        model.cross_reference()
Example #24
0
    def test_solid_03(self):
        """checks linear static solid material"""
        mid = 2
        pid = 4
        rho = 0.1
        tableID = 42
        cards = [
            #$ Solid Nodes
            ['GRID', 11, 0, 0., 0., 0., 0],
            ['GRID', 12, 0, 1., 0., 0., 0],
            ['GRID', 13, 0, 1., 1., 0., 0],
            ['GRID', 14, 0, 0., 1., 0., 0],
            ['GRID', 15, 0, 0., 0., 2., 0],
            ['GRID', 16, 0, 1., 0., 2., 0],
            ['GRID', 17, 0, 1., 1., 2., 0],
            ['GRID', 18, 0, 0., 1., 2., 0],

            # Solids
            ['CHEXA', 7, pid, 11, 12, 13, 14, 15, 16, 17, 18],
            ['CTETRA', 8, pid, 11, 12, 13, 15],

            # Solid Nodes
            [
                'GRID',
                21,
                0,
                0.,
                0.,
                0.,
                0,
            ],
            [
                'GRID',
                22,
                0,
                1.,
                0.,
                0.,
                0,
            ],
            [
                'GRID',
                23,
                0,
                1.,
                1.,
                0.,
                0,
            ],
            [
                'GRID',
                24,
                0,
                0.,
                0.,
                2.,
                0,
            ],
            [
                'GRID',
                25,
                0,
                1.,
                0.,
                2.,
                0,
            ],
            [
                'GRID',
                26,
                0,
                1.,
                1.,
                2.,
                0,
            ],
            ['CPENTA', 9, pid, 21, 22, 23, 24, 25, 26],

            # static
            ['PSOLID', pid, mid, 0],
            ['MAT1', mid, 1.0, 2.0, 3.0, rho],
            [
                'MATS1',
                mid,
                tableID,
                'PLASTIC',
                0.0,
                1,
                1,
                100000.,
            ],
            #['TABLEST'],
            [
                'TABLES1', tableID, 1, None, None, None, None, None, None, 1.0,
                10.0, 2.0, 10.0, 'ENDT'
            ],
        ]
        card_count = {
            'GRID': 14,
            'CPENTA6': 1,
            'CTETRA4': 1,
            'PSOLID': 1,
            'CHEXA8': 1,
            'MAT1': 1,
            'MATS1': 1,
            'TABLES1': 1,
        }
        model = BDF(debug=False)
        model.allocate(card_count)
        for fields in cards:
            model.add_card(fields, fields[0], is_list=True)
        model.cross_reference()

        mat = model.materials[mid]
        print('----MAT----', type(mat))
        print(mat)
        print('E = %s' % mat.get_E_by_material_index())
        print('E = %s' % mat.get_E_by_material_id())
Example #25
0
def run(bdf_filename, debug=True):
    # http://www.3dpanelmethod.com/documents/Graduate%20Work.pdf
    model = BDF(debug=debug)
    model.read_bdf(bdf_filename)

    grids = model.grid
    #print(list(grids.node_id))
    xyz_global = grids.get_position_by_node_index()

    tris = model.elements.elements_shell.ctria3
    quads = model.elements.elements_shell.cquad4

    if tris.n:
        et = tris.element_id
        pt = tris.property_id
        At = tris.get_area_by_element_index()
        nt = tris.get_normal_by_element_index()
        ct = tris.get_centroid_by_element_index()

        #i = arange(tris.n)
        #n1, n2, n3 = tris._node_locations(xyz_cid0, i)
        # n3 = n4
        # is this right?
        #ut = (n1 + n2 - 2 * n3) / 2.
        #pt = (n2 - n1) / 2.
        #ot = cross(nt, ut)
    if quads.n:
        eq = quads.element_id
        pq = quads.property_id
        Aq = quads.get_area_by_element_index()
        nq = quads.get_normal_by_element_index()
        cq = quads.get_centroid_by_element_index()

        i = arange(quads.n)
        #n1, n2, n3, n4 = quads._node_locations(xyz_cid0, i)
        #uq = (n1 + n2 - n3 - n4) / 2.
        #pq = (n2 + n3 - n4 - n1) / 2.
        #oq = cross(nq, uq)

    if tris.n and quads.n:
        e = hstack([et, eq])
        p = hstack([pt, pq])
        A = hstack([At, Aq])
        n = hstack([nt, nq])
        c = hstack([ct, cq])
        o = hstack([ot, oq])
    elif tris.n:
        e = et
        p = pt
        A = At
        n = nt
        c = ct
        #o = ot
    elif quads.n:
        e = eq
        p = pq
        A = Aq
        n = nq
        c = cq
        #o = oq

    bcs = {}
    for key, set3i in iteritems(model.set3):
        if set3i.desc == 'ELEM':
            bcs[key] = set3i.IDs

    #A = array([1, 2, 3, 4, 5], dtype='float32')
    nelements = len(e)
    #print('c.shape', c.shape)

    # could we take advantage of upper triangular matrix?
    # it's a factor of 2 speedup, which is pretty minor relative to the
    # added code complexity
    #
    # we split the x, y, z components to make it easier to run our calculations
    csquarex = repeat(c[:, 0], nelements).reshape(nelements, nelements)
    csquarey = repeat(c[:, 1], nelements).reshape(nelements, nelements)
    csquarez = repeat(c[:, 2], nelements).reshape(nelements, nelements)

    csquarex -= c[:, 0]
    csquarey -= c[:, 1]
    csquarez -= c[:, 2]

    # 2-norm
    dist = sqrt(csquarex**2 + csquarey**2 + csquarez**2)

    print('dist', dist, dist.shape)
Example #26
0
    def test_pcomp_01(self):
        """
        asymmetrical, nsm=0.0 and nsm=1.0
        """
        #self.pid = data[0]
        #self.z0 = data[1]
        #self.nsm = data[2]
        #self.sb = data[3]
        #self.ft = data[4]
        #self.TRef = data[5]
        #self.ge = data[6]
        #self.lam = data[7]
        #Mid = data[8]
        #T = data[9]
        #Theta = data[10]
        #Sout = data[11]

        pid = 1
        z0 = 0.
        nsm = 0.
        sb = 0.
        ft = 'HILL'
        TRef = 0.
        ge = 0.
        #lam = 'NO'  # isSymmetrical YES/NO
        lam = 'BEND'  # isSymmetrical YES/NO
        Mid = [1, 2, 3]
        Theta = [0., 10., 20.]
        T = [.1, .2, .3]
        Sout = ['YES', 'YES', 'NO']  # 0-NO, 1-YES
        data = [
            'PCOMP',
            pid,
            z0,
            nsm,
            sb,
            ft,
            TRef,
            ge,
            lam,
            Mid[0],
            T[0],
            Theta[0],
            Sout[0],
            Mid[1],
            T[1],
            Theta[1],
            Sout[1],
            Mid[2],
            T[2],
            Theta[2],
            Sout[2],
        ]
        model = BDF()
        card = BDFCard(data)
        p = PCOMP(model)
        #p = model.properties.pcomp
        p.add(card)
        p.build()
        #self.assertFalse(p.is_symmetrical())
        self.assertEqual(p.get_nplies_by_property_id(), 3)

        self.assertAlmostEqual(p.get_thickness_by_property_id(pid), 0.6)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 0), 0.1)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 1), 0.2)
        self.assertAlmostEqual(p.get_thickness_by_property_id_ply(pid, 2), 0.3)
        with self.assertRaises(IndexError):
            p.get_thickness_by_property_id_ply(pid, 3)

        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 0), 0.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 1), 10.)
        self.assertAlmostEqual(p.get_theta_by_property_id_ply(pid, 2), 20.)
        with self.assertRaises(IndexError):
            p.get_theta_by_property_id_ply(pid, 3)

        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 0), 1)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 1), 2)
        self.assertEqual(p.get_material_id_by_property_id_ply(pid, 2), 3)
        with self.assertRaises(IndexError):
            p.get_material_id_by_property_id_ply(pid, 3)

        print('get_material_ids_by_property_id = ',
              p.get_material_ids_by_property_id(pid))
        self.assertEqual(p.get_material_ids_by_property_id(pid)[0][0], 1)
        self.assertEqual(p.get_material_ids_by_property_id(pid)[0][0], 1)
        self.assertEqual(p.get_material_ids_by_property_id(pid)[0][1], 2)
        self.assertEqual(p.get_material_ids_by_property_id(pid)[0][2], 3)

        self.assertEqual(p.get_sout_by_property_id_ply(pid, 0), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 1), 'YES')
        self.assertEqual(p.get_sout_by_property_id_ply(pid, 2), 'NO')
        with self.assertRaises(IndexError):
            p.get_sout_by_property_id_ply(pid, 3)

        # material...
        mid = 1
        E = 1e7
        G = None
        nu = None
        rho = 1.0
        a = None
        St = None
        Sc = None
        Ss = None
        Mcsid = None
        mat1 = ['MAT1', mid, E, G, nu, rho, a, TRef, ge, St, Sc, Ss, Mcsid]
        card = BDFCard(mat1)
        m = MAT1(model)
        m.allocate(1)
        m.add(card)
        m.build()
        #for iply in range(len(p.plies)):
        #mid = p.plies[iply][0]
        #p.plies[iply][0] = m # MAT1
        ##p.mids = [m, m, m]

        #Rho
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 0), 1.0)
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 1), 1.0)
        self.assertAlmostEqual(p.get_density_by_property_id_ply(pid, 2), 1.0)
        with self.assertRaises(IndexError):
            p.get_density_by_property_id_ply(pid, 3)

        # MassPerArea
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id(), 0.6)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_iply(pid, 0),
                               0.1)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_iply(pid, 1),
                               0.2)
        self.assertAlmostEqual(p.get_mass_per_area_by_property_id_iply(pid, 2),
                               0.3)
        with self.assertRaises(IndexError):
            p.MassPerArea(3)

        #----------------------
        # change the nsm to 1.0
        p.nsm = 1.0

        self.assertEqual(p.Nsm(), 1.0)
        # MassPerArea
        self.assertAlmostEqual(p.MassPerArea(), 1.6)
        self.assertAlmostEqual(p.MassPerArea(0, method='nplies'), 0.1 + 1 / 3.)
        self.assertAlmostEqual(p.MassPerArea(1, method='nplies'), 0.2 + 1 / 3.)
        self.assertAlmostEqual(p.MassPerArea(2, method='nplies'), 0.3 + 1 / 3.)

        self.assertAlmostEqual(p.MassPerArea(0, method='rho*t'), 0.1 + 1 / 6.)
        self.assertAlmostEqual(p.MassPerArea(1, method='rho*t'), 0.2 + 2 / 6.)
        self.assertAlmostEqual(p.MassPerArea(2, method='rho*t'), 0.3 + 3 / 6.)

        self.assertAlmostEqual(p.MassPerArea(0, method='t'), 0.1 + 1 / 6.)
        self.assertAlmostEqual(p.MassPerArea(1, method='t'), 0.2 + 2 / 6.)
        self.assertAlmostEqual(p.MassPerArea(2, method='t'), 0.3 + 3 / 6.)
        with self.assertRaises(IndexError):
            p.MassPerArea(3, method='nplies')

        z = p.get_z_locations()
        z_expected = array([0., T[0], T[0] + T[1], T[0] + T[1] + T[2]])
        for za, ze in zip(z, z_expected):
            self.assertAlmostEqual(za, ze)

        #z0  =
        p.z0 = 1.0
        z_expected = 1.0 + z_expected
        z = p.get_z_locations()
        for za, ze in zip(z, z_expected):
            self.assertAlmostEqual(za, ze)
Example #27
0
def bdf_renumber(bdf_filename, bdf_filename_out, size=8, is_double=False,
                 starting_id_dict=None, round_ids=False, cards_to_skip=None):
    """
    Renumbers a BDF

    Parameters
    ----------
    bdf_filename : str
        a bdf_filename (string; supported) or a BDF model (BDF)
        that has been cross referenced and is fully valid (a equivalenced deck is not valid)
    bdf_filename_out : str
        a bdf_filename to write
    size : int; {8, 16}; default=8
        the bdf write precision
    is_double : bool; default=False
        the field precision to write
    starting_id_dict : dict, None (default=None)
        None : renumber everything starting from 1
        dict : {key : starting_id}
            key : str
                the key (e.g. eid, nid, cid, ...)
            starting_id : int, None
                int : the value to start from
                None : don't renumber this key
    round_ids : bool; default=False
        Should a rounding up be applied for each variable?
        This makes it easier to read a deck and verify that it's been renumbered properly.
        This only really applies when starting_id_dict is None
    cards_to_skip : List[str]; (default=None -> don't skip any cards)
        There are edge cases (e.g. FLUTTER analysis) where things can break due to
        uncross-referenced cards.  You need to disable entire classes of cards in
        that case (e.g. all aero cards).

    .. todo:: bdf_model option for bdf_filename hasn't been tested
    .. todo:: add support for subsets (e.g. renumber only a subset of nodes/elements)
    .. todo:: doesn't support partial renumbering
    .. todo:: doesn't support element material coordinate systems

    ..warning :: spoints might be problematic...check
    ..warning :: still in development, but it usually brutally crashes if it's not supported
    ..warning :: be careful of card unsupported cards (e.g. ones not read in)

    Supports
    ========
     - GRIDs
       - no superelements
     - COORDx

     - elements
        - CELASx/CONROD/CBAR/CBEAM/CQUAD4/CTRIA3/CTETRA/CPENTA/CHEXA
        - RBAR/RBAR1/RBE1/RBE2/RBE3/RSPLINE

     - properties
        - PSHELL/PCOMP/PCOMPG/PSOLID/PSHEAR/PBAR/PBARL
          PROD/PTUBE/PBEAM
     - mass
        - CMASSx/CONMx/PMASS

     - aero
       - FLFACT
       - SPLINEx
       - FLUTTER

     - partial case control
       - METHOD/CMETHOD/FREQENCY
       - LOAD/DLOAD/LSEQ/LOADSET...LOADSET/LSEQ is iffy
       - SET cards
         - nodes
         - elements
       - SPC/MPC/FLUTTER/FLFACT

    - constraints
       - SPC/SPCADD/SPCAX/SPCD
       - MPC/MPCADD
       - SUPORT/SUPORT1

    - solution control/methods
       - TSTEP/TSTEPNL
       - NLPARM
       - EIGB/EIGC/EIGRL/EIGR

    - sets
       - USET

    - other
      - tables
      - materials
      - loads/dloads


    Not Done
    ========
     - SPOINT
     - any cards with SPOINTs
       - DMIG/DMI/DMIJ/DMIJI/DMIK/etc.
       - CELASx
       - CDAMPx
     - superelements
     - aero cards
       - CAEROx
       - PAEROx
     - thermal cards?
     - optimization cards
     - SETx
     - PARAM,GRDPNT,x; where x>0
     - GRID SEID
     - case control
       - STATSUB
       - SUBCASE
       - global SET cards won't be renumbered properly

    Example 1 - Renumber Everything; Start from 1
    ---------------------------------------------
    bdf_renumber(bdf_filename, bdf_filename_out, size=8, is_double=False,
                 round_ids=False)

    Example 2 - Renumber Everything; Start Material IDs from 100
    ------------------------------------------------------------
    starting_id_dict = {
        'mid' : 100,
    }
    bdf_renumber(bdf_filename, bdf_filename_out, size=8, is_double=False,
                 starting_ids_dict=starting_ids_dict, round_ids=False)

    Example 3 - Only Renumber Material IDs
    --------------------------------------
    starting_id_dict = {
        'cid' : None,
        'nid' : None,
        'eid' : None,
        'pid' : None,
        'mid' : 1,
        'spc_id' : None,
        'mpc_id' : None,
        'load_id' : None,
        'dload_id' : None,

        'method_id' : None,
        'cmethod_id' : None,
        'spline_id' : None,
        'table_id' : None,
        'flfact_id' : None,
        'flutter_id' : None,
        'freq_id' : None,
        'tstep_id' : None,
        'tstepnl_id' : None,
        'suport_id' : None,
        'suport1_id' : None,
        'tf_id' : None,
    }
    bdf_renumber(bdf_filename, bdf_filename_out, size=8, is_double=False,
                 starting_ids_dict=starting_ids_dict, round_ids=False)
    """
    starting_id_dict_default = {
        'cid' : 1,
        'nid' : 1,
        'eid' : 1,
        'pid' : 1,
        'mid' : 1,
        'spc_id' : 1,
        'mpc_id' : 1,
        'load_id' : 1,
        'dload_id' : 1,

        'method_id' : 1,
        'cmethod_id' : 1,
        'spline_id' : 1,
        'table_id' : 1,
        'flfact_id' : 1,
        'flutter_id' : 1,
        'freq_id' : 1,
        'tstep_id' : 1,
        'tstepnl_id' : 1,
        'suport_id' : 1,
        'suport1_id' : 1,
        'tf_id' : 1,
    }
    # fill up starting_id_dict
    if starting_id_dict is None:
        starting_id_dict = starting_id_dict_default
    else:
        for key, value in iteritems(starting_id_dict_default):
            if key not in starting_id_dict:
                starting_id_dict[key] = value

    nid = None
    cid = None
    eid = None
    pid = None
    mid = None
    spc_id = None
    mpc_id = None
    load_id = None
    dload_id = None
    method_id = None
    cmethod_id = None
    spline_id = None
    table_id = None
    flfact_id = None
    flutter_id = None
    freq_id = None
    tstep_id = None
    tstepnl_id = None
    suport_id = None
    suport1_id = None
    tf_id = None

    # turn them into variables
    for key, value in sorted(iteritems(starting_id_dict)):
        #assert isinstance(key, string_types), key
        assert key in starting_id_dict_default, 'key=%r is invalid' % (key)
        if value is None:
            pass
        else:
            if not isinstance(value, integer_types):
                msg = 'key=%r value=%r must be an integer; type(value)=%s' % (
                    key, value, type(value))
                raise TypeError(msg)

        if key == 'nid':
            nid = int(value)
        elif key == 'cid':
            if value is None:
                cid = None
            else:
                cid = int(value)
        elif key == 'eid':
            eid = int(value)
        elif key == 'pid':
            if value is None:
                pid = None
            else:
                pid = int(value)
        elif key == 'mid':
            if value is None:
                mid = None
            else:
                mid = int(value)
        elif key == 'spc_id':
            spc_id = int(value)
        elif key == 'mpc_id':
            mpc_id = int(value)

        elif key == 'load_id':
            load_id = int(value)
        elif key == 'dload_id':
            dload_id = int(value)
        elif key == 'method_id':
            method_id = int(value)
        elif key == 'cmethod_id':
            cmethod_id = int(value)
        elif key == 'spline_id':
            spline_id = int(value)
        elif key == 'table_id':
            table_id = int(value)
        elif key == 'flfact_id':
            flfact_id = int(value)
        elif key == 'flutter_id':
            flutter_id = int(value)
        elif key == 'freq_id':
            freq_id = int(value)
        elif key == 'tstep_id':
            tstep_id = int(value)
        elif key == 'tstepnl_id':
            tstepnl_id = int(value)
        elif key == 'suport_id':
            suport_id = int(value)
        elif key == 'suport1_id':
            suport1_id = int(value)
        elif key == 'tf_id':
            tf_id = int(value)
        else:
            raise NotImplementedError('key=%r' % key)

    # build the maps
    #eid_map = {}
    #nid_map = {}
    #reverse_nid_map = {}
    #pid_map = {}
    #mid_map = {}
    #mpc_map = {}
    #spc_map = {}
    dload_map = {}
    load_map = {}

    cmethod_map = {}
    method_map = {}
    #flfact_map = {}
    #flutter_map = {}
    #aefact_map = {}
    #freq_map = {}
    tstep_map = {}
    tstepnl_map = {}
    suport_map = {}
    suport1_map = {}

    if isinstance(bdf_filename, string_types):
        model = BDF(debug=False)
        model.disable_cards(cards_to_skip)
        model.read_bdf(bdf_filename)
    else:
        model = bdf_filename

    elements = [
        model.celas1,
        model.celas2,
        model.celas3,
        model.celas4,
        #model.cdamp1,
        #model.cdamp2,
        #model.cdamp3,
        #model.cdamp4,
        model.conrod,
        model.crod,
        model.ctube,
        model.cbar,
        model.cbeam,
        model.cshear,

        model.cquad4,
        model.ctria3,
        model.cquad8,
        model.ctria6,
        #model.ctriax,
        model.ctriax6,
        model.ctetra4, model.ctetra10,
        model.cpenta6, model.cpenta15,
        #model.cpyram5, model.cpyram13,
        model.chexa8, model.chexa20,
    ]
    props = [
        model.pelas,
        #model.pdamp,
        model.ptube,
        model.ptube,

        model.pbar,
        model.pbarl,
        model.pbeam,
        model.pbeaml,

        model.pshear,
        model.pshell,
        model.pcomp,
        #model.pcompg,
        model.psolid,
        model.plsolid,
    ]
    materials = [
        model.mat1,
        #model.mat2,
        #model.mat3,
        #model.mat4,
        #model.mat5,
        model.mat8,
        #model.mat9,
        #model.mat10,
        #model.mat11,
    ]
    loads = [
        model.force,
        model.force1,
        model.force2,
        model.moment,
        model.moment1,
        model.moment2,
        model.pload,
        model.pload1,
        model.pload2,
        model.pload4,
        #model.rforce,
        #model.dload,
        #model.load,
        #model.sload,
    ]


    nid_map = {}
    #reverse_nid_map = {}
    if 'nid' in starting_id_dict and nid is not None:
        #i = nid
        #nid_map = {}
        ngrids = model.grid.n
        if ngrids:
            nids = model.grid.node_id - 1
            nid_map.update(
                {(nid + nids[i]) : (i+1) for i in range(ngrids)})
            #reverse_nid_map.update(
                #{(i+1) : (nid + nids[i]) for i in range(ngrids)}) # index to nid
        #print(min(nid_map))
        # TODO: SPOINTs
        # TODO: EPOINTs
        #if model.spoints.points:

    cid_map = {}
    if 'cid' in starting_id_dict and cid is not None:
        cids = model.coords.coords.keys()
        #print(cids)
        ncoords = len(cids)
        cids.sort()
        #print('cids =', cids)
        cid_map.update(
            {(cid + cids[i] - 1) : (i) for i in range(ncoords)})
        #print('cid_map =', cid_map)

    eid_map = {}
    if 'eid' in starting_id_dict and pid is not None:

        eids = [element.element_id for element in elements if element.n]
        eids.append(model.rigid_elements.keys())
        eids = np.hstack(eids)
        neids = len(eids)
        eids.sort()
        eid_map.update(
            {eids[i] : (i + eid) for i in range(neids)})

    pid_map = {}
    if 'pid' in starting_id_dict and pid is not None:
        pids = np.hstack([prop.property_id for prop in props if prop.n])
        npids = len(pids)
        pids.sort()
        pid_map.update(
            {pids[i] : (i + pid) for i in range(npids)})

    mid_map = {}
    if 'mid' in starting_id_dict and mid is not None:
        mids = np.hstack([mat.material_id for mat in materials])
        nmids = len(mids)
        mids.sort()
        mid_map.update(
            {mids[i] : (mid + i) for i in range(nmids)})

    load_map = {}
    if 'load_id' in starting_id_dict and load_id is not None:
        loadsi = [load.load_id for load in loads if load.n]
        if loadsi:
            #print(loadsi)
            load_ids = np.unique(np.hstack(loadsi))
            del loadsi
            nload_ids = len(load_ids)
            load_ids.sort()
            load_map.update(
                {load_ids[i] : (load_id + i) for i in range(nload_ids)})

    spc_map = {}
    if 'spc_id' in starting_id_dict and spc_map is not None:
        spcs = [model.spc, model.spc1, model.spcadd]
        spcsi = []
        for spc_obj in spcs:
            #print(spc_obj)
            #spc_ids = [spc.spc_id for spc_id, spc in iteritems(spc_obj) if spc.n]
            spc_ids = spc_obj.keys()
            if spc_ids:
                spcsi.append(spc_ids)
        #spcsi = [spc_id for spc_id in spcs]
        #print('spcsi =', spcsi)
        #asdf
        if spcsi:
            #print(loadsi)
            spc_ids = np.unique(np.hstack(spcsi))
            #del spcsi
            nspc_ids = len(spc_ids)
            spc_ids.sort()
            spc_map.update(
                {spc_ids[i] : (spc_id + i) for i in range(nspc_ids)})
            #print('spc_ids =', spc_ids)

    caero_map = {}
    #if model.caeros:
        #caeros = model.caeros.keys()
        #caeros.sort()
        #ncaeros = len(caeros)
        #caero_map = {caeros[i] : (i+1) for i in range(ncaeros)}

    paero_map = {}
    if model.paeros:
        paeros = model.paeros.keys()
        paeros.sort()
        npaeros = len(paeros)
        paero_map = {paeros[i] : (i+1) for i in range(npaeros)}

    aefact_map = {}
    if model.aefacts:
        aefacts = model.aefacts.keys()
        aefacts.sort()
        naefacts = len(aefacts)
        aefact_map = {aefacts[i] : (i+1) for i in range(naefacts)}

    spline_map = {}
    #if model.splines:
        #splines = model.splines.keys()
        #splines.sort()
        #nsplines = len(splines)
        #spline_map = {splines[i] : (i+1) for i in range(nsplines)}

    set_map = {}
    if model.sets:
        sets = model.sets.keys()
        sets.sort()
        nsets = len(sets)
        set_map = {sets[i] : (i+1) for i in range(nsets)}

    #load_map = {}
    maps = {
        'node' : nid_map,
        'coord' : cid_map,
        'property' : pid_map,
        'element' : eid_map,
        'load' : load_map,
        'material' : mid_map,

        'caero' : caero_map, # ???
        'paero' : paero_map, # PAEROx
        'aefact' : aefact_map, # ???
        'spline' : spline_map, # SPLINE1-SPLINE5
        'set' : set_map,
    }

    model.grid.update(maps)
    model.coords.update(maps)
    for elem in elements:
        elem.update(maps)

    rigid_elements2 = {}
    for eid, elem in iteritems(model.rigid_elements):
        eid2 = eid_map[eid]
        rigid_elements2[eid2] = eid_map[eid]
        elem.update(maps)

    for prop in props:
        prop.update(maps)
    for mat in materials:
        mat.update(maps)
    for spc_dict in spcs:
        for spc_id, spc in iteritems(spc_dict):
            spc.update(maps)

    if model.aero is not None:
        model.aero.update(maps)
    if model.aeros is not None:
        model.aeros.update(maps)

    for caero in itervalues(model.caeros):
        caero.update(maps)
    for spline in itervalues(model.splines):
        spline.update(model, maps)
    for flutter in itervalues(model.flutters):
        flutter.update(maps)
    for flfact in itervalues(model.flfacts):
        flfact.update(maps)
    for flutter in itervalues(model.flutters):
        flutter.update(maps)

    for desvar in itervalues(model.desvars):
        desvar.update(maps)
    for dconstr in itervalues(model.dconstrs):
        dconstr.update(maps)
    for dresp in itervalues(model.dresps):
        dresp.update(maps)
    for dconadd in itervalues(model.dconadds):
        dconadd.update(maps)
    for dvgrid in itervalues(model.dvgrids):
        dvgrid.update(maps)
    for dvcrel in itervalues(model.dvcrels):
        dvcrel.update(maps)
    for dvmrel in itervalues(model.dvmrels):
        dvmrel.update(maps)
    for dvprel in itervalues(model.dvprels):
        dvprel.update(maps)

    model.darea.update(maps)
    model.dphase.update(maps)

    if bdf_filename_out is not None:
        model.write_bdf(bdf_filename_out, size=size, is_double=is_double,
                        interspersed=False)
    return model
Example #28
0
    def test_mass_shell_1(self):  # passes
        model = BDF(debug=False, log=None)
        bdfname = os.path.join(testpath, 'test_mass.dat')
        model.read_bdf(bdfname, include_dir=None, xref=True)

        ###########
        # QUADS
        centroid = array([.5, .5, 0.])
        normal = array([.0, .0, 1.])
        ###########
        # quad - pcomp
        quad = model.elements[1]
        prop = model.properties_shell.pcomp[quad.property_id]
        #mat = model.properties_shell.pshell[prop.material_id]
        mass = 0.12
        area = 1.0
        nsm = 0.
        thickness = 0.7
        rho1 = 0.1
        rho10 = 0.2
        t1 = 0.1
        t10 = 0.5
        # there are two layers of t1
        mpa = (2. * rho1 * t1 + rho10 * t10) + nsm
        mass2 = mpa * area
        assert allclose(mass, mass2), 'mass=%s mass2=%s diff=%s' % (mass, mass2, abs(mass - mass2))
        self.verify_pcomp_element(quad, prop, nsm, thickness, mass, area, centroid, normal)

        rho = None

        # quad - pshell, nsm=0
        eid = 3
        pid = 2
        quad = model.elements[eid]
        prop = model.properties_shell.pshell[pid]
        mat = model.materials[prop.material_id]
        rho = 0.1
        mass = 0.0125
        t = 0.125
        nsm = 0.
        area = 1.
        mass2 = area * (rho * t + nsm)
        assert allclose(mass, mass2), 'eid=%s pid=%s mass=%s mass2=%s diff=%s\n%s%s%s\nrho=%s A=%s t=%s nsm=%s' % (
            eid, pid, mass, mass2, abs(mass - mass2), quad, prop, mat, rho, area, t, nsm)
        centroid = array([.5, .5, 0.])
        normal = array([.0, .0, 1.])
        self.verify_pshell_element(quad, prop, mat, rho, mass, area, centroid, normal, nsm)

        # quad - pshell, nsm=1
        quad = model.elements[5]
        prop = model.properties_shell.pshell[quad.property_id]
        mat = model.properties_shell.pshell[prop.material_id]
        mass = 1.0125 # mass w/o nsm + 1.0 b/c area=1
        nsm = 1.
        self.verify_pshell_element(quad, prop, mat, rho, mass, area, centroid, normal, nsm)

        ###########
        # TRIS
        centroid = array([2., 1., 0.]) / 3.
        normal   = array([.0, .0, 1.])
        ###########
        # tri - pcomp
        tri = model.elements[2]
        prop = model.properties_shell.pcomp[tri.property_id]
        #mat = model.properties_shell.pshell[prop.material_id]
        mass = 0.06
        area = 0.5
        nsm = 0.
        thickness = 0.7
        self.verify_pcomp_element(tri, prop, nsm, thickness, mass, area, centroid, normal)

        # tri - pshell, nsm=0
        tri = model.elements[4]
        prop = model.properties_shell.pshell[tri.property_id]
        mat = model.properties_shell.pshell[prop.material_id]
        mass = 0.00625
        nsm = 0.
        self.verify_pshell_element(tri, prop, mat, rho, mass, area, centroid, normal, nsm)

        # tri - pshell, nsm=1
        tri = model.elements[6]
        prop = model.properties_shell.pshell[tri.property_id]
        mat = model.properties_shell.pshell[prop.material_id]
        mass = 0.50625 # mass w/o nsm + 0.5 b/c area=0.5
        nsm = 1.
        self.verify_pshell_element(tri, prop, mat, rho, mass, area, centroid, normal, nsm)
Example #29
0
    def test_cord2r_bad_01(self):
        model = BDF(debug=True)

        card_count = {
            'GRID': 4,
            'CORD2R': 3,
        }
        cards = {'GRID': [], 'CORD2R': []}
        grids = [
            ['GRID', 1, 0],
            ['GRID', 20, 0],
            ['GRID', 30, 0],
            ['GRID', 11, 5],
        ]
        for grid in grids:
            cards['GRID'].append(('', grid))

        coord_cards = [
            ['CORD2R', 1, 0, 0., 0., 0., 0., 0., 0., 0., 0.,
             0.],  # fails on self.k
            ['CORD2R', 2, 0, 0., 0., 0., 1., 0., 0., 0., 0.,
             0.],  # fails on normalize self.j
            ['CORD2R', 3, 0, 0., 0., 0., 1., 0., 0., 1., 1., 0.],  # passes
            ['CORD2R', 4, 0, 0., 1., 0., 1., 0., 0., 1., 1., 0.],  # passes
            ['CORD2R', 5, 4, 0., 1., 0., 1., 0., 0., 1., 1., 0.],  # passes
        ]
        for card in coord_cards:
            card_name = card[0]
            cid = card[1]
            if cid in [1, 2]:
                with self.assertRaises(RuntimeError):
                    cards[card_name].append(('', card))
            else:
                cards[card_name].append(('', card))
        model.add_cards(cards, card_count)
        model.build()

        # this runs because it's got rid=0
        coords = model.coords  #.slice_by_coord_id(4)
        coords.transform_node_id_to_global_xyz(30)  # nid
        coords.transform_node_id_to_global_xyz([30, 1, 11])  # [nid, nid, nid]
        coords.transform_node_id_to_local_by_coord_id([30, 1, 11],
                                                      4)  # [nid, ...], cp_goal
        coords.transform_node_id_to_local_by_coord_id([30, 1, 11],
                                                      0)  # [nid, ...], cp_goal

        xyz = [0., 0., 0.]
        coords.transform_xyz_to_global_by_coord_id(xyz, 4)  # [xyz], cp_initial
        xyz = [
            [0., 0., 0.],
            [1., 1., 1.],
        ]
        coords.transform_xyz_to_global_by_coord_id(xyz, 4)  # [xyz], cp_initial

        # global from global
        coords.transform_xyz_to_global_by_coord_id(xyz, 0)  # [xyz], cp_initial

        # this doesn't run because rid != 0
        with self.assertRaises(RuntimeError):
            # cp=0 doesn't exist
            coords.transform_xyz_to_global_by_coord_id(xyz, 2)
Example #30
0
    def test_pshell_01(self):
        """tests a CQUAD4 and a PSHELL"""

        rho = 0.1
        nu = 0.3
        G = None
        E = 1e7
        t = 0.3
        nsm = 0.0

        card_count = {
            'GRID': 4,
            'CQUAD4': 1,
            #'CTRIA3': 1,
            'PSHELL': 1,
            'PCOMP': 1,
            'MAT1': 1,
            'MAT8': 1,
        }
        #print('starting BDF1')
        model = BDF(debug=True)
        model.allocate(card_count)
        self._make_cquad4(model, rho, nu, G, E, t, nsm)

        card_count1 = {
            'GRID': 3,
            #'CQUAD4': 1,
            'CTRIA3': 2,
            'PSHELL': 1,
            'PCOMP': 1,
            'MAT1': 1,
            'MAT8': 1,
        }
        #print('starting BDF2')
        model = BDF(debug=True)
        model.allocate(card_count1)
        self._make_ctria3(model, rho, nu, G, E, t, nsm)

        card_count = {
            'GRID': 4,
            'CQUAD4': 1,
            #'CTRIA3': 2,
            'PSHELL': 1,
            'PCOMP': 1,
            'MAT1': 1,
            'MAT8': 1,
        }
        #print('starting BDF3')
        nsm = 1.0
        model = BDF(debug=False)
        model.allocate(card_count)
        self._make_cquad4(model, rho, nu, G, E, t, nsm)

        card_count = {
            'GRID': 3,
            #'CQUAD4': 1,
            'CTRIA3': 2,
            'PSHELL': 1,
            'PCOMP': 1,
            'MAT1': 1,
            'MAT8': 1,
        }
        #print('starting BDF4')
        model = BDF(debug=False)
        model.allocate(card_count)
        self._make_ctria3(model, rho, nu, G, E, t, nsm)