Exemplo n.º 1
0
 def readPROD(self, data):
     """
     PROD(902,9,29) - the marker for Record 49
     """
     #print "reading PROD"
     while len(data) >= 24:  # 6*4
         eData = data[:24]
         data = data[24:]
         out = unpack(b'2i4f', eData)
         (pid, mid, a, j, c, nsm) = out
         prop = PROD(None, out)
         self.addOp2Property(prop)
Exemplo n.º 2
0
 def _readPROD(self, data, n):
     """
     PROD(902,9,29) - the marker for Record 49
     """
     ntotal = 24  # 6*4
     s = Struct(b'2i4f')
     nproperties = (len(data) - n) // ntotal
     for i in range(nproperties):
         eData = data[n:n + 24]
         out = s.unpack(eData)
         (pid, mid, a, j, c, nsm) = out
         prop = PROD(None, out)
         self.binary_debug.write('  PROD=%s\n' % str(out))
         self.addOp2Property(prop)
         n += ntotal
     self.card_count['PROD'] = nproperties
     return n
Exemplo n.º 3
0
 def _read_prod(self, data, n):
     """
     PROD(902,9,29) - the marker for Record 49
     """
     ntotal = 24  # 6*4
     s = Struct(b(self._endian + '2i4f'))
     nproperties = (len(data) - n) // ntotal
     for i in range(nproperties):
         edata = data[n:n+24]
         out = s.unpack(edata)
         (pid, mid, a, j, c, nsm) = out
         prop = PROD.add_op2_data(out)
         if self.is_debug_file:
             self.binary_debug.write('  PROD=%s\n' % str(out))
         self._add_op2_property(prop)
         n += ntotal
     self.card_count['PROD'] = nproperties
     return n
