Example #1
0
    def test_pbeam_03(self):
        lines =['PBEAM,39,6,2.9,3.5,5.97',
                '     ,  , ,2.0,-4.0',
                '     ,YES,1.0,5.3,56.2,78.6',
                '     ,   ,   ,2.5,-5.0',
                '     ,   ,   ,1.1,    ,2.1,,0.21',
                '     ,   ,   ,   ,    ,0.5,,0.0',]

        card = bdf.process_card(lines)
        #print print_card(card)
        card = BDFCard(card)
        #print "card =", card
        card2 = PBEAM(card)
        fields = card2.rawFields()
        msg = print_card(fields)
        #print msg

        lines_expected = ['PBEAM         39       6     2.9     3.5    5.97      0.      0.      0.',
                          '              0.      0.      2.     -4.      0.      0.      0.      0.',
                          '             YES      1.     5.3    56.2    78.6    56.2      0.      0.',
                          '              0.      0.      0.     2.5     -5.      0.      0.      0.',
                          '              1.      1.     1.1      0.     2.1     2.1     .21     .21',
                          '              0.      0.      0.      0.      .5      .5      0.      0.',]
        lines_actual = msg.rstrip().split('\n')
        msg = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
        msg += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
        self.assertEqual(len(lines_actual), len(lines_expected), msg)
        for actual, expected in zip(lines_actual, lines_expected):
            self.assertEqual(actual, expected)
Example #2
0
    def test_pbeam_02(self):
        lines = [
            'PBEAM,39,6,2.9,3.5,5.97',
            '     ,  , ,2.0,-4.0',
            '     ,YES,1.0,5.3,56.2,78.6',
            '     ,   ,   ,2.5,-5.0',
            #'     ,YES,1.0,5.3,56.2,78.6',
            #'     ,   ,   ,2.5,-5.0',
            #'     ,YES,1.0,5.3,56.2,78.6',
            #'     ,   ,   ,2.5,-5.0',
            '     ,   ,   ,1.1,    ,2.1,,0.21',
            '     ,   ,   ,   ,    ,0.5,,0.0',
        ]

        card = bdf.process_card(lines)
        card = BDFCard(card)
        card2 = PBEAM(card)
        fields = card2.raw_fields()

        lines_expected = [
            'PBEAM         39       6     2.9     3.5    5.97      0.      0.      0.',
            '              0.      0.      2.     -4.      0.      0.      0.      0.',
            '             YES      1.     5.3    56.2    78.6      0.      0.      0.',
            '              0.      0.     2.5     -5.      0.      0.      0.      0.',
            #'             YES      1.     5.3    56.2    78.6      0.      0.      0.',
            #'              0.      0.     2.5     -5.      0.      0.      0.      0.',
            #'             YES      1.     5.3    56.2    78.6      0.      0.      0.',
            #'              0.      0.     2.5     -5.      0.      0.      0.      0.',
            '              1.      1.     1.1      0.     2.1     2.1     .21     .21',
            '              0.      0.      0.      0.      .5      .5      0.      0.'
        ]
        self._compare(fields, lines_expected)
Example #3
0
    def _test_pbeam_07(self):

        lines = ['PBEAM   100     100     1.00    10.     1.0                             +Z1',
                 '+Z1     NO      1.0                                                     +Z4',
                 '+Z4     0.0     0.0',]
        card = bdf.process_card(lines)
        #print(print_card(card))
        card = BDFCard(card)
        #print("card =", card)
        #with self.assertRaises(RuntimeError):  # temporary RuntimeError
        card2 = PBEAM(card)
        
        if 0:
            fields = card2.rawFields()
            msg = print_card(fields)
            #print(msg)

            lines_actual = msg.rstrip().split('\n')
            msg = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
            msg += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
            self.assertEqual(len(lines_actual), len(lines_expected), msg)
            for actual, expected in zip(lines_actual, lines_expected):
                msg =  'actual   = %r\n' % actual
                msg += 'expected = %r' % expected
                self.assertEqual(actual, expected, msg)
