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)
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)
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.raw_fields() 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)
def test_pbeam_08(self): 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() card2.add_card(cardi) if 1: 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)
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.raw_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. 1.1 0. 2.1 2.1 .21 .21', ' 0. 0. 0. 0. .5 .5 0. 0.', ] self._compare(fields, lines_expected)
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.raw_fields() 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)
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_8(card)) card = BDFCard(card) card2 = PBEAM(card) fields = card2.raw_fields() msg = print_card_8(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)
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.raw_fields() 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)
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.raw_fields() lines_expected = [ 'PBEAM 1 1 1. 60. 1. 0. 0. 0.', ' 5. 0. -5. 0. 0. 0. 0. 0.', ' YES 1. 2. 240. 1. 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)
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.raw_fields() 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)