Exemplo n.º 4
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"""
        model = BDF(debug=False)
        lines = [
            'conrod,%i, %i, %i, %i, %f, %f, %f, %f' %
            (eid, nid1, nid2, mid, A, J, c, nsm)
        ]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        conrod = CONROD.add_card(cardi)
        model._add_element_object(conrod)
        card = model.elements[eid]
        node_ids = card.node_ids
        assert node_ids == [nid1, nid2], node_ids  # probably wrong

        lines = ['crod,%i, %i, %i, %i' % (eid + 1, pid, nid1, nid2)]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        crod = CROD.add_card(cardi)
        model._add_element_object(crod)
        card = model.elements[eid + 1]
        node_ids = card.node_ids
        assert node_ids == [nid1, nid2], node_ids  # probably wrong

        lines = ['ctube,%i, %i, %i, %i' % (eid + 2, pid + 1, nid1, nid2)]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        ctube = CTUBE.add_card(cardi)
        model._add_element_object(ctube)
        card = model.elements[eid + 2]
        node_ids = card.node_ids
        assert node_ids == [nid1, nid2], node_ids  # probably wrong

        lines = ['prod,%i, %i, %f, %f, %f, %f' % (pid, mid, A, J, c, nsm)]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        prod = PROD.add_card(cardi)
        model._add_property_object(prod)

        #self.pid = integer(card, 1, 'pid')
        #self.mid = integer(card, 2, 'mid')
        #self.OD1 = double(card, 3, 'OD1')
        #self.t = double_or_blank(card, 4, 't', self.OD1 / 2.)
        #self.nsm = double_or_blank(card, 5, 'nsm', 0.0)
        #self.OD2 = double_or_blank(card, 6, 'OD2', self.OD1)
        OD1 = sqrt(4 * A / pi)
        t = 0.
        OD2 = OD1
        lines = [
            'ptube,%i, %i, %f, %f, %f, %f' % (pid + 1, mid, OD1, t, nsm, OD2)
        ]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        ptube = PTUBE.add_card(cardi)
        model._add_property_object(ptube)

        lines = ['mat1,%i, %.2e, %.2e, %f, %f' % (mid, E, G, nu, rho)]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        card = MAT1.add_card(cardi)
        model._add_structural_material_object(card)

        lines = [
            'grid,%i, %i, %f, %f, %f' % (nid1, 0, xyz1[0], xyz1[1], xyz1[2])
        ]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        card = GRID.add_card(cardi)
        model._add_node_object(card)

        lines = [
            'grid,%i, %i, %f, %f, %f' % (nid2, 0, xyz2[0], xyz2[1], xyz2[2])
        ]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        card = GRID.add_card(cardi)
        model._add_node_object(card)

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

        # conrod
        self.assertEqual(conrod.eid, eid)
        self.assertEqual(conrod.Pid(), -10)
        self.assertEqual(conrod.Mid(), mid)
        self.assertEqual(conrod.Length(), L)
        self.assertEqual(conrod.Nsm(), nsm)
        self.assertEqual(conrod.Mass(), mass)
        self.assertEqual(conrod.E(), E)
        self.assertEqual(conrod.G(), G)
        self.assertEqual(conrod.Area(), A)
        self.assertEqual(conrod.J(), J)
        self.assertEqual(conrod.C(), c)
        self.assertEqual(conrod.Rho(), rho)

        # crod
        self.assertEqual(crod.eid, eid + 1)
        self.assertEqual(crod.Pid(), pid)
        self.assertEqual(crod.Mid(), mid)
        self.assertEqual(crod.Length(), L)
        self.assertEqual(crod.Nsm(), nsm)
        self.assertEqual(crod.Mass(), mass)
        self.assertEqual(crod.E(), E)
        self.assertEqual(crod.G(), G)
        self.assertEqual(crod.Area(), A)
        self.assertEqual(crod.J(), J)
        self.assertEqual(crod.C(), c)
        self.assertEqual(crod.Rho(), rho)
        #self.assertEqual(crod.Nu(), nu)

        # prod
        self.assertEqual(prod.Pid(), pid)
        self.assertEqual(prod.Mid(), mid)
        self.assertEqual(prod.Nsm(), nsm)
        self.assertEqual(prod.E(), E)
        self.assertEqual(prod.G(), G)
        self.assertEqual(prod.Area(), A)
        self.assertEqual(prod.J(), J)
        self.assertEqual(prod.C(), c)
        self.assertEqual(prod.Rho(), rho)

        # ctube
        self.assertEqual(ctube.eid, eid + 2)
        self.assertEqual(ctube.Pid(), pid + 1)
        self.assertEqual(ctube.Mid(), mid)
        self.assertEqual(ctube.Length(), L)
        self.assertEqual(ctube.Nsm(), nsm)
        self.assertAlmostEqual(ctube.Mass(), mass, 5)
        self.assertEqual(ctube.E(), E)
        self.assertEqual(ctube.G(), G)
        self.assertAlmostEqual(ctube.Area(), A, 5)
        ctube.J()
        self.assertEqual(ctube.Rho(), rho)

        # ptube
        self.assertEqual(ptube.Pid(), pid + 1)
        self.assertEqual(ptube.Mid(), mid)
        self.assertEqual(ptube.Nsm(), nsm)
        self.assertEqual(ptube.E(), E)
        self.assertEqual(ptube.G(), G)
        self.assertAlmostEqual(ptube.Area(), A, 5)
        ptube.J()
        self.assertEqual(ptube.Rho(), rho)
Exemplo n.º 5
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"""
        model = BDF(debug=False)
        lines = ['conrod,%i, %i, %i, %i, %f, %f, %f, %f' % (eid, nid1, nid2, mid, A, J, c, nsm)]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        conrod = CONROD.add_card(cardi)
        model._add_element_object(conrod)
        card = model.elements[eid]
        node_ids = card.node_ids
        assert node_ids == [nid1, nid2], node_ids # probably wrong

        lines = ['crod,%i, %i, %i, %i' % (eid+1, pid, nid1, nid2)]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        crod = CROD.add_card(cardi)
        model._add_element_object(crod)
        card = model.elements[eid+1]
        node_ids = card.node_ids
        assert node_ids == [nid1, nid2], node_ids # probably wrong

        lines = ['ctube,%i, %i, %i, %i' % (eid+2, pid+1, nid1, nid2)]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        ctube = CTUBE.add_card(cardi)
        model._add_element_object(ctube)
        card = model.elements[eid+2]
        node_ids = card.node_ids
        assert node_ids == [nid1, nid2], node_ids # probably wrong

        lines = ['prod,%i, %i, %f, %f, %f, %f' % (pid, mid, A, J, c, nsm)]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        prod = PROD.add_card(cardi)
        model._add_property_object(prod)

        #self.pid = integer(card, 1, 'pid')
        #self.mid = integer(card, 2, 'mid')
        #self.OD1 = double(card, 3, 'OD1')
        #self.t = double_or_blank(card, 4, 't', self.OD1 / 2.)
        #self.nsm = double_or_blank(card, 5, 'nsm', 0.0)
        #self.OD2 = double_or_blank(card, 6, 'OD2', self.OD1)
        OD1 = sqrt(4*A/pi)
        t = 0.
        OD2 = OD1
        lines = ['ptube,%i, %i, %f, %f, %f, %f' % (pid+1, mid, OD1, t, nsm, OD2)]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        ptube = PTUBE.add_card(cardi)
        model._add_property_object(ptube)

        lines = ['mat1,%i, %.2e, %.2e, %f, %f' % (mid, E, G, nu, rho)]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        card = MAT1.add_card(cardi)
        model._add_structural_material_object(card)

        lines = ['grid,%i, %i, %f, %f, %f' % (nid1, 0, xyz1[0], xyz1[1], xyz1[2])]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        card = GRID.add_card(cardi)
        model._add_node_object(card)

        lines = ['grid,%i, %i, %f, %f, %f' % (nid2, 0, xyz2[0], xyz2[1], xyz2[2])]
        card = model.process_card(lines)
        cardi = BDFCard(card)
        card = GRID.add_card(cardi)
        model._add_node_object(card)

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

        # conrod
        self.assertEqual(conrod.eid, eid)
        self.assertEqual(conrod.Pid(), None)
        self.assertEqual(conrod.Mid(), mid)
        self.assertEqual(conrod.Length(), L)
        self.assertEqual(conrod.Nsm(), nsm)
        self.assertEqual(conrod.Mass(), mass)
        self.assertEqual(conrod.E(), E)
        self.assertEqual(conrod.G(), G)
        self.assertEqual(conrod.Area(), A)
        self.assertEqual(conrod.J(), J)
        self.assertEqual(conrod.C(), c)
        self.assertEqual(conrod.Rho(), rho)

        # crod
        self.assertEqual(crod.eid, eid+1)
        self.assertEqual(crod.Pid(), pid)
        self.assertEqual(crod.Mid(), mid)
        self.assertEqual(crod.Length(), L)
        self.assertEqual(crod.Nsm(), nsm)
        self.assertEqual(crod.Mass(), mass)
        self.assertEqual(crod.E(), E)
        self.assertEqual(crod.G(), G)
        self.assertEqual(crod.Area(), A)
        self.assertEqual(crod.J(), J)
        self.assertEqual(crod.C(), c)
        self.assertEqual(crod.Rho(), rho)
        #self.assertEqual(crod.Nu(), nu)

        # prod
        self.assertEqual(prod.Pid(), pid)
        self.assertEqual(prod.Mid(), mid)
        self.assertEqual(prod.Nsm(), nsm)
        self.assertEqual(prod.E(), E)
        self.assertEqual(prod.G(), G)
        self.assertEqual(prod.Area(), A)
        self.assertEqual(prod.J(), J)
        self.assertEqual(prod.C(), c)
        self.assertEqual(prod.Rho(), rho)

        # ctube
        self.assertEqual(ctube.eid, eid+2)
        self.assertEqual(ctube.Pid(), pid+1)
        self.assertEqual(ctube.Mid(), mid)
        self.assertEqual(ctube.Length(), L)
        self.assertEqual(ctube.Nsm(), nsm)
        self.assertAlmostEqual(ctube.Mass(), mass, 5)
        self.assertEqual(ctube.E(), E)
        self.assertEqual(ctube.G(), G)
        self.assertAlmostEqual(ctube.Area(), A, 5)
        ctube.J()
        self.assertEqual(ctube.Rho(), rho)

        # ptube
        self.assertEqual(ptube.Pid(), pid+1)
        self.assertEqual(ptube.Mid(), mid)
        self.assertEqual(ptube.Nsm(), nsm)
        self.assertEqual(ptube.E(), E)
        self.assertEqual(ptube.G(), G)
        self.assertAlmostEqual(ptube.Area(), A, 5)
        ptube.J()
        self.assertEqual(ptube.Rho(), rho)