Ejemplo n.º 1
0
    def __init__(self, card=None, data=None, comment=''):
        Table.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.tid = integer(card, 1, 'tid')
            self.x1 = double(card, 2, 'x1')
            self.x2 = double(card, 3, 'x2')
            assert self.x2 != 0.0

            nfields = len(card) - 1
            nterms = (nfields - 9) // 2
            xy = []
            for i in range(nterms):
                n = 9 + i * 2
                if card.field(n) == 'ENDT':
                    break
                x = double(card, n, 'x' + str(i + 1))
                y = double(card, n + 1, 'y' + str(i + 1))
                xy += [x, y]
            ENDT = string(card, nfields, 'ENDT')
            isData = False
        else:
            self.tid = data[0]
            self.x1 = data[1]
            self.x2 = data[2]
            xy = data[3:]
            isData = True
        self.parse_fields(xy, nrepeated=2, isData=isData)
Ejemplo n.º 2
0
 def __init__(self, card=None, data=None, comment=''):
     Property.__init__(self, card, data)
     if comment:
         self._comment = comment
     if card:
         #: Property ID
         self.pid = integer(card, 1, 'pid')
         #: diameter of the fastener
         self.d = double(card, 2, 'd')
         assert self.d > 0
         #: Specifies the element stiffness coordinate system
         self.mcid = integer_or_blank(card, 3, 'mcid', -1)
         assert self.mcid >= -1
         self.mflag = integer_or_blank(card, 4, 'mflag', 0)  # 0-absolute 1-relative
         assert self.mflag in [0, 1]
         #: stiffness values in directions 1-3
         self.kt1 = double(card, 5, 'kt1')
         self.kt2 = double(card, 6, 'kt2')
         self.kt3 = double(card, 7, 'kt3')
         #: Rotational stiffness values in directions 1-3
         self.kr1 = double_or_blank(card, 8, 'kr1', 0.0)
         self.kr2 = double_or_blank(card, 9, 'kr2', 0.0)
         self.kr3 = double_or_blank(card, 10, 'kr3', 0.0)
         #: Lumped mass of fastener
         self.mass = double_or_blank(card, 11, 'mass', 0.0)
         #: Structural damping
         self.ge = double_or_blank(card, 12, 'ge', 0.0)
         assert len(card) <= 13, 'len(PFAST card) = %i' % len(card)
     else:
         raise NotImplementedError(data)
Ejemplo n.º 3
0
    def add(self, card, comment=''):
        assert self.n > 0, self.n
        i = self.i
        load_id = integer(card, 1, 'load_id')
        tbar = double(card, 3, 'Tbar')
        tprime = double(card, 4, 'Tprime')
        t1 = double_or_blank(card, 5, 'T1')
        t2 = double_or_blank(card, 6, 'T2')

        self.load_id[i] = load_id
        self.element_id[i] = integer(card, 2, 'element_id')
        self.tbar[i] = tbar
        self.tprime[i] = tprime
        self.temp[i, 0] = t1
        self.temp[i, 1] = t2
        self.i += 1

        if len(card) >= 7:
            # i must be < self.n
            eids = expand_thru(card[9:])
            for eid in eids:
                self.load_id[i] = load_id
                assert isinstance(eid, int), eid
                self.element_id[i] = eid
                self.tbar[i] = tbar
                self.tprime[i] = tprime
                self.temp[i, 0] = t1
                self.temp[i, 1] = t2
                self.i += 1
                assert self.i <= self.n

        assert len(card) <= 7, '%s; n=%s' % (card, len(card))
        #assert len(card) <= 7, len(card)
        self.eids = None