Example #4
0
    def test_pbeam_06(self):
        lines =['PBEAM   1       1       1.      60.     1.                              PBEAM1',
                '+BEAM1  5.              -5.                                             PBEAM2',
                '+BEAM2  YES     1.      2.      240.                                    PBEAM3',
                '+BEAM3  10.             -10.                                            PBEAM4',
                '+BEAM4                  -.666667',]

        card = bdf.process_card(lines)
        #print(print_card(card))
        card = BDFCard(card)
        #print("card =", card)
        card2 = PBEAM(card)
        fields = card2.rawFields()
        msg = print_card(fields)
        #print(msg)

        lines_expected = ['PBEAM          1       1      1.     60.      1.      0.      0.      0.',
                          '              5.      0.     -5.      0.      0.      0.      0.      0.',
                          '             YES      1.      2.    240.      0.    240.      0.      0.',
                          '              0.     10.      0.    -10.      0.      0.      0.      0.',
                          '              1.      1.-.666667      0.      0.      0.      0.      0.',
                          '              0.      0.      0.      0.      0.      0.      0.      0.',
        ]
        #print('\n'.join(lines_expected))
        lines_actual = msg.rstrip().split('\n')
        msg = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
        msg += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
        self.assertEqual(len(lines_actual), len(lines_expected), msg)
        for actual, expected in zip(lines_actual, lines_expected):
            msg =  'actual   = %r\n' % actual
            msg += 'expected = %r' % expected
            self.assertEqual(actual, expected, msg)
Example #5
0
    def test_pbeam_05(self):
        lines =['PBEAM,39,6,2.9,3.5,5.97',
                '     ,  , ,2.0,-4.0',]

        card = bdf.process_card(lines)
        #print(print_card(card))
        card = BDFCard(card)
        #print("card =", card)
        card2 = PBEAM(card)
        fields = card2.rawFields()
        msg = print_card(fields)
        #print(msg)

        lines_expected = ['PBEAM         39       6     2.9     3.5    5.97      0.      0.      0.',
                          '              0.      0.      2.     -4.      0.      0.      0.      0.',
                          '              1.      1.      0.      0.      0.      0.      0.      0.',
                          '              0.      0.      0.      0.      0.      0.      0.      0.',]
        lines_actual = msg.rstrip().split('\n')
        msg = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
        msg += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
        self.assertEqual(len(lines_actual), len(lines_expected), msg)
        for actual, expected in zip(lines_actual, lines_expected):
            msg =  'actual   = %r\n' % actual
            msg += 'expected = %r' % expected
            self.assertEqual(actual, expected, msg)
Example #6
0
 def test_pbeam_07(self):
     lines = [
         'PBEAM   100     100     1.00    10.     1.0                             +Z1',
         '+Z1     NO      1.0                                                     +Z4',
         '+Z4     0.0     0.0',
     ]
     card = bdf.process_card(lines)
     cardi = BDFCard(card)
     card2 = PBEAM()
     card2.add_card(cardi)
Example #7
0
    def test_pbeam_04(self):
        lines =['PBEAM,39,6,2.9,3.5,5.97',
                '     ,  , ,2.0,-4.0',
                '     ,   ,   ,1.1,    ,2.1,,0.21',
                '     ,   ,   ,   ,    ,0.5,,0.0',]

        card = bdf.process_card(lines)
        card = BDFCard(card)
        card2 = PBEAM(card)
        fields = card2.rawFields()
        lines_expected = ['PBEAM         39       6     2.9     3.5    5.97      0.      0.      0.',
                          '              0.      0.      2.     -4.      0.      0.      0.      0.',
                          '              1.      1.     1.1      0.     2.1     2.1     .21     .21',
                          '              0.      0.      0.      0.      .5      .5      0.      0.',]
        self._compare(fields, lines_expected)
Example #8
0
    def test_pbeam_05(self):
        lines =['PBEAM,39,6,2.9,3.5,5.97',
                '     ,  , ,2.0,-4.0',]

        card = bdf.process_card(lines)
        #print(print_card(card))
        card = BDFCard(card)
        card2 = PBEAM(card)
        fields = card2.rawFields()
        msg = print_card(fields)

        lines_expected = ['PBEAM         39       6     2.9     3.5    5.97      0.      0.      0.',
                          '              0.      0.      2.     -4.      0.      0.      0.      0.',
                          '              1.      1.      0.      0.      0.      0.      0.      0.',
                          '              0.      0.      0.      0.      0.      0.      0.      0.',]
        self._compare(fields, lines_expected)
