def add_card(cls, card, comment=''): #: Property ID pid = integer(card, 1, 'pid') #: Material ID mid1 = integer_or_blank(card, 2, 'mid1', 0) t1 = double_or_blank(card, 3, 't1') mid2 = integer_or_blank(card, 4, 'mid2', 0) if mid2 > 0: i = double(card, 5, 'i') assert i > 0.0 else: i = blank(card, 5, 'i') mid3 = integer(card, 6, 0) if mid3 > 0: t2 = double(card, 7, 't3') assert t2 > 0.0 else: t2 = blank(card, 7, 't3') nsm = double(card, 8, 'nsm') z1 = double(card, 9, 'z1') z2 = double(card, 10, 'z2') j = 1 phi = [] for i in range(11, len(card)): phii = double(card, i, 'phi' % j) phi.append(phii) j += 1 return PCONEAX(pid, mid1, t1, mid2, i, mid3, t2, nsm, z1, z2, phi, comment=comment)
def add_card(cls, card, comment=''): sid = integer(card, 1, 'sid') method = string_or_blank(card, 2, 'method', 'LAN') f1 = double_or_blank(card, 3, 'f1') f2 = double_or_blank(card, 4, 'f2') ne = integer_or_blank(card, 5, 'ne') if method not in cls.allowed_methods: msg = 'method=%s; allowed_methods=[%s]' % (method, ', '.join( cls.allowed_methods)) raise ValueError(msg) if method == 'SINV': nd = integer_or_blank(card, 6, 'nd', 600) elif method == 'INV': nd = integer_or_blank(card, 6, 'nd', 3 * ne) elif method in ['GIV', 'MGIV', 'HOU', 'MHOU']: nd = integer_or_blank(card, 6, 'nd', 0) else: nd = integer(card, 6, 'nd') norm = string_or_blank(card, 9, 'norm', 'MASS') if method == 'POINT': G = integer(card, 10, 'G') C = components(card, 11, 'C') else: G = blank(card, 10, 'G') C = blank(card, 11, 'C') assert len(card) <= 12, 'len(EIGR card) = %i\ncard=%s' % (len(card), card) return EIGR(sid, method, f1, f2, ne, nd, norm, G, C, comment=comment)
def add_card(cls, card, comment=''): """ Adds a NLPCI card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ nlpci_id = integer(card, 1, 'nlpci_id') Type = string_or_blank(card, 2, 'Type', 'CRIS') minalr = double_or_blank(card, 3, 'minalr', 0.25) maxalr = double_or_blank(card, 4, 'maxalr', 4.0) scale = double_or_blank(card, 5, 'scale', 0.0) blank(card, 6, 'blank') desiter = integer_or_blank(card, 7, 'desiter', 12) mxinc = integer_or_blank(card, 8, 'mxinc', 20) return NLPCI(nlpci_id, Type=Type, minalr=minalr, maxalr=maxalr, scale=scale, desiter=desiter, mxinc=mxinc, comment=comment)
def add_card(cls, card, comment=''): sid = integer(card, 1, 'sid') method = string_or_blank(card, 2, 'method', 'LAN') f1 = double_or_blank(card, 3, 'f1') f2 = double_or_blank(card, 4, 'f2') ne = integer_or_blank(card, 5, 'ne') if method not in cls.allowed_methods: msg = 'method=%s; allowed_methods=[%s]' % ( method, ', '.join(cls.allowed_methods)) raise ValueError(msg) if method == 'SINV': nd = integer_or_blank(card, 6, 'nd', 600) if method == 'INV': nd = integer_or_blank(card, 6, 'nd', 3 * ne) elif method in ['GIV', 'MGIV', 'HOU', 'MHOU']: nd = integer_or_blank(card, 6, 'nd', 0) else: nd = integer(card, 6, 'nd') norm = string_or_blank(card, 9, 'norm', 'MASS') if method == 'POINT': G = integer(card, 10, 'G') C = components(card, 11, 'C') else: G = blank(card, 10, 'G') C = blank(card, 11, 'C') assert len(card) <= 12, 'len(EIGR card) = %i\ncard=%s' % (len(card), card) return EIGR(sid, method, f1, f2, ne, nd, norm, G, C, comment=comment)
def add_card(cls, card, comment=''): """ Adds a PQUAD1 card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ #| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | #|--------|-------|-------|-------|-------|-------|-------|-------|-------|-----| #|PQUAD1 | PID | MID1 | T1 | MID2 | I | MID3 | T3 | NSM |abc | #|+bc | Z1 | Z2 | | | | | | | | #|PQUAD1 | 32 | 16 | 2.98 | 9 | 6.45 | 16 | 5.29 | 6.32 |WXYZ1| #|+XYZ1 | 0.09 | -0.06 | | | | | | | | pid = integer(card, 1, 'pid') mid1 = blank(card, 2, 'mid1') t_membrane = blank(card, 3, 't_membrane') mid2 = integer(card, 4, 'mid2') inertia = double(card, 5, 'inertia') # poor name mid3 = blank(card, 6, 'mid3') t_shear = blank(card, 7, 't_shear') nsm = double(card, 8, 'nsm') if t_membrane is not None: t_over_2 = t_membrane / 2. z1 = double_or_blank(card, 9, 'z1', -t_over_2) z2 = double_or_blank(card, 10, 'z2', t_over_2) else: z1 = double_or_blank(card, 9, 'z1') z2 = double_or_blank(card, 10, 'z2') #if self.mid2 is None: # assert self.mid3 is None #else: # mid2 is defined # #print (self.mid2 = ", self.mid2) # assert self.mid2 >= -1 # #assert self.mid3 > 0 assert len( card) <= 11, f'len(PQUAD1 card) = {len(card):d}\ncard={card}' return PQUAD1(pid, mid1, t_membrane, mid2, inertia=inertia, mid3=mid3, t_shear=t_shear, nsm=nsm, z1=z1, z2=z2, comment=comment)
def add_card(cls, card, comment=''): nlpci_id = integer(card, 1, 'nlpci_id') Type = string_or_blank(card, 2, 'Type', 'CRIS') minalr = double_or_blank(card, 3, 'minalr', 0.25) maxalr = double_or_blank(card, 4, 'maxalr', 4.0) scale = double_or_blank(card, 5, 'scale', 0.0) blank(card, 6, 'blank') desiter = integer_or_blank(card, 7, 'desiter', 12) mxinc = integer_or_blank(card, 8, 'mxinc', 20) return NLPCI(nlpci_id, Type, minalr, maxalr, scale, desiter, mxinc, comment=comment)
def add_card(self, card=None, comment=''): if comment: self.set_comment(mid, comment) i = self.i #: Identification number of a MAT1, MAT2, or MAT9 entry. self.material_id[i] = integer(card, 1, 'mid') #: Identification number of a TABLES1 or TABLEST entry. If H is #: given, then this field must be blank. self.table_id[i] = integer_or_blank(card, 2, 'tid', 0) #: Type of material nonlinearity. ('NLELAST' for nonlinear elastic #: or 'PLASTIC' for elastoplastic.) self.Type[i] = string(card, 3, 'Type') if self.Type[i] == 'NLELAST': self.h[i] = blank(card, 4, 'h') self.hr[i] = blank(card, 6, 'hr') self.yf[i] = blank(card, 5, 'yf') self.limit1[i] = blank(card, 7, 'yf') self.limit2[i] = blank(card, 8, 'yf') else: #: Work hardening slope (slope of stress versus plastic strain) in #: units of stress. For elastic-perfectly plastic cases, H=0.0. #: For more than a single slope in the plastic range, the #: stress-strain data must be supplied on a TABLES1 entry #: referenced by TID, and this field must be blank h = double_or_blank(card, 4, 'H') self.h[i] = h if h is None: self.hflag[i] = False else: self.hflag[i] = True #: Yield function criterion, selected by one of the following #: values (1) Von Mises (2) Tresca (3) Mohr-Coulomb #: (4) Drucker-Prager self.yf[i] = integer_or_blank(card, 5, 'yf', 1) #: Hardening Rule, selected by one of the following values #: (Integer): (1) Isotropic (Default) (2) Kinematic #: (3) Combined isotropic and kinematic hardening self.hr[i] = integer_or_blank(card, 6, 'hr', 1) #: Initial yield point self.limit1[i] = double(card, 7, 'limit1') if self.yf[i] == 3 or self.yf[i] == 4: #: Internal friction angle, measured in degrees, for the #: Mohr-Coulomb and Drucker-Prager yield criteria self.limit2[i] = double(card, 8, 'limit2') else: #self.limit2[i] = blank(card, 8, 'limit2') #self.limit2[i] = None pass assert len(card) <= 9, 'len(MATS1 card) = %i\ncard=%s' % (len(card), card) self.i += 1
def add(self, card=None, comment=''): if comment: self._comment = comment i = self.i #: Identification number of a MAT1, MAT2, or MAT9 entry. self.material_id[i] = integer(card, 1, 'mid') #: Identification number of a TABLES1 or TABLEST entry. If H is #: given, then this field must be blank. self.table_id[i] = integer_or_blank(card, 2, 'tid', 0) #: Type of material nonlinearity. ('NLELAST' for nonlinear elastic #: or 'PLASTIC' for elastoplastic.) self.Type[i] = string(card, 3, 'Type') if self.Type[i] == 'NLELAST': self.h[i] = blank(card, 4, 'h') self.hr[i] = blank(card, 6, 'hr') self.yf[i] = blank(card, 5, 'yf') self.limit1[i] = blank(card, 7, 'yf') self.limit2[i] = blank(card, 8, 'yf') else: #: Work hardening slope (slope of stress versus plastic strain) in #: units of stress. For elastic-perfectly plastic cases, H=0.0. #: For more than a single slope in the plastic range, the #: stress-strain data must be supplied on a TABLES1 entry #: referenced by TID, and this field must be blank h = double_or_blank(card, 4, 'H') self.h[i] = h if h is None: self.hflag[i] = False else: self.hflag[i] = True #: Yield function criterion, selected by one of the following #: values (1) Von Mises (2) Tresca (3) Mohr-Coulomb #: (4) Drucker-Prager self.yf[i] = integer_or_blank(card, 5, 'yf', 1) #: Hardening Rule, selected by one of the following values #: (Integer): (1) Isotropic (Default) (2) Kinematic #: (3) Combined isotropic and kinematic hardening self.hr[i] = integer_or_blank(card, 6, 'hr', 1) #: Initial yield point self.limit1[i] = double(card, 7, 'limit1') if self.yf[i] == 3 or self.yf[i] == 4: #: Internal friction angle, measured in degrees, for the #: Mohr-Coulomb and Drucker-Prager yield criteria self.limit2[i] = double(card, 8, 'limit2') else: #self.limit2[i] = blank(card, 8, 'limit2') #self.limit2[i] = None pass assert len(card) <= 9, 'len(MATS1 card) = %i\ncard=%s' % (len(card), card) self.i += 1
def add_card(self, card=None, comment=''): if comment: self.comment = comment self.nlpci_id = integer(card, 1, 'nlparm_id') self.Type = string_or_blank(card, 2, 'Type', 'CRIS') self.minalr = double_or_blank(card, 3, 'minalr', 0.25) self.maxalr = double_or_blank(card, 4, 'maxalr', 4.0) self.scale = double_or_blank(card, 5, 'scale', 0.0) blank(card, 6, 'blank') self.desiter = double_or_blank(card, 7, 'minalr', 12) self.mxinc = integer_or_blank(card, 8, 'minalr', 20)
def add_card(cls, card, comment=''): """ Adds a PCONEAX card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ #: Property ID pid = integer(card, 1, 'pid') #: Material ID mid1 = integer_or_blank(card, 2, 'mid1', 0) t1 = double_or_blank(card, 3, 't1') mid2 = integer_or_blank(card, 4, 'mid2', 0) if mid2 > 0: i = double(card, 5, 'i') assert i > 0.0 else: i = blank(card, 5, 'i') mid3 = integer_or_blank(card, 6, 'mid3', 0) if mid3 > 0: t2 = double(card, 7, 't3') assert t2 > 0.0 else: t2 = blank(card, 7, 't3') nsm = double_or_blank(card, 8, 'nsm', 0.0) z1 = double_or_blank(card, 9, 'z1', None) z2 = double_or_blank(card, 10, 'z2', None) j = 1 phi = [] for icard in range(11, len(card)): phii = double(card, icard, 'phi%i' % icard) phi.append(phii) j += 1 return PCONEAX(pid, mid1, t1, mid2, i, mid3, t2, nsm, z1, z2, phi, comment=comment)
def __init__(self, card=None, data=None, comment=''): if comment: self._comment = comment self.nlpci_id = integer(card, 1, 'nlpci_id') self.Type = string_or_blank(card, 2, 'Type', 'CRIS') self.minalr = double_or_blank(card, 3, 'minalr', 0.25) self.maxalr = double_or_blank(card, 4, 'maxalr', 4.0) self.scale = double_or_blank(card, 5, 'scale', 0.0) blank(card, 6, 'blank') self.desiter = integer_or_blank(card, 7, 'desiter', 12) self.mxinc = integer_or_blank(card, 8, 'mxinc', 20)
def __init__(self, card=None, data=None, comment=''): """ Creates the POINT card :param card: a BDFCard object :type card: BDFCard :param data: a list with the POINT fields defined in OP2 format :type data: LIST :param comment: a comment for the card :type comment: string """ if comment: self._comment = comment Node.__init__(self, card, data) if card: #: Node ID self.nid = integer(card, 1, 'nid') #: Grid point coordinate system self.cp = integer_or_blank(card, 2, 'cp', 0) #: node location in local frame self.xyz = np.array([ double_or_blank(card, 3, 'x1', 0.), double_or_blank(card, 4, 'x2', 0.), double_or_blank(card, 5, 'x3', 0.)], dtype='float64') #: Analysis coordinate system self.cd = blank(card, 6, 'cd', 0) #: SPC constraint self.ps = blank(card, 7, 'ps', '') #: Superelement ID self.seid = blank(card, 8, 'seid', 0) assert len(card) <= 9, 'len(POINT card) = %i' % len(card) else: self.nid = data[0] self.cp = data[1] self.xyz = np.array(data[2:5]) assert len(self.xyz) == 3 self.ps = '' self.seid = 0 self.cd = 0 assert self.nid > 0, 'nid=%s' % (self.nid) assert self.cp >= 0, 'cp=%s' % (self.cp)
def add_card(cls, card, comment=''): """ Adds a GRDSET card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ #: Grid point coordinate system blank(card, 1, 'blank') cp = integer_or_blank(card, 2, 'cp', 0) blank(card, 3, 'blank') blank(card, 4, 'blank') blank(card, 5, 'blank') cd = integer_or_blank(card, 6, 'cd', 0) ps = str(integer_or_blank(card, 7, 'ps', '')) seid = integer_or_blank(card, 8, 'seid', 0) assert len(card) <= 9, 'len(GRDSET card) = %i\ncard=%s' % (len(card), card) return GRDSET(cp, cd, ps, seid, comment=comment)
def __init__(self, card=None, data=None, comment=''): Method.__init__(self, card, data) if comment: self._comment = comment if card: #: Set identification number. (Unique Integer > 0) self.sid = integer(card, 1, 'sid') #: Method of eigenvalue extraction. (Character: 'INV' for inverse #: power method or 'SINV' for enhanced inverse power method.) self.method = string_or_blank(card, 2, 'method', 'LAN') assert self.method in ['LAN', 'AHOU', 'INV', 'SINV', 'GIV', 'MGIV', 'HOU', 'MHOU', 'AGIV'], 'method=%s' % self.method #: Frequency range of interest self.f1 = double_or_blank(card, 3, 'f1') self.f2 = double_or_blank(card, 4, 'f2') #: Estimate of number of roots in range (Required for #: METHOD = 'INV'). Not used by 'SINV' method. self.ne = integer_or_blank(card, 5, 'ne') #: Desired number of roots (default=600 for SINV 3*ne for INV) if self.method in ['SINV']: self.nd = integer_or_blank(card, 6, 'nd', 600) if self.method in ['INV']: self.nd = integer_or_blank(card, 6, 'nd', 3 * self.ne) elif self.method in ['GIV', 'MGIV', 'HOU', 'MHOU']: self.nd = integer_or_blank(card, 6, 'nd', 0) else: self.nd = integer(card, 6, 'nd') #: Method for normalizing eigenvectors. ('MAX' or 'POINT'; #: Default='MAX') self.norm = string_or_blank(card, 9, 'norm', 'MASS') assert self.norm in ['POINT', 'MASS', 'MAX'] if self.method == 'POINT': #: Grid or scalar point identification number. Required only if #: NORM='POINT'. (Integer>0) self.G = integer(card, 10, 'G') #: Component number. Required only if NORM='POINT' and G is a #: geometric grid point. (1<Integer<6) self.C = components(card, 11, 'C') else: self.G = blank(card, 10, 'G') self.C = blank(card, 11, 'C') assert len(card) <= 12, 'len(EIGR card) = %i' % len(card) else: raise NotImplementedError('EIGR')
def __init__(self, card=None, data=None, comment=''): ThermalElement.__init__(self, card) if comment: self._comment = comment if card: #: Surface element ID self.eid = integer(card, 1, 'eid') #: PHBDY property entry identification numbers. (Integer > 0) self.pid = integer(card, 2, 'pid') assert self.pid > 0 self.Type = string(card, 3, 'Type') #print("self.Type = %s" % self.Type) # msg = 'CHBDYP Type=%r' % self.Type #assert self.Type in ['POINT','LINE','ELCYL','FTUBE','TUBE'], msg #: A VIEW entry identification number for the front face. self.iViewFront = integer_or_blank(card, 4, 'iViewFront', 0) #: A VIEW entry identification number for the back face. self.iViewBack = integer_or_blank(card, 5, 'iViewBack', 0) #: Grid point identification numbers of grids bounding the surface. #: (Integer > 0) self.g1 = integer(card, 6, 'g1') #: Grid point identification numbers of grids bounding the surface. #: (Integer > 0) if self.Type != 'POINT': self.g2 = integer(card, 7, 'g2') else: self.g2 = blank(card, 7, 'g2') #: Orientation grid point. (Integer > 0; Default = 0) self.g0 = integer_or_blank(card, 8, 'g0', 0) #: RADM identification number for front face of surface element. #: (Integer > 0) self.radMidFront = integer_or_blank(card, 9, 'radMidFront', 0) #: RADM identification number for back face of surface element. #: (Integer > 0) self.radMidBack = integer_or_blank(card, 10, 'radMidBack', 0) #: Grid point identification number of a midside node if it is used #: with the line type surface element. self.gmid = integer_or_blank(card, 11, 'gmid') #: Coordinate system for defining orientation vector. #: (Integer > 0; Default = 0 self.ce = integer_or_blank(card, 12, 'ce', 0) #: Components of the orientation vector in coordinate system CE. #: The origin of the orientation vector is grid point G1. #: (Real or blank) self.e1 = double_or_blank(card, 13, 'e3') self.e2 = double_or_blank(card, 14, 'e3') self.e3 = double_or_blank(card, 15, 'e3') assert len(card) <= 16, 'len(CHBDYP card) = %i' % len(card) else: raise NotImplementedError(data)
def add_card(cls, card, comment=''): eid = integer(card, 1, 'eid') pid = integer(card, 2, 'pid') Type = string(card, 3, 'Type') #print("self.Type = %s" % self.Type) # msg = 'CHBDYP Type=%r' % self.Type #assert self.Type in ['POINT','LINE','ELCYL','FTUBE','TUBE'], msg iViewFront = integer_or_blank(card, 4, 'iViewFront', 0) iViewBack = integer_or_blank(card, 5, 'iViewBack', 0) g1 = integer(card, 6, 'g1') if Type != 'POINT': g2 = integer(card, 7, 'g2') else: g2 = blank(card, 7, 'g2') g0 = integer_or_blank(card, 8, 'g0', 0) radMidFront = integer_or_blank(card, 9, 'radMidFront', 0) radMidBack = integer_or_blank(card, 10, 'radMidBack', 0) gmid = integer_or_blank(card, 11, 'gmid') ce = integer_or_blank(card, 12, 'ce', 0) e1 = double_or_blank(card, 13, 'e3') e2 = double_or_blank(card, 14, 'e3') e3 = double_or_blank(card, 15, 'e3') assert len(card) <= 16, 'len(CHBDYP card) = %i\ncard=%s' % (len(card), card) return CHBDYP(eid, pid, Type, g1, g2, g0=g0, gmid=gmid, ce=ce, iViewFront=iViewFront, iViewBack=iViewBack, radMidFront=radMidFront, radMidBack=radMidBack, e1=e1, e2=e2, e3=e3, comment=comment)
def _read_shock(self, card, istart): """ F(u, v) = Cv * S(u) * sign(v) * |v|^ev """ self.shockType = string_or_blank(card, istart + 1, 'shockType') self.shockCVT = double(card, istart + 2, 'shockCVT') self.shockCVC = double_or_blank(card, istart + 3, 'shockCVC') self.shockExpVT = double_or_blank(card, istart + 4, 'shockExpVT', 1.0) self.shockExpVC = double_or_blank(card, istart + 5, 'shockExpVC', self.shockExpVT) if self.shockType == 'TABLE': pass # self.shockIDTS = integer(card, istart + 6, 'shockIDTS') # self.shockIDETS = blank(card, istart + 9, 'shockIDETS') # self.shockIDECS = blank(card, istart + 10, 'shockIDECS') # self.shockIDETSD = blank(card, istart + 11, 'shockIDETSD') # self.shockIDECSD = blank(card, istart + 12, 'shockIDECSD') elif self.shockType == 'EQUAT': self.shockIDTS = blank(card, istart + 6, 'shockIDTS') self.shockIDETS = integer(card, istart + 9, 'shockIDETS') self.shockIDECS = integer_or_blank(card, istart + 10, 'shockIDECS', self.shockIDETS) self.shockIDETSD = integer(card, istart + 11, 'shockIDETSD') self.shockIDECSD = integer_or_blank(card, istart + 11, 'shockIDECSD', self.shockIDETSD) #def DEquation(self): #if isinstance(self.dequation, int): #return self.dequation #return self.dequation.equation_id else: raise RuntimeError('Invalid shockType=%r on card\n%s' %(self.shockType, card)) istart += 8 return istart
def add_card(cls, card, comment=''): """ Adds an EIGR card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ sid = integer(card, 1, 'sid') method = string_or_blank(card, 2, 'method', 'LAN') f1 = double_or_blank(card, 3, 'f1') f2 = double_or_blank(card, 4, 'f2') ne = integer_or_blank(card, 5, 'ne') if method not in cls.allowed_methods: msg = 'method=%s; allowed_methods=[%s]' % ( method, ', '.join(cls.allowed_methods)) raise ValueError(msg) if method == 'SINV': nd = integer_or_blank(card, 6, 'nd', 600) elif method == 'INV': ne = integer(card, 5, 'ne') nd = integer_or_blank(card, 6, 'nd', 3 * ne) elif method in ['GIV', 'MGIV', 'HOU', 'MHOU']: nd = integer_or_blank(card, 6, 'nd', 0) else: nd = integer(card, 6, 'nd') crit = double_or_blank(card, 8, 'crit') norm = string_or_blank(card, 9, 'norm', 'MASS') if norm == 'POINT': G = integer(card, 10, 'G') C = parse_components(card, 11, 'C') else: G = blank(card, 10, 'G') C = blank(card, 11, 'C') assert len(card) <= 12, f'len(EIGR card) = {len(card):d}\ncard={card}' return EIGR(sid, method, f1, f2, ne, nd, crit=crit, norm=norm, G=G, C=C, comment=comment)
def _read_damper(self, card, istart): """ F(v) = Ft(u) """ self.damperType = string_or_blank(card, istart + 1, 'damperType') self.damperIDT = integer(card, istart + 2, 'damperIDT') if self.damperType == 'TABLE': self.damperIDC = blank(card, istart + 3, 'damperIDC') self.damperIDTDV = blank(card, istart + 4, 'damperIDTDV') self.damperIDCDV = blank(card, istart + 5, 'damperIDCDV') elif self.damperType == 'EQUAT': self.damperIDC = integer_or_blank(card, istart + 3, 'damperIDC') self.damperIDTDV = integer(card, istart + 4, 'damperIDTDV') self.damperIDCDV = integer_or_blank(card, istart + 5, 'damperIDCDV', self.damperIDTDV) else: raise RuntimeError('Invalid springType=|%s| on card\n%s' %(self.springType, card)) self.vars.append('DAMPER')
def add_card(self, card, comment=""): i = self.i self.element_id[i] = integer(card, 1, "element_id") self.property_id[i] = integer(card, 2, "property_id") self.node_ids[i] = [integer(card, 3, "n1"), integer(card, 4, "n2"), integer(card, 5, "n3")] # self.thetaMcid = integer_double_or_blank(card, 6, 'thetaMcid', 0.0) # self.zOffset = double_or_blank(card, 7, 'zOffset', 0.0) blank(card, 8, "blank") blank(card, 9, "blank") self.t_flag[i] = integer_or_blank(card, 10, "TFlag", 0) self.thickness[i] = [ double_or_blank(card, 11, "T1", 1.0), double_or_blank(card, 12, "T2", 1.0), double_or_blank(card, 13, "T3", 1.0), ] self.i += 1
def _read_damper(card, istart): """ F(v) = Ft(u) """ damper_type = string_or_blank(card, istart + 1, 'damperType') damper_idt = integer(card, istart + 2, 'damperIDT') if damper_type == 'TABLE': damper_idc = blank(card, istart + 3, 'damperIDC') damper_idtdv = blank(card, istart + 4, 'damperIDTDV') damper_idcdv = blank(card, istart + 5, 'damperIDCDV') elif damper_type == 'EQUAT': damper_idc = integer_or_blank(card, istart + 3, 'damperIDC') damper_idtdv = integer(card, istart + 4, 'damperIDTDV') damper_idcdv = integer_or_blank(card, istart + 5, 'damperIDCDV', damper_idtdv) else: msg = 'Invalid damper_type=%r on card\n%s' % (damper_type, card) raise RuntimeError(msg) return damper_type, damper_idt, damper_idc, damper_idtdv, damper_idcdv
def add_card(self, card, comment=''): i = self.i self.element_id[i] = integer(card, 1, 'element_id') self.property_id[i] = integer(card, 2, 'property_id') self.node_ids[i] = [integer(card, 3, 'n1'), integer(card, 4, 'n2'), integer(card, 5, 'n3')] #self.theta_mcid = integer_double_or_blank(card, 6, 'theta_mcid', 0.0) #self.zoffset = double_or_blank(card, 7, 'zoffset', 0.0) blank(card, 8, 'blank') blank(card, 9, 'blank') self.t_flag[i] = integer_or_blank(card, 10, 'tflag', 0) self.thickness[i] = [ double_or_blank(card, 11, 'T1', 1.0), double_or_blank(card, 12, 'T2', 1.0), double_or_blank(card, 13, 'T3', 1.0), ] self.i += 1
def add_card(self, card, comment=''): i = self.i self.element_id[i] = integer(card, 1, 'element_id') self.property_id[i] = integer(card, 2, 'property_id') self.node_ids[i] = [integer(card, 3, 'n1'), integer(card, 4, 'n2'), integer(card, 5, 'n3')] #self.theta_mcid = integer_double_or_blank(card, 6, 'theta_mcid', 0.0) #self.zoffset = double_or_blank(card, 7, 'zoffset', 0.0) blank(card, 8, 'blank') blank(card, 9, 'blank') self.t_flag[i] = integer_or_blank(card, 10, 'TFlag', 0) self.thickness[i] = [ double_or_blank(card, 11, 'T1', 1.0), double_or_blank(card, 12, 'T2', 1.0), double_or_blank(card, 13, 'T3', 1.0), ] self.i += 1
def add_card(cls, card, comment=''): sid = integer(card, 1, 'sid') method = string(card, 2, 'method') assert method in ['ARNO', 'INV', 'HESS', 'CLAN', 'ISRR', 'IRAM'], ( 'method=%s is not ARNO, INV, HESS, CLAN, ISRR, IRAM' % method) norm = string_or_blank(card, 3, 'norm') if norm == 'POINT': G = integer(card, 4, 'G') C = components(card, 5, 'C') else: G = blank(card, 4, 'G') C = blank(card, 5, 'C') E = double_or_blank(card, 6, 'E') ndo = integer_double_string_or_blank(card, 7, 'ND0') # ALPHAAJ OMEGAAJ ALPHABJ OMEGABJ LJ NEJ NDJ fields = [interpret_value(field) for field in card[9:]] alphaAjs = [] omegaAjs = [] nfields = len(fields) nrows = nfields // 8 if nfields % 8 > 0: nrows += 1 #if nrows == 0: #msg = 'invalid row count=0; nfields=%s \ncard=%s\nfields=%s' % ( #nfields, card, fields) #raise RuntimeError(msg) if method == 'CLAN': alphaAjs, omegaAjs, mblkszs, iblkszs, ksteps, NJIs = cls._load_clan(nrows, card) elif method in ['HESS', 'INV']: # HESS, INV cls._load_hess_inv(nrows, method, card) elif method == 'ISRR': cls._load_isrr(nrows, card) else: msg = 'invalid EIGC method...method=%r' % method raise RuntimeError(msg) #assert card.nFields() < 8, 'card = %s' % card return EIGC(sid, method, norm, G, C, E, ndo, comment=comment)
def _read_spring(self, card, istart): """ F(u) = Ft(u) """ self.springType = string_or_blank(card, istart + 1, 'springType') self.springIDT = integer(card, istart + 2, 'springIDT') if self.springType == 'TABLE': self.springIDC = blank(card, istart + 3, 'springIDC') self.springIDTDU = blank(card, istart + 4, 'springIDTDU') self.springIDCDU = blank(card, istart + 5, 'springIDCDU') elif self.springType == 'EQUAT': self.springIDC = integer_or_blank(card, istart + 3, 'springIDC', self.springIDT) self.springIDTDU = integer(card, istart + 4, 'springIDTDU') self.springIDCDU = integer_or_blank(card, istart + 5, 'springIDCDU', self.springIDTDU) else: raise RuntimeError('Invalid springType=|%s| on card\n%s' %(self.springType, card)) self.vars.append('SPRING')
def _read_spring(card, istart): """ F(u) = Ft(u) """ spring_type = string_or_blank(card, istart + 1, 'springType') spring_idt = integer(card, istart + 2, 'springIDT') if spring_type == 'TABLE': spring_idc = blank(card, istart + 3, 'springIDC') spring_idtdu = blank(card, istart + 4, 'springIDTDU') spring_idcdu = blank(card, istart + 5, 'springIDCDU') elif spring_type == 'EQUAT': spring_idc = integer_or_blank(card, istart + 3, 'springIDC', spring_idt) spring_idtdu = integer(card, istart + 4, 'springIDTDU') spring_idcdu = integer_or_blank(card, istart + 5, 'springIDCDU', spring_idtdu) else: msg = 'Invalid springType=%r on card\n%s' % (spring_type, card) raise RuntimeError(msg) return spring_type, spring_idt, spring_idc, spring_idtdu, spring_idcdu
def add_card(cls, card, comment=''): pid = integer(card, 1, 'pid') mid = integer(card, 2, 'mid') A = double_or_blank(card, 3, 'A', 0.0) i1 = double_or_blank(card, 4, 'I1', 0.0) i2 = double_or_blank(card, 5, 'I2', 0.0) j = double_or_blank(card, 6, 'J', 0.0) nsm = double_or_blank(card, 7, 'nsm', 0.0) 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) i12 = double_or_blank(card, 19, 'I12', 0.0) if A == 0.0: k1 = blank(card, 17, 'K1') k2 = blank(card, 18, 'K2') elif i12 != 0.0: # K1 / K2 are ignored k1 = None k2 = None else: #: default=infinite; assume 1e8 k1 = double_or_blank(card, 17, 'K1', 1e8) #: default=infinite; assume 1e8 k2 = double_or_blank(card, 18, 'K2', 1e8) assert len(card) <= 20, 'len(PBAR card) = %i\ncard=%s' % (len(card), card) return PBAR(pid, mid, A, i1, i2, i12, j, nsm, c1, c2, d1, d2, e1, e2, f1, f2, k1, k2, comment=comment)
def _read_shock(card, istart): """ F(u, v) = Cv * S(u) * sign(v) * |v|^ev """ shock_type = string_or_blank(card, istart + 1, 'shockType') shock_cvt = double(card, istart + 2, 'shockCVT') shock_cvc = double_or_blank(card, istart + 3, 'shockCVC') shock_exp_vt = double_or_blank(card, istart + 4, 'shockExpVT', 1.0) shock_exp_vc = double_or_blank(card, istart + 5, 'shockExpVC', shock_exp_vt) if shock_type == 'TABLE': shock_idts = None shock_idets = None shock_idecs = None shock_idetsd = None shock_idecsd = None # shock_idts = integer(card, istart + 6, 'shockIDTS') # shock_idets = blank(card, istart + 9, 'shockIDETS') # shock_idecs = blank(card, istart + 10, 'shockIDECS') # shock_idetsd = blank(card, istart + 11, 'shockIDETSD') # shock_idecsd = blank(card, istart + 12, 'shockIDECSD') elif shock_type == 'EQUAT': shock_idts = blank(card, istart + 6, 'shockIDTS') shock_idets = integer(card, istart + 9, 'shockIDETS') shock_idecs = integer_or_blank(card, istart + 10, 'shockIDECS', shock_idets) shock_idetsd = integer(card, istart + 11, 'shockIDETSD') shock_idecsd = integer_or_blank(card, istart + 11, 'shockIDECSD', shock_idetsd) #def DEquation(self): #if isinstance(self.dequation, int): #return self.dequation #return self.dequation.equation_id else: msg = 'Invalid shockType=%r on card\n%s' % (shock_type, card) raise RuntimeError(msg) out = ( shock_type, shock_cvt, shock_cvc, shock_exp_vt, shock_exp_vc, shock_idts, shock_idets, shock_idecs, shock_idetsd, shock_idecsd ) istart += 8 return istart, out
def add_card(cls, card, comment=''): """ Parameters ---------- card : BDFCard() a BDFCard object comment : str a comment for the card """ #: Grid point coordinate system blank(card, 1, 'blank') cp = integer_or_blank(card, 2, 'cp', 0) blank(card, 3, 'blank') blank(card, 4, 'blank') blank(card, 5, 'blank') cd = integer_or_blank(card, 6, 'cd', 0) ps = str(integer_or_blank(card, 7, 'ps', '')) seid = integer_or_blank(card, 8, 'seid', 0) assert len(card) <= 9, 'len(GRDSET card) = %i\ncard=%s' % (len(card), card) return GRDSET(cp, cd, ps, seid, comment=comment)
def __init__(self, card=None, data=None, comment=''): """ Creates the GRDSET card :param card: a BDFCard object :type card: BDFCard :param data: a list with the GRDSET fields defined in OP2 format :type data: LIST :param comment: a comment for the card :type comment: string """ if comment: self._comment = comment #: Grid point coordinate system blank(card, 1, 'blank') #: Output Coordinate System self.cp = integer_or_blank(card, 2, 'cp', 0) blank(card, 3, 'blank') blank(card, 4, 'blank') blank(card, 5, 'blank') #: Analysis coordinate system self.cd = integer_or_blank(card, 6, 'cd', 0) #: Default SPC constraint on undefined nodes self.ps = str(integer_or_blank(card, 7, 'ps', '')) #: Superelement ID self.seid = integer_or_blank(card, 8, 'seid', 0) assert len(card) <= 9, 'len(GRDSET card) = %i' % len(card)
def add_card(cls, card, comment=''): """ Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ nid = integer(card, 1, 'nid') blank(card, 2, 'blank') R = double(card, 3, 'R') z = double(card, 4, 'z') blank(card, 5, 'blank') blank(card, 6, 'blank') ps = integer_or_blank(card, 7, 'ps') assert len(card) <= 8, 'len(RINGAX card) = %i\ncard=%s' % (len(card), card) return RINGAX(nid, R, z, ps, comment=comment)
def __init__(self, card=None, data=None, comment=''): # this card has missing fields """ Creates the RINGAX card :param card: a BDFCard object :type card: BDFCard :param data: a list with the RINGAX fields defined in OP2 format :type data: LIST :param comment: a comment for the card :type comment: string """ Ring.__init__(self) if comment: self._comment = comment if card: #: Node ID self.nid = integer(card, 1, 'nid') blank(card, 2, 'blank') #: Radius self.R = double(card, 3, 'R') self.z = double(card, 4, 'z') blank(card, 5, 'blank') blank(card, 6, 'blank') #: local SPC constraint self.ps = integer_or_blank(card, 7, 'ps') assert len(card) <= 8, 'len(RINGAX card) = %i' % len(card) else: # hasn't been validated self.nid = data[0] self.R = data[1] self.z = data[2] self.ps = data[3] assert len(data) == 4, data
def add_card(cls, card, comment=''): """ Adds a RINGAX card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ nid = integer(card, 1, 'nid') blank(card, 2, 'blank') R = double(card, 3, 'R') z = double(card, 4, 'z') blank(card, 5, 'blank') blank(card, 6, 'blank') ps = integer_or_blank(card, 7, 'ps') assert len(card) <= 8, f'len(RINGAX card) = {len(card):d}\ncard={card}' return RINGAX(nid, R, z, ps, comment=comment)
def add_card(cls, card, comment=''): eid = integer(card, 1, 'eid') blank(card, 2, 'blank') refgrid = integer(card, 3, 'refgrid') refc = components_or_blank(card, 4, 'refc') fields = [field.upper() if isinstance(field, string_types) else field for field in card[5:]] ioffset = 5 iwt_max = len(fields) + ioffset try: ialpha = fields.index('ALPHA') + ioffset iwt_max = ialpha # the index to start parsing UM ium_stop = ialpha # the index to stop parsing UM except ValueError: ialpha = None ium_stop = iwt_max try: ium = fields.index('UM') + ioffset iwt_max = ium except ValueError: ium = None i = ioffset n = 1 weights = [] comps = [] Gijs = [] while i < iwt_max: Gij = [] wtname = 'wt' + str(n) wt = double_or_blank(card, i, wtname) if wt is not None: cname = 'c'+str(n) compi = components_or_blank(card, i + 1, cname) #print("%s=%s %s=%s" % (wtname, wt, cname, compi)) i += 2 gij = 0 j = 0 while isinstance(gij, int) and i < iwt_max: j += 1 gij_name = 'g%s,%s' % (n, j) gij = integer_double_or_blank(card, i, gij_name) if isinstance(gij, float): break #print("%s = %s" % (gij_name, gij)) if gij is not None: Gij.append(gij) i += 1 assert compi is not None assert len(Gij) > 0, Gij assert Gij[0] is not None, Gij weights.append(wt) comps.append(compi) Gijs.append(Gij) #print('----finished a group=%r----' % weight_cg_group) else: i += 1 Gmi = [] Cmi = [] if ium: #print('UM = %s' % card.field(ium)) # UM i = ium + 1 n = 1 #print("i=%s iUmStop=%s" % (i, iUmStop)) for j in range(i, ium_stop, 2): gm_name = 'gm' + str(n) cm_name = 'cm' + str(n) gmi = integer_or_blank(card, j, gm_name) if gmi is not None: cmi = components(card, j + 1, cm_name) #print("gmi=%s cmi=%s" % (gmi, cmi)) Gmi.append(gmi) Cmi.append(cmi) if ialpha: alpha = double_or_blank(card, ialpha + 1, 'alpha') else: #: thermal expansion coefficient alpha = 0.0 return RBE3(eid, refgrid, refc, weights, comps, Gijs, Gmi=Gmi, Cmi=Cmi, alpha=alpha, comment=comment)
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') #if comment: # self.comment = comment self.element_id[i] = integer(card, 1, 'eid') blank(card, 2, 'blank') self.refgrid[i] = integer(card, 3, 'refgrid') self.refc[i] = components_or_blank(card, 4, 'refc', 0) #iUM = fields.index('UM') fields = [ field.upper() if isinstance(field, string_types) else field for field in card[5:] ] iOffset = 5 iWtMax = len(fields) + iOffset try: iAlpha = fields.index('ALPHA') + iOffset iWtMax = iAlpha # the index to start parsing UM iUmStop = iAlpha # the index to stop parsing UM except ValueError: iAlpha = None iUmStop = iWtMax #print("iAlpha = %s" % iAlpha) try: iUm = fields.index('UM') + iOffset iWtMax = iUm except ValueError: iUm = None #print("iAlpha=%s iUm=%s" % (iAlpha, iUm)) #print("iAlpha=%s iWtMax=%s" % (iAlpha, iWtMax)) #print("iUM = %s" % iUM) WtCG_groups = [] i = iOffset n = 1 while i < iWtMax: Gij = [] wtname = 'wt' + str(n) wt = double_or_blank(card, i, wtname) if wt is not None: cname = 'c' + str(n) ci = components_or_blank(card, i + 1, cname) #print("%s=%s %s=%s" % (wtname, wt, cname, ci)) i += 2 gij = 0 j = 0 while isinstance(gij, int) and i < iWtMax: j += 1 gij_name = 'g%s,%s' % (n, j) gij = integer_double_or_blank(card, i, gij_name) if isinstance(gij, float): break #print("%s = %s" % (gij_name, gij)) if gij is not None: Gij.append(gij) i += 1 wtCG_group = [wt, ci, Gij] WtCG_groups.append(wtCG_group) #print('----finished a group=%r----' % wtCG_group) else: i += 1 self.WtCG_groups[i] = WtCG_groups Gmi = [] Cmi = [] #print("") if iUm: #print('UM = %s' % card.field(iUm)) # UM i = iUm + 1 n = 1 #print("i=%s iUmStop=%s" % (i, iUmStop)) for j in range(i, iUmStop, 2): gm_name = 'gm' + str(n) cm_name = 'cm' + str(n) gmi = integer_or_blank(card, j, gm_name) if gmi is not None: cmi = components(card, j + 1, cm_name) #print("gmi=%s cmi=%s" % (gmi, cmi)) Gmi.append(gmi) Cmi.append(cmi) self.Gmi[i] = Gmi self.Cmi[i] = Cmi if iAlpha: alpha = double_or_blank(card, iAlpha + 1, 'alpha', 0.0) else: alpha = 0.0 self.alpha[i] = alpha
def test_blank(self): """ value = integer(card, n, fieldname) """ # integer with self.assertRaises(SyntaxError): blank(BDFCard([1]), 0, 'field') with self.assertRaises(SyntaxError): blank(BDFCard(['1']), 0, 'field') # float with self.assertRaises(SyntaxError): blank(BDFCard([1.]), 0, 'field') with self.assertRaises(SyntaxError): blank(BDFCard(['1.']), 0, 'field') # string with self.assertRaises(SyntaxError): blank(BDFCard(['a']), 0, 'field') with self.assertRaises(SyntaxError): blank(BDFCard(['1b']), 0, 'field') # blank val = blank(BDFCard(['']), 0, 'field') self.assertEqual(val, None) val = blank(BDFCard([None]), 0, 'field') self.assertEqual(val, None) val = blank(BDFCard([None]), 0, 'field', 'default') self.assertEqual(val, 'default')
def add_card(cls, card, comment=''): sid = integer(card, 1, 'sid') method = string(card, 2, 'method') assert method in [ 'ARNO', 'INV', 'HESS', 'CLAN', 'ISRR', 'IRAM' ], ('method=%s is not ARNO, INV, HESS, CLAN, ISRR, IRAM' % method) norm = string_or_blank(card, 3, 'norm') if norm == 'POINT': G = integer(card, 4, 'G') C = components(card, 5, 'C') else: G = blank(card, 4, 'G') C = blank(card, 5, 'C') E = double_or_blank(card, 6, 'E') ndo = integer_double_string_or_blank(card, 7, 'ND0') # ALPHAAJ OMEGAAJ ALPHABJ OMEGABJ LJ NEJ NDJ fields = [interpret_value(field) for field in card[9:]] #-------CLAN-------------- mblkszs = [] iblkszs = [] ksteps = [] NJIs = [] #-------CLAN-------------- #-------HESS-------------- alphaAjs = [] alphaBjs = [] omegaAjs = [] omegaBjs = [] mblkszs = [] iblkszs = [] ksteps = [] LJs = [] NEJs = [] NDJs = [] #-------HESS-------------- #-------ISRR-------------- shift_r1 = 0.0 shift_i1 = 0.0 isrr_flag = 0 nd1 = None #-------ISRR-------------- nfields = len(fields) nrows = nfields // 8 if nfields % 8 > 0: nrows += 1 #if nrows == 0: #msg = 'invalid row count=0; nfields=%s \ncard=%s\nfields=%s' % ( #nfields, card, fields) #raise RuntimeError(msg) if method == 'CLAN': alphaAjs, omegaAjs, mblkszs, iblkszs, ksteps, NJIs = cls._load_clan( nrows, card) elif method in ['HESS', 'INV']: # HESS, INV alphaAjs, omegaAjs, alphaBjs, omegaBjs, LJs, NEJs, NDJs = cls._load_hess_inv( nrows, method, card) elif method == 'ISRR': shift_r1, shift_i1, isrr_flag, nd1 = cls._load_isrr(nrows, card) else: msg = 'invalid EIGC method...method=%r' % method raise RuntimeError(msg) #assert card.nFields() < 8, 'card = %s' % card return EIGC( sid, method, norm, G, C, E, ndo, mblkszs, iblkszs, ksteps, NJIs, # CLAN alphaAjs, omegaAjs, alphaBjs, omegaBjs, LJs, NEJs, NDJs, # HESS/INV shift_r1, shift_i1, isrr_flag, nd1, # ISRR comment=comment)
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") # if comment: # self.comment = comment self.element_id[i] = integer(card, 1, "eid") blank(card, 2, "blank") self.refgrid[i] = integer(card, 3, "refgrid") self.refc[i] = components_or_blank(card, 4, "refc", 0) # iUM = fields.index('UM') fields = [field.upper() if isinstance(field, string_types) else field for field in card[5:]] iOffset = 5 iWtMax = len(fields) + iOffset try: iAlpha = fields.index("ALPHA") + iOffset iWtMax = iAlpha # the index to start parsing UM iUmStop = iAlpha # the index to stop parsing UM except ValueError: iAlpha = None iUmStop = iWtMax # print("iAlpha = %s" % iAlpha) try: iUm = fields.index("UM") + iOffset iWtMax = iUm except ValueError: iUm = None # print("iAlpha=%s iUm=%s" % (iAlpha, iUm)) # print("iAlpha=%s iWtMax=%s" % (iAlpha, iWtMax)) # print("iUM = %s" % iUM) WtCG_groups = [] i = iOffset n = 1 while i < iWtMax: Gij = [] wtname = "wt" + str(n) wt = double_or_blank(card, i, wtname) if wt is not None: cname = "c" + str(n) ci = components_or_blank(card, i + 1, cname) # print("%s=%s %s=%s" % (wtname, wt, cname, ci)) i += 2 gij = 0 j = 0 while isinstance(gij, int) and i < iWtMax: j += 1 gij_name = "g%s,%s" % (n, j) gij = integer_double_or_blank(card, i, gij_name) if isinstance(gij, float): break # print("%s = %s" % (gij_name, gij)) if gij is not None: Gij.append(gij) i += 1 wtCG_group = [wt, ci, Gij] WtCG_groups.append(wtCG_group) # print('----finished a group=%r----' % wtCG_group) else: i += 1 self.WtCG_groups[i] = WtCG_groups Gmi = [] Cmi = [] # print("") if iUm: # print('UM = %s' % card.field(iUm)) # UM i = iUm + 1 n = 1 # print("i=%s iUmStop=%s" % (i, iUmStop)) for j in range(i, iUmStop, 2): gm_name = "gm" + str(n) cm_name = "cm" + str(n) gmi = integer_or_blank(card, j, gm_name) if gmi is not None: cmi = components(card, j + 1, cm_name) # print("gmi=%s cmi=%s" % (gmi, cmi)) Gmi.append(gmi) Cmi.append(cmi) self.Gmi[i] = Gmi self.Cmi[i] = Cmi if iAlpha: alpha = double_or_blank(card, iAlpha + 1, "alpha", 0.0) else: alpha = 0.0 self.alpha[i] = alpha
def add_card(cls, card, comment=''): """ Adds an EIGC card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ sid = integer(card, 1, 'sid') method = string(card, 2, 'method') assert method in ['ARNO', 'INV', 'HESS', 'CLAN', 'ISRR', 'IRAM', 'DET'], ( 'method=%s is not ARNO, INV, HESS, CLAN, ISRR, IRAM, DET' % method) norm = string_or_blank(card, 3, 'norm', 'MAX') if norm == 'POINT': grid = integer(card, 4, 'G') component = parse_components(card, 5, 'C') else: grid = blank(card, 4, 'G') component = blank(card, 5, 'C') epsilon = double_or_blank(card, 6, 'epsilon') neigenvalues = integer_double_string_or_blank(card, 7, 'ND0/neigenvalues') # ALPHAAJ OMEGAAJ ALPHABJ OMEGABJ LJ NEJ NDJ fields = [interpret_value(field) for field in card[9:]] #-------CLAN-------------- mblkszs = [] iblkszs = [] ksteps = [] NJIs = [] #-------CLAN-------------- #-------HESS-------------- alphaAjs = [] alphaBjs = [] omegaAjs = [] omegaBjs = [] mblkszs = [] iblkszs = [] ksteps = [] LJs = [] NEJs = [] NDJs = [] #-------HESS-------------- #-------ISRR-------------- shift_r1 = 0.0 shift_i1 = 0.0 isrr_flag = 0 nd1 = None #-------ISRR-------------- nfields = len(fields) nrows = nfields // 8 if nfields % 8 > 0: nrows += 1 #if nrows == 0: #msg = 'invalid row count=0; nfields=%s \ncard=%s\nfields=%s' % ( #nfields, card, fields) #raise RuntimeError(msg) if method == 'CLAN': alphaAjs, omegaAjs, mblkszs, iblkszs, ksteps, NJIs = cls._load_clan(nrows, card) elif method in ['HESS', 'INV', 'DET']: # HESS, INV alphaAjs, omegaAjs, alphaBjs, omegaBjs, LJs, NEJs, NDJs = cls._load_hess_inv( nrows, method, card) elif method == 'ISRR': shift_r1, shift_i1, isrr_flag, nd1 = cls._load_isrr(nrows, card) else: msg = 'invalid EIGC method...method=%r' % method raise RuntimeError(msg) #assert card.nfields() < 8, 'card = %s' % card return EIGC(sid, method, grid, component, epsilon, neigenvalues, norm, # common mblkszs, iblkszs, ksteps, NJIs, # CLAN alphaAjs, omegaAjs, alphaBjs, omegaBjs, LJs, NEJs, NDJs, # HESS/INV shift_r1, shift_i1, isrr_flag, nd1, # ISRR comment=comment)
def __init__(self, card=None, data=None, comment=''): Method.__init__(self, card, data) if comment: self._comment = comment # CLAN self.mblkszs = [] self.iblkszs = [] self.ksteps = [] self.NJIs = [] # HESS self.alphaBjs = [] self.omegaBjs = [] self.LJs = [] self.NEJs = [] self.NDJs = [] if card: #: Set identification number. (Unique Integer > 0) self.sid = integer(card, 1, 'sid') #: Method of complex eigenvalue extraction #: MSC 2014 = [INV, HESS, CLAN, IRAM] #: NX 8.5 = [INV, HESS, CLAN, ISRR] #: Autodesk 2015 = [ARNO, HESS, CLAN] self.method = string(card, 2, 'method') assert self.method in ['ARNO', 'INV', 'HESS', 'CLAN', 'ISRR', 'IRAM'], ( 'method=%s is not ARNO, INV, HESS, CLAN, ISRR, IRAM' % self.method) #: Method for normalizing eigenvectors self.norm = string_or_blank(card, 3, 'norm') if self.norm == 'POINT': #: Grid or scalar point identification number. Required only if #: NORM='POINT'. (Integer>0) self.G = integer(card, 4, 'G') #: Component number. Required only if NORM='POINT' and G is a #: geometric grid point. (1<Integer<6) self.C = components(card, 5, 'C') else: self.G = blank(card, 4, 'G') self.C = blank(card, 5, 'C') #: Convergence criterion. (Real > 0.0. Default values are: #: 10^-4 for METHOD = "INV", #: 10^-8 for METHOD = "CLAN", #: 10^-8 for METHOD = "ISRR", #: 10^-15 for METHOD = "HESS", #: E is machine dependent for METHOD = "CLAN".) self.E = double_or_blank(card, 6, 'E') self.ndo = integer_double_string_or_blank(card, 7, 'ND0') # ALPHAAJ OMEGAAJ ALPHABJ OMEGABJ LJ NEJ NDJ fields = [interpret_value(field) for field in card[9:]] self.alphaAjs = [] self.omegaAjs = [] nfields = len(fields) nrows = nfields // 8 if nfields % 8 > 0: nrows += 1 #if nrows == 0: #raise RuntimeError('invalid row count=0; nfields=%s \ncard=%s\nfields=%s' % (nfields, card, fields)) if self.method == 'CLAN': self.loadCLAN(nrows, card) elif self.method in ['HESS', 'INV']: # HESS, INV self.loadHESS_INV(nrows, card) elif self.method == 'ISRR': self._load_isrr(nrows, card) else: msg = 'invalid EIGC method...method=%r' % self.method raise RuntimeError(msg) #assert card.nFields() < 8, 'card = %s' % card else: raise NotImplementedError('EIGC')
def add_card(cls, card, comment=''): """ Adds a RBE3 card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ eid = integer(card, 1, 'eid') blank(card, 2, 'blank') refgrid = integer(card, 3, 'refgrid') refc = components_or_blank(card, 4, 'refc') fields = [ field.upper() if isinstance(field, string_types) else field for field in card[5:] ] ioffset = 5 iwt_max = len(fields) + ioffset try: ialpha = fields.index('ALPHA') + ioffset iwt_max = ialpha # the index to start parsing UM ium_stop = ialpha # the index to stop parsing UM except ValueError: ialpha = None ium_stop = iwt_max try: ium = fields.index('UM') + ioffset iwt_max = ium except ValueError: ium = None i = ioffset n = 1 weights = [] comps = [] Gijs = [] while i < iwt_max: Gij = [] wtname = 'wt' + str(n) wt = double_or_blank(card, i, wtname) if wt is not None: cname = 'c' + str(n) compi = components_or_blank(card, i + 1, cname) #print("%s=%s %s=%s" % (wtname, wt, cname, compi)) i += 2 gij = 0 j = 0 while isinstance(gij, int) and i < iwt_max: j += 1 gij_name = 'g%s,%s' % (n, j) gij = integer_double_or_blank(card, i, gij_name) if isinstance(gij, float): break #print("%s = %s" % (gij_name, gij)) if gij is not None: Gij.append(gij) i += 1 assert compi is not None assert len(Gij) > 0, Gij assert Gij[0] is not None, Gij weights.append(wt) comps.append(compi) Gijs.append(Gij) #print('----finished a group=%r----' % weight_cg_group) else: i += 1 Gmi = [] Cmi = [] if ium: #print('UM = %s' % card.field(ium)) # UM i = ium + 1 n = 1 #print("i=%s iUmStop=%s" % (i, iUmStop)) for j in range(i, ium_stop, 2): gm_name = 'gm' + str(n) cm_name = 'cm' + str(n) gmi = integer_or_blank(card, j, gm_name) if gmi is not None: cmi = parse_components(card, j + 1, cm_name) #print("gmi=%s cmi=%s" % (gmi, cmi)) Gmi.append(gmi) Cmi.append(cmi) if ialpha: alpha = double_or_blank(card, ialpha + 1, 'alpha') else: #: thermal expansion coefficient alpha = 0.0 return RBE3(eid, refgrid, refc, weights, comps, Gijs, Gmi=Gmi, Cmi=Cmi, alpha=alpha, comment=comment)