Ejemplo n.º 4
0
    def __init__(self, card, data):
        Load.__init__(self, card, data)

        if card:
            #: load ID
            self.sid = integer(card, 1, 'sid')

            #: overall scale factor
            self.scale = double(card, 2, 'scale')

            #: individual scale factors (corresponds to loadIDs)
            self.scaleFactors = []

            #: individual loadIDs (corresponds to scaleFactors)
            self.loadIDs = []

            # alternating of scale factor & load set ID
            nLoads = len(card) - 3
            assert nLoads % 2 == 0
            for i in xrange(nLoads // 2):
                n = 2 * i + 3
                self.scaleFactors.append(double(card, n, 'scaleFactor'))
                self.loadIDs.append(integer(card, n + 1, 'loadID'))
        else:
            self.sid = data[0]
            self.scale = data[1]
            self.scaleFactors = data[2]
            self.loadIDs = data[3]
            assert len(data) == 4, '%s data=%s' % (self.type, data)
Ejemplo n.º 5
0
    def __init__(self, card=None, data=None, comment=''):
        Property.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Property ID
            self.pid = integer(card, 1, 'pid')
            #: Material ID
            self.mid1 = integer_or_blank(card, 2, 'mid1', 0)
            self.t1 = double_or_blank(card, 3, 't1')

            self.mid2 = integer_or_blank(card, 4, 'mid2', 0)
            if self.mid2 > 0:
                self.i = double(card, 5, 'i')
                assert self.i > 0.0
            else:
                self.i = blank(card, 5, 'i')

            self.mid3 = integer(card, 6, 0)
            if self.mid3 > 0:
                self.t2 = double(card, 7, 't3')
                assert self.t2 > 0.0
            else:
                self.t2 = blank(card, 7, 't3')

            self.nsm = double(card, 8, 'nsm')
            self.z1 = double(card, 9, 'z1')
            self.z2 = double(card, 10, 'z2')
            self.phi = fields(double, card, 'phi', i=11, j=len(card))
        else:
            raise NotImplementedError(data)
Ejemplo n.º 6
0
    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')

            #: Coordinates of point in complex plane. (Real)
            self.alpha1 = double(card, 2, 'alpha1')
            #: Coordinates of point in complex plane. (Real)
            self.omega1 = double(card, 3, 'omega1')
            #: Multiplicity of complex root at pole defined by point at ALPHAi
            #: and OMEGAi
            self.m1 = integer(card, 4, 'm1')

            #: Coordinates of point in complex plane. (Real)
            self.alpha2 = double(card, 5, 'alpha2')
            #: Coordinates of point in complex plane. (Real)
            self.omega2 = double(card, 6, 'omega2')
            #: Multiplicity of complex root at pole defined by point at ALPHAi
            #: and OMEGAi
            self.m2 = integer(card, 7, 'm2')
            assert len(card) == 8, 'len(EIGP card) = %i' % len(card)
        else:
            raise NotImplementedError('EIGP')
Ejemplo n.º 7
0
    def __init__(self, card=None, data=None, comment=''):
        Table.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.tid = integer(card, 1, 'tid')

            nfields = len(card) - 1
            nterms = (nfields - 9) // 2
            if nterms < 0:
                raise SyntaxError('%r card is too short' % self.type)
            xy = []
            for i in range(nterms):
                n = 9 + i * 2
                if card.field(n) == 'ENDT':
                    break
                x = double(card, n, 'x' + str(i + 1))
                y = double(card, n + 1, 'y' + str(i + 1))
                xy += [x, y]
            string(card, nfields, 'ENDT')
            isData = False
        else:
            self.tid = data[0]
            xy = data[1:]
            isData = True
        self.parse_fields(xy, nrepeated=2, isData=isData)
Ejemplo n.º 8
0
    def add(self, card, comment=""):
        i = self.i
        # if comment:
        #    self._comment = comment
        self.material_id[i] = integer(card, 1, "material_id")
        self.e11[i] = double(card, 2, "E11")  #: .. todo:: is this the correct default
        self.e22[i] = double(card, 3, "E22")  #: .. todo:: is this the correct default
        self.nu12[i] = double(card, 4, "nu12")  #: .. todo:: is this the correct default

        self.g12[i] = double_or_blank(card, 5, "g12", 0.0)
        self.g1z[i] = double_or_blank(card, 6, "g1z", 1e8)
        self.g2z[i] = double_or_blank(card, 7, "g2z", 1e8)
        self.rho[i] = double_or_blank(card, 8, "rho", 0.0)
        self.a1[i] = double_or_blank(card, 9, "a1", 0.0)
        self.a2[i] = double_or_blank(card, 10, "a2", 0.0)
        self.TRef[i] = double_or_blank(card, 11, "TRef", 0.0)
        self.Xt[i] = double_or_blank(card, 12, "Xt", 0.0)
        self.Xc[i] = double_or_blank(card, 13, "Xc", self.Xt[i])
        self.Yt[i] = double_or_blank(card, 14, "Yt", 0.0)
        self.Yc[i] = double_or_blank(card, 15, "Yc", self.Yt[i])
        self.S[i] = double_or_blank(card, 16, "S", 0.0)
        self.ge[i] = double_or_blank(card, 17, "ge", 0.0)
        self.F12[i] = double_or_blank(card, 18, "F12", 0.0)
        self.strn[i] = double_or_blank(card, 19, "strn", 0.0)
        assert len(card) <= 20, "len(MAT8 card) = %i" % len(card)
        self.i += 1
Ejemplo n.º 9
0
    def __init__(self, card=None, data=None, comment=''):
        RandomTable.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.tid = integer(card, 1, 'tid')
            self.xaxis = string_or_blank(card, 2, 'xaxis', 'LINEAR')
            self.yaxis = string_or_blank(card, 3, 'yaxis', 'LINEAR')

            nfields = len(card) - 1
            nterms = (nfields - 9) // 2
            if nterms < 0:
                raise SyntaxError('%r card is too short' % self.type)
            xy = []
            for i in range(nterms):
                n = 9 + i * 2
                if card.field(n) == 'ENDT':
                    break
                x = double(card, n, 'x' + str(i + 1))
                y = double(card, n + 1, 'y' + str(i + 1))
                xy += [x, y]
            string(card, nfields, 'ENDT')
            isData = False
        else:
            self.tid = data[0]
            self.xaxis = self.map_axis(data[1])
            self.yaxis = self.map_axis(data[2])
            xy = data[3:]
            isData = True
        assert self.xaxis in ['LINEAR', 'LOG'], 'xaxis=|%s|' % (self.xaxis)
        assert self.yaxis in ['LINEAR', 'LOG'], 'yaxis=|%s|' % (self.yaxis)
        self.parse_fields(xy, nrepeated=2, isData=isData)
Ejemplo n.º 10
0
    def __init__(self, card=None, data=None, comment=''):
        Table.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.tid = integer(card, 1, 'tid')
            self.Type = string_or_blank(card, 2, 'Type', 'G')
            assert self.Type in ['G', 'CRIT', 'Q'], 'Type=%r' % self.Type

            nfields = len(card) - 1
            nterms = (nfields - 9) // 2
            if nterms < 0:
                raise SyntaxError('%r card is too short' % self.type)
            xy = []
            for i in range(nterms):
                n = 9 + i * 2
                if card.field(n) == 'ENDT':
                    break
                x = double(card, n, 'x' + str(i + 1))
                y = double(card, n + 1, 'y' + str(i + 1))
                xy += [x, y]
            ENDT = string(card, nfields, 'ENDT')
            isData = False
        else:
            self.tid = data[0]
            self.x1 = data[1]
            self.Type = data[2]
            xy = data[5:]
            isData = True
        self.parse_fields(xy, nrepeated=2, isData=isData)
Ejemplo n.º 11
0
 def __init__(self, card=None, data=None, comment=''):
     if comment:
         self._comment = comment
     if card:
         self.sid = integer(card, 1, 'sid')
         self.eid = integer(card, 2, 'eid')
         self.Type = string(card, 3, 'Type')
         self.scale = string(card, 4, 'scale')
         self.x1 = double(card, 5, 'x1')
         self.p1 = double(card, 6, 'p1')
         self.x2 = double_or_blank(card, 7, 'x2', self.x1)
         self.p2 = double_or_blank(card, 8, 'p2', self.p1)
         assert 0 <= self.x1 <= self.x2
         assert len(card) <= 9, 'len(PLOAD1 card) = %i' % len(card)
     else:
         self.sid = data[0]
         self.eid = data[1]
         self.Type = data[2]
         self.scale = data[3]
         self.x1 = data[4]
         self.p1 = data[5]
         self.x2 = data[6]
         self.p2 = data[7]
     if self.Type not in self.validTypes:
         msg = '%s is an invalid type on the PLOAD1 card' % self.Type
         raise RuntimeError(msg)
     assert self.scale in self.validScales, '%s is an invalid scale on the PLOAD1 card' % (self.scale)
Ejemplo n.º 12
0
    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' % len(card)
        self.i += 1
Ejemplo n.º 13
0
 def __init__(self, card=None, data=None, comment=''):  # this card has missing fields
     Ring.__init__(self, card, data)
     if comment:
         self._comment = comment
     self.nid = integer(card, 1, 'nid')
     blank(card, 2, 'blank')
     self.R = double(card, 3, 'R')
     self.z = double(card, 4, 'z')
     blank(card, 5, 'blank')
     blank(card, 6, 'blank')
     self.ps = integer_or_blank(card, 7, 'ps')
     assert len(card) <= 8, 'len(RINGAX card) = %i' % len(card)
Ejemplo n.º 14
0
    def __init__(self, card=None, data=None, comment=''):
        if comment:
            self._comment = comment
        self.sid = integer(card, 1, 'sid')
        f1 = double(card, 2, 'f1')  # default=0.0 ?
        f2 = double(card, 3, 'f2')
        nf = integer_or_blank(card, 4, 'nf', 1)
        assert len(card) <= 5, 'len(FREQ2 card) = %i' % len(card)

        d = 1. / nf * log(f2 / f1)
        self.freqs = []
        for i in xrange(nf):
            self.freqs.append(f1 * exp(i * d))  # 0 based index
        self.cleanFreqs()
Ejemplo n.º 15
0
 def add_tempd(self, card, comment):
     assert (len(card) - 1) % 2 == 0, card
     for i in range(1, len(card), 2):
         temp_id = integer(card, i, 'temp_id')
         temperature = double(card, i+1, 'temperature')
         self._objs[temp_id].add_default(temp_id, temperature, comment)
     self.model.log.debug('TEMPs keys=%s' % self._objs.keys())
Ejemplo n.º 16
0
    def __init__(self, card=None, data=None, comment=''):
        """
        Defines a static concentrated moment at a grid point by specifying a
        magnitude and two grid points that determine the direction.::

          MOMENT1 SID G M G1 G2
        """
        Moment.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.sid = integer(card, 1, 'sid')
            self.node = integer(card, 2, 'node')
            self.mag = double(card, 3, 'mag')
            self.g1 = integer(card, 4, 'g1')
            self.g2 = integer(card, 5, 'g2')
            assert len(card) == 6, 'len(MOMENT1 card) = %i' % len(card)
        else:
            self.sid = data[0]
            self.node = data[1]
            self.mag = data[2]
            self.g1 = data[3]
            self.g2 = data[4]
            self.g3 = data[5]
            self.g4 = data[6]
            xyz = data[7:10]
            raise NotImplementedError('MOMENT1 is probably wrong')

        #assert len(xyz) == 3, 'xyz=%s' % (xyz)
        #self.xyz = array(xyz)
        self.xyz = None
Ejemplo n.º 17
0
    def __init__(self, card=None, data=None, comment=''):
        """
        Defines a static concentrated moment at a grid point by specification
        of a magnitude and four grid points that determine the direction.::

          MOMENT2 SID G M G1 G2 G3 G4
        """
        Moment.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.sid = integer(card, 1, 'sid')
            self.node = integer(card, 2, 'node')
            self.mag = double(card, 3, 'mag')
            self.g1 = integer(card, 4, 'g1')
            self.g2 = integer(card, 5, 'g2')
            self.g3 = integer(card, 6, 'g3')
            self.g4 = integer(card, 7, 'g4')
            xyz = array([double_or_blank(card, 5, 'X1', 0.0),
                         double_or_blank(card, 6, 'X2', 0.0),
                         double_or_blank(card, 7, 'X3', 0.0)])
            assert len(card) <= 8, 'len(MOMENT2 card) = %i' % len(card)
        else:
            self.sid = data[0]
            self.node = data[1]
            self.mag = data[2]
            self.g1 = data[3]
            self.g2 = data[4]
            self.g3 = data[5]
            self.g4 = data[6]
            xyz = data[7:10]
        assert len(xyz) == 3, 'xyz=%s' % (xyz)
        self.xyz = array(xyz)
Ejemplo n.º 18
0
    def __init__(self, card=None, data=None, comment=''):
        """
        Defines the properties of a shear panel (CSHEAR entry).

        +--------+-----+-----+---+-----+----+----+
        | PSHEAR | PID | MID | T | NSM | F1 | F2 |
        +--------+-----+-----+---+-----+----+----+
        """
        ShellProperty.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Property ID
            self.pid = integer(card, 1, 'pid')
            #: Material ID
            self.mid = integer(card, 2, 'mid')
            self.t = double(card, 3, 't')
            self.nsm = double_or_blank(card, 4, 'nsm', 0.0)
            self.f1 = double_or_blank(card, 5, 'f1', 0.0)
            self.f2 = double_or_blank(card, 6, 'f2', 0.0)
            assert self.t > 0.0
            #assert self.f1 >= 0.0
            #assert self.f2 >= 0.0
            assert len(card) <= 7, 'len(PSHEAR card) = %i' % len(card)
        else:
            #(pid,mid,t,nsm,f1,f2) = out
            self.pid = data[0]
            self.mid = data[1]
            self.t = data[2]
            self.nsm = data[3]
            self.f1 = data[4]
            self.f2 = data[5]
Ejemplo n.º 19
0
    def __init__(self, card=None, data=None, comment=''):
        """
        if coming from a BDF object, card is used
        if coming from the OP2, data is used
        """
        if comment:
            self._comment = comment
        Node.__init__(self, card, data)

        if card:
            self.nid = integer(card, 1, 'nid')
            self.phi = double(card, 4, 'phi')
            self.cd = integer(card, 6, 'cd')
            self.ps = integer(card, 7, 'ps')
            self.idf = integer(card, 8, 'idf')
        else:
            self.nid = data[0]
            self.phi = data[1]
            self.cd = data[2]
            self.ps = data[3]
            self.idf = data[4]

        assert self.nid > 0, 'nid=%s' % self.nid
        assert self.phi >= 0, 'phi=%s' % self.phi
        assert self.cd >= 0, 'cd=%s' % self.cd
        assert self.ps >= 0, 'ps=%s' % self.ps
        assert self.idf >= 0, 'idf=%s' % self.idf
Ejemplo n.º 20
0
    def getShockA(self, card, iStart):
        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)
        else:
            raise RuntimeError('Invalid shockType=|%s| on card\n%s' %(self.shockType, card))

        iStart += 8
        return iStart