Example #9
0
    def test_pbeam_01(self):
        lines = [
            'PBEAM,39,6,2.9,3.5,5.97',
            '     ,  , ,2.0,-4.0',
            '     ,YES,1.0,5.3,56.2,78.6',
            '     ,   ,   ,2.5,-5.0',
            '     ,   ,   ,1.1,    ,2.1,,0.21',
            '     ,   ,   ,   ,    ,0.5,,0.0',
        ]
        bdf = BDF(debug=False)
        card = bdf.process_card(lines)
        #print(print_card_8(card))
        cardi = BDFCard(card)
        card2 = PBEAM.add_card(cardi)
        fields = card2.raw_fields()

        lines_expected = [
            'PBEAM         39       6     2.9     3.5    5.97      0.      0.      0.',
            '              0.      0.      2.     -4.      0.      0.      0.      0.',
            '             YES      1.     5.3    56.2    78.6      0.      0.      0.',
            '              0.      0.     2.5     -5.      0.      0.      0.      0.',
            '              1.      1.     1.1      0.     2.1     2.1     .21     .21',
            '              0.      0.      0.      0.      .5      .5      0.      0.'
        ]
        self._compare(fields, lines_expected)
Example #10
0
    def test_pbeam_08(self):  # should fail...
        lines = [
        'PBEAM*   4570049         4570010        .12             2.56-4          *    HRY',
        '*    HRY.005625                         8.889-4         6.4444-7        *    HRZ',
        '*    HRZ-.04            -.75            .04             -.75            *    HSA',
        '*    HSA.04             .75             -.04            .75             *    HSB',
        '*    HSB YES            1.              .12             2.56-4          *    HSC',
        '*    HSC.005625                         8.889-4         6.4444-7        *    HSD',
        '*    HSD-.04            -.75            .04             -.75            *    HSE',
        '*    HSE.04             .75             -.04            .75             *    HSF',
        '*    HSF.853433         .849842                                         *    HSG',
        '*    HSG',
        ]
        lines_expected = [
        'PBEAM*           4570049         4570010             .12         .000256',
        '*                .005625                        .0008889    .00000064444',
        '*                   -.04            -.75             .04            -.75',
        '*                    .04             .75            -.04             .75',
        '*                    YES              1.             .12         .000256',
        '*                .005625                        .0008889    .00000064444',
        '*                   -.04            -.75             .04            -.75',
        '*                    .04             .75            -.04             .75',
        '*                .853433         .849842',
        '*',
        ]

        card = bdf.process_card(lines)
        card = BDFCard(card)
        #with self.assertRaises(RuntimeError):  # temporary RuntimeError
        card2 = PBEAM(card)

        if 1:
            fields = card2.rawFields()
            msg = print_card(fields)
            size = 16
            msg = card2.write_bdf(size, 'dummy')

            lines_actual = msg.rstrip().split('\n')
            msgA = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
            msgA += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
            self.assertEqual(len(lines_actual), len(lines_expected), msg)
            for actual, expected in zip(lines_actual, lines_expected):
                actual = str(actual)
                expected = str(expected)
                msg =  msgA + '\nactual   = %r\n' % actual
                msg += 'expected = %r' % expected
                self.assertEqual(actual, expected, msg)
Example #11
0
 def test_pbeam_09(self):
     fields = [u'PBEAM', 4570049, 4570010, 0.12, 0.000256, 0.005625, None,
         0.0008889, 6.4444e-07, -0.04, -0.75, 0.04, -0.75, 0.04, 0.75,
         -0.04, 0.75, 'YES', 1.0, 0.12, 0.000256, 0.005625, 0.000256,
         None, 0.0008889, 6.4444e-07, -0.04, -0.75, 0.04, -0.75, 0.04,
         0.75, -0.04, 0.853433, 0.849842]
     #fields = [u'PBAR', 1510998, 1520998, 0.0, 4.9000000000000006e-14, 4.9000000000000006e-14, 0.0, 0.0, None, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, None, None, 0.0]
     card = print_card(fields)
     #print(card)
     card = print_card(fields)
     lines = card.split('\n')
     card = bdf.process_card(lines)
     card2 = BDFCard(card)
     #with self.assertRaises(AssertionError):  # A=0, I12=0, K1=0
     pbeam = PBEAM(card2)
     fields2 = pbeam.reprFields()
     assert fields == fields
