Пример #1
0
 def readPTUBE(self, data):
     """
     PTUBE(1602,16,30) - the marker for Record 56
     @todo OD2 only exists for heat transfer...how do i know if there's heat transfer at this point...
     @todo I could store all the tubes and add them later, but what about themal/non-thermal subcases
     @warning assuming OD2 is not written (only done for thermal)
     """
     #print "reading PTUBE"
     while len(data) >= 20:  # 5*4
         eData = data[:20]
         data = data[20:]  # or 24
         (pid, mid, OD, t, nsm) = unpack(b'2i3f', eData)
         dataIn = [pid, mid, OD, t, nsm]
         prop = PTUBE(None, dataIn)
         self.addOp2Property(prop)
Пример #2
0
 def _readPTUBE(self, data, n):
     """
     PTUBE(1602,16,30) - the marker for Record 56
     .. todo:: OD2 only exists for heat transfer...how do i know if there's heat transfer at this point...
     .. todo:: I could store all the tubes and add them later, but what about themal/non-thermal subcases
     .. warning:: assuming OD2 is not written (only done for thermal)
     """
     s = Struct(b'2i3f')
     nproperties = (len(data) - n) // 20
     for i in range(nproperties):
         eData = data[n:n + 20]  # or 24???
         (pid, mid, OD, t, nsm) = s.unpack(eData)
         dataIn = [pid, mid, OD, t, nsm]
         self.binary_debug.write('  PTUBE=%s\n' % str(out))
         prop = PTUBE(None, dataIn)
         self.addOp2Property(prop)
         n += 20
     self.card_count['PTUBE'] = nproperties
Пример #3
0
 def _read_ptube(self, data, n):
     """
     PTUBE(1602,16,30) - the marker for Record 56
     .. todo:: OD2 only exists for heat transfer...how do i know if there's heat transfer at this point...
     .. todo:: I could store all the tubes and add them later, but what about themal/non-thermal subcases
     .. warning:: assuming OD2 is not written (only done for thermal)
     """
     s = Struct(b(self._endian + '2i3f'))
     nproperties = (len(data) - n) // 20
     for i in range(nproperties):
         edata = data[n:n+20]  # or 24???
         out = s.unpack(edata)
         (pid, mid, OD, t, nsm) = out
         data_in = [pid, mid, OD, t, nsm]
         if self.is_debug_file:
             self.binary_debug.write('  PTUBE=%s\n' % str(out))
         prop = PTUBE.add_op2_data(data_in)
         self._add_op2_property(prop)
         n += 20
     self.card_count['PTUBE'] = nproperties
     return 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)
Пример #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)