Ejemplo n.º 21
0
    def __init__(self, card=None, data=None, comment=''):
        LineDamper.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.eid = integer(card, 1, 'eid')

            #: Value of the scalar damper (Real)
            self.b = double(card, 2, 'b')
            nids = [integer_or_blank(card, 3, 'n1', 0),
                    integer_or_blank(card, 5, 'n2', 0)]

            #: component number
            self.c1 = integer_or_blank(card, 4, 'c1', 0)
            self.c2 = integer_or_blank(card, 6, 'c2', 0)
            assert len(card) <= 7, 'len(CDAMP2 card) = %i' % len(card)
        else:
            self.eid = data[0]
            self.b = data[1]
            nids = [data[2], data[4]]
            self.c1 = data[3]
            self.c2 = data[5]

        self.prepare_node_ids(nids, allow_empty_nodes=True)
        assert len(self.nodes) == 2
        msg = 'on\n%s\n is invalid validComponents=[0,1,2,3,4,5,6]' % str(self)
        assert self.c1 in [0, 1, 2, 3, 4, 5, 6], 'c1=%r %s' % (self.c1, msg)
        assert self.c2 in [0, 1, 2, 3, 4, 5, 6], 'c2=%r %s' % (self.c2, msg)
Ejemplo n.º 22
0
    def __init__(self, card=None, data=None, comment=''):
        """
        ::

          FORCE          3       1            100.      0.      0.      1.
        """
        Force.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.sid = integer(card, 1, 'sid')
            self.node = integer(card, 2, 'node')
            self.cid = integer_or_blank(card, 3, 'cid', 0)
            self.mag = double(card, 4, 'mag')
            xyz = array([double_or_blank(card, 5, 'X1', 0.0),
                         double_or_blank(card, 6, 'X2', 0.0),
                         double_or_blank(card, 7, 'X3', 0.0)])
            assert len(card) <= 8, 'len(FORCE card) = %i' % len(card)
        else:
            self.sid = data[0]
            self.node = data[1]
            self.cid = data[2]
            self.mag = data[3]
            xyz = data[4:7]

        assert len(xyz) == 3, 'xyz=%s' % (xyz)
        self.xyz = array(xyz)
Ejemplo n.º 23
0
    def __init__(self, card=None, data=None, comment=''):
        """
        Defines a static concentrated moment at a grid point by specifying a
        scale factor and a vector that determines the direction.::

          MOMENT SID G CID M    N1  N2  N3
          MOMENT 2   5   6 2.9 0.0 1.0 0.0
        """
        Moment.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.sid = integer(card, 1, 'sid')
            self.node = integer(card, 2, 'node')
            self.cid = integer_or_blank(card, 3, 'cid', 0)
            self.mag = double(card, 4, 'mag')

            xyz = array([double_or_blank(card, 5, 'X1', 0.0),
                         double_or_blank(card, 6, 'X2', 0.0),
                         double_or_blank(card, 7, 'X3', 0.0)])
            assert len(card) <= 8, 'len(MOMENT card) = %i' % len(card)
        else:
            raise NotImplementedError(data)
        assert len(xyz) == 3, 'xyz=%s' % xyz
        self.xyz = xyz
Ejemplo n.º 24
0
    def __init__(self, card=None, data=None, comment=''):
        """
        ::

          FORCE2 SID G F G1 G2 G3 G4
        """
        Force.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.sid = integer(card, 1, 'sid')
            self.node = integer(card, 2, 'node')
            self.mag = double(card, 3, 'mag')
            self.g1 = integer(card, 4, 'g1')
            self.g2 = integer(card, 5, 'g2')
            self.g3 = integer(card, 6, 'g3')
            self.g4 = integer(card, 7, 'g4')
            assert len(card) == 8, 'len(FORCE2 card) = %i' % len(card)
        else:
            self.sid = data[0]
            self.node = data[1]
            self.mag = data[2]
            self.g1 = data[3]
            self.g2 = data[4]
            self.g3 = data[5]
            self.g4 = data[6]
Ejemplo n.º 25
0
    def __init__(self, card=None, data=None, comment=''):
        ThermalLoad.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Load set identification number. (Integer > 0)
            self.sid = integer(card, 1, 'sid')

            #: Heat flux into element (FLOAT)
            self.qFlux = double(card, 2, 'qFlux')
            eids  = []
            j = 1
            for i in range(3, len(card)):
                eid = integer_or_string(card, i, 'eid%i' % j)
                eids.append(eid)
                j += 1
            #: CHBDYj element identification numbers (Integer)
            assert len(eids) > 0
            
            #: .. todo:: use expand_thru_by ???
            self.eids = expand_thru(eids)
        else:
            self.sid = data[0]
            self.qFlux = data[1]
            self.eids = data[2:]