Example #12
0
 def test_pbeam_07(self):
     bdf = BDF(debug=False)
     lines = [
         'PBEAM   100     100     1.00    10.     1.0                             +Z1',
         '+Z1     NO      1.0                                                     +Z4',
         '+Z4     0.0     0.0',
     ]
     card = bdf.process_card(lines)
     cardi = BDFCard(card)
     card2 = PBEAM.add_card(cardi)
Example #13
0
    def test_pbeam_06(self):
        lines =['PBEAM   1       1       1.      60.     1.                              PBEAM1',
                '+BEAM1  5.              -5.                                             PBEAM2',
                '+BEAM2  YES     1.      2.      240.                                    PBEAM3',
                '+BEAM3  10.             -10.                                            PBEAM4',
                '+BEAM4                  -.666667',]

        card = bdf.process_card(lines)
        card = BDFCard(card)
        card2 = PBEAM(card)
        fields = card2.rawFields()

        lines_expected = ['PBEAM          1       1      1.     60.      1.      0.      0.      0.',
                          '              5.      0.     -5.      0.      0.      0.      0.      0.',
                          '             YES      1.      2.    240.      0.      0.      0.      0.',
                          '             10.      0.    -10.      0.      0.      0.      0.      0.',
                          '              1.      1.-.666667      0.      0.      0.      0.      0.',
                          '              0.      0.      0.      0.      0.      0.      0.      0.',
        ]
        self._compare(fields, lines_expected)
Example #14
0
    def test_pbeam_07(self):
        lines = ['PBEAM   100     100     1.00    10.     1.0                             +Z1',
                 '+Z1     NO      1.0                                                     +Z4',
                 '+Z4     0.0     0.0',]
        card = bdf.process_card(lines)
        card = BDFCard(card)
        with self.assertRaises(SyntaxError):  # ..todo:: is this correct?
            card2 = PBEAM(card)

        if 0:
            fields = card2.rawFields()
            msg = print_card(fields)

            lines_actual = msg.rstrip().split('\n')
            msg = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
            msg += 'nlines_actual=%i nlines_expected=%i' % (len(lines_actual), len(lines_expected))
            self.assertEqual(len(lines_actual), len(lines_expected), msg)
            for actual, expected in zip(lines_actual, lines_expected):
                msg =  '\nactual   = %r\n' % actual
                msg += 'expected = %r' % expected
                self.assertEqual(actual, expected, msg)
Example #15
0
    def test_pbeam_08(self):
        bdf = BDF(debug=False)
        lines = [
            'PBEAM*   4570049         4570010        .12             2.56-4          *    HRY',
            '*    HRY.005625                         8.889-4         6.4444-7        *    HRZ',
            '*    HRZ-.04            -.75            .04             -.75            *    HSA',
            '*    HSA.04             .75             -.04            .75             *    HSB',
            '*    HSB YES            1.              .12             2.56-4          *    HSC',
            '*    HSC.005625                         8.889-4         6.4444-7        *    HSD',
            '*    HSD-.04            -.75            .04             -.75            *    HSE',
            '*    HSE.04             .75             -.04            .75             *    HSF',
            '*    HSF.853433         .849842                                         *    HSG',
            '*    HSG',
        ]
        lines_expected = [
            'PBEAM*           4570049         4570010             .12         .000256',
            '*                .005625                        .0008889    .00000064444',
            '*                   -.04            -.75             .04            -.75',
            '*                    .04             .75            -.04             .75',
            '*                    YES              1.             .12         .000256',
            '*                .005625                        .0008889    .00000064444',
            '*                   -.04            -.75             .04            -.75',
            '*                    .04             .75            -.04             .75',
            '*                .853433         .849842',
            '*',
        ]

        card = bdf.process_card(lines)
        cardi = BDFCard(card)
        card2 = PBEAM.add_card(cardi)

        fields = card2.raw_fields()
        msg = print_card_8(fields)
        size = 16
        msg = card2.write_card(size, 'dummy')

        lines_actual = msg.rstrip().split('\n')
        msg_a = '\n%s\n\n%s' % ('\n'.join(lines_expected), msg)
        msg_a += 'nlines_actual=%i nlines_expected=%i' % (
            len(lines_actual), len(lines_expected))
        self.assertEqual(len(lines_actual), len(lines_expected), msg)
        for actual, expected in zip(lines_actual, lines_expected):
            actual = str(actual)
            expected = str(expected)
            msg = msg_a + '\nactual   = %r\n' % actual
            msg += 'expected = %r' % expected
            self.assertEqual(actual, expected, msg)
