def __init__(self, card=None, data=None, comment=''): """ +--------+-----------+------------+-------+------+--------+-------+-----+-------+ | DRESP1 | 1S1 | CSTRAIN | PCOMP | | | 1 | 1 | 10000 | +--------+-----------+------------+-------+------+--------+-------+-----+-------+ """ if comment: self._comment = comment if card: self.oid = integer(card, 1, 'oid') self.label = string(card, 2, 'label') self.rtype = string(card, 3, 'rtype') # elem, pbar, pshell, etc. (ELEM flag or Prop Name) self.ptype = integer_string_or_blank(card, 4, 'ptype') #if 1: ## incomplete #assert self.ptype in ['ELEM', 'PSHELL', 'PBAR', 'PROD', 'PCOMP', #'PSOLID', 'PELAS', 'PBARL', 'PBEAM', #'PBEAML', 'PSHEAR', 'PTUBE', #'PKNL', #None], 'DRESP1 ptype=%s' % self.ptype self.region = integer_or_blank(card, 5, 'region') self.atta = integer_double_string_or_blank(card, 6, 'atta') self.attb = integer_double_string_or_blank(card, 7, 'attb') self.atti = [] for i in range(8, len(card)): atti = integer_double_string_or_blank(card, i, 'atti_%i' % (i + 1)) self.atti.append(atti) else: raise RuntimeError(data)
def __init__(self, card=None, data=None, comment=''): """ :: DRESP1 1S1 CSTRAIN PCOMP 1 1 10000 """ if comment: self._comment = comment self.oid = integer(card, 1, 'oid') self.label = string(card, 2, 'label') self.rtype = string(card, 3, 'rtype') # elem, pbar, pshell, etc. (ELEM flag or Prop Name) self.ptype = integer_string_or_blank(card, 4, 'ptype') if 0: assert self.ptype in ['ELEM', 'PSHELL', 'PBAR', 'PROD', 'PCOMP', 'PSOLID', 'PELAS', 'PBARL', 'PBEAM', 'PBEAML', 'PSHEAR', 'PTUBE', 'PKNL', #: .. todo:: is this correct? None], 'DRESP1 ptype=%s' % self.ptype self.region = integer_or_blank(card, 5, 'region') self.atta = integer_double_string_or_blank(card, 6, 'atta') self.attb = integer_double_string_or_blank(card, 7, 'attb') self.atti = integer_double_string_or_blank(card, 8, 'atti') self.others = [interpret_value(field) for field in card[9:] ]
def __init__(self, card=None, data=None, comment=''): """ :: DRESP1 1S1 CSTRAIN PCOMP 1 1 10000 """ if comment: self._comment = comment self.oid = integer(card, 1, 'oid') self.label = string(card, 2, 'label') self.rtype = string(card, 3, 'rtype') # elem, pbar, pshell, etc. (ELEM flag or Prop Name) self.ptype = integer_string_or_blank(card, 4, 'ptype') if 0: assert self.ptype in [ 'ELEM', 'PSHELL', 'PBAR', 'PROD', 'PCOMP', 'PSOLID', 'PELAS', 'PBARL', 'PBEAM', 'PBEAML', 'PSHEAR', 'PTUBE', 'PKNL', #: .. todo:: is this correct? None ], 'DRESP1 ptype=%s' % self.ptype self.region = integer_or_blank(card, 5, 'region') self.atta = integer_double_string_or_blank(card, 6, 'atta') self.attb = integer_double_string_or_blank(card, 7, 'attb') self.atti = integer_double_string_or_blank(card, 8, 'atti') self.others = [interpret_value(field) for field in card[9:]]
def initOfftBit(self, card): field8 = integer_double_string_or_blank(card, 8, 'field8') if isinstance(field8, float): self.isOfft = False self.offt = None self.bit = field8 elif field8 is None: self.isOfft = True self.offt = 'GGG' # default self.bit = None elif isinstance(field8, string_types): self.isOfft = True self.bit = None self.offt = field8 #print("self.offt = ", self.offt) msg = 'invalid offt parameter of CBEAM...offt=%s' % self.offt assert self.offt[0] in ['G', 'B', 'O', 'E'], msg assert self.offt[1] in ['G', 'B', 'O', 'E'], msg assert self.offt[2] in ['G', 'B', 'O', 'E'], msg else: msg = ('field8 on %s card is not a string(offt) or bit ' '(float)...field8=%s\n' % (self.type, field8)) raise RuntimeError("Card Instantiation: %s" % msg)
def initOfftBit(self, card): field8 = integer_double_string_or_blank(card, 8, 'field8') if isinstance(field8, float): self.isOfft = False self.offt = None self.bit = field8 elif field8 is None: self.isOfft = True self.offt = 'GGG' # default self.bit = None elif is_string(field8): self.isOfft = True self.bit = None self.offt = field8 #print("self.offt = ", self.offt) msg = 'invalid offt parameter of CBEAM...offt=%s' % self.offt assert self.offt[0] in ['G', 'B', 'O', 'E'], msg assert self.offt[1] in ['G', 'B', 'O', 'E'], msg assert self.offt[2] in ['G', 'B', 'O', 'E'], msg else: msg = ('field8 on %s card is not a string(offt) or bit ' '(float)...field8=%s\n' % (self.type, field8)) raise RuntimeError("Card Instantiation: %s" % msg)
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 self.method = string(card, 2, 'method') assert self.method in ['INV', 'HESS', 'CLAN'],( 'method=%s is not INV, HESS, CLAN' % (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^-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 % 7 > 0: nRows += 1 if self.method == 'CLAN': self.loadCLAN(nRows, card) elif self.method in ['HESS', 'INV']: # HESS, INV self.loadHESS_INV(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 __init__(self, card, data=None, comment=''): """ Creates a PARAM card. Parameters ---------- self : PARAM() the object pointer card : BDFCard(); default=None BDFCard object data : List[int/float/str]; default=None list of PARAM entries not including 'PARAM'; intended to be used by OP2 Reader comment : str; default='' optional string """ if comment: self._comment = comment if data: card = BDFCard(['PARAM'] + data) self.key = string(card, 1, 'key') n = 1 value = None if self.key == 'ACOUT': value = string_or_blank(card, 2, 'value', 'PEAK') elif self.key == 'ACOWEAK': value = string_or_blank(card, 2, 'value', 'NO') elif self.key == 'ACSYM': value = string_or_blank(card, 2, 'value', 'YES') elif self.key == 'ADJMETH': value = integer_or_blank(card, 2, 'value', 0) elif self.key == 'ADPCON': value = double_or_blank(card, 2, 'value', 1.0) #elif self.key == 'ADMPOST': #value = string_or_blank(card, 2, 'value', 0) ## TODO: 0 is not a string elif self.key == 'ADSDISC': value = double_or_blank(card, 2, 'value', 1e-8) elif self.key == 'AESMAXIT': value = integer_or_blank(card, 2, 'value', 15) elif self.key == 'AESMETH': value = string_or_blank(card, 2, 'value', 'SELECT') assert value in ['SELECT', 'AUTO', 'DIRECT', 'RITZ', 'ITER'], 'value=%s' % value elif self.key == 'AESTOL': value = double_or_blank(card, 2, 'value', 1e-10) elif self.key == 'ADSTAT': value = string_or_blank(card, 2, 'value', 'YES') elif self.key in ['ALPHA1', 'ALPHA2', 'ALPHA1FL', 'ALPHA2FL']: # check alpha1/alpha1FL value1 = double_or_blank(card, 2, 'value1', 0.0) value2 = double_or_blank(card, 3, 'value2', 0.0) n = 2 elif self.key in ['CB1', 'CB2', 'CK1', 'CK2', 'CK3', 'CK41', 'CK42', 'CM1', 'CM2', 'CP1', 'CP2']: value1 = double_or_blank(card, 2, 'value1', 1.0) value2 = double_or_blank(card, 3, 'value2', 0.0) n = 2 elif self.key == 'POST': value = integer_or_blank(card, 2, 'value', 1) else: value1 = integer_double_string_or_blank(card, 2, 'value1') value2 = integer_double_string_or_blank(card, 3, 'value2') if value2 is None: value = value1 if value is None: if isinstance(value1, string_types): assert ' ' not in value1, 'PARAM value1=%r' % value1 if isinstance(value2, string_types): assert ' ' not in value2, 'PARAM value2=%r' % value2 self.values = [value1, value2] else: if isinstance(value, string_types): assert ' ' not in value, 'PARAM value=%r' % value self.values = [value] if n == 1: assert len(card) <= 3, 'len(PARAM card)=%i card=%r' % (len(card), card) else: assert len(card) <= 4, 'len(PARAM card)=%i card=%r' % (len(card), card)
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 self.method = string(card, 2, 'method') assert self.method in [ 'INV', 'HESS', 'CLAN' ], ('method=%s is not INV, HESS, CLAN' % (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^-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 = card[9:] self.alphaAjs = [] self.omegaAjs = [] nFields = len(fields) nRows = nFields // 8 if nFields % 7 > 0: nRows += 1 if self.method == 'CLAN': self.loadCLAN(nRows, card) elif self.method in ['HESS', 'INV']: # HESS, INV self.loadHESS_INV(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 __init__(self, card, data=None, comment=''): """ Creates a PARAM card. :param self: the object :param card: BDFCard object :param data: list of PARAM entries not including 'PARAM'; intended to be used by OP2 Reader (default=None) :param comment: optional string (default='') """ if comment: self._comment = comment if data: card = BDFCard(['PARAM'] + data) self.key = string(card, 1, 'key') n = 1 value = None if self.key == 'ACOUT': value = string_or_blank(card, 2, 'value', 'PEAK') elif self.key == 'ACOWEAK': value = string_or_blank(card, 2, 'value', 'NO') elif self.key == 'ACSYM': value = string_or_blank(card, 2, 'value', 'YES') elif self.key == 'ADJMETH': value = integer_or_blank(card, 2, 'value', 0) elif self.key == 'ADPCON': value = float_or_blank(card, 2, 'value', 1.0) #elif self.key == 'ADMPOST': #value = string_or_blank(card, 2, 'value', 0) ## TODO: 0 is not a string elif self.key == 'ADSDISC': value = float_or_blank(card, 2, 'value', 1e-8) elif self.key == 'AESMAXIT': value = integer_or_blank(card, 2, 'value', 15) elif self.key == 'AESMETH': value = string_or_blank(card, 2, 'value', 'SELECT') assert value in ['SELECT', 'AUTO', 'DIRECT', 'RITZ', 'ITER'], 'value=%s' % value elif self.key == 'AESTOL': value = ifloat_or_blank(card, 2, 'value', 1e-10) elif self.key == 'ADSTAT': value = string_or_blank(card, 2, 'value', 'YES') elif self.key in ['ALPHA1', 'ALPHA2', 'ALPHA1FL', 'ALPHA2FL']: # check alpha1/alpha1FL value1 = double_or_blank(card, 2, 'value1', 0.0) value2 = double_or_blank(card, 3, 'value2', 0.0) n = 2 elif self.key in ['CB1', 'CB2', 'CK1', 'CK2', 'CK3', 'CM1', 'CM2', 'CP1', 'CP2']: value1 = double_or_blank(card, 2, 'value1', 1.0) value2 = double_or_blank(card, 3, 'value2', 0.0) n = 2 elif self.key == 'POST': value = integer_or_blank(card, 2, 'value', 1) else: value1 = integer_double_string_or_blank(card, 2, 'value1') value2 = integer_double_string_or_blank(card, 3, 'value2') if value2 is None: value = value1 if value is None: if isinstance(value1, basestring): assert ' ' not in value1, 'PARAM value1=%r' % value1 if isinstance(value2, basestring): assert ' ' not in value2, 'PARAM value2=%r' % value2 self.values = [value1, value2] else: if isinstance(value, basestring): assert ' ' not in value, 'PARAM value=%r' % value self.values = [value] if n == 1: if len(card) != 3: raise RuntimeError('len(PARAM card)=%i card=%r' % (len(card), card)) else: if len(card) != 4: raise RuntimeError('len(PARAM card)=%i card=%r' % (len(card), card))
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 __init__(self, card, data=None, comment=''): """ Creates a PARAM card. :param self: the object :param card: BDFCard object :param data: list of PARAM entries not including 'PARAM'; intended to be used by OP2 Reader (default=None) :param comment: optional string (default='') """ if comment: self._comment = comment if data: card = BDFCard(['PARAM'] + data) self.key = string(card, 1, 'key') n = 1 value = None if self.key == 'ACOUT': value = string_or_blank(card, 2, 'value', 'PEAK') elif self.key == 'ACOWEAK': value = string_or_blank(card, 2, 'value', 'NO') elif self.key == 'ACSYM': value = string_or_blank(card, 2, 'value', 'YES') elif self.key == 'ADJMETH': value = integer_or_blank(card, 2, 'value', 0) elif self.key == 'ADPCON': value = double_or_blank(card, 2, 'value', 1.0) #elif self.key == 'ADMPOST': #value = string_or_blank(card, 2, 'value', 0) ## TODO: 0 is not a string elif self.key == 'ADSDISC': value = double_or_blank(card, 2, 'value', 1e-8) elif self.key == 'AESMAXIT': value = integer_or_blank(card, 2, 'value', 15) elif self.key == 'AESMETH': value = string_or_blank(card, 2, 'value', 'SELECT') assert value in ['SELECT', 'AUTO', 'DIRECT', 'RITZ', 'ITER'], 'value=%s' % value elif self.key == 'AESTOL': value = double_or_blank(card, 2, 'value', 1e-10) elif self.key == 'ADSTAT': value = string_or_blank(card, 2, 'value', 'YES') elif self.key in ['ALPHA1', 'ALPHA2', 'ALPHA1FL', 'ALPHA2FL']: # check alpha1/alpha1FL value1 = double_or_blank(card, 2, 'value1', 0.0) value2 = double_or_blank(card, 3, 'value2', 0.0) n = 2 elif self.key in ['CB1', 'CB2', 'CK1', 'CK2', 'CK3', 'CM1', 'CM2', 'CP1', 'CP2']: value1 = double_or_blank(card, 2, 'value1', 1.0) value2 = double_or_blank(card, 3, 'value2', 0.0) n = 2 elif self.key == 'POST': value = integer_or_blank(card, 2, 'value', 1) else: value1 = integer_double_string_or_blank(card, 2, 'value1') value2 = integer_double_string_or_blank(card, 3, 'value2') if value2 is None: value = value1 if value is None: if isinstance(value1, string_types): assert ' ' not in value1, 'PARAM value1=%r' % value1 if isinstance(value2, string_types): assert ' ' not in value2, 'PARAM value2=%r' % value2 self.values = [value1, value2] else: if isinstance(value, string_types): assert ' ' not in value, 'PARAM value=%r' % value self.values = [value] if n == 1: if len(card) != 3: raise RuntimeError('len(PARAM card)=%i card=%r' % (len(card), card)) else: if len(card) != 4: raise RuntimeError('len(PARAM card)=%i card=%r' % (len(card), card))
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)