Ejemplo n.º 26
0
    def __init__(self, card=None, data=None, comment=''):
        if comment:
            self._comment = comment
        if card:
            #: Set identification number
            self.sid = integer(card, 1, 'sid')
            #: Coordinate system identification number.
            self.cid = integer_or_blank(card, 2, 'cid', 0)
            #: scale factor
            self.scale = double(card, 3, 'scale')
            #: Acceleration vector components measured in coordinate system CID
            self.N = array([double_or_blank(card, 4, 'N1', 0.0),
                            double_or_blank(card, 5, 'N2', 0.0),
                            double_or_blank(card, 6, 'N3', 0.0)])
            #: Indicates whether the CID coordinate system is defined in the
            #: main Bulk Data Section (MB = -1) or the partitioned superelement
            #: Bulk Data Section (MB = 0). Coordinate systems referenced in the
            #: main Bulk Data Section are considered stationary with respect to
            #: the assembly basic coordinate system. See Remark 10.
            #: (Integer; Default = 0)
            self.mb = integer_or_blank(card, 7, 'mb', 0)
            assert len(card) <= 8, 'len(GRAV card) = %i' % len(card)
        else:
            self.sid = data[0]
            self.cid = data[1]
            self.a = data[2]
            self.N = array(data[3:6])
            self.mb = data[6]
            self.scale = 1.
            assert len(data) == 7

        assert not allclose(max(abs(self.N)), 0.), ('GRAV N is a zero vector, '
                                                   'N=%s' % (str(self.N)))
Ejemplo n.º 27
0
    def __init__(self, card=None, data=None, comment=''):
        ThermalLoad.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Load set identification number. (Integer > 0)
            self.sid = integer(card, 1, 'eid')

            self.flag = string(card, 2, 'flag')
            assert self.flag in ['POINT', 'LINE', 'REV', 'AREA3', 'AREA4',
                                 'AREA6', 'AREA8']

            #: Magnitude of thermal flux into face. Q0 is positive for heat
            #: into the surface. (Real)
            self.Q0 = double(card, 3, 'Q0')

            #: Area factor depends on type. (Real > 0.0 or blank)
            self.af = double_or_blank(card, 4, 'af')
            nfields = card.nFields()

            #: grids
            self.grids = fields(integer, card, 'grid', i=5, j=nfields)

            #: Grid point identification of connected grid points.
            #: (Integer > 0 or blank)
            self.grids = expand_thru_by(self.grids)
        else:
            self.sid = data[0]
            self.flag = data[1]
            self.Q0 = data[2]
            self.af = data[3]
            self.grids = data[4:]
Ejemplo n.º 28
0
    def __init__(self, card=None, data=None, comment=''):
        CrackProperty.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Property ID
            self.pid = integer(card, 1, 'pid')
            #: Material ID
            self.mid = integer(card, 2, 'mid')
            self.thick = double(card, 3, 'thick')
            #: Plane strain or plane stress option.
            #: Use 0 for plane strain; 1 for plane stress. (Integer = 0 or 1)
            self.iPlane = integer(card, 4, 'iPlane')
            if self.iPlane not in [0, 1]:
                raise RuntimeError('Invalid value for iPlane on PRAC2D, can '
                                   'only be 0,1 iPlane=|%s|' % self.iPlane)
            #: Non-structural mass per unit area.(Real >= 0.0; Default = 0)
            self.nsm = double_or_blank(card, 5, 'nsm', 0.)
            #: Exponent used in the displacement field. See Remark 4.
            #: (Real; Default = 0.5)
            self.gamma = double_or_blank(card, 6, 'gamma', 0.5)
            #: Angle (in degrees) relative to the element x-axis along which
            #: stress intensity factors are to be calculated. See Remark 4.
            #: (Real; Default = 180.0)
            self.phi = double_or_blank(card, 7, 'phi', 180.)
            assert len(card) <= 8, 'len(PRAC2D card) = %i' % len(card)

        else:
            raise NotImplementedError(data)
Ejemplo n.º 29
0
    def __init__(self, card=None, data=None, comment=''):
        if comment:
            self._comment = comment
        if card:
            #: Load set identification number (Integer>0)
            self.sid = integer(card, 1, 'sid')

            #: Coordinate system identification number. (Integer>0: Default=0)
            self.cid = integer_or_blank(card, 2, 'cid', 0)

            #: Acceleration vector scale factor. (Real)
            self.scale = double(card, 3, 'scale')

            #: Components of the acceleration vector measured in coordinate system
            #: CID. (Real; at least one Ni != 0)
            self.N = array([double_or_blank(card, 4, 'N1', 0.0),
                            double_or_blank(card, 5, 'N2', 0.0),
                            double_or_blank(card, 6, 'N3', 0.0)])
            assert max(abs(self.N)) > 0.

            nodes = fields(integer_or_string, card, 'node', i=9, j=len(card))
        else:
            raise NotImplementedError(data)

        #: nodes to apply the acceleration to
        self.nodes = expand_thru_by(nodes)
Ejemplo n.º 30
0
    def __init__(self, card=None, icard=0, data=None, comment=''):
        SpringProperty.__init__(self, card, data)
        if comment:
            self._comment = comment
        nOffset = icard * 5
        if card:
            # 2 PELAS properties can be defined on 1 PELAS card
            # these are split into 2 separate cards

            #: Property identification number. (Integer > 0)
            self.pid = integer(card, 1 + nOffset, 'pid')
            #: Ki Elastic property value. (Real)
            self.k = double(card, 2 + nOffset, 'k')

            #: Damping coefficient, . See Remarks 5. and 6. (Real)
            #: To obtain the damping coefficient GE, multiply the
            #: critical damping ratio c/c0 by 2.0.
            self.ge = double_or_blank(card, 3 + nOffset, 'ge', 0.)
            #: Stress coefficient. (Real)
            self.s = double_or_blank(card, 4 + nOffset, 's', 0.)
        else:
            self.pid = data[0]
            self.k = data[1]
            self.ge = data[2]
            self.s = data[3]
Ejemplo n.º 31
0
 def __init__(self, card=None, data=None, comment=''):
     RodElement.__init__(self, card, data)
     if comment:
         self._comment = comment
     if card:
         self.eid = integer(card, 1, 'eid')
         nids = [integer(card, 2, 'n1'), integer(card, 3, 'n2')]
         self.mid = integer(card, 4, 'mid')
         self.A = double(card, 5, 'A')
         self.j = double_or_blank(card, 6, 'j', 0.0)
         self.c = double_or_blank(card, 7, 'c', 0.0)
         self.nsm = double_or_blank(card, 8, 'nsm', 0.0)
     else:
         self.eid = data[0]
         nids = data[1:3]
         self.mid = data[3]
         self.A = data[4]
         self.j = data[5]
         self.c = data[6]
         self.nsm = data[7]
     self.prepareNodeIDs(nids)
     assert len(self.nodes) == 2
Ejemplo n.º 32
0
    def __init__(self, card=None, data=None, comment=''):
        SpringElement.__init__(self, card, data)

        if comment:
            self._comment = comment
        if card:
            self.eid = integer(card, 1, 'eid')

            #: stiffness of the scalar spring
            self.k = double(card, 2, 'k')

            #: Scalar point identification numbers
            self.s1 = integer_or_blank(card, 3, 's1', 0)
            self.s2 = integer_or_blank(card, 4, 's2', 0)
            assert self.s1 > 0 or self.s2 > 0, 's1=%s s2=%s' % (self.s1,
                                                                self.s2)
            assert len(card) <= 5, 'len(CELAS4 card) = %i' % len(card)
        else:
            self.eid = data[0]
            self.k = data[1]
            self.s1 = data[2]
            self.s2 = data[3]
