def test_integer_or_double(self): # out of range with self.assertRaises(SyntaxError): integer_or_double(BDFCard([1.]), 1, 'field') self.assertEqual(1.e-9, integer_or_double(BDFCard(['1-9']), 0, 'field')) self.assertEqual(1.e+9, integer_or_double(BDFCard(['1+9']), 0, 'field'))
def test_integer_double_or_string(self): # out of range with self.assertRaises(SyntaxError): integer_or_double(BDFCard([1.]), 1, 'field') # integer self.check_integer(integer_double_or_string) # float self.check_double(integer_double_or_string) # string self.assertEqual('LOAD', integer_double_or_string(BDFCard(['load']), 0, 'field'))
def add_card(self, card, comment=''): #self.model.log.debug('RBE2.add') i = self.i #if comment: # self.comment = comment eid = integer(card, 1, 'element_id') gn = integer(card, 2, 'gn') cm = components_or_blank(card, 3, 'cm') #assert gn is not None, 'gn=%s' % self.gn #assert cm is not None, 'cm=%s' % self.cm self.element_id[i] = eid self.gn[i] = gn self.cm[i] = cm alpha = integer_or_double(card, len(card) - 1, 'alpha') if isinstance(alpha, float): # the last field is not part of Gmi self.alpha[i] = alpha n = 1 else: # the last field is part of Gmi n = 0 #self.alpha[i] = 0.0 # we don't need to set alpha j = 4 gmis = [] for k in range(len(card) - 4 - n): gmi = integer(card, j + k, 'Gm%i' % (k + 1)) #print('GM%i = %s' % (k + 1, gmi)) gmis.append(gmi) self.gmi[i] = gmis self.i += 1
def add_card(cls, card, comment=''): """ Adds a CBARAO card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ eid = integer(card, 1, 'eid') scale = string(card, 2, 'scale') x1_npoints = integer_or_double(card, 3, 'x1/npoints') if isinstance(x1_npoints, integer_types): npoints = x1_npoints x1 = double_or_blank(card, 4, 'x1') delta_x = double_or_blank(card, 4, 'delta_x') x = np.arange(x1, npoints, delta_x) raise NotImplementedError('card=%s x=%s' % (card, x)) else: x = [ x1_npoints, double_or_blank(card, 4, 'x2'), double_or_blank(card, 5, 'x3'), double_or_blank(card, 6, 'x4'), double_or_blank(card, 7, 'x5'), double_or_blank(card, 8, 'x6'), ] assert len(card) <= 9, 'len(CBARAO card) = %i\ncard=%s' % (len(card), card) return CBARAO(eid, scale, x, comment=comment)
def add_card(cls, card, comment=''): """ Adds a RBE2 card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ eid = integer(card, 1, 'eid') gn = integer(card, 2, 'gn') cm = components_or_blank(card, 3, 'cm') alpha = integer_or_double(card, len(card) - 1, 'alpha') if isinstance(alpha, float): # alpha is correct # the last field is not part of Gmi n = 1 else: # the last field is part of Gmi n = 0 alpha = 0.0 j = 4 Gmi = [] for i in range(len(card) - 4 - n): gmi = integer(card, j + i, 'Gm%i' % (i + 1)) Gmi.append(gmi) return RBE2(eid, gn, cm, Gmi, alpha, comment=comment)
def add(self, card, comment=''): #self.model.log.debug('RBE2.add') i = self.i #if comment: #self._comment = comment eid = integer(card, 1, 'element_id') gn = integer(card, 2, 'gn') cm = components_or_blank(card, 3, 'cm') #assert gn is not None, 'gn=%s' % self.gn #assert cm is not None, 'cm=%s' % self.cm self.element_id[i] = eid self.gn[i] = gn self.cm[i] = cm alpha = integer_or_double(card, len(card) - 1, 'alpha') if isinstance(alpha, float): # the last field is not part of Gmi self.alpha[i] = alpha n = 1 else: # the last field is part of Gmi n = 0 #self.alpha[i] = 0.0 # we don't need to set alpha j = 4 gmis = [] for k in range(len(card) - 4 - n): gmi = integer(card, j + k, 'Gm%i' % (k + 1)) #print('GM%i = %s' % (k + 1, gmi)) gmis.append(gmi) self.gmi[i] = gmis self.i += 1
def add_card(cls, card, comment=''): """ Adds a CBARAO card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ eid = integer(card, 1, 'eid') scale = string(card, 2, 'scale') x1_npoints = integer_or_double(card, 3, 'x1/npoints') if isinstance(x1_npoints, integer_types): npoints = x1_npoints assert 0 < npoints < 7, 'CBARAO npoints=%r must be 1-6' % npoints x1 = double(card, 4, 'x1') delta_x = double(card, 5, 'delta_x') x = np.linspace(x1, x1 + delta_x * (npoints-1), num=npoints) assert len(x) == npoints, x else: x = [ x1_npoints, double_or_blank(card, 4, 'x2'), double_or_blank(card, 5, 'x3'), double_or_blank(card, 6, 'x4'), double_or_blank(card, 7, 'x5'), double_or_blank(card, 8, 'x6'), ] x = [xi for xi in x if xi is not None] assert len(card) <= 9, 'len(CBARAO card) = %i\ncard=%s' % (len(card), card) return CBARAO(eid, scale, x, comment=comment)
def test_integer_double_or_string(self): # out of range with self.assertRaises(SyntaxError): integer_or_double(BDFCard([1.]), 1, 'field') # integer self.check_integer(integer_double_or_string) # float self.check_double(integer_double_or_string) # string self.assertEqual( 'LOAD', integer_double_or_string(BDFCard(['load']), 0, 'field')) self.assertEqual( 'MN-MM', integer_double_string_or_blank(BDFCard(['MN-MM']), 0, 'field'))
def test_integer_or_double(self): """tests the integer_or_double function""" # out of range with self.assertRaises(SyntaxError): integer_or_double(BDFCard([1.]), 1, 'field') self.assertEqual(1.e-9, integer_or_double(BDFCard(['1-9']), 0, 'field')) self.assertEqual(1.e+9, integer_or_double(BDFCard(['1+9']), 0, 'field')) self.assertEqual(-1, integer_or_double(BDFCard(['-1']), 0, 'field')) with self.assertRaises(SyntaxError): integer_or_double(BDFCard(['cat']), 0, 'field') with self.assertRaises(SyntaxError): integer_or_double(BDFCard(['.']), 0, 'field') self.assertEqual(100., integer_or_double(BDFCard(['1+2']), 0, 'field'))
def add_card(cls, card, comment=''): eid = integer(card, 1, 'eid') gn = integer(card, 2, 'gn') cm = components_or_blank(card, 3, 'cm') alpha = integer_or_double(card, len(card) - 1, 'alpha') if isinstance(alpha, float): # alpha is correct # the last field is not part of Gmi n = 1 else: # the last field is part of Gmi n = 0 alpha = 0.0 j = 4 Gmi = [] for i in range(len(card) - 4 - n): gmi = integer(card, j + i, 'Gm%i' % (i + 1)) Gmi.append(gmi) return RBE2(eid, gn, cm, Gmi, alpha, comment=comment)
def add_card(cls, card, comment=''): """ Adds a SEQGP card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ ncard = len(card) - 1 n = ncard // 2 assert ncard % 2 == 0, card nids = [] seqids = [] for ifield in range(1, ncard, 2): nid = integer(card, ifield, 'nid') seqid = integer_or_double(card, ifield + 1, 'seqid') nids.append(nid) seqids.append(seqid) return SEQGP(nids, seqids, comment=comment)
def test_integer_or_double(self): # out of range with self.assertRaises(SyntaxError): integer_or_double(BDFCard([1.]), 1, 'field')
def __init__(self, card=None, data=None, comment=''): LineProperty.__init__(self, card, data) if comment: self._comment = comment if card: self.pid = integer(card, 1, 'pid') self.mid = integer(card, 2, 'mid') value3 = integer_or_double(card, 3, 'A_FSI') if isinstance(value3, float): self.beamType = 1 #: Area of the beam cross section self.A = double(card, 3, 'A') #: Area moments of inertia in planes 1 and 2. self.i1 = double(card, 4, 'I1') self.i2 = double(card, 5, 'I2') #: Torsional stiffness :math:`J` self.j = double(card, 6, 'J') # line2 #: The r,z locations from the geometric centroid for stress #: data recovery. self.c1 = double(card, 9, 'c1') self.c2 = double(card, 10, 'c2') self.d1 = double(card, 11, 'd1') self.d2 = double(card, 12, 'd2') self.e1 = double(card, 13, 'e1') self.e2 = double(card, 14, 'e2') self.f1 = double(card, 15, 'f1') self.f2 = double(card, 16, 'f2') # line 3 #: Shear stiffness factor K in K*A*G for plane 1. self.k1 = double(card, 17, 'k1') #: Shear stiffness factor K in K*A*G for plane 2. self.k2 = double(card, 18, 'k2') #: Nonstructural mass per unit length. self.nsm = double(card, 19, 'nsm') #: Radial offset of the geometric centroid from points GA and GB. self.rc = double(card, 20, 'rc') #: Offset of the geometric centroid in a direction perpendicular #: to the plane of points GA and GB and vector v self.zc = double(card, 21, 'zc') #: Radial offset of the neutral axis from the geometric #: centroid, positive is toward the center of curvature self.deltaN = double(card, 22, 'deltaN') elif isinstance(value3, integer_types): # alternate form self.beamType = 2 #: Flag selecting the flexibility and stress intensification #: factors. See Remark 3. (Integer = 1, 2, or 3) self.fsi = integer(card, 3, 'fsi') assert self.fsi in [1, 2, 3] #: Mean cross-sectional radius of the curved pipe self.rm = double(card, 4, 'rm') #: Wall thickness of the curved pipe self.t = double(card, 5, 't') #: Internal pressure self.p = double(card, 6, 'p') # line3 # Non-structural mass :math:`nsm` self.nsm = double(card, 11, 'nsm') self.rc = double(card, 12, 'rc') self.zc = double(card, 13, 'zc') else: raise RuntimeError('Area/FSI on CBEND must be defined...') #: Bend radius of the line of centroids self.rb = double_or_blank(card, 7, 'rb') #: Arc angle :math:`\theta_B` of element (optional) self.thetab = double_or_blank(card, 8, 'thetab') assert len(card) <= 23, 'len(PBEND card) = %i\ncard=%s' % (len(card), card) else: raise NotImplementedError(data)