def __init__(self, card=None, data=None, comment=''): if comment: self._comment = comment if card: self.oid = integer(card, 1, 'oid') n = 1 ddvals = [] for i in range(2, len(card)): ddval = double_string_or_blank(card, i, 'DDVAL%s' % n) if ddval: ddvals.append(ddval) self.ddvals = expand_thru_by(ddvals) self.ddvals.sort() else: raise NotImplementedError(data)
def __init__(self, card=None, data=None, comment=''): if comment: self._comment = comment if card: self.oid = integer(card, 1, 'oid') n = 1 ddvals = [] for i in range(2, len(card)): ddval = double_string_or_blank(card, i, 'DDVAL%s' % n) if ddval: ddvals.append(ddval) self.ddvals = expand_thru_by(ddvals) self.ddvals.sort() else: raise NotImplementedError(data)
def __init__(self, card=None, data=None, comment=''): """ .. todo:: fix 0th entry of self.so, self.xxb """ IntegratedLineProperty.__init__(self, card, data) if comment: self._comment = comment if card: #: Property ID self.pid = integer(card, 1, 'property_id') #: Material ID self.mid = integer(card, 2, 'material_id') area0 = double(card, 3, 'Area') #: Area self.A = [area0] i1a = double_or_blank(card, 4, 'I1', 0.0) i2a = double_or_blank(card, 5, 'I2', 0.0) i12a = double_or_blank(card, 6, 'I12', 0.0) ja = double_or_blank(card, 7, 'J', 0.0) nsma = double_or_blank(card, 8, 'nsm', 0.0) #: Moment of Inertia about the 1 axis :math:`I_1` self.i1 = [i1a] #: Moment of Inertia about the 2 axis :math:`I_2` self.i2 = [i2a] #: Moment of Inertia about the 12 axis :math:`I_{12}` self.i12 = [i12a] #: Polar Moment of Inertia :math:`J` self.j = [ja] #: Non-structural mass :math:`nsm` self.nsm = [nsma] assert self.A[0] >= 0., self.A assert self.i1[0] >= 0., self.i1 assert self.i2[0] >= 0., self.i2 # we'll do a check for warping later; cwa/cwb -> j > 0.0 assert self.j[0] >= 0., self.j if not (i1a*i2a - i12a **2 > 0.): msg = 'I1 * I2 - I12^2=0 and must be greater than 0.0 at End A\n' msg += 'i1=%s i2=%s i12=%s' % (i1a, i2a, i12a) raise ValueError(msg) # TODO: can you have a single lined PBEAM...I think so... # the second line is blank, so all values would be None (End A) # the NO xxb would be implicitly defined as 1.0 # the End B values would try to use End A values, but because they're not set, # the defaults would get applied # the final 2 lines will default # finally, there would be no output at End A, but there would be output at End A. ifield = 9 field9 = double_string_or_blank(card, 9, 'field9', 0.0) if isinstance(field9, float): # C/D/E/F c1a = double_or_blank(card, 9, 'c1', 0.0) c2a = double_or_blank(card, 10, 'c2', 0.0) d1a = double_or_blank(card, 11, 'd1', 0.0) d2a = double_or_blank(card, 12, 'd2', 0.0) e1a = double_or_blank(card, 13, 'e1', 0.0) e2a = double_or_blank(card, 14, 'e2', 0.0) f1a = double_or_blank(card, 15, 'f1', 0.0) f2a = double_or_blank(card, 16, 'f2', 0.0) self.c1 = [c1a] self.c2 = [c2a] self.d1 = [d1a] self.d2 = [d2a] self.e1 = [e1a] self.e2 = [e2a] self.f1 = [f1a] self.f2 = [f2a] so = 'YES' ifield += 8 # 9 + 8 = 17 else: c1a = c2a = d1a = d2a = e1a = e2a = f1a = f2a = 0.0 self.c1 = [None] self.c2 = [None] self.d1 = [None] self.d2 = [None] self.e1 = [None] self.e2 = [None] self.f1 = [None] self.f2 = [None] so = 'NO' if field9 not in ['YES', 'YESA', 'NO']: msg = 'field9=%r on the PBEAM pid=%s must be [YES, YESA, NO] because C/D/E/F at A is not specified' % field9 raise ValueError(field9) # at least one cross section is required; even if it's empty # xxb[0] isn't explicitly used #: Section position self.xxb = [0.] #: Output flag self.so = [so] irow = 0 nrows_max = 10 for irow in range(nrows_max): nrepeated = irow + 1 SOi_k1 = double_string_or_blank(card, ifield, 'SO_%i/K1' % nrepeated) if isinstance(SOi_k1, float) or SOi_k1 is None: # we found K1 break else: so = string(card, ifield, 'SO%i' % nrepeated) xxb = double(card, ifield + 1, 'x/xb%i' % nrepeated) if xxb == 1.0: # these have already been checked such that they're greater than 0 # so when we interpolate, our values will be correct A = double_or_blank(card, ifield + 2, 'Area%i' % nrepeated, area0) i1 = double_or_blank(card, ifield + 3, 'I1 %i' % nrepeated, i1a) i2 = double_or_blank(card, ifield + 4, 'I2 %i' % nrepeated, i2a) i12 = double_or_blank(card, ifield + 5, 'I12 %i' % nrepeated, i12a) assert self.A[-1] >= 0., self.A assert self.i1[-1] >= 0., self.i1 assert self.i2[-1] >= 0., self.i2 # we'll do a check for warping later; cwa/cwb -> j > 0.0 assert self.j[-1] >= 0., self.j if not (i1 * i2 - i12 ** 2 > 0.): msg = 'I1 * I2 - I12^2=0 and must be greater than 0.0 at End B\n' msg += 'xxb=1.0 i1=%s i2=%s i12=%s' % (i1, i2, i12) raise ValueError(msg) j = double_or_blank(card, ifield + 6, 'J%i' % nrepeated, ja) nsm = double_or_blank(card, ifield + 7, 'nsm%i' % nrepeated, nsma) else: # we'll go through and do linear interpolation afterwards A = double_or_blank(card, ifield + 2, 'Area%i' % nrepeated, 0.0) i1 = double_or_blank(card, ifield + 3, 'I1 %i' % nrepeated, 0.0) i2 = double_or_blank(card, ifield + 4, 'I2 %i' % nrepeated, 0.0) i12 = double_or_blank(card, ifield + 5, 'I12 %i' % nrepeated, 0.0) j = double_or_blank(card, ifield + 6, 'J%i' % nrepeated, 0.0) nsm = double_or_blank(card, ifield + 7, 'nsm%i' % nrepeated, 0.0) self.so.append(so) self.xxb.append(xxb) self.A.append(A) self.i1.append(i1) self.i2.append(i2) self.i12.append(i12) self.j.append(j) self.nsm.append(nsm) if so == 'YES': c1 = double_or_blank(card, ifield + 8, 'c1 %i' % nrepeated, 0.0) c2 = double_or_blank(card, ifield + 9, 'c2 %i' % nrepeated, 0.0) d1 = double_or_blank(card, ifield + 10, 'd1 %i' % nrepeated, 0.0) d2 = double_or_blank(card, ifield + 11, 'd2 %i' % nrepeated, 0.0) e1 = double_or_blank(card, ifield + 12, 'e1 %i' % nrepeated, 0.0) e2 = double_or_blank(card, ifield + 13, 'e2 %i' % nrepeated, 0.0) f1 = double_or_blank(card, ifield + 14, 'f1 %i' % nrepeated, 0.0) f2 = double_or_blank(card, ifield + 15, 'f2 %i' % nrepeated, 0.0) ifield += 16 elif so == 'YESA': c1 = c1a c2 = c2a d1 = d1a d2 = d2a e1 = e1a e2 = e2a f1 = f1a f2 = f2a ifield += 8 elif so == 'NO': c1 = None c2 = None d1 = None d2 = None e1 = None e2 = None f1 = None f2 = None ifield += 8 else: raise RuntimeError('so=%r and not [YES, YESA, NO]' % so) self.c1.append(c1) self.c2.append(c2) self.d1.append(d1) self.d2.append(d2) self.e1.append(e1) self.e2.append(e2) self.f1.append(f1) self.f2.append(f2) if irow != 0: assert min(self.xxb) == 0.0, self.xxb assert max(self.xxb) == 1.0, self.xxb assert len(self.xxb) == len(unique(self.xxb)), self.xxb #ifield += 8 # sort xxb ixxb = argsort(self.xxb) self.so = array(self.so, dtype='|U8')[ixxb] self.xxb = array(self.xxb, dtype='float64')[ixxb] self.A = array(self.A, dtype='float64')[ixxb] self.i1 = array(self.i1, dtype='float64')[ixxb] self.i2 = array(self.i2, dtype='float64')[ixxb] self.i12 = array(self.i12, dtype='float64')[ixxb] self.j = array(self.j, dtype='float64')[ixxb] self.nsm = array(self.nsm, dtype='float64')[ixxb] self.c1 = array(self.c1, dtype='float64')[ixxb] self.c2 = array(self.c2, dtype='float64')[ixxb] self.d1 = array(self.d1, dtype='float64')[ixxb] self.d2 = array(self.d2, dtype='float64')[ixxb] self.e1 = array(self.e1, dtype='float64')[ixxb] self.e2 = array(self.e2, dtype='float64')[ixxb] self.f1 = array(self.f1, dtype='float64')[ixxb] self.f2 = array(self.f2, dtype='float64')[ixxb] # now we interpolate to fix up missing data # from arrays that were potentially out of order # (they're sorted now) # # we've also already checked xxb=0.0 and xxb=1.0 for I1, I2, I12, J loop_vars = ( count(), self.xxb, self.A, self.i1, self.i2, self.i12, self.j, self.nsm, self.c1, self.c2, self.d1, self.d2, self.e1, self.e2, self.f1, self.f2 ) #for i, xxb, a, i1, i2, j, nsm, c1, c2, d1, d2, e1, e2, f1, f2 in zip(loop_vars): for interp_data in zip(*loop_vars): i, xxb, a, i1, i2, i12, j, nsm, c1, c2, d1, d2, e1, e2, f1, f2 = interp_data if xxb not in [0., 1.]: if a == 0.0: self.A[i] = self.A[-1] + self.A[0] * (1 - xxb) if i1 == 0.0: self.i1[i] = self.i1[-1] + self.i1[0] * (1 - xxb) if i2 == 0.0: self.i12[i] = self.i2[-1] + self.i2[0] * (1 - xxb) if j == 0.0: self.j[i] = self.j[-1] + self.j[0] * (1 - xxb) assert self.A[i] >= 0., self.A assert self.i1[i] >= 0., self.i1 assert self.i2[i] >= 0., self.i2 assert self.j[i] >= 0., self.j # we check warping later di12 = self.i1[i] * self.i2[i] - self.i12[i] ** 2 if not di12 > 0.: msg = 'I1 * I2 - I12^2=0 and must be greater than 0.0 at End B\n' msg += 'xxb=%s i1=%s i2=%s i12=%s i1*i2-i12^2=%s' % ( self.xxb[i], self.i1[i], self.i2[i], self.i12[i], di12) raise ValueError(msg) if nsm == 0.0: #print('iterpolating nsm; i=%s xxb=%s' % (i, xxb)) self.nsm[i] = self.nsm[-1] + self.nsm[0] * (1 - xxb) if c1 == 0.0: self.c1[i] = self.c1[-1] + self.c1[0] * (1 - xxb) if c2 == 0.0: self.c2[i] = self.c2[-1] + self.c2[0] * (1 - xxb) if d1 == 0.0: self.d1[i] = self.d1[-1] + self.d1[0] * (1 - xxb) if d2 == 0.0: self.d2[i] = self.d2[-1] + self.d2[0] * (1 - xxb) if e1 == 0.0: self.e1[i] = self.e1[-1] + self.e1[0] * (1 - xxb) if e2 == 0.0: self.e2[i] = self.e2[-1] + self.e2[0] * (1 - xxb) if f1 == 0.0: self.f1[i] = self.f1[-1] + self.f1[0] * (1 - xxb) if f2 == 0.0: self.f2[i] = self.f2[-1] + self.f2[0] * (1 - xxb) # calculate: # k1, k2, s1, s2 # m1a, m2a, n1a, n2a, etc. # footer fields #: Shear stiffness factor K in K*A*G for plane 1. self.k1 = double_or_blank(card, ifield, 'k1', 1.0) #: Shear stiffness factor K in K*A*G for plane 2. self.k2 = double_or_blank(card, ifield + 1, 'k2', 1.0) #: Shear relief coefficient due to taper for plane 1. self.s1 = double_or_blank(card, ifield + 2, 's1', 0.0) #: Shear relief coefficient due to taper for plane 2. self.s2 = double_or_blank(card, ifield + 3, 's2', 0.0) #: non structural mass moment of inertia per unit length #: about nsm center of gravity at Point A. self.nsia = double_or_blank(card, ifield + 4, 'nsia', 0.0) #: non structural mass moment of inertia per unit length #: about nsm center of gravity at Point B. self.nsib = double_or_blank(card, ifield + 5, 'nsib', self.nsia) #: warping coefficient for end A. self.cwa = double_or_blank(card, ifield + 6, 'cwa', 0.0) #: warping coefficient for end B. self.cwb = double_or_blank(card, ifield + 7, 'cwb', self.cwa) #: y coordinate of center of gravity of #: nonstructural mass for end A. self.m1a = double_or_blank(card, ifield + 8, 'm1a', 0.0) #: z coordinate of center of gravity of #: nonstructural mass for end A. self.m2a = double_or_blank(card, ifield + 9, 'm2a', self.m1a) #: y coordinate of center of gravity of #: nonstructural mass for end B. self.m1b = double_or_blank(card, ifield + 10, 'm1b', 0.0) #: z coordinate of center of gravity of #: nonstructural mass for end B. self.m2b = double_or_blank(card, ifield + 11, 'm2b', self.m1b) #: y coordinate of neutral axis for end A. self.n1a = double_or_blank(card, ifield + 12, 'n1a', 0.0) #: z coordinate of neutral axis for end A. self.n2a = double_or_blank(card, ifield + 13, 'n2a', self.n1a) #: y coordinate of neutral axis for end B. self.n1b = double_or_blank(card, ifield + 14, 'n1a', 0.0) #: z coordinate of neutral axis for end B. self.n2b = double_or_blank(card, ifield + 15, 'n2b', self.n1b) if self.cwa or self.cwb: # if either is non-zero for i, xxb, j in zip(count(), self.xxb, self.j): if self.j[i] > 0.: msg = 'Warping Check Error; j[%i] must be greater than 0.0' % i msg += ' cwa=%s cwb=%s\n' % (self.cwa, self.cwb) msg += ' i=%s xxb=%s j=%s; j[%i]=%s\n' % (i, xxb, self.j, i, j) raise ValueError(msg) ifield += 16 if len(card) > ifield: msg = 'len(card)=%s is too long; max=%s\n' % (len(card), ifield) msg += 'You probably have a empty line after the YESA/NO line.\n' msg += 'The next line must have K1.\n' msg += 'pid = %s\n' % self.pid msg += 'mid = %s\n' % self.mid msg += 's0 = %s\n' % self.so msg += 'xxb = %s\n' % self.xxb msg += 'A = %s\n' % self.A msg += 'i1 = %s\n' % self.i1 msg += 'i2 = %s\n' % self.i2 msg += 'i12 = %s\n' % self.i12 msg += 'j = %s\n' % self.j msg += 'nsm = %s\n\n' % self.nsm msg += 'c1 = %s\n' % self.c1 msg += 'c2 = %s\n' % self.c2 msg += 'd1 = %s\n' % self.d1 msg += 'd2 = %s\n' % self.d2 msg += 'e1 = %s\n' % self.e1 msg += 'e2 = %s\n' % self.e2 msg += 'f1 = %s\n' % self.f1 msg += 'f2 = %s\n\n' % self.f2 msg += 'k1 = %s\n' % self.k1 msg += 'k2 = %s\n' % self.k2 msg += 's1 = %s\n' % self.s1 msg += 's2 = %s\n' % self.s2 msg += 'nsia = %s\n' % self.nsia msg += 'nsib = %s\n\n' % self.nsib msg += 'cwa = %s\n' % self.cwa msg += 'cwb = %s\n' % self.cwb msg += 'm1a = %s\n' % self.m1a msg += 'm2a = %s\n' % self.m2a msg += 'mb1 = %s\n' % self.m1b msg += 'm2b = %s\n' % self.m2b msg += 'n1a = %s\n' % self.n1a msg += 'n2a = %s\n' % self.n2a msg += 'n1b = %s\n' % self.n1b msg += 'n2b = %s\n' % self.n2b raise RuntimeError(msg) else: raise NotImplementedError(data)
def add(self, card, comment=''): i = self.i eid = integer(card, 1, 'element_id') self.element_id[i] = eid self.property_id[i] = integer_or_blank(card, 2, 'property_id', eid) self.node_ids[i] = [integer(card, 3, 'GA'), integer(card, 4, 'GB')] #--------------------------------------------------------- # x / g0 field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0) if isinstance(field5, int): self.is_g0[i] = True self.g0[i] = field5 elif isinstance(field5, float): self.is_g0[i] = False x = array([field5, double_or_blank(card, 6, 'x2', 0.0), double_or_blank(card, 7, 'x3', 0.0)]) self.x[i, :] = x if norm(x) == 0.0: msg = 'G0 vector defining plane 1 is not defined on %s %s.\n' % (self.type, eid) msg += 'G0 = %s\n' % field5 msg += 'X = %s\n' % x msg += '%s' % card raise RuntimeError(msg) else: msg = ('field5 on %s (G0/X1) is the wrong type...id=%s field5=%s ' 'type=%s' % (self.type, self.eid, field5, type(field5))) raise RuntimeError(msg) #--------------------------------------------------------- # offt/bit field8 = double_string_or_blank(card, 8, 'offt/bit', 'GGG') if isinstance(field8, float): self.is_offt[i] = False self.bit[i] = field8 elif isinstance(field8, string_types): self.is_offt[i] = True offt = field8 msg = 'invalid offt parameter of CBEAM...offt=%s' % offt assert offt[0] in ['G', 'B', 'O', 'E'], msg assert offt[1] in ['G', 'B', 'O', 'E'], msg assert offt[2] in ['G', 'B', 'O', 'E'], msg self.offt[i] = offt else: msg = ('field8 on %s (offt/bit) is the wrong type...id=%s field5=%s ' 'type=%s' % (self.type, self.eid, field8, type(field8))) raise RuntimeError(msg) self.pin_flags[i, :] = [integer_or_blank(card, 9, 'pa', 0), integer_or_blank(card, 10, 'pb', 0)] self.wa[i, :] = [double_or_blank(card, 11, 'w1a', 0.0), double_or_blank(card, 12, 'w2a', 0.0), double_or_blank(card, 13, 'w3a', 0.0),] self.wb[i, :] = [double_or_blank(card, 14, 'w1b', 0.0), double_or_blank(card, 15, 'w2b', 0.0), double_or_blank(card, 16, 'w3b', 0.0),] self.sa[i] = integer_or_blank(card, 17, 'sa', 0) self.sb[i] = integer_or_blank(card, 18, 'sb', 0) assert len(card) <= 19, 'len(CBEAM card) = %i' % len(card) self.i += 1
def __init__(self, card=None, data=None, comment=''): """ .. todo:: fix 0th entry of self.so, self.xxb """ IntegratedLineProperty.__init__(self, card, data) if comment: self._comment = comment if card: #: Property ID self.pid = integer(card, 1, 'property_id') #: Material ID self.mid = integer(card, 2, 'material_id') # at least one cross section are required # so[0] and xxb[0] aren't used #: Output flag self.so = ['YES'] #: Section position self.xxb = [0.] A = double(card, 3, 'Area') #: Area self.A = [A] #: Moment of Inertia about the 1 axis :math:`I_1` self.i1 = [double_or_blank(card, 4, 'I1', 0.0)] #: Moment of Inertia about the 2 axis :math:`I_2` self.i2 = [double_or_blank(card, 5, 'I2', 0.0)] #: Moment of Inertia about the 12 axis :math:`I_{12}` self.i12 = [double_or_blank(card, 6, 'I12', 0.0)] #: Polar Moment of Inertia :math:`J` self.j = [double_or_blank(card, 7, 'J', 0.0)] #: Non-structural mass :math:`nsm` self.nsm = [double_or_blank(card, 8, 'nsm', 0.0)] assert self.A[0] >= 0., self.A assert self.i1[0] >= 0., self.i1 assert self.i2[0] >= 0., self.i2 is_cdef = False field9 = double_string_or_blank(card, 9, 'field9') field17 = double_string_or_blank(card, 17, 'field17') try: isinstance(field17, float) is_cdef = True is_footer = True except SyntaxError: pass #print("f9=%s f17=%s" % (field9, field17)) #nlines = nfields // 8 if field9 in ['YES', 'YESA', 'NO']: is_cdef = False is_continue = True elif field17 in ['YES', 'YESA', 'NO']: is_cdef = True is_continue = True else: is_continue = False is_cdef = True #if nlines == 2: # isCDEF = True #elif nlines == 3: # isCDEF = Tru #else: #print("isCDEF=%s isContinue=%s" % (isCDEF, isContinue)) #if isCDEF: self.c1 = [double_or_blank(card, 9, 'c1', 0.0)] self.c2 = [double_or_blank(card, 10, 'c2', 0.0)] self.d1 = [double_or_blank(card, 11, 'd1', 0.0)] self.d2 = [double_or_blank(card, 12, 'd2', 0.0)] self.e1 = [double_or_blank(card, 13, 'e1', 0.0)] self.e2 = [double_or_blank(card, 14, 'e2', 0.0)] self.f1 = [double_or_blank(card, 15, 'f1', 0.0)] self.f2 = [double_or_blank(card, 16, 'f2', 0.0)] #else: #msg = ('On PBEAM %s, only YES format is supported.\n' # 'All C, D, E, and F fields must be specified.'% self.pid) #raise RuntimeError(msg) #self.c1 = [None] #self.c2 = [None] #self.d1 = [None] #self.d2 = [None] #self.e1 = [None] #self.e2 = [None] #self.f1 = [None] #self.f2 = [None] # ---------------------------------------------------------------- # figure out how many YES/YESA/NO fields there are # and if there is a footer # counting continuation cards nfields = len(card) - 1 # -1 for PBEAM field if is_cdef: nmajor = nfields // 16 nleftover = nfields % 16 if nleftover == 0: nmajor -= 1 if nmajor == 0: nmajor = 1 # jump to the last block of 16 x = nmajor * 16 + 1 # If it's an SO field, we don't read the footer # remark 6: # The fourth and fifth continuation entries, which # contain fields K1 through N2(B), are optional # and may be omitted if the default values are appropriate. val = integer_double_string_or_blank(card, x, 'YES/YESA/NO') if val in ['YES', 'YESA', 'NO']: # there is no footer nmajor += 1 x += 16 else: # read the footer pass else: nmajor = nfields // 8 nleftover = nfields % 8 if nleftover == 0: nmajor -= 1 if nmajor == 0: nmajor = 1 x = nmajor * 8 + 1 val = integer_double_string_or_blank(card, x, 'YES/YESA/NO') if val in ['YES', 'YESA', 'NO']: # there is no footer nmajor += 1 x += 8 else: # read the footer pass # ---------------------------------------------------------------- for nrepeated in range(1, nmajor): # start at 1 to drop the header #print(" adding a major") # field 17 is the first possible so if is_cdef: nstart = nrepeated * 16 + 1 else: nstart = nrepeated * 8 + 1 #propFields = [] #n = 1 so = string(card, nstart, 'SO%i' % nrepeated) xxb = double(card, nstart + 1, 'x/xb%i' % nrepeated) A = double_or_blank(card, nstart + 2, 'Area%i' % nrepeated, 0.0) i1 = double_or_blank(card, nstart + 3, 'I1 %i' % nrepeated, 0.0) i2 = double_or_blank(card, nstart + 4, 'I2 %i' % nrepeated, 0.0) i12 = double_or_blank(card, nstart + 5, 'I12 %i' % nrepeated, 0.0) j = double_or_blank(card, nstart + 6, 'J%i' % nrepeated, 0.0) nsm = double_or_blank(card, nstart + 7, 'nsm%i' % nrepeated, 0.0) self.so.append(so) self.xxb.append(xxb) self.A.append(A) self.i1.append(i1) self.i2.append(i2) self.i12.append(i12) self.j.append(j) self.nsm.append(nsm) if is_cdef: c1 = double_or_blank(card, nstart + 8, 'c1 %i' % nrepeated, 0.0) c2 = double_or_blank(card, nstart + 9, 'c2 %i' % nrepeated, 0.0) d1 = double_or_blank(card, nstart + 10, 'd1 %i' % nrepeated, 0.0) d2 = double_or_blank(card, nstart + 11, 'd2 %i' % nrepeated, 0.0) e1 = double_or_blank(card, nstart + 12, 'e1 %i' % nrepeated, 0.0) e2 = double_or_blank(card, nstart + 13, 'e2 %i' % nrepeated, 0.0) f1 = double_or_blank(card, nstart + 14, 'f1 %i' % nrepeated, 0.0) f2 = double_or_blank(card, nstart + 15, 'f2 %i' % nrepeated, 0.0) self.c1.append(c1) self.c2.append(c2) self.d1.append(d1) self.d2.append(d2) self.e1.append(e1) self.e2.append(e2) self.f1.append(f1) self.f2.append(f2) else: # YESA or NO, values MUST be omitted; remark 5 self.c1.append(None) self.c2.append(None) self.d1.append(None) self.d2.append(None) self.e1.append(None) self.e2.append(None) self.f1.append(None) self.f2.append(None) if len(self.xxb) > 1: assert min( self.xxb) == 0.0, 'min=%s, but should be 0.0\nxxb=%s' % ( min(self.xxb), self.xxb) assert max( self.xxb) == 1.0, 'max=%s, but should be 1.0\nxxb=%s' % ( max(self.xxb), self.xxb) # footer fields #: Shear stiffness factor K in K*A*G for plane 1. self.k1 = double_or_blank(card, x, 'k1', 1.0) #: Shear stiffness factor K in K*A*G for plane 2. self.k2 = double_or_blank(card, x + 1, 'k2', 1.0) #: Shear relief coefficient due to taper for plane 1. self.s1 = double_or_blank(card, x + 2, 's1', 0.0) #: Shear relief coefficient due to taper for plane 2. self.s2 = double_or_blank(card, x + 3, 's2', 0.0) #: non structural mass moment of inertia per unit length #: about nsm center of gravity at Point A. self.nsia = double_or_blank(card, x + 4, 'nsia', 0.0) #: non structural mass moment of inertia per unit length #: about nsm center of gravity at Point B. self.nsib = double_or_blank(card, x + 5, 'nsib', self.nsia) #: warping coefficient for end A. self.cwa = double_or_blank(card, x + 6, 'cwa', 0.0) #: warping coefficient for end B. self.cwb = double_or_blank(card, x + 7, 'cwb', self.cwa) #: y coordinate of center of gravity of #: nonstructural mass for end A. self.m1a = double_or_blank(card, x + 8, 'm1a', 0.0) #: z coordinate of center of gravity of #: nonstructural mass for end A. self.m2a = double_or_blank(card, x + 9, 'm2a', self.m1a) #: y coordinate of center of gravity of #: nonstructural mass for end B. self.m1b = double_or_blank(card, x + 10, 'm1b', 0.0) #: z coordinate of center of gravity of #: nonstructural mass for end B. self.m2b = double_or_blank(card, x + 11, 'm2b', self.m1b) #: y coordinate of neutral axis for end A. self.n1a = double_or_blank(card, x + 12, 'n1a', 0.0) #: z coordinate of neutral axis for end A. self.n2a = double_or_blank(card, x + 13, 'n2a', self.n1a) #: y coordinate of neutral axis for end B. self.n1b = double_or_blank(card, x + 14, 'n1a', 0.0) #: z coordinate of neutral axis for end B. self.n2b = double_or_blank(card, x + 15, 'n2b', self.n1b) else: raise NotImplementedError(data)
def add(self, card, comment=''): i = self.i eid = integer(card, 1, 'element_id') self.element_id[i] = eid self.property_id[i] = integer_or_blank(card, 2, 'property_id', eid) self.node_ids[i] = [integer(card, 3, 'GA'), integer(card, 4, 'GB')] #--------------------------------------------------------- # x / g0 field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0) if isinstance(field5, int): self.is_g0[i] = True self.g0[i] = field5 elif isinstance(field5, float): self.is_g0[i] = False x = array([ field5, double_or_blank(card, 6, 'x2', 0.0), double_or_blank(card, 7, 'x3', 0.0) ]) self.x[i, :] = x if norm(x) == 0.0: msg = 'G0 vector defining plane 1 is not defined on %s %s.\n' % ( self.type, eid) msg += 'G0 = %s\n' % field5 msg += 'X = %s\n' % x msg += '%s' % card raise RuntimeError(msg) else: msg = ('field5 on %s (G0/X1) is the wrong type...id=%s field5=%s ' 'type=%s' % (self.type, self.eid, field5, type(field5))) raise RuntimeError(msg) #--------------------------------------------------------- # offt/bit field8 = double_string_or_blank(card, 8, 'offt/bit', 'GGG') if isinstance(field8, float): self.is_offt[i] = False self.bit[i] = field8 elif isinstance(field8, string_types): self.is_offt[i] = True offt = field8 msg = 'invalid offt parameter of CBEAM...offt=%s' % offt assert offt[0] in ['G', 'B', 'O', 'E'], msg assert offt[1] in ['G', 'B', 'O', 'E'], msg assert offt[2] in ['G', 'B', 'O', 'E'], msg self.offt[i] = offt else: msg = ( 'field8 on %s (offt/bit) is the wrong type...id=%s field5=%s ' 'type=%s' % (self.type, self.eid, field8, type(field8))) raise RuntimeError(msg) self.pin_flags[i, :] = [ integer_or_blank(card, 9, 'pa', 0), integer_or_blank(card, 10, 'pb', 0) ] self.wa[i, :] = [ double_or_blank(card, 11, 'w1a', 0.0), double_or_blank(card, 12, 'w2a', 0.0), double_or_blank(card, 13, 'w3a', 0.0), ] self.wb[i, :] = [ double_or_blank(card, 14, 'w1b', 0.0), double_or_blank(card, 15, 'w2b', 0.0), double_or_blank(card, 16, 'w3b', 0.0), ] self.sa[i] = integer_or_blank(card, 17, 'sa', 0) self.sb[i] = integer_or_blank(card, 18, 'sb', 0) assert len(card) <= 19, 'len(CBEAM card) = %i' % len(card) self.i += 1
def add_card(self, card, i): #: property ID self.property_id[i] = integer(card, 1, 'property_id') #: material ID self.material_id[i] = integer(card, 2, 'material_id') SO = [] XXB = [] A = [] I1 = [] I2 = [] I12 = [] J = [] NSM = [] # at least one cross section are required # so[0] and xxb[0] aren't used #: Output flag SO = ['YES'] #: Section position XXB = [0.] A.append(double(card, 3, 'A')) I1.append(double_or_blank(card, 4, 'I1', 0.0)) I2.append(double_or_blank(card, 5, 'I2', 0.0)) I12.append(double_or_blank(card, 6, 'I12', 0.0)) J.append(double_or_blank(card, 7, 'J', 0.0)) NSM.append(double_or_blank(card, 8, 'nsm', 0.0)) print(card) assert I1[0] > 0, I1[0] assert I2[0] > 0, I2[0] isCDEF = False field9 = double_string_or_blank(card, 9, 'field9') field17 = double_string_or_blank(card, 17, 'field17') try: isinstance(field17, float) isCDEF = True isFooter = True except SyntaxError: pass #print("f9=%s f17=%s" % (field9, field17)) #nlines = nfields // 8 if field9 in ['YES', 'YESA', 'NO']: isCDEF = False isContinue = True elif field17 in ['YES', 'YESA', 'NO']: isCDEF = True isContinue = True else: isContinue = False isCDEF = True C1 = [double_or_blank(card, 9, 'c1', 0.0)] C2 = [double_or_blank(card, 10, 'c2', 0.0)] D1 = [double_or_blank(card, 11, 'd1', 0.0)] D2 = [double_or_blank(card, 12, 'd2', 0.0)] E1 = [double_or_blank(card, 13, 'e1', 0.0)] E2 = [double_or_blank(card, 14, 'e2', 0.0)] F1 = [double_or_blank(card, 15, 'f1', 0.0)] F2 = [double_or_blank(card, 16, 'f2', 0.0)] # ---------------------------------------------------------------- # figure out how many YES/YESA/NO fields there are # and if there is a footer # counting continuation cards nfields = len(card) - 1 # -1 for PBEAM field if isCDEF: nmajor = nfields // 16 nleftover = nfields % 16 if nleftover == 0: nmajor -= 1 if nmajor == 0: nmajor = 1 # jump to the last block of 16 x = nmajor * 16 + 1 # If it's an SO field, we don't read the footer # remark 6: # The fourth and fifth continuation entries, which # contain fields K1 through N2(B), are optional # and may be omitted if the default values are appropriate. val = integer_double_string_or_blank(card, x, 'YES/YESA/NO') if val in ['YES', 'YESA', 'NO']: # there is no footer nmajor += 1 x += 16 else: # read the footer pass else: nmajor = nfields // 8 nleftover = nfields % 8 if nleftover == 0: nmajor -= 1 if nmajor == 0: nmajor = 1 x = nmajor * 8 + 1 val = integer_double_string_or_blank(card, x, 'YES/YESA/NO') if val in ['YES', 'YESA', 'NO']: # there is no footer nmajor += 1 x += 8 else: # read the footer pass # ---------------------------------------------------------------- for nRepeated in xrange(1, nmajor): # start at 1 to drop the header # field 17 is the first possible so if isCDEF: nStart = nRepeated * 16 + 1 else: nStart = nRepeated * 8 + 1 so = string(card, nStart, 'SO%i' % nRepeated) xxb = double(card, nStart + 1, 'x/xb%i' % nRepeated) a = double_or_blank(card, nStart + 2, 'Area%i' % nRepeated, 0.0) i1 = double_or_blank(card, nStart + 3, 'I1 %i' % nRepeated, 0.0) i2 = double_or_blank(card, nStart + 4, 'I2 %i' % nRepeated, 0.0) i12 = double_or_blank(card, nStart + 5, 'I12 %i' % nRepeated, 0.0) j = double_or_blank(card, nStart + 6, 'J%i' % nRepeated, 0.0) nsm = double_or_blank(card, nStart + 7, 'nsm%i' % nRepeated, 0.0) SO.append(so) XXB.append(xxb) A.append(a) I1.append(i1) I2.append(i2) I12.append(i12) J.append(j) NSM.append(nsm) if isCDEF: c1 = double_or_blank(card, nStart + 8, 'c1 %i' % nRepeated, 0.0) c2 = double_or_blank(card, nStart + 9, 'c2 %i' % nRepeated, 0.0) d1 = double_or_blank(card, nStart + 10, 'd1 %i' % nRepeated, 0.0) d2 = double_or_blank(card, nStart + 11, 'd2 %i' % nRepeated, 0.0) e1 = double_or_blank(card, nStart + 12, 'e1 %i' % nRepeated, 0.0) e2 = double_or_blank(card, nStart + 13, 'e2 %i' % nRepeated, 0.0) f1 = double_or_blank(card, nStart + 14, 'f1 %i' % nRepeated, 0.0) f2 = double_or_blank(card, nStart + 15, 'f2 %i' % nRepeated, 0.0) C1.append(c1) C2.append(c2) D1.append(d1) D2.append(d2) E1.append(e1) E2.append(e2) F1.append(f1) F2.append(f2) else: # YESA or NO, values MUST be omitted; remark 5 C1.append(None) C2.append(None) D1.append(None) D2.append(None) E1.append(None) E2.append(None) F1.append(None) F2.append(None) if len(XXB) > 1: assert min(XXB) == 0.0, 'min=%s, but should be 0.0\nxxb=%s' % (min(XXB), XXB) assert max(XXB) == 1.0, 'max=%s, but should be 1.0\nxxb=%s' % (max(XXB), XXB) # footer fields #: Shear stiffness factor K in K*A*G for plane 1. self.k1[i] = double_or_blank(card, x, 'k1', 1.0) #: Shear stiffness factor K in K*A*G for plane 2. self.k2[i] = double_or_blank(card, x + 1, 'k2', 1.0) #: Shear relief coefficient due to taper for plane 1. self.s1[i] = double_or_blank(card, x + 2, 's1', 0.0) #: Shear relief coefficient due to taper for plane 2. self.s2[i] = double_or_blank(card, x + 3, 's2', 0.0) #: non structural mass moment of inertia per unit length #: about nsm center of gravity at Point A. self.nsia[i] = double_or_blank(card, x + 4, 'nsia', 0.0) #: non structural mass moment of inertia per unit length #: about nsm center of gravity at Point B. self.nsib[i] = double_or_blank(card, x + 5, 'nsib', self.nsia) #: warping coefficient for end A. self.cwa[i] = double_or_blank(card, x + 6, 'cwa', 0.0) #: warping coefficient for end B. self.cwb[i] = double_or_blank(card, x + 7, 'cwb', self.cwa) #: y coordinate of center of gravity of #: nonstructural mass for end A. self.m1a[i] = double_or_blank(card, x + 8, 'm1a', 0.0) #: z coordinate of center of gravity of #: nonstructural mass for end A. self.m2a[i] = double_or_blank(card, x + 9, 'm2a', self.m1a) #: y coordinate of center of gravity of #: nonstructural mass for end B. self.m1b[i] = double_or_blank(card, x + 10, 'm1b', 0.0) #: z coordinate of center of gravity of #: nonstructural mass for end B. self.m2b[i] = double_or_blank(card, x + 11, 'm2b', self.m1b) #: y coordinate of neutral axis for end A. self.n1a[i] = double_or_blank(card, x + 12, 'n1a', 0.0) #: z coordinate of neutral axis for end A. self.n2a[i] = double_or_blank(card, x + 13, 'n2a', self.n1a) #: y coordinate of neutral axis for end B. self.n1b[i] = double_or_blank(card, x + 14, 'n1a', 0.0) #: z coordinate of neutral axis for end B. self.n2b[i] = double_or_blank(card, x + 15, 'n2b', self.n1b)