Ejemplo n.º 33
0
    def add(self, card, comment=''):
        i = self.i
        #self.model.log.debug('adding %s; i=%s' %(card, i))
        self.property_id[i] = integer(card, 1, 'property_id')
        self.material_id[i] = integer(card, 2, 'material_id')
        self.thickness[i] = double(card, 3, 'thickness')

        #: Material identification number for bending
        self.material_id2[i] = integer_or_blank(card, 4, 'material_id2', -1)

        # ..todo:: poor name
        #: ..math:: I = \frac{12I}{t^3} I_{plate}
        #: Scales the moment of interia of the element based on the
        #: moment of interia for a plate
        self.twelveIt3[i] = double_or_blank(card, 5, '12*I/t^3', 1.0)

        self.material_id3[i] = integer_or_blank(card, 6, 'material_id3', -1)
        self.tst[i] = double_or_blank(card, 7, 'ts/t', 0.833333)

        #: Non-structural Mass
        self.nsm[i] = double_or_blank(card, 8, 'nsm', 0.0)

        tOver2 = self.thickness[i] / 2.
        self.z1[i] = double_or_blank(card, 9,  'z1', -tOver2)
        self.z2[i] = double_or_blank(card, 10, 'z2',  tOver2)
        self.material_id4[i] = integer_or_blank(card, 11, 'material_id4', -1)

        #if self.material_id2 is None:
        #    assert self.material_id3 is None
        #else: # material_id2 is defined
        #    #print "self.material_id2 = ",self.material_id2
        #    assert self.material_id2 >= -1
        #    #assert self.material_id3 >   0

        #if self.material_id is not None and self.material_id2 is not None:
        #    assert self.material_id4==None
        assert len(card) <= 12, 'len(PSHELL card) = %i' % len(card)
        self.i += 1
Ejemplo n.º 34
0
    def build(self):
        """
        :param self: the MOMENT object
        :param cards: the list of MOMENT cards
        """
        cards = self._cards
        ncards = len(cards)
        self.n = ncards
        if ncards:
            float_fmt = self.model.float
            #: Property ID
            self.load_id = zeros(ncards, 'int32')
            self.node_id = zeros(ncards, 'int32')
            self.coord_id = zeros(ncards, 'int32')
            self.mag = zeros(ncards, float_fmt)
            self.xyz = zeros((ncards, 3), float_fmt)

            for i, card in enumerate(cards):
                self.load_id[i] = integer(card, 1, 'sid')
                self.node_id[i] = integer(card, 2, 'node')
                self.coord_id[i] = integer_or_blank(card, 3, 'cid', 0)
                self.mag[i] = double(card, 4, 'mag')
                xyz = [
                    double_or_blank(card, 5, 'X1', 0.0),
                    double_or_blank(card, 6, 'X2', 0.0),
                    double_or_blank(card, 7, 'X3', 0.0)
                ]
                self.xyz[i] = xyz
                assert len(card) <= 8, 'len(MOMENT card) = %i' % len(card)

            i = self.load_id.argsort()
            self.load_id = self.load_id[i]
            self.node_id = self.node_id[i]
            self.coord_id = self.coord_id[i]
            self.mag = self.mag[i]
            self.xyz = self.xyz[i]
            self._cards = []
            self._comments = []
Ejemplo n.º 35
0
    def __init__(self, card=None, data=None, comment=''):
        ThermalBC.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Material identification number
            self.radmid = integer(card, 1, 'radmid')
            assert self.radmid > 0

            self.absorb = double(card, 2, 'absorb')
            assert 0. <= self.absorb <= 1.0

            nfields = card.nFields()

            self.emissivity = fields(double,
                                     card,
                                     'emissivity',
                                     i=3,
                                     j=nfields)
        else:
            raise NotImplementedError(data)
        for e in self.emissivity:
            assert 0. <= e <= 1.0
Ejemplo n.º 36
0
    def __init__(self, card=None, data=None, comment=''):
        ThermalLoad.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Load set identification number. (Integer > 0)
            self.sid = integer(card, 1, 'sid')

            nfields = len(card) - 2
            assert nfields % 2 == 0

            #: dictionary of temperatures where the key is the grid ID (Gi)
            #: and the value is the temperature (Ti)
            self.temperatures = {}
            for i in range(nfields // 2):
                n = i * 2 + 2
                gi = integer(card, n, 'g' + str(i))
                Ti = double(card, n + 1, 'T' + str(i))
                self.temperatures[gi] = Ti
        else:
            #print "TEMP data = ",data
            self.sid = data[0]
            self.temperatures = {data[1]: data[2]}
Ejemplo n.º 37
0
    def __init__(self, card=None, data=None, comment=''):
        SpringElement.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.eid = integer(card, 1, 'eid')

            #: stiffness of the scalar spring
            self.k = double(card, 2, 'k')

            nids = [integer_or_blank(card, 3, 'g1', 0),
                    integer_or_blank(card, 5, 'g2', 0)]

            #: component number
            self.c1 = integer_or_blank(card, 4, 'c1', 0)
            self.c2 = integer_or_blank(card, 6, 'c2', 0)

            #: damping coefficient
            self.ge = double_or_blank(card, 7, 'ge', 0.)

            #: stress coefficient
            self.s = double_or_blank(card, 8, 's', 0.)
            assert len(card) <= 9, 'len(CELAS2 card) = %i' % len(card)
        else:
            self.eid = data[0]
            self.k = data[1]
            nids = [data[2], data[4]]
            self.c1 = data[3]
            self.c2 = data[5]
            self.ge = data[6]
            self.s = data[7]

        msg = 'on\n%s\n is invalid validComponents=[0,1,2,3,4,5,6]' % str(self)
        assert self.c1 in [0, 1, 2, 3, 4, 5, 6], 'c1=|%s| %s' % (self.c1, msg)
        assert self.c2 in [0, 1, 2, 3, 4, 5, 6], 'c2=|%s| %s' % (self.c2, msg)
        self.prepareNodeIDs(nids, allowEmptyNodes=True)
        assert len(self.nodes) == 2
Ejemplo n.º 38
0
    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)
Ejemplo n.º 39
0
    def __init__(self, card=None, data=None, comment=''):
        if comment:
            self._comment = comment
        if card:
            #: Convection property identification number. (Integer > 0)
            self.pconid = integer(card, 1, 'pconid')
            assert self.pconid > 0

            #: Material property identification number. (Integer > 0)
            self.mid = integer(card, 2, 'mid')
            assert self.mid > 0

            #: Type of formula used for free convection.
            #: (Integer 0, 1, 10, 11, 20, or 21)
            self.form = integer_or_blank(card, 3, 'form', 0)
            assert self.form in [0, 1, 10, 11, 20, 21]

            #: Flag for mass flow convection. (Integer = 0 or 1; Default = 0)
            self.flag = integer_or_blank(card, 4, 'flag', 0)

            #: Constant coefficient used for forced convection
            self.coef = double(card, 5, 'coef')

            #: Reynolds number convection exponent. (Real > 0.0; Default = 0.0)
            self.expr = double_or_blank(card, 6, 'expr', 0.0)

            #: Prandtl number convection exponent for heat transfer into the
            #: workingfluid. (Real > 0.0; Default = 0.0)
            self.exppi = double_or_blank(card, 7, 'exppi', 0.0)

            #: Prandtl number convection exponent for heat transfer into the
            #: working fluid. (Real > 0.0; Default = 0.0)
            self.exppo = double_or_blank(card, 8, 'exppo', 0.0)
            assert len(card) <= 9, 'len(PCONVM card) = %i' % len(card)
        else:
            raise NotImplementedError(data)
