def __init__(self, nodamb, famb, cntrlnd, eids, comment=''): ThermalBC.__init__(self) if comment: self.comment = comment #: NODAMB Ambient point for radiation exchange. (Integer > 0) self.nodamb = nodamb #: Radiation view factor between the face and the ambient point. #: (Real > 0.0) self.famb = famb #: Control point for thermal flux load. (Integer > 0; Default = 0) self.cntrlnd = cntrlnd #: CHBDYi element identification number self.eids = expand_thru_by(eids) assert self.nodamb > 0 assert self.famb > 0.0 assert self.cntrlnd >= 0 min_eid = min(self.eids) if min_eid < 1: msg = 'min(eids)=%i' % min_eid raise ValueError(msg) self.eids_ref = None
def __init__(self, sid, q0, cntrlnd, eids, comment=''): """ Creates a QBDY3 card Parameters ---------- sid : int Load set identification number. (Integer > 0) q0 : float; default=None Magnitude of thermal flux vector into face control_id : int; default=0 Control point eids : List[int] or THRU Element identification number of a CHBDYE, CHBDYG, or CHBDYP entry comment : str; default='' a comment for the card """ ThermalLoad.__init__(self) if comment: self.comment = comment #: Load set identification number. (Integer > 0) self.sid = sid #: Heat flux into element self.q0 = q0 #: Control point for thermal flux load. (Integer > 0; Default = 0) self.cntrlnd = cntrlnd #: CHBDYj element identification numbers self.eids = expand_thru_by(eids) self.eids_ref = None
def __init__(self, card=None, data=None, comment=''): ThermalBC.__init__(self) if comment: self.comment = comment if card: #: NODAMB Ambient point for radiation exchange. (Integer > 0) self.nodamb = integer(card, 1, 'nodamb') assert self.nodamb > 0 #: Radiation view factor between the face and the ambient point. #: (Real > 0.0) self.famb = double(card, 2, 'famb') assert self.famb > 0.0 #: Control point for thermal flux load. (Integer > 0; Default = 0) self.cntrlnd = integer_or_blank(card, 3, 'cntrlnd', 0) assert self.cntrlnd >= 0 nfields = card.nfields eids = fields(integer_or_string, card, 'eid', i=4, j=nfields) #: CHBDYi element identification number self.eids = expand_thru_by(eids) else: raise NotImplementedError(data) min_eid = min(self.eids) if min_eid < 1: msg = 'min(eids)=%i' % min_eid raise ValueError(msg)
def add_card(cls, card, comment=''): """ Adds a QVECT card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ sid = integer(card, 1, 'sid') q0 = double(card, 2, 'q0') t_source = double_or_blank(card, 3, 't_source') ce = integer_or_blank(card, 4, 'ce', 0) vector_tableds = [ integer_double_or_blank(card, 5, 'e1_tabled1', 0.0), integer_double_or_blank(card, 6, 'e2_tabled2', 0.0), integer_double_or_blank(card, 7, 'e3_tabled3', 0.0), ] control_id = integer_or_blank(card, 8, 'control_id', 0) i = 1 eids = [] for ifield in range(9, len(card)): eid = integer_or_string(card, ifield, 'eid_%i' % i) eids.append(eid) assert eid != 0, card i += 1 elements = expand_thru_by(eids) return QVECT(sid, q0, elements, t_source=t_source, ce=ce, vector_tableds=vector_tableds, control_id=control_id, comment=comment)
def __init__(self, line_id, nodes, comment=''): if comment: self.comment = comment self.line_id = line_id self.nodes = expand_thru_by(nodes) self.nodes_ref = None
def __init__(self, card=None, data=None, comment=''): ThermalBC.__init__(self, card, data) if comment: self._comment = comment if card: #: NODAMB Ambient point for radiation exchange. (Integer > 0) self.nodamb = integer(card, 1, 'nodamb') assert self.nodamb > 0 #: Radiation view factor between the face and the ambient point. #: (Real > 0.0) self.famb = double(card, 2, 'famb') assert self.famb > 0.0 #: Control point for thermal flux load. (Integer > 0; Default = 0) self.cntrlnd = integer_or_blank(card, 3, 'cntrlnd', 0) assert self.cntrlnd >= 0 nfields = card.nfields eids = fields(integer_or_string, card, 'eid', i=4, j=nfields) #: CHBDYi element identification number self.eids = expand_thru_by(eids) else: raise NotImplementedError(data) min_eid = min(self.eids) if min_eid < 1: msg = 'min(eids)=%i' % min_eid raise ValueError(msg)
def test_expand_thru(self): """tests expand_thru""" values = expand_thru(['1', 'THRU', '10']) assert values == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], values values = expand_thru(['1', 'thru', '10']) assert values == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], values values = expand_thru([1, 2, 3, 4, 5]) assert values == [1, 2, 3, 4, 5], values values = expand_thru_by(['1', 'THRU', '10', 'BY', 2]) assert values == [1, 3, 5, 7, 9, 10], values values = expand_thru_by(['1', 'thru', '10', 'by', 2]) assert values == [1, 3, 5, 7, 9, 10], values values = expand_thru_by([1, 2, 3, 4, 5]) assert values == [1, 2, 3, 4, 5], values
def test_accel1_2(self): """tests problematic ACCEL1 cards""" cards = [ ['ACCEL1 1 -32.2 0.2672610.5345220.801784', '+ 1 2 3 4 5'], ['ACCEL1 2 -64.4 0.2672610.5345220.801784', '+ 6 THRU 9 10'], ['ACCEL1 3 -96.6 0.2672610.5345220.801784', '+ 11 12 THRU 15'], ['ACCEL1 4 -128.8 0.2672610.5345220.801784', '+ 1 THRU 10 BY 2 12 THRU 24', '+ BY 2'], ['ACCEL1 5 -161.0 0.2672610.5345220.801784', '+ 14 THRU 24 BY 3'], ] fields = ['14', 'THRU', '24', 'BY', '2'] fields = expand_thru_by(fields, set_fields=True, sort_fields=True) assert fields == [14, 16, 18, 20, 22, 24], 'fields=%s' % fields assert collapse_thru_by(fields) == [14, 'THRU', 24, 'BY', 2], collapse_thru_by(fields) fields = ['2', 'THRU', '5', 'BY', '1', '10'] fields = expand_thru_by(fields, set_fields=True, sort_fields=True) assert fields == [2, 3, 4, 5, 10], 'fields=%s' % fields assert collapse_thru_by(fields) == [2, 'THRU', 5, 10], collapse_thru_by(fields) fields = ['14', 'THRU', '24', 'BY', '3'] fields = expand_thru_by(fields, set_fields=True, sort_fields=True) assert fields == [14, 17, 20, 23, 24], 'fields=%s' % fields # [14, 'THRU', 24, 'BY', 3] - this is the ideal answer, but close enough... assert collapse_thru_by(fields) == [14, 17, 20, 23, 24], collapse_thru_by(fields) fields = ['14', 'THRU', '24', 'BY', '2'] fields = expand_thru_by(fields, set_fields=True, sort_fields=True) assert collapse_thru_by(fields) == [14, 'THRU', 24, 'BY', 2], collapse_thru_by(fields) model = BDF() for card_lines in cards: model.add_card(card_lines, 'ACCEL1', comment='', is_list=False, has_none=True) for key, loads in sorted(model.loads.items()): for load in loads: str(load)
def add_card(cls, card, icard=0, comment=''): """ Adds a TEMPD card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object icard : int; default=0 sid to be parsed comment : str; default='' a comment for the card """ sid = integer(card, 1, 'sid') eid = integer(card, 2, 'eid') t = [] ifield = 3 for var in ['A', 'B', 'C']: ti = double_or_blank(card, ifield, 'T(%s)' % var, default=0.0) t.append(ti) ifield += 1 tpy = [] tpz = [] for var in ['A', 'B', 'C']: tpyi = double_or_blank(card, ifield, 'TPY(%s)' % var, default=0.0) tpzi = double_or_blank(card, ifield + 1, 'TPZ(%s)' % var, default=0.0) tpy.append(tpyi) tpz.append(tpzi) ifield += 2 tc = [] td = [] te = [] tf = [] for var in ['A', 'B', 'C']: tci = double_or_blank(card, ifield, 'TC(%s)' % var, default=0.0) tdi = double_or_blank(card, ifield + 1, 'TD(%s)' % var, default=0.0) tei = double_or_blank(card, ifield + 2, 'TE(%s)' % var, default=0.0) tfi = double_or_blank(card, ifield + 3, 'TF(%s)' % var, default=0.0) tc.append(tci) td.append(tdi) te.append(tei) tf.append(tfi) ifield += 4 ifield += 1 # skip the None list_fields = card[ifield:] eids = expand_thru_by(list_fields, set_fields=True, sort_fields=True, require_int=True, allow_blanks=False) return TEMPB3(sid, eid, t, tpy, tpz, tc, td, te, tf, eids, comment=comment)
def __init__(self, sid, nsm_type, value, ids, comment=''): """ Creates an NSM1/NSML1 card Parameters ---------- sid : int Case control NSM id nsm_type : str Type of card the NSM is applied to valid_properties = { PSHELL, PCOMP, PBAR, PBARL, PBEAM, PBEAML, PBCOMP, PROD, CONROD, PBEND, PSHEAR, PTUBE, PCONEAX, PRAC2D, ELEMENT } value : float NSM1: the non-structural pass per unit length/area NSML1: the total non-structural pass per unit length/area; the nsm will be broken down based on a weighted area/length ids : List[int] property ids or element ids depending on nsm_type comment : str; default='' a comment for the card """ Property.__init__(self) if comment: self.comment = comment if isinstance(ids, integer_types): ids = [ids] if isinstance(ids, str): assert ids == 'ALL', 'ids=%r is not ALL' % ids ids = [ids] else: # With the 'THRU' and 'THRU', 'BY' forms, blanks fields are # allowed for readability. Any combination of a list of IDs # and 'THRU' and 'THRU', 'BY' is allowed. The "THRU" and "BY" # lists may have missing IDs. That is the list of IDs in a # THRU range need not be continuous. ids = expand_thru_by(ids, allow_blanks=True) assert len(ids) > 0, ids self.sid = sid self.nsm_type = nsm_type # TODO: expand the node ids self.ids = ids self.value = value #print(str(self)) if self.nsm_type not in self.valid_properties: raise TypeError('nsm_type=%r must be in [%s]' % (self.nsm_type, ', '.join(self.valid_properties))) assert isinstance(ids, list), 'ids=%r is not a list' % (ids)
def add_card(cls, card, comment=''): sid = integer(card, 1, 'sid') #: Number (float) nfields = card.nfields i = 2 eid_data = [] while i < nfields: d = integer_string_or_blank(card, i, 'field_%s' % i) if d is not None: eid_data.append(d) i += 1 eids = expand_thru_by(eid_data) return BSURF(sid, eids, comment=comment)
def add_card(cls, card, comment=''): sid = integer(card, 1, 'sid') qvol = double(card, 2, 'qvol') control_point = integer_or_blank(card, 3, 'control_id', 0) i = 1 eids = [] for ifield in range(4, len(card)): eid = integer_or_string(card, ifield, 'eid_%i' % i) eids.append(eid) i += 1 elements = expand_thru_by(eids) return QVOL(sid, qvol, control_point, elements, comment=comment)
def __init__(self, sid, Q0, cntrlnd, eids, comment=''): ThermalLoad.__init__(self) if comment: self.comment = comment #: Load set identification number. (Integer > 0) self.sid = sid #: Heat flux into element self.Q0 = Q0 #: Control point for thermal flux load. (Integer > 0; Default = 0) self.cntrlnd = cntrlnd #: CHBDYj element identification numbers self.eids = expand_thru_by(eids)
def __init__(self, card=None, data=None, comment=''): if comment: self._comment = comment if card: #: Set identification number. (Unique Integer > 0) self.sid = integer(card, 1, 'sid') #: Number (float) nfields = card.nfields i = 2 eid_data = [] while i < nfields: d = integer_string_or_blank(card, i, 'field_%s' % i) if d is not None: eid_data.append(d) i += 1 #: Element identification numbers of shell elements. (Integer > 0) self.eids = expand_thru_by(eid_data) else: msg = '%s has not implemented data parsing' % self.type raise NotImplementedError(msg)
def add_card(cls, card, comment=''): """ Adds a QVOL card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ sid = integer(card, 1, 'sid') qvol = double(card, 2, 'qvol') control_point = integer_or_blank(card, 3, 'control_id', 0) i = 1 eids = [] for ifield in range(4, len(card)): eid = integer_or_string(card, ifield, 'eid_%i' % i) eids.append(eid) i += 1 elements = expand_thru_by(eids) return QVOL(sid, qvol, control_point, elements, comment=comment)
def add_card(cls, card, comment=''): """ Adds a BSURF card from ``BDF.add_card(...)`` Parameters ---------- card : BDFCard() a BDFCard object comment : str; default='' a comment for the card """ sid = integer(card, 1, 'sid') #: Number (float) nfields = card.nfields i = 2 eid_data = [] while i < nfields: d = integer_string_or_blank(card, i, 'field_%s' % i) if d is not None: eid_data.append(d) i += 1 eids = expand_thru_by(eid_data) return BSURF(sid, eids, comment=comment)
def __init__(self, nodamb, famb, cntrlnd, eids, comment=''): ThermalBC.__init__(self) if comment: self.comment = comment #: NODAMB Ambient point for radiation exchange. (Integer > 0) self.nodamb = nodamb #: Radiation view factor between the face and the ambient point. #: (Real > 0.0) self.famb = famb #: Control point for thermal flux load. (Integer > 0; Default = 0) self.cntrlnd = cntrlnd #: CHBDYi element identification number if isinstance(eids, int): eids = [eids] self.eids = expand_thru_by(eids) assert self.nodamb > 0 assert self.famb > 0.0 assert self.cntrlnd >= 0 self.eids_ref = None