Example #16
0
    def _read_pbeam(self, data, n):
        """
        PBEAM(5402,54,262) - the marker for Record 14
        .. todo:: add object
        """
        struct1 = Struct(b(self._endian + '4if'))
        struct2 = Struct(b(self._endian + '16f'))
        struct3 = Struct(b(self._endian + '16f'))
        ntotal = 1072  # 44+12*84+20
        nproperties = (len(data) - n) // ntotal
        print('')
        #assert nproperties > 0, 'ndata-n=%s n=%s datai\n%s' % (len(data)-n, n, self.show_data(data[n:100+n]))
        ndata = len(data)
        while n < ndata:
        #while 1: #for i in range(nproperties):
            edata = data[n:n+20]
            n += 20
            data_in = list(struct1.unpack(edata))
            if self.is_debug_file:
                self.log.info('PBEAM pid=%s mid=%s nsegments=%s ccf=%s x=%s\n' % tuple(data_in))
            (pid, mid, nsegments, ccf, x) = data_in
            self.log.info('PBEAM pid=%s mid=%s nsegments=%s ccf=%s x=%s' % tuple(data_in))

            # Constant cross-section flag: 1=yes and 0=no
            # what is 2?
            assert ccf in [0, 1, 2], '  PBEAM pid=%s mid=%s nsegments=%s ccf=%s x=%s\n' % tuple(data_in)
            for i in range(11):
                edata = data[n:n+64]
                if len(edata) != 64:
                    endpack = []
                    raise RuntimeError('PBEAM unexpected length i=%s...' % i)
                n += 64
                pack = struct2.unpack(edata)
                (soi, xxb, a, i1, i2, i12, j, nsm, c1, c2,
                 d1, d2, e1, e2, f1, f2) = pack

                if soi == 0.0:
                    so_str = 'NO'
                elif soi == 1.0:
                    so_str = 'YES'
                else:
                    raise NotImplementedError('PBEAM pid=%s i=%s x/xb=%s soi=%s' % (pid, i, xxbi, soi))

                pack2 = (so_str, xxb, a, i1, i2, i12, j, nsm, c1, c2,
                         d1, d2, e1, e2, f1, f2)
                data_in.append(pack2)
                if self.is_debug_file:
                    self.binary_debug.write('     %s\n' % str(pack))
                self.log.info('    i=%-2s' % i + ' so=%s xxb=%.1f a=%g i1=%g i2=%g i12=%g j=%g nsm=%g '
                              'c=[%s,%s] d=[%s,%s] e=[%s,%s] f=[%s,%s]' % (tuple(pack2)))
            edata = data[n:n+64]
            if len(edata) != 64:
                endpack = []
                raise RuntimeError('PBEAM unexpected length 2...')
                #break
            else:
                endpack = struct3.unpack(edata)
                n += 64

            assert len(endpack) == 16, endpack
            (k1, k2, s1, s2, nsia, nsib, cwa, cwb, # 8
             m1a, m2a, m1b, m2b, n1a, n2a, n1b, n2b ) = endpack # 8 -> 16
            self.log.info('    k=[%s,%s] s=[%s,%s] nsi=[%s,%s] cw=[%s,%s] '
                          'ma=[%s,%s] mb=[%s,%s] na=[%s,%s] nb=[%s,%s]' % (tuple(endpack)))
            data_in.append(endpack)

            prop = PBEAM.add_op2_data(data_in)
            self._add_op2_property(prop)
        self.card_count['PBEAM'] = nproperties
        return n