Ejemplo n.º 40
0
    def __init__(self, card=None, data=None, comment=''):
        Table.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.tid = integer(card, 1, 'tid')
            self.x1 = double(card, 2, 'x1')
            self.x2 = double(card, 3, 'x2')
            self.x3 = double(card, 4, 'x3')
            self.x4 = double(card, 5, 'x4')

            assert self.x2 != 0.0
            assert self.x3 < self.x4

            nfields = len(card) - 1
            nterms = (nfields - 9) // 2
            if nterms < 0:
                raise SyntaxError('%r card is too short' % self.type)
            xy = []
            for i in range(nterms):
                n = 9 + i * 2
                if card.field(n) == 'ENDT':
                    break
                x = double(card, n, 'x' + str(i + 1))
                y = double(card, n + 1, 'y' + str(i + 1))
                xy += [x, y]
            ENDT = string(card, nfields, 'ENDT')
            isData = False
        else:
            self.tid = data[0]
            self.x1 = data[1]
            self.x2 = data[2]
            self.x3 = data[3]
            self.x4 = data[4]
            xy = data[5:]
            isData = True
        self.parse_fields(xy, nrepeated=2, isData=isData)
Ejemplo n.º 41
0
    def __init__(self, card=None, data=None, comment=''):
        Property.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Property ID
            self.pid = integer(card, 1, 'pid')
            #: Material ID
            self.mid1 = integer_or_blank(card, 2, 'mid1', 0)
            self.t1 = double_or_blank(card, 3, 't1')

            self.mid2 = integer_or_blank(card, 4, 'mid2', 0)
            if self.mid2 > 0:
                self.i = double(card, 5, 'i')
                assert self.i > 0.0
            else:
                self.i = blank(card, 5, 'i')

            self.mid3 = integer(card, 6, 0)
            if self.mid3 > 0:
                self.t2 = double(card, 7, 't3')
                assert self.t2 > 0.0
            else:
                self.t2 = blank(card, 7, 't3')

            self.nsm = double(card, 8, 'nsm')
            self.z1 = double(card, 9, 'z1')
            self.z2 = double(card, 10, 'z2')

            j = 1
            self.phi = []
            for i in range(11, len(card)):
                phii = double(card, i, 'phi' % j)
                self.phi.append(phii)
                j += 1
        else:
            raise NotImplementedError(data)
Ejemplo n.º 42
0
    def build(self):
        cards = self._cards
        ncards = len(cards)
        self.n = ncards
        if ncards:
            float_fmt = self.model.float
            #: Property ID
            self.property_id = zeros(ncards, 'int32')
            self.material_id = zeros(ncards, 'int32')
            self.thickness = zeros(ncards, float_fmt)

            self.material_id2 = zeros(ncards, 'int32')
            self.twelveIt3 = zeros(ncards, float_fmt)
            self.material_id3 = zeros(ncards, 'int32')

            self.tst = zeros(ncards, float_fmt)
            self.nsm = zeros(ncards, float_fmt)
            self.z1 = zeros(ncards, float_fmt)
            self.z2 = zeros(ncards, float_fmt)
            self.material_id4 = zeros(ncards, 'int32')

            # ..todo:: incomplete
            for i, card in enumerate(cards):
                self.property_id[i] = integer(card, 1, 'property_id')
                self.material_id[i] = integer(card, 2, 'material_id')
                self.thickness[i] = double(card, 3, 'thickness')

                #: Material identification number for bending
                self.material_id2[i] = integer_or_blank(card, 4, 'material_id2', -1)

                # ..todo:: poor name
                #: ..math:: I = \frac{12I}{t^3} I_{plate}
                #: Scales the moment of interia of the element based on the
                #: moment of interia for a plate
                self.twelveIt3[i] = double_or_blank(card, 5, '12*I/t^3', 1.0)

                self.material_id3[i] = integer_or_blank(card, 6, 'material_id3', -1)
                self.tst[i] = double_or_blank(card, 7, 'ts/t', 0.833333)

                #: Non-structural Mass
                self.nsm[i] = double_or_blank(card, 8, 'nsm', 0.0)

                tOver2 = self.thickness[i] / 2.
                self.z1[i] = double_or_blank(card, 9,  'z1', -tOver2)
                self.z2[i] = double_or_blank(card, 10, 'z2',  tOver2)
                self.material_id4[i] = integer_or_blank(card, 11, 'material_id4', -1)

                #if self.material_id2 is None:
                #    assert self.material_id3 is None
                #else: # material_id2 is defined
                #    #print "self.material_id2 = ",self.material_id2
                #    assert self.material_id2 >= -1
                #    #assert self.material_id3 >   0

                #if self.material_id is not None and self.material_id2 is not None:
                #    assert self.material_id4==None
                assert len(card) <= 12, 'len(PSHELL card) = %i' % len(card)

            # nan is float specific
            #self.material_id[where(self.material_id2 == -1)[0]] = nan

            # sort the NDARRAYs so we can use searchsorted
            i = self.property_id.argsort()
            self.property_id = self.property_id[i]
            self.material_id = self.material_id[i]
            self.thickness = self.thickness[i]
            self.material_id2 = self.material_id2[i]
            self.twelveIt3 = self.twelveIt3[i]
            self.material_id3 = self.material_id3[i]
            self.tst = self.tst[i]
            self.nsm = self.nsm[i]
            self.z1 = self.z1[i]
            self.z2 = self.z2[i]
            self.material_id4 = self.material_id4[i]
        
            if len(unique(self.property_id)) != len(self.property_id):
                raise RuntimeError('There are duplicate PSHELL IDs...')
            self._cards = []
            self._comments = []
Ejemplo n.º 43
0
    def __init__(self, card=None, data=None, comment=''):
        LineProperty.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.pid = integer(card, 1, 'pid')
            self.mid = integer(card, 2, 'mid')

            self.A = double(card, 3, 'A')
            self.iz = double(card, 4, 'Iz')
            self.iy = double(card, 5, 'Iy')
            self.iyz = double_or_blank(card, 6, 'Iyz', 0.0)
            self.j = double_or_blank(card, 7, 'J', self.iy + self.iz)
            self.nsm = double_or_blank(card, 8, 'nsm', 0.0)

            self.cy = double(card, 9, 'cy')
            self.cz = double(card, 10, 'cz')
            self.dy = double(card, 11, 'dy')
            self.dz = double(card, 12, 'dz')
            self.ey = double(card, 13, 'ey')
            self.dz = double(card, 14, 'ez')
            self.fy = double(card, 15, 'fy')
            self.fz = double(card, 16, 'fz')
            # more...
        else:
            raise NotImplementedError(data)
Ejemplo n.º 44
0
    def __init__(self, card=None, data=None, comment=''):
        LineProperty.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.pid = integer(card, 1, 'pid')
            self.mid = integer(card, 2, 'mid')

            value3 = integer_or_double(card, 3, 'A_FSI')
            if isinstance(value3, float):
                self.beamType = 1
                #: Area of the beam cross section
                self.A = double(card, 3, 'A')

                #: Area moments of inertia in planes 1 and 2.
                self.i1 = double(card, 4, 'I1')
                self.i2 = double(card, 5, 'I2')

                #: Torsional stiffness :math:`J`
                self.j = double(card, 6, 'J')

                # line2
                #: The r,z locations from the geometric centroid for stress
                #: data recovery.
                self.c1 = double(card, 9, 'c1')
                self.c2 = double(card, 10, 'c2')
                self.d1 = double(card, 11, 'd1')
                self.d2 = double(card, 12, 'd2')
                self.e1 = double(card, 13, 'e1')
                self.e2 = double(card, 14, 'e2')
                self.f1 = double(card, 15, 'f1')
                self.f2 = double(card, 16, 'f2')

                # line 3
                #: Shear stiffness factor K in K*A*G for plane 1.
                self.k1 = double(card, 17, 'k1')
                #: Shear stiffness factor K in K*A*G for plane 2.
                self.k2 = double(card, 18, 'k2')

                #: Nonstructural mass per unit length.
                self.nsm = double(card, 19, 'nsm')

                #: Radial offset of the geometric centroid from points GA and GB.
                self.rc = double(card, 20, 'rc')

                #: Offset of the geometric centroid in a direction perpendicular
                #: to the plane of points GA and GB and vector v
                self.zc = double(card, 21, 'zc')

                #: Radial offset of the neutral axis from the geometric
                #: centroid, positive is toward the center of curvature
                self.deltaN = double(card, 22, 'deltaN')

            elif isinstance(value3, int):  # alternate form
                self.beamType = 2
                #: Flag selecting the flexibility and stress intensification
                #: factors. See Remark 3. (Integer = 1, 2, or 3)
                self.fsi = integer(card, 3, 'fsi')
                assert self.fsi in [1, 2, 3]

                #: Mean cross-sectional radius of the curved pipe
                self.rm = double(card, 4, 'rm')

                #: Wall thickness of the curved pipe
                self.t = double(card, 5, 't')

                #: Internal pressure
                self.p = double(card, 6, 'p')

                # line3
                # Non-structural mass :math:`nsm`
                self.nsm = double(card, 11, 'nsm')
                self.rc = double(card, 12, 'rc')
                self.zc = double(card, 13, 'zc')
            else:
                raise RuntimeError('Area/FSI on CBEND must be defined...')

            #: Bend radius of the line of centroids
            self.rb = double_or_blank(card, 7, 'rb')

            #: Arc angle :math:`\theta_B` of element  (optional)
            self.thetab = double_or_blank(card, 8, 'thetab')
            assert len(card) <= 23, 'len(PBEND card) = %i' % len(card)

        else:
            raise NotImplementedError(data)
Ejemplo n.º 45
0
    def addColumn(self, card=None, data=None, comment=''):
        if comment:
            if hasattr(self, '_comment'):
                self._comment += comment
            else:
                self._comment = comment
        Gj = integer(card, 2, 'Gj')
        Cj = integer(card, 3, 'Cj')
        #Cj = components(card, 3, 'Cj')
        #assert isinstance(Cj, int), 'type(Cj)=%s not int; Cj=%s' % (type(Cj), Cj)

        nfields = len(card)
        #print("nfields =", nfields)
        #print("card[5:] =", card[5:])
        #print("(nfields - 5) % 4 =", (nfields - 5) % 4)

        nloops = (nfields - 5) // 4
        if (nfields - 5) % 4 == 3:
            nloops += 1
        #assert nFields <= 8,'nFields=%s' % nFields

        #print "nloops   = ",nloops
        for i in xrange(nloops):
            self.GCj.append((Gj, Cj))

        if self.isComplex():
            if self.isPolar():
                for i in xrange(nloops):
                    n = 5 + 4 * i
                    Gi = integer(card, n, 'Gi')
                    Ci = integer(card, n + 1, 'Ci')
                    #Ci = components(card, n + 1, 'Ci')
                    #assert isinstance(Cj, int), 'type(Ci)=%s not int; Ci=%s' % (type(Ci), Ci)
                    self.GCi.append((Gi, Ci))
                    magi = double(card, n + 2, 'ai')
                    phasei = double(card, n + 3, 'bi')
                    reali = magi * cos(radians(phasei))
                    complexi = magi * sin(radians(phasei))
                    self.Real.append(reali)
                    self.Complex.append(complexi)
            else:
                for i in xrange(nloops):
                    n = 5 + 4 * i
                    Gi = integer(card, n, 'Gi')
                    Ci = integer(card, n + 1, 'Ci')
                    #Ci = components(card, n + 1, 'Ci')
                    #assert isinstance(Cj, int), 'type(Ci)=%s not int; Ci=%s' % (type(Ci), Ci)
                    self.GCi.append((Gi, Ci))
                    reali = double(card, n + 2, 'real')
                    complexi = double(card, n + 3, 'complex')
                    self.Real.append(reali)
                    self.Complex.append(complexi)
        else:
            for i in xrange(nloops):
                n = 5 + 4 * i
                Gi = integer(card, n, 'Gi')
                Ci = integer(card, n + 1, 'Ci')
                #Ci = components(card, n + 1, 'Ci')
                reali = double(card, n + 2, 'real')
                self.GCi.append((Gi, Ci))
                self.Real.append(reali)
                #print("GC=%s,%s real=%s" % (Gi, Ci, reali))

        msg = '(len(GCj)=%s len(GCi)=%s' % (len(self.GCj), len(self.GCi))
        assert len(self.GCj) == len(self.GCi), msg
Ejemplo n.º 46
0
    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)
Ejemplo n.º 47
0
    def __init__(self, card=None, data=None, comment=''):
        MaterialDependence.__init__(self, card, data)
        if comment:
            self._comment = comment

        if card:
            #: Identification number of a MAT1, MAT2, or MAT9 entry.
            self.mid = integer(card, 1, 'mid')
            #: Identification number of a TABLES1 or TABLEST entry. If H is
            #: given, then this field must be blank.
            self.tid = integer_or_blank(card, 2, 'tid')
            #: Type of material nonlinearity. ('NLELAST' for nonlinear elastic
            #: or 'PLASTIC' for elastoplastic.)
            self.Type = string(card, 3, 'Type')

            if self.Type not in ['NELAST', 'PLASTIC']:
                raise ValueError(
                    'MATS1 Type must be [NELAST, PLASTIC]; Type=%r' %
                    self.Type)
            if self.Type == 'NLELAST':
                self.h = blank(card, 4, 'h')
                self.hr = blank(card, 6, 'hr')
                self.yf = blank(card, 5, 'yf')
                self.limit1 = blank(card, 7, 'yf')
                self.limit2 = 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
                self.h = double_or_blank(card, 4, 'H')

                #: Yield function criterion, selected by one of the following
                #: values (1) Von Mises (2) Tresca (3) Mohr-Coulomb
                #: (4) Drucker-Prager
                self.yf = 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 = integer_or_blank(card, 6, 'hr', 1)
                #: Initial yield point
                self.limit1 = double(card, 7, 'limit1')

                if self.yf == 3 or self.yf == 4:
                    #: Internal friction angle, measured in degrees, for the
                    #: Mohr-Coulomb and Drucker-Prager yield criteria
                    self.limit2 = double(card, 8, 'limit2')
                else:
                    #self.limit2 = blank(card, 8, 'limit2')
                    self.limit2 = None
            assert len(card) <= 9, 'len(MATS1 card) = %i' % len(card)
        else:
            (mid, tid, Type, h, yf, hr, limit1, limit2) = data
            self.mid = mid
            self.tid = tid
            if Type == 1:
                self.Type = 'NLELAST'
            elif Type == 2:
                self.Type = 'PLASTIC'
            else:
                raise RuntimeError('Invalid Type:  Type=%s; must be 1=NLELAST '
                                   'or 2=PLASTIC' % (Type))
            self.h = h
            self.yf = yf
            self.hr = hr
            self.limit1 = limit1
            self.limit2 = limit2
Ejemplo n.º 48
0
    def __init__(self, card=None, data=None, comment=''):
        if comment:
            self._comment = comment
        if card:
            self.sid = integer(card, 1, 'sid')
            self.ndt = integer(card, 2, 'ndt')
            assert self.ndt >= 3
            self.dt = double(card, 3, 'dt')
            assert self.dt > 0.
            self.no = integer_or_blank(card, 4, 'no', 1)

            #: .. note:: not listed in all QRGs
            self.method = string_or_blank(card, 5, 'method', 'ADAPT')
            if self.method == 'ADAPT':
                self.kStep = integer_or_blank(card, 6, 'kStep', 2)
            elif self.method == 'ITER':
                self.kStep = integer_or_blank(card, 6, 'kStep', 10)
            elif self.method in ['AUTO', 'TSTEP']:
                self.kStep = None
                #self.kStep = blank(card, 6, 'kStep') #: .. todo:: not blank
            else:
                msg = 'invalid TSTEPNL Method.  method=|%s|' % (self.method)
                raise RuntimeError(msg)
            self.maxIter = integer_or_blank(card, 7, 'maxIter', 10)
            self.conv = string_or_blank(card, 8, 'conv', 'PW')

            # line 2
            self.epsU = double_or_blank(card, 9, 'epsU', 1.E-2)
            self.epsP = double_or_blank(card, 10, 'epsP', 1.E-3)
            self.epsW = double_or_blank(card, 11, 'epsW', 1.E-6)
            self.maxDiv = integer_or_blank(card, 12, 'maxDiv', 2)
            self.maxQn = integer_or_blank(card, 13, 'maxQn', 10)
            self.MaxLs = integer_or_blank(card, 14, 'MaxLs', 2)
            self.fStress = double_or_blank(card, 15, 'fStress', 0.2)

            # line 3
            self.maxBisect = integer_or_blank(card, 17, 'maxBisect', 5)
            self.adjust = integer_or_blank(card, 18, 'adjust', 5)
            self.mStep = integer_or_blank(card, 19, 'mStep')
            self.rb = double_or_blank(card, 20, 'rb', 0.6)
            self.maxR = double_or_blank(card, 21, 'maxR', 32.)
            self.uTol = double_or_blank(card, 22, 'uTol', 0.1)
            self.rTolB = double_or_blank(card, 23, 'rTolB', 20.)

            # not listed in all QRGs
            self.minIter = integer_or_blank(card, 24, 'minIter')
            assert len(card) <= 25, 'len(TSTEPNL card) = %i' % len(card)
        else:
            (sid, ndt, dt, no, method, kStep, maxIter, conv, epsU, epsP, epsW,
             maxDiv, maxQn, maxLs, fStress, maxBisect, adjust, mStep, rb, maxR,
             uTol, rTolB) = data
            self.sid = sid
            self.ndt = ndt
            self.dt = dt
            self.no = no
            self.method = method
            self.kStep = kStep
            self.maxIter = maxIter
            self.conv = conv

            # line 2
            self.epsU = epsU
            self.epsP = epsP
            self.epsW = epsW
            self.maxDiv = maxDiv
            self.maxQn = maxQn
            self.MaxLs = maxLs
            self.fStress = fStress

            # line 3
            self.maxBisect = maxBisect
            self.adjust = adjust
            self.mStep = mStep
            self.rb = rb
            self.maxR = maxR
            self.uTol = uTol
            self.rTolB = rTolB
            self.minIter = None  # not listed in DMAP 2005
Ejemplo n.º 49
0
    def build(self):
        """
        :param self: the CELAS2 object
        """
        cards = self._cards
        ncards = len(cards)
        self.n = ncards

        if ncards:
            float_fmt = self.model.float
            self.element_id = array(self.element_id, 'int32')
            self.node_ids = array(self.node_ids)
            self.K = array(self.K, float_fmt)
            self.components = array(self.components, 'int32')
            self.ge = array(self.ge, float_fmt)
            self.s = array(self.s, float_fmt)
            return

            float_fmt = self.model.float

            self.element_id = zeros(ncards, 'int32')
            #: Property ID
            self.property_id = zeros(ncards, 'int32')

            # Node IDs
            self.node_ids = zeros((ncards, 2), 'int32')

            #: stiffness of the scalar spring
            self.K = zeros(ncards, float_fmt)

            #: component number
            self.components = zeros((ncards, 2), 'int32')

            #: damping coefficient
            self.ge = zeros(ncards, float_fmt)

            #: stress coefficient
            self.s = zeros(ncards, float_fmt)

            for i, card in enumerate(cards):
                self.element_id[i] = integer(card, 1, 'eid')
                self.K[i] = double(card, 2, 'k')
                self.node_ids[i] = [
                    integer(card, 3, 'G1'),
                    integer(card, 5, 'G2')
                ]
                self.components[i] = [
                    integer_or_blank(card, 4, 'C1', 0),
                    integer_or_blank(card, 6, 'C2', 0)
                ]
                self.ge[i] = double_or_blank(card, 7, 'ge', 0.)
                self.s[i] = double_or_blank(card, 8, 's', 0.)
                assert len(
                    card) <= 9, 'len(CELAS2 card) = %i' % len(card) + str(card)

            i = self.element_id.argsort()
            self.element_id = self.element_id[i]
            self.K = self.K[i]
            self.node_ids = self.node_ids[i, :]
            self.components = self.components[i, :]
            self.ge = self.ge[i]
            self.s = self.s[i]

            unique_eids = unique(self.element_id)
            if len(unique_eids) != len(self.element_id):
                raise RuntimeError('There are duplicate CELAS2 IDs...')
            self._cards = []
            self._comments = []
Ejemplo n.º 50
0
    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)
Ejemplo n.º 51
0
    def __init__(self, card=None, data=None, comment=''):
        Constraint.__init__(self, card, data)
        if comment:
            self._comment = comment

        if card:
            #: Set identification number. (Integer > 0)
            self.conid = integer(card, 1, 'conid')
            #: Identification number of grid or scalar point. (Integer > 0)
            self.gids = []
            #: Component number. (Any one of the Integers 1 through 6 for grid
            #: points; blank or zero for scalar points.)
            self.constraints = []
            #: Coefficient. (Real; Default = 0.0 except A1 must be nonzero.)
            self.enforced = []

            fields = card.fields(0)
            nfields = len(fields)

            i = 1
            for ifield in range(2, nfields, 8):
                grid = integer(card, ifield, 'G%i' % i)
                component = components_or_blank(card, ifield + 1,
                                                'constraint%i' % i,
                                                0)  # scalar point
                if i == 1:
                    value = double(card, ifield + 2, 'enforced%i' % i)
                    if value == 0.0:
                        raise RuntimeError(
                            'enforced1 must be nonzero; value=%r' % value)
                else:
                    value = double_or_blank(card, ifield + 2, 'enforced%i' % i,
                                            0.0)
                self.gids.append(grid)
                self.constraints.append(component)
                self.enforced.append(value)
                i += 1

                if ifield + 4 > nfields and i != 2:
                    # if G2 is empty (it's ifield+4 because nfields is length based and not loop friendly)
                    break
                grid = integer(card, ifield + 3, 'G%i' % i)
                component = components_or_blank(card, ifield + 4,
                                                'constraint%i' % i,
                                                0)  # scalar point
                value = double_or_blank(card, ifield + 5, 'enforced%i' % i)
                self.gids.append(grid)
                self.constraints.append(component)
                self.enforced.append(value)
                i += 1

            # reduce the size if there are duplicate Nones
            #nConstraints = max(len(self.gids       ),
            #                   len(self.constraints),
            #                   len(self.enforced   ))
            #self.gids        = self.gids[       0:nConstraints]
            #self.constraints = self.constraints[0:nConstraints]
            #self.enforced    = self.enforced[   0:nConstraints]
        else:
            msg = '%s has not implemented data parsing' % self.type
            raise NotImplementedError(msg)
Ejemplo n.º 52
0
    def test_double(self):
        """
        value = double(card, n, fieldname)
        """
        # integer
        with self.assertRaises(SyntaxError):
            double(BDFCard([1]), 0, 'field')
        with self.assertRaises(SyntaxError):
            double(BDFCard(['1']), 0, 'field')

        # float
        double(BDFCard([1.]), 0, 'field')
        double(BDFCard(['1.']), 0, 'field')

        # string
        with self.assertRaises(SyntaxError):
            double(BDFCard(['a']), 0, 'field')
        with self.assertRaises(SyntaxError):
            double(BDFCard(['1b']), 0, 'field')

        # blank
        with self.assertRaises(SyntaxError):
            double(BDFCard(['']), 0, 'field')
        with self.assertRaises(SyntaxError):
            double(BDFCard([None]), 0, 'field')

        card = [1.0, '2.0', '3.', 'C', None, '']
        exact = [1.0, 2.0, 3.0, SyntaxError, SyntaxError, SyntaxError]
        self.run_function(double, card, exact)