Esempio n. 1
0
    def add_card(self, card, comment=''):
        i = self.i
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0.)
        dphase = integer_double_or_blank(card, 4, 'dphase', 0.)
        tc = integer_double_or_blank(card, 5, 'tc', 0)
        td = integer_double_or_blank(card, 6, 'td', 0)
        Type = integer_string_or_blank(card, 7, 'Type', 'LOAD')

        if Type in [0, 'L', 'LO', 'LOA', 'LOAD']:
            Type = 'LOAD'
        elif Type in [1, 'D', 'DI', 'DIS', 'DISP']:
            Type = 'DISP'
        elif Type in [2, 'V', 'VE', 'VEL', 'VELO']:
            Type = 'VELO'
        elif Type in [3, 'A', 'AC', 'ACC', 'ACCE']:
            Type = 'ACCE'
        elif Type in [5, 6, 7, 12, 13]:
            pass
        else:
            msg = 'invalid TLOAD2 type  Type=%r' % Type
            raise RuntimeError(msg)
        assert len(card) <= 13, 'len(TLOAD2 card) = %i\ncard=%s' % (len(card), card)

        self.sid[i] = sid
        self.excite_id[i] = excite_id
        if isinstance(delay, int):
            self.delay_id[i] = delay
            self.is_delay_table[i] = 1
        elif isinstance(delay, float):
            self.delay_tau[i] = delay
            self.is_delay_table[i] = 0
        else:
            raise NotImplementedError(delay)

        if isinstance(dphase, int):
            self.dphase_id[i] = dphase
            self.is_dphase_table[i] = 1
        elif isinstance(dphase, float):
            self.dphase_lead[i] = dphase
            self.is_dphase_table[i] = 0
        else:
            raise NotImplementedError(dphase)

        self.Type[i] = Type
        if isinstance(tc, int):
            self.table_c[i] = tc
        elif isinstance(tc, float):
            self.constant_c[i] = tc
        else:
            raise NotImplementedError('tc=%r' % tc)

        if isinstance(td, int):
            self.table_d[i] = td
        elif isinstance(td, float):
            self.constant_d[i] = td
        else:
            raise NotImplementedError('tc=%r' % tc)
        self.i += 1
Esempio n. 2
0
    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id') # DAREA, FBALOAD, SLOAD
        delay = integer_double_or_blank(card, 3, 'delay', 0) # DELAY, FBADLAY
        dphase = integer_double_or_blank(card, 4, 'dphase', 0) # DPHASE, FBAPHAS
        power = integer_double_or_blank(card, 5, 'power/tp/rp', 0) # TABLEDi/power
        rho = double(card, 6, 'rho')
        b = double(card, 7, 'bulk modulus')

        assert len(card) <= 8, 'len(ACSRCE card) = %i\n%s' % (len(card), card)
        return ACSRCE(sid, excite_id, delay, dphase, power, rho, b, comment=comment)
Esempio n. 3
0
    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0)
        dphase = integer_double_or_blank(card, 4, 'dphase', 0)
        tc = integer_double_or_blank(card, 5, 'tc', 0)
        td = integer_double_or_blank(card, 6, 'td', 0)
        Type = integer_string_or_blank(card, 7, 'Type', 'LOAD')

        assert len(card) <= 8, 'len(RLOAD1 card) = %i\ncard=%s' % (len(card), card)
        return RLOAD1(sid, excite_id, delay, dphase, tc, td, Type, comment=comment)
Esempio n. 4
0
    def test_integer_double_or_blank(self):
        """
        value = double_or_blank(card, n, fieldname, default=None)
        """
        # integer
        self.check_integer(integer_double_or_blank)

        # float
        self.check_double(integer_double_or_blank)
        self.assertEqual(1.e-9, integer_double_or_blank(BDFCard(['1-9']), 0, 'field'))
        self.assertEqual(1.e+9, integer_double_or_blank(BDFCard(['1+9']), 0, 'field'))

        # error - string
        with self.assertRaises(SyntaxError):
            integer_double_or_blank(BDFCard(['C']), 0, 'field')
        with self.assertRaises(SyntaxError):
            integer_double_or_blank(BDFCard(['1C']), 0, 'field')
        with self.assertRaises(SyntaxError):
            integer_double_or_blank(BDFCard(['C1']), 0, 'field')

        # blank
        double_or_blank(BDFCard(['   ']), 0, 'field')
        double_or_blank(BDFCard([None]), 0, 'field')
        self.assertEqual(1.e-9, double_or_blank(BDFCard(['1-9']), 0, 'field'))
        self.assertEqual(1.e+9, double_or_blank(BDFCard(['1+9']), 0, 'field'))
Esempio n. 5
0
    def add_card(self, card, comment=''):
        if self.n == 1:
            raise RuntimeError('only one CBAROR is allowed')
        self.n = 1
        if comment:
            self.comment = comment

        self.property_id = integer_or_blank(card, 2, 'pid')

        # x / g0
        field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0)
        if isinstance(field5, integer_types):
            self.is_g0 = True
            self.g0 = field5
            self.x = [0., 0., 0.]
        elif isinstance(field5, float):
            self.is_g0 = False
            self.g0 = None
            self.x = np.array([
                field5,
                double_or_blank(card, 6, 'x2', 0.0),
                double_or_blank(card, 7, 'x3', 0.0)
            ],
                              dtype='float64')
        self.offt = string_or_blank(card, 8, 'offt', 'GGG')
        assert len(card) <= 9, 'len(CBAROR card) = %i\ncard=%s' % (len(card),
                                                                   card)
Esempio n. 6
0
    def add_card(cls, card, comment=''):
        """
        Adds a CGAP card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        eid = integer(card, 1, 'eid')
        pid = integer_or_blank(card, 2, 'pid', eid)
        ga = integer_or_blank(card, 3, 'ga')
        gb = integer_or_blank(card, 4, 'gb')
        x1_g0 = integer_double_or_blank(card, 5, 'x1_g0')
        cid = integer_or_blank(card, 8, 'cid')
        if isinstance(x1_g0, integer_types):
            g0 = x1_g0
            x = None
        elif isinstance(x1_g0, float):
            g0 = None
            x1 = x1_g0
            x2 = double_or_blank(card, 6, 'x2', 0.0)
            x3 = double_or_blank(card, 7, 'x3', 0.0)
            x = [x1, x2, x3]
        else:
            #raise RuntimeError('invalid CGAP...x1/g0 = %r' %(x1_g0))
            g0 = None
            x = [None, None, None]
        assert len(card) <= 9, 'len(CGAP card) = %i\ncard=%s' % (len(card),
                                                                 card)
        return CGAP(eid, pid, [ga, gb], x, g0, cid=cid, comment=comment)
Esempio n. 7
0
    def add_card(cls, card, comment=''):
        pid = integer_or_blank(card, 2, 'pid')

        # x / g0
        field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0)
        if isinstance(field5, integer_types):
            is_g0 = True
            g0 = field5
            x = [0., 0., 0.]
        elif isinstance(field5, float):
            is_g0 = False
            g0 = None
            x = np.array([
                field5,
                double_or_blank(card, 6, 'x2', 0.0),
                double_or_blank(card, 7, 'x3', 0.0)
            ],
                         dtype='float64')
        else:
            raise NotImplementedError('BEAMOR field5 = %r' % field5)
        offt = integer_string_or_blank(card, 8, 'offt', 'GGG')
        if isinstance(offt, integer_types):
            raise NotImplementedError(
                'the integer form of offt is not supported; offt=%s' % offt)
        assert len(card) <= 9, 'len(BEAMOR card) = %i\ncard=%s' % (len(card),
                                                                   card)
        return BEAMOR(pid, is_g0, g0, x, offt=offt, comment=comment)
Esempio n. 8
0
    def add_card(cls, card, comment=''):
        """
        Adds a CQUADX card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        eid = integer(card, 1, 'eid')
        pid = integer(card, 2, 'pid')
        nids = [
            integer(card, 3, 'n1'),
            integer(card, 4, 'n2'),
            integer(card, 5, 'n3'),
            integer(card, 6, 'n4'),
            integer_or_blank(card, 7, 'n5'),
            integer_or_blank(card, 8, 'n6'),
            integer_or_blank(card, 9, 'n7'),
            integer_or_blank(card, 10, 'n8'),
            integer_or_blank(card, 11, 'n9')
        ]
        theta_mcid = integer_double_or_blank(card, 12, 'theta/mcid', 0.)
        assert len(card) <= 12, 'len(CQUADX card) = %i\ncard=%s' % (len(card),
                                                                    card)
        return CQUADX(eid, pid, nids, theta_mcid=theta_mcid, comment=comment)
Esempio n. 9
0
    def add_card(self, card, comment=''):
        i = self.i
        self.element_id[i] = integer(card, 1, 'eid')
        self.property_id[i] = integer(card, 2, 'pid')

        self.node_ids[i, :] = [
            integer(card, 3, 'n1'),
            integer(card, 4, 'n2'),
            integer(card, 5, 'n3'),
            integer(card, 6, 'n4')
        ]

        theta_mcid = integer_double_or_blank(card, 7, 'theta_mcid', 0.0)

        if isinstance(theta_mcid, float):
            self.is_theta[i] = 1
            self.theta[i] = theta_mcid
        else:
            self.is_theta[i] = 0
            self.mcid[i] = theta_mcid


        #self.theta_mcid =
        #self.zoffset = double_or_blank(card, 7, 'zoffset', 0.0)
        #blank(card, 8, 'blank')
        #blank(card, 9, 'blank')

        self.t_flag[i] = integer_or_blank(card, 10, 'tflag', 0)
        self.thickness[i, :] = [
            double_or_blank(card, 11, 'T1', 1.0),
            double_or_blank(card, 12, 'T2', 1.0),
            double_or_blank(card, 13, 'T3', 1.0),
            double_or_blank(card, 14, 'T4', 1.0),
        ]
        self.i += 1
Esempio n. 10
0
    def add_card(cls, card, comment=''):
        eid = integer(card, 1, 'eid')
        pid = integer_or_blank(card, 2, 'pid', eid)
        ga = integer(card, 3, 'ga')
        gb = integer(card, 4, 'gb')
        x1_g0 = integer_double_or_blank(card, 5, 'x1_g0', 0.0)
        if isinstance(x1_g0, integer_types):
            g0 = x1_g0
            x = None
        elif isinstance(x1_g0, float):
            g0 = None
            x = np.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)], dtype='float64')
            if norm(x) == 0.0:
                msg = 'G0 vector defining plane 1 is not defined.\n'
                msg += 'G0 = %s\n' % g0
                msg += 'X  = %s\n' % x
                raise RuntimeError(msg)
        else:
            raise ValueError('invalid x1Go=%r on CBEND' % x1_g0)
        geom = integer(card, 8, 'geom')

        assert len(card) == 9, 'len(CBEND card) = %i\ncard=%s' % (len(card), card)
        return CBEND(eid, pid, ga, gb, g0, x, geom, comment=comment)
Esempio n. 11
0
    def add_card(self, card, comment=''):
        i = self.i
        self.element_id[i] = integer(card, 1, 'eid')
        self.property_id[i] = integer(card, 2, 'pid')

        self.node_ids[i, :] = [
            integer(card, 3, 'n1'),
            integer(card, 4, 'n2'),
            integer(card, 5, 'n3'),
            integer(card, 6, 'n4')
        ]

        theta_mcid = integer_double_or_blank(card, 7, 'theta_mcid', 0.0)

        if isinstance(theta_mcid, float):
            self.is_theta[i] = 1
            self.theta[i] = theta_mcid
        else:
            self.is_theta[i] = 0
            self.mcid[i] = theta_mcid


        #self.thetaMcid =
        #self.zOffset = double_or_blank(card, 7, 'zOffset', 0.0)
        #blank(card, 8, 'blank')
        #blank(card, 9, 'blank')

        self.t_flag[i] = integer_or_blank(card, 10, 'TFlag', 0)
        self.thickness[i, :] = [
            double_or_blank(card, 11, 'T1', 1.0),
            double_or_blank(card, 12, 'T2', 1.0),
            double_or_blank(card, 13, 'T3', 1.0),
            double_or_blank(card, 14, 'T4', 1.0),
        ]
        self.i += 1
Esempio n. 12
0
    def add_card(cls, card, comment=''):
        csid = integer(card, 1, 'csid')
        i = 2
        j = 1
        params = {}
        while i < card.nfields:
            param = string(card, i, 'param%s' % j)
            i += 1
            if param == 'TYPE':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [0, 1, 2], 'TYPE must be [0, 1, 2]; TYPE=%r' % value
            elif param == 'NSIDE':
                value = integer_or_blank(card, i, 'value%s' % j, 1)
                assert value in [1, 2], 'NSIDE must be [1, 2]; NSIDE=%r' % value
            elif param == 'TBIRTH':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)
            elif param == 'TDEATH':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)
            elif param == 'INIPENE':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [0, 1, 2, 3], 'INIPENE must be [0, 1, 2]; INIPENE=%r' % value
            elif param == 'PDEPTH':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)
            elif param == 'SEGNORM':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [-1, 0, 1], 'SEGNORM must be [-1, 0, 1]; SEGNORM=%r' % value
            elif param == 'OFFTYPE':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [0, 1, 2], 'OFFTYPE must be [0, 1, 2]; OFFTYPE=%r' % value
            elif param == 'OFFSET':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)
            elif param == 'TZPENE':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)

            elif param == 'CSTIFF':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [0, 1], 'CSTIFF must be [0, 1]; CSTIFF=%r' % value
            elif param == 'TIED':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [0, 1], 'TIED must be [0, 1]; TIED=%r' % value
            elif param == 'TIEDTOL':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)
            elif param == 'EXTFAC':
                value = double_or_blank(card, i, 'value%s' % j, 0.001)
                assert 1.0E-6 <= value <= 0.1, 'EXTFAC must be 1.0E-6 < EXTFAC < 0.1; EXTFAC=%r' % value
            else:
                # FRICMOD, FPARA1/2/3/4/5, EPSN, EPST, CFACTOR1, PENETOL
                # NCMOD, TCMOD, RFORCE, LFORCE, RTPCHECK, RTPMAX, XTYPE
                # ...
                value = integer_double_or_blank(card, i, 'value%s' % j)
                assert value is not None, '%s%i must not be None' % (param, j)

            params[param] = value
            i += 1
            j += 1
            if j == 4:
                i += 1
        return BCTPARA(csid, params, comment=comment)
Esempio n. 13
0
    def add_card(self, card, comment=''):
        i = self.i
        eid = integer(card, 1, 'element_id')
        self.element_id[i] = eid
        self.property_id[i] = integer_or_blank(card, 2, 'property_id', eid)
        self.node_ids[i] = [integer(card, 3, 'GA'),
                            integer(card, 4, 'GB')]

        #---------------------------------------------------------
        # x / g0
        field5 = integer_double_or_blank(card, 5, 'x1_g0')
        if isinstance(field5, integer_types):
            self.is_g0[i] = True
            self.g0[i] = field5
        elif isinstance(field5, float):
            self.is_g0[i] = False

            # TODO: why is this custom?
            x2_default = 0.0
            x3_default = 0.0
            x = array([field5,
                       double_or_blank(card, 6, 'x2', x2_default),
                       double_or_blank(card, 7, 'x3', x3_default)], dtype='float64')
            self.x[i, :] = x
            if norm(x) == 0.0:
                msg = 'G0 vector defining plane 1 is not defined on %s %s.\n' % (self.type, eid)
                msg += 'G0 = %s\n' % field5
                msg += 'X  = %s\n' % x
                msg += '%s' % card
                raise RuntimeError(msg)
        #else:
            #msg = ('field5 on %s (G0/X1) is the wrong type...eid=%s field5=%s '
                   #'type=%s' % (self.type, eid, field5, type(field5)))
            #raise RuntimeError(msg)

        #---------------------------------------------------------
        #: Element coordinate system identification. A 0 means the basic
        #: coordinate system. If CID is blank (-1), then the element coordinate
        #: system is determined from GO or Xi.
        #: (default=blank=element-based)
        cid = integer_or_blank(card, 8, 'cid', -1)
        if cid is not None:
            self.cid[i] = cid
        #: Location of spring damper (0 <= s <= 1.0)
        self.s[i] = double_or_blank(card, 9, 's', 0.5)
        #: Coordinate system identification of spring-damper offset. See
        #: Remark 9. (Integer > -1; Default = -1, which means the offset
        #: point lies on the line between GA and GB
        self.ocid[i] = integer_or_blank(card, 10, 'ocid', -1)
        #: Components of spring-damper offset in the OCID coordinate system
        #: if OCID > 0.
        self.si[i, :] = [double_or_blank(card, 11, 's1'),
                   double_or_blank(card, 12, 's2'),
                   double_or_blank(card, 13, 's3')]
        assert len(card) <= 14, 'len(CBUSH card) = %i\ncard=%s' % (len(card), card)
        self.i += 1
Esempio n. 14
0
    def add_card(self, card, comment=''):
        i = self.i
        eid = integer(card, 1, 'element_id')
        self.element_id[i] = eid
        self.property_id[i] = integer_or_blank(card, 2, 'property_id', eid)
        self.node_ids[i] = [integer(card, 3, 'GA'),
                            integer(card, 4, 'GB')]

        #---------------------------------------------------------
        # x / g0
        field5 = integer_double_or_blank(card, 5, 'x1_g0')
        if isinstance(field5, integer_types):
            self.is_g0[i] = True
            self.g0[i] = field5
        elif isinstance(field5, float):
            self.is_g0[i] = False

            # TODO: why is this custom?
            x2_default = 0.0
            x3_default = 0.0
            x = array([field5,
                       double_or_blank(card, 6, 'x2', x2_default),
                       double_or_blank(card, 7, 'x3', x3_default)], dtype='float64')
            self.x[i, :] = x
            if norm(x) == 0.0:
                msg = 'G0 vector defining plane 1 is not defined on CBUSH eid=%s.\n' % eid
                msg += 'G0 = %s\n' % field5
                msg += 'X  = %s\n' % x
                msg += '%s' % card
                raise RuntimeError(msg)
        #else:
            #msg = ('field5 on %s (G0/X1) is the wrong type...eid=%s field5=%s '
                   #'type=%s' % (self.type, eid, field5, type(field5)))
            #raise RuntimeError(msg)

        #---------------------------------------------------------
        #: Element coordinate system identification. A 0 means the basic
        #: coordinate system. If CID is blank (-1), then the element coordinate
        #: system is determined from GO or Xi.
        #: (default=blank=element-based)
        cid = integer_or_blank(card, 8, 'cid', -1)
        if cid is not None:
            self.cid[i] = cid
        #: Location of spring damper (0 <= s <= 1.0)
        self.s[i] = double_or_blank(card, 9, 's', 0.5)
        #: Coordinate system identification of spring-damper offset. See
        #: Remark 9. (Integer > -1; Default = -1, which means the offset
        #: point lies on the line between GA and GB
        self.ocid[i] = integer_or_blank(card, 10, 'ocid', -1)
        #: Components of spring-damper offset in the OCID coordinate system
        #: if OCID > 0.
        self.si[i, :] = [double_or_blank(card, 11, 's1'),
                   double_or_blank(card, 12, 's2'),
                   double_or_blank(card, 13, 's3')]
        assert len(card) <= 14, 'len(CBUSH card) = %i\ncard=%s' % (len(card), card)
        self.i += 1
Esempio n. 15
0
    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0)
        dphase = integer_double_or_blank(card, 4, 'dphase', 0)
        tc = integer_double_or_blank(card, 5, 'tc', 0)
        td = integer_double_or_blank(card, 6, 'td', 0)
        Type = integer_string_or_blank(card, 7, 'Type', 'LOAD')

        assert len(card) <= 8, 'len(RLOAD1 card) = %i\ncard=%s' % (len(card),
                                                                   card)
        return RLOAD1(sid,
                      excite_id,
                      delay,
                      dphase,
                      tc,
                      td,
                      Type,
                      comment=comment)
Esempio n. 16
0
    def add_card(self, card, comment=''):
        i = self.i

        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0.0)
        Type = integer_string_or_blank(card, 4, 'Type', 'LOAD')

        T1 = double_or_blank(card, 5, 'T1', 0.0)
        T2 = double_or_blank(card, 6, 'T2', T1)
        frequency = double_or_blank(card, 7, 'frequency', 0.)
        phase = double_or_blank(card, 8, 'phase', 0.)
        c = double_or_blank(card, 9, 'c', 0.)
        b = double_or_blank(card, 10, 'b', 0.)
        us0 = double_or_blank(card, 11, 'us0', 0.)
        vs0 = double_or_blank(card, 12, 'vs0', 0.)

        if Type in [0, 'L', 'LO', 'LOA', 'LOAD']:
            Type = 'LOAD'
        elif Type in [1, 'D', 'DI', 'DIS', 'DISP']:
            Type = 'DISP'
        elif Type in [2, 'V', 'VE', 'VEL', 'VELO']:
            Type = 'VELO'
        elif Type in [3, 'A', 'AC', 'ACC', 'ACCE']:
            Type = 'ACCE'
        elif Type in [5, 6, 7, 12, 13]:
            pass
        else:
            msg = 'invalid TLOAD2 type  Type=%r' % Type
            raise RuntimeError(msg)
        assert len(card) <= 13, 'len(TLOAD2 card) = %i\ncard=%s' % (len(card),
                                                                    card)

        self.sid[i] = sid
        self.excite_id[i] = excite_id
        if isinstance(delay, int):
            self.delay_id[i] = delay
            self.is_delay_table[i] = 1
        elif isinstance(delay, float):
            self.delay_tau[i] = delay
            self.is_delay_table[i] = 0
        else:
            raise NotImplementedError(delay)

        self.Type[i] = Type
        self.tau[i, :] = [T1, T2]
        #self.T1[i] = T1
        #self.T2[i] = T2
        self.frequency[i] = frequency
        self.phase[i] = phase
        self.c[i] = c
        self.b[i] = b
        self.us0[i] = us0
        self.vs0[i] = vs0
        self.i += 1
Esempio n. 17
0
    def add_card(self, card, comment=''):
        i = self.i

        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0.0)
        Type = integer_string_or_blank(card, 4, 'Type', 'LOAD')

        T1 = double_or_blank(card, 5, 'T1', 0.0)
        T2 = double_or_blank(card, 6, 'T2', T1)
        frequency = double_or_blank(card, 7, 'frequency', 0.)
        phase = double_or_blank(card, 8, 'phase', 0.)
        c = double_or_blank(card, 9, 'c', 0.)
        b = double_or_blank(card, 10, 'b', 0.)
        us0 = double_or_blank(card, 11, 'us0', 0.)
        vs0 = double_or_blank(card, 12, 'vs0', 0.)

        if Type in [0, 'L', 'LO', 'LOA', 'LOAD']:
            Type = 'LOAD'
        elif Type in [1, 'D', 'DI', 'DIS', 'DISP']:
            Type = 'DISP'
        elif Type in [2, 'V', 'VE', 'VEL', 'VELO']:
            Type = 'VELO'
        elif Type in [3, 'A', 'AC', 'ACC', 'ACCE']:
            Type = 'ACCE'
        elif Type in [5, 6, 7, 12, 13]:
            pass
        else:
            msg = 'invalid TLOAD2 type  Type=%r' % Type
            raise RuntimeError(msg)
        assert len(card) <= 13, 'len(TLOAD2 card) = %i\ncard=%s' % (len(card), card)

        self.sid[i] = sid
        self.excite_id[i] = excite_id
        if isinstance(delay, int):
            self.delay_id[i] = delay
            self.is_delay_table[i] = 1
        elif isinstance(delay, float):
            self.delay_tau[i] = delay
            self.is_delay_table[i] = 0
        else:
            raise NotImplementedError(delay)

        self.Type[i] = Type
        self.tau[i, :] = [T1, T2]
        #self.T1[i] = T1
        #self.T2[i] = T2
        self.frequency[i] = frequency
        self.phase[i] = phase
        self.c[i] = c
        self.b[i] = b
        self.us0[i] = us0
        self.vs0[i] = vs0
        self.i += 1
Esempio n. 18
0
    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')  # DAREA, FBALOAD, SLOAD
        delay = integer_double_or_blank(card, 3, 'delay', 0)  # DELAY, FBADLAY
        dphase = integer_double_or_blank(card, 4, 'dphase',
                                         0)  # DPHASE, FBAPHAS
        power = integer_double_or_blank(card, 5, 'power/tp/rp',
                                        0)  # TABLEDi/power
        rho = double(card, 6, 'rho')
        b = double(card, 7, 'bulk modulus')

        assert len(card) <= 8, 'len(ACSRCE card) = %i\n%s' % (len(card), card)
        return ACSRCE(sid,
                      excite_id,
                      rho,
                      b,
                      delay=delay,
                      dphase=dphase,
                      power=power,
                      comment=comment)
Esempio n. 19
0
    def add_card(cls, card, comment=''):
        """
        Adds a RLOAD2 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0)
        dphase = integer_double_or_blank(card, 4, 'dphase', 0)
        tb = integer_double_or_blank(card, 5, 'tb', 0)
        tp = integer_double_or_blank(card, 6, 'tp', 0)
        Type = integer_string_or_blank(card, 7, 'Type', 'LOAD')

        assert len(card) <= 8, 'len(RLOAD2 card) = %i\ncard=%s' % (len(card), card)
        return RLOAD2(sid, excite_id, delay, dphase, tb, tp, Type, comment=comment)
    def add_card(cls, card, comment=''):
        eid = integer(card, 1, 'eid')
        pid = integer(card, 2, 'pid')

        nids = [
            integer_or_blank(card, 3, 'n1'),
            integer_or_blank(card, 4, 'n2'),
            integer_or_blank(card, 5, 'n3'),
            ]
        theta = integer_double_or_blank(card, 6, 'theta', 0.0)
        assert len(card) <= 7, 'len(CTRAX3 card) = %i\ncard=%s' % (len(card), card)
        return CTRAX3(eid, pid, nids, theta=theta, comment=comment)
Esempio n. 21
0
    def add_card(self, card, comment=''):
        """
        Adds a CBUSH card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        eid = integer(card, 1, 'eid')
        pid = integer_or_blank(card, 2, 'pid', eid)
        ga = integer(card, 3, 'ga')
        gb = integer_or_blank(card, 4, 'gb')

        #: Element coordinate system identification. A 0 means the basic
        #: coordinate system. If CID is blank, then the element coordinate
        #: system is determined from GO or Xi.
        #: (default=blank=element-based)
        cid = integer_or_blank(card, 8, 'cid')

        x1_g0 = integer_double_or_blank(card, 5, 'x1_g0')
        if isinstance(x1_g0, integer_types):
            g0 = x1_g0
            x = None
        elif isinstance(x1_g0, float):
            g0 = None
            x1 = x1_g0
            x2 = double_or_blank(card, 6, 'x2', 0.0)
            x3 = double_or_blank(card, 7, 'x3', 0.0)
            x = [x1, x2, x3]
            if not isinstance(cid, integer_types):
                assert max(x) != min(x), 'x=%s' % x
        else:
            g0 = None
            x = [None, None, None]

        #: Location of spring damper (0 <= s <= 1.0)
        s = double_or_blank(card, 9, 's', 0.5)
        #: Coordinate system identification of spring-damper offset. See
        #: Remark 9. (Integer > -1; Default = -1, which means the offset
        #: point lies on the line between GA and GB
        ocid = integer_or_blank(card, 10, 'ocid', -1)
        #: Components of spring-damper offset in the OCID coordinate system
        #: if OCID > 0.
        si = [double_or_blank(card, 11, 's1'),
              double_or_blank(card, 12, 's2'),
              double_or_blank(card, 13, 's3')]
        assert len(card) <= 14, 'len(CBUSH card) = %i\ncard=%s' % (len(card), card)
        #return CBUSH(eid, pid, [ga, gb], x, g0, cid=cid, s=s, ocid=ocid, si=si, comment=comment)
        return self.add(eid, pid, [ga, gb], x, g0, cid=cid, s=s, ocid=ocid, si=si, comment=comment)
Esempio n. 22
0
    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)
Esempio n. 23
0
 def add_card(cls, card, comment=''):
     eid = integer(card, 1, 'eid')
     pid = integer(card, 2, 'pid')
     nids = [
         integer(card, 3, 'n1'),
         integer(card, 4, 'n2'),
         integer(card, 5, 'n3'),
         integer(card, 6, 'n4'),
     ]
     theta = integer_double_or_blank(card, 7, 'theta', 0.)
     assert len(card) <= 8, 'len(CQUADX4 card) = %i\ncard=%s' % (len(card),
                                                                 card)
     return CQUADX4(eid, pid, nids, theta=theta, comment=comment)
Esempio n. 24
0
    def add_card(cls, card, comment=''):
        """
        Adds a ACSRCE card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id') # DAREA, FBALOAD, SLOAD
        delay = integer_double_or_blank(card, 3, 'delay', 0) # DELAY, FBADLAY
        dphase = integer_double_or_blank(card, 4, 'dphase', 0) # DPHASE, FBAPHAS
        power = integer_double_or_blank(card, 5, 'power/tp/rp', 0) # TABLEDi/power
        rho = double(card, 6, 'rho')
        b = double(card, 7, 'bulk modulus')

        assert len(card) <= 8, 'len(ACSRCE card) = %i\n%s' % (len(card), card)
        return ACSRCE(sid, excite_id, rho, b,
                      delay=delay, dphase=dphase, power=power, comment=comment)
Esempio n. 25
0
    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0)
        dphase = integer_double_or_blank(card, 4, 'dphase', 0)
        tb = integer_or_blank(card, 5, 'tb', 0)
        tp = integer_or_blank(card, 6, 'tp', 0)
        Type = integer_string_or_blank(card, 7, 'Type', 'LOAD')

        if Type in [0, 'L', 'LO', 'LOA', 'LOAD']:
            Type = 'LOAD'
        elif Type in [1, 'D', 'DI', 'DIS', 'DISP']:
            Type = 'DISP'
        elif Type in [2, 'V', 'VE', 'VEL', 'VELO']:
            Type = 'VELO'
        elif Type in [3, 'A', 'AC', 'ACC', 'ACCE']:
            Type = 'ACCE'
        else:
            msg = 'invalid RLOAD2 type  Type=%r' % Type
            raise RuntimeError(msg)
        assert len(card) <= 8, 'len(RLOAD2 card) = %i\ncard=%s' % (len(card), card)
        return RLOAD2(sid, excite_id, delay, dphase, tb, tp, Type, comment=comment)
    def add_card(cls, card, comment=''):
        eid = integer(card, 1, 'eid')
        pid = integer(card, 2, 'pid')

        nids = [
            integer_or_blank(card, 3, 'n1'),
            integer_or_blank(card, 4, 'n2'),
            integer_or_blank(card, 5, 'n3'),
            integer_or_blank(card, 6, 'n4'),
            integer_or_blank(card, 7, 'n5'),
            integer_or_blank(card, 8, 'n6'),
            ]
        theta_mcid = integer_double_or_blank(card, 9, 'theta_mcsid', 0.0)
        assert len(card) <= 10, 'len(CTRIAX card) = %i\ncard=%s' % (len(card), card)
        return CTRIAX(eid, pid, nids, theta_mcid=theta_mcid, comment=comment)
 def add_card(cls, card, comment=''):
     eid = integer(card, 1, 'eid')
     pid = integer(card, 2, 'pid')
     nids = [
         integer(card, 3, 'n1'),
         integer(card, 4, 'n2'),
         integer(card, 5, 'n3'),
         integer(card, 6, 'n4'),
         integer_or_blank(card, 7, 'n5'),
         integer_or_blank(card, 8, 'n6'),
         integer_or_blank(card, 9, 'n7'),
         integer_or_blank(card, 10, 'n8'),
     ]
     theta = integer_double_or_blank(card, 11, 'theta', 0.)
     assert len(card) <= 12, 'len(CQUADX8 card) = %i\ncard=%s' % (len(card), card)
     return CQUADX8(eid, pid, nids, theta=theta, comment=comment)
Esempio n. 28
0
    def add_card(cls, card, comment=''):
        eid = integer(card, 1, 'eid')
        pid = integer(card, 2, 'pid')

        nids = [
            integer_or_blank(card, 3, 'n1'),
            integer_or_blank(card, 4, 'n2'),
            integer_or_blank(card, 5, 'n3'),
            integer_or_blank(card, 6, 'n4'),
            integer_or_blank(card, 7, 'n5'),
            integer_or_blank(card, 8, 'n6'),
        ]
        theta_mcid = integer_double_or_blank(card, 9, 'theta_mcsid', 0.0)
        assert len(card) <= 10, 'len(CTRIAX card) = %i\ncard=%s' % (len(card),
                                                                    card)
        return CTRIAX(eid, pid, nids, theta_mcid=theta_mcid, comment=comment)
Esempio n. 29
0
    def add_card(self, card, comment=''):
        i = self.i

        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0.0)
        Type = integer_string_or_blank(card, 4, 'Type', 'LOAD')
        table_id = integer(card, 5, 'table_id')
        us0 = double_or_blank(card, 6, 'us0', 0.0)
        vs0 = double_or_blank(card, 7, 'vs0', 0.0)

        if Type in [0, 'L', 'LO', 'LOA', 'LOAD']:
            Type = 'LOAD'
        elif Type in [1, 'D', 'DI', 'DIS', 'DISP']:
            Type = 'DISP'
        elif Type in [2, 'V', 'VE', 'VEL', 'VELO']:
            Type = 'VELO'
        elif Type in [3, 'A', 'AC', 'ACC', 'ACCE']:
            Type = 'ACCE'
        elif Type in [5, 6, 7, 12, 13]:
            pass
        else:
            msg = 'invalid TLOAD2 type  Type=%r' % Type
            raise RuntimeError(msg)
        assert len(card) <= 13, 'len(TLOAD2 card) = %i\ncard=%s' % (len(card),
                                                                    card)

        self.sid[i] = sid
        self.excite_id[i] = excite_id
        if isinstance(delay, int):
            self.delay_id[i] = delay
            self.is_delay_table[i] = 1
        elif isinstance(delay, float):
            self.delay_tau[i] = delay
            self.is_delay_table[i] = 0
        else:
            raise NotImplementedError(delay)

        self.Type[i] = Type
        self.table_id[i] = table_id
        self.us0[i] = us0
        self.vs0[i] = vs0
        self.i += 1
Esempio n. 30
0
 def _init_x_g0(cls, card, eid):
     field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0)
     if isinstance(field5, integer_types):
         g0 = field5
         x = None
     elif isinstance(field5, float):
         g0 = None
         x = np.array([field5,
                       double_or_blank(card, 6, 'x2', 0.0),
                       double_or_blank(card, 7, 'x3', 0.0)], dtype='float64')
         if norm(x) == 0.0:
             msg = 'G0 vector defining plane 1 is not defined.\n'
             msg += 'G0 = %s\n' % g0
             msg += 'X  = %s\n' % x
             raise RuntimeError(msg)
     else:
         msg = ('field5 on %s (G0/X1) is the wrong type...id=%s field5=%s '
                'type=%s' % (cls.type, eid, field5, type(field5)))
         raise RuntimeError(msg)
     return x, g0
Esempio n. 31
0
 def _init_x_g0(cls, card, eid):
     field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0)
     if isinstance(field5, integer_types):
         g0 = field5
         x = None
     elif isinstance(field5, float):
         g0 = None
         x = np.array([field5,
                       double_or_blank(card, 6, 'x2', 0.0),
                       double_or_blank(card, 7, 'x3', 0.0)], dtype='float64')
         if norm(x) == 0.0:
             msg = 'G0 vector defining plane 1 is not defined.\n'
             msg += 'G0 = %s\n' % g0
             msg += 'X  = %s\n' % x
             raise RuntimeError(msg)
     else:
         msg = ('field5 on %s (G0/X1) is the wrong type...id=%s field5=%s '
                'type=%s' % (cls.type, eid, field5, type(field5)))
         raise RuntimeError(msg)
     return x, g0
Esempio n. 32
0
def init_x_g0(card, eid):
    """common method to read the x/g0 field for the CBAR, CBEAM, CBEAM3"""
    field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0)
    if isinstance(field5, integer_types):
        g0 = field5
        x = np.full(3, np.nan)
    elif isinstance(field5, float):
        g0 = 0
        x = np.array([field5,
                      double_or_blank(card, 6, 'x2', 0.0),
                      double_or_blank(card, 7, 'x3', 0.0)], dtype='float64')
        if np.linalg.norm(x) == 0.0:
            msg = 'G0 vector defining plane 1 is not defined.\n'
            msg += 'G0 = %s\n' % g0
            msg += 'X  = %s\n' % x
            raise RuntimeError(msg)
    else:
        msg = ('field5 on %s (G0/X1) is the wrong type...id=%s field5=%s '
               'type=%s' % (card.field(0), eid, field5, type(field5)))
        raise RuntimeError(msg)
    return x, g0
Esempio n. 33
0
    def add_card(cls, card, comment=''):
        """
        Adds a TLOAD1 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0)
        Type = integer_string_or_blank(card, 4, 'Type', 'LOAD')
        tid = integer(card, 5, 'tid')
        us0 = double_or_blank(card, 6, 'us0', 0.0)
        vs0 = double_or_blank(card, 7, 'vs0', 0.0)

        assert len(card) <= 8, 'len(TLOAD1 card) = %i\ncard=%s' % (len(card), card)
        return TLOAD1(sid, excite_id, tid, delay=delay, Type=Type, us0=us0, vs0=vs0, comment=comment)
Esempio n. 34
0
    def add_card(cls, card, comment=''):
        """
        Adds a CTRAX3 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        eid = integer(card, 1, 'eid')
        pid = integer(card, 2, 'pid')

        nids = [
            integer_or_blank(card, 3, 'n1'),
            integer_or_blank(card, 4, 'n2'),
            integer_or_blank(card, 5, 'n3'),
            ]
        theta = integer_double_or_blank(card, 6, 'theta', 0.0)
        assert len(card) <= 7, 'len(CTRAX3 card) = %i\ncard=%s' % (len(card), card)
        return CTRAX3(eid, pid, nids, theta=theta, comment=comment)
Esempio n. 35
0
    def add_card(cls, card, comment=''):
        """
        Adds a CBEND card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        eid = integer(card, 1, 'eid')
        pid = integer_or_blank(card, 2, 'pid', eid)
        ga = integer(card, 3, 'ga')
        gb = integer(card, 4, 'gb')
        x1_g0 = integer_double_or_blank(card, 5, 'x1_g0', 0.0)
        if isinstance(x1_g0, integer_types):
            g0 = x1_g0
            x = None
        elif isinstance(x1_g0, float):
            g0 = None
            x = np.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)
            ],
                         dtype='float64')
            if norm(x) == 0.0:
                msg = 'G0 vector defining plane 1 is not defined.\n'
                msg += 'G0 = %s\n' % g0
                msg += 'X  = %s\n' % x
                raise RuntimeError(msg)
        else:
            raise ValueError('invalid x1Go=%r on CBEND' % x1_g0)
        geom = integer(card, 8, 'geom')

        assert len(card) == 9, 'len(CBEND card) = %i\ncard=%s' % (len(card),
                                                                  card)
        return CBEND(eid, pid, [ga, gb], g0, x, geom, comment=comment)
Esempio n. 36
0
    def add_card(cls, card, comment=''):
        eid = integer(card, 1, 'eid')
        pid = integer_or_blank(card, 2, 'pid', eid)
        ga = integer(card, 3, 'ga')
        gb = integer_or_blank(card, 4, 'gb')

        x1_g0 = integer_double_or_blank(card, 5, 'x1_g0')
        if isinstance(x1_g0, integer_types):
            g0 = x1_g0
            x = None
        elif isinstance(x1_g0, float):
            g0 = None
            x1 = x1_g0
            x2 = double_or_blank(card, 6, 'x2', 0.0)
            x3 = double_or_blank(card, 7, 'x3', 0.0)
            x = [x1, x2, x3]
            assert max(x) != min(x), 'x=%s' % x
        else:
            g0 = None
            x = [None, None, None]

        #: Element coordinate system identification. A 0 means the basic
        #: coordinate system. If CID is blank, then the element coordinate
        #: system is determined from GO or Xi.
        #: (default=blank=element-based)
        cid = integer_or_blank(card, 8, 'cid')
        #: Location of spring damper (0 <= s <= 1.0)
        s = double_or_blank(card, 9, 's', 0.5)
        #: Coordinate system identification of spring-damper offset. See
        #: Remark 9. (Integer > -1; Default = -1, which means the offset
        #: point lies on the line between GA and GB
        ocid = integer_or_blank(card, 10, 'ocid', -1)
        #: Components of spring-damper offset in the OCID coordinate system
        #: if OCID > 0.
        si = [double_or_blank(card, 11, 's1'),
              double_or_blank(card, 12, 's2'),
              double_or_blank(card, 13, 's3')]
        assert len(card) <= 14, 'len(CBUSH card) = %i\ncard=%s' % (len(card), card)
        return CBUSH(eid, pid, ga, gb, x, g0, cid, s, ocid, si, comment=comment)
Esempio n. 37
0
    def add_card(cls, card, comment=''):
        """
        Adds a CQUADX4 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        eid = integer(card, 1, 'eid')
        pid = integer(card, 2, 'pid')
        nids = [
            integer(card, 3, 'n1'),
            integer(card, 4, 'n2'),
            integer(card, 5, 'n3'),
            integer(card, 6, 'n4'),
        ]
        theta = integer_double_or_blank(card, 7, 'theta', 0.)
        assert len(card) <= 8, f'len(CQUADX4 card) = {len(card):d}\ncard={card}'
        return CQUADX4(eid, pid, nids, theta=theta, comment=comment)
Esempio n. 38
0
    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0)
        Type = integer_string_or_blank(card, 4, 'Type', 'LOAD')
        tid = integer(card, 5, 'tid')
        us0 = double_or_blank(card, 6, 'us0', 0.0)
        vs0 = double_or_blank(card, 7, 'vs0', 0.0)

        if Type in [0, 'L', 'LO', 'LOA', 'LOAD']:
            Type = 'LOAD'
        elif Type in [1, 'D', 'DI', 'DIS', 'DISP']:
            Type = 'DISP'
        elif Type in [2, 'V', 'VE', 'VEL', 'VELO']:
            Type = 'VELO'
        elif Type in [3, 'A', 'AC', 'ACC', 'ACCE']:
            Type = 'ACCE'
        else:
            msg = 'invalid TLOAD1 type  Type=%r' % Type
            raise RuntimeError(msg)
        assert len(card) <= 8, 'len(TLOAD1 card) = %i\ncard=%s' % (len(card), card)
        return TLOAD1(sid, excite_id, delay, Type, tid, us0, vs0, comment=comment)
Esempio n. 39
0
    def add_card(self, card, comment=''):
        if self.n == 1:
            raise RuntimeError('only one BAROR is allowed')
        self.n = 1

        property_id = integer_or_blank(card, 2, 'pid')

        # x / g0
        field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0)
        if isinstance(field5, integer_types):
            is_g0 = True
            g0 = field5
            x = [0., 0., 0.]
        elif isinstance(field5, float):
            is_g0 = False
            g0 = None
            x = np.array([field5,
                          double_or_blank(card, 6, 'x2', 0.0),
                          double_or_blank(card, 7, 'x3', 0.0)],
                         dtype='float64')
        offt = string_or_blank(card, 8, 'offt', 'GGG')
        assert len(card) <= 8, 'len(BAROR card) = %i\ncard=%s' % (len(card), card)
        return BAROR(property_id, is_g0, g0, x, offt=offt, comment=comment)
Esempio n. 40
0
    def add(self, card=None, data=None, comment=''):
        if self.n == 1:
            raise RuntimeError('only one CBAROR is allowed')
        self.n = 1
        if comment:
            self.comment = comment

        self.property_id = integer_or_blank(card, 2, 'pid')

        # x / g0
        field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0)
        if isinstance(field5, integer_types):
            self.is_g0 = True
            self.g0 = field5
            self.x = [0., 0., 0.]
        elif isinstance(field5, float):
            self.is_g0 = False
            self.g0 = None
            self.x = np.array([field5,
                               double_or_blank(card, 6, 'x2', 0.0),
                               double_or_blank(card, 7, 'x3', 0.0)],
                              dtype='float64')
        self.offt = string_or_blank(card, 8, 'offt', 'GGG')
        assert len(card) <= 9, 'len(CBAROR card) = %i\ncard=%s' % (len(card), card)
Esempio n. 41
0
 def add_card(cls, card, comment=''):
     eid = integer(card, 1, 'eid')
     pid = integer_or_blank(card, 2, 'pid', eid)
     ga = integer_or_blank(card, 3, 'ga')
     gb = integer_or_blank(card, 4, 'gb')
     x1_g0 = integer_double_or_blank(card, 5, 'x1_g0')
     if isinstance(x1_g0, integer_types):
         g0 = x1_g0
         x = None
         cid = None
     elif isinstance(x1_g0, float):
         g0 = None
         x1 = x1_g0
         x2 = double_or_blank(card, 6, 'x2', 0.0)
         x3 = double_or_blank(card, 7, 'x3', 0.0)
         x = [x1, x2, x3]
         cid = integer_or_blank(card, 8, 'cid', 0)
     else:
         #raise RuntimeError('invalid CGAP...x1/g0 = %r' %(x1_g0))
         g0 = None
         x = [None, None, None]
         cid = None
     assert len(card) <= 9, 'len(CGAP card) = %i\ncard=%s' % (len(card), card)
     return CGAP(eid, pid, ga, gb, x, g0, cid, comment=comment)
Esempio n. 42
0
    def add_card(self, card, comment=''):
        i = self.i

        if 0 and self.model.cbaror.n > 0:
            cbaror = self.model.cbaror
            pid_default = cbaror.property_id
            is_g0_default = cbaror.is_g0
            x1_default = cbaror.x[0]
            x2_default = cbaror.x[1]
            x3_default = cbaror.x[2]
            g0_default = cbaror.g0
            offt_default = cbaror.offt
        else:
            pid_default = None
            is_g0_default = None
            x1_default = 0.0
            x2_default = 0.0
            x3_default = 0.0
            g0_default = None
            offt_default = 'GGG'

        eid = integer(card, 1, 'element_id')
        self.element_id[i] = eid
        if pid_default is not None:
            self.property_id[i] = integer_or_blank(card, 2, 'property_id',
                                                   pid_default)
        else:
            self.property_id[i] = integer_or_blank(card, 2, 'property_id', eid)
        self.node_ids[i] = [integer(card, 3, 'GA'), integer(card, 4, 'GB')]

        #---------------------------------------------------------
        # x / g0
        if g0_default is not None:
            field5 = integer_double_or_blank(card, 5, 'g0_x1', g0_default)
        else:
            field5 = integer_double_or_blank(card, 5, 'g0_x1', x1_default)

        if isinstance(field5, integer_types):
            self.is_g0[i] = True
            self.g0[i] = field5
        elif isinstance(field5, float):
            self.is_g0[i] = False
            x = array([
                field5,
                double_or_blank(card, 6, 'x2', x2_default),
                double_or_blank(card, 7, 'x3', x3_default)
            ],
                      dtype='float64')
            self.x[i, :] = x
            if norm(x) == 0.0:
                msg = 'G0 vector defining plane 1 is not defined on CBAR %s.\n' % eid
                msg += 'G0 = %s\n' % field5
                msg += 'X  = %s\n' % x
                msg += '%s' % card
                raise RuntimeError(msg)
        else:
            msg = (
                'field5 on CBAR (G0/X1) is the wrong type...id=%s field5=%s '
                'type=%s' % (self.eid, field5, type(field5)))
            raise RuntimeError(msg)

        #---------------------------------------------------------
        # offt
        # bit doesn't exist on the CBAR
        offt = string_or_blank(card, 8, 'offt', offt_default)

        msg = 'invalid offt parameter of CBEAM...offt=%s' % offt
        assert offt[0] in ['G', 'B', 'O', 'E'], msg
        assert offt[1] in ['G', 'B', 'O', 'E'], msg
        assert offt[2] in ['G', 'B', 'O', 'E'], msg
        self.offt[i] = offt

        self.pin_flags[i, :] = [
            integer_or_blank(card, 9, 'pa', 0),
            integer_or_blank(card, 10, 'pb', 0)
        ]

        self.wa[i, :] = [
            double_or_blank(card, 11, 'w1a', 0.0),
            double_or_blank(card, 12, 'w2a', 0.0),
            double_or_blank(card, 13, 'w3a', 0.0),
        ]

        self.wb[i, :] = [
            double_or_blank(card, 14, 'w1b', 0.0),
            double_or_blank(card, 15, 'w2b', 0.0),
            double_or_blank(card, 16, 'w3b', 0.0),
        ]
        assert len(card) <= 17, 'len(CBAR card) = %i\ncard=%s' % (len(card),
                                                                  card)

        self.i += 1
Esempio n. 43
0
    def add_card(self, card, comment=''):
        i = self.i
        eid = integer(card, 1, 'element_id')
        self.element_id[i] = eid
        self.property_id[i] = integer_or_blank(card, 2, 'property_id', eid)
        self.node_ids[i] = [integer(card, 3, 'GA'), integer(card, 4, 'GB')]

        #---------------------------------------------------------
        # x / g0
        field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0)
        if isinstance(field5, integer_types):
            self.is_g0[i] = True
            self.g0[i] = field5
        elif isinstance(field5, float):
            self.is_g0[i] = False
            x = array([
                field5,
                double_or_blank(card, 6, 'x2', 0.0),
                double_or_blank(card, 7, 'x3', 0.0)
            ])
            self.x[i, :] = x
            if norm(x) == 0.0:
                msg = 'G0 vector defining plane 1 is not defined on CBEAM eid=%s.\n' % eid
                msg += 'G0 = %s\n' % field5
                msg += 'X  = %s\n' % x
                msg += '%s' % card
                raise RuntimeError(msg)
        else:
            msg = (
                'field5 on CBEAM (G0/X1) is the wrong type...id=%s field5=%s '
                'type=%s' % (self.eid, field5, type(field5)))
            raise RuntimeError(msg)

        #---------------------------------------------------------
        # offt/bit
        field8 = double_string_or_blank(card, 8, 'offt/bit', 'GGG')
        if isinstance(field8, float):
            self.is_offt[i] = False
            self.bit[i] = field8
        elif isinstance(field8, str):
            self.is_offt[i] = True
            offt = field8
            msg = 'invalid offt parameter of CBEAM...offt=%s' % offt
            assert offt[0] in ['G', 'B', 'O', 'E'], msg
            assert offt[1] in ['G', 'B', 'O', 'E'], msg
            assert offt[2] in ['G', 'B', 'O', 'E'], msg
            self.offt[i] = offt
        else:
            msg = (
                'field8 on %s (offt/bit) is the wrong type...id=%s field5=%s '
                'type=%s' % (self.type, self.eid, field8, type(field8)))
            raise RuntimeError(msg)

        self.pin_flags[i, :] = [
            integer_or_blank(card, 9, 'pa', 0),
            integer_or_blank(card, 10, 'pb', 0)
        ]

        self.wa[i, :] = [
            double_or_blank(card, 11, 'w1a', 0.0),
            double_or_blank(card, 12, 'w2a', 0.0),
            double_or_blank(card, 13, 'w3a', 0.0),
        ]

        self.wb[i, :] = [
            double_or_blank(card, 14, 'w1b', 0.0),
            double_or_blank(card, 15, 'w2b', 0.0),
            double_or_blank(card, 16, 'w3b', 0.0),
        ]
        self.sa[i] = integer_or_blank(card, 17, 'sa', 0)
        self.sb[i] = integer_or_blank(card, 18, 'sb', 0)
        assert len(card) <= 19, 'len(CBEAM card) = %i\ncard=%s' % (len(card),
                                                                   card)
        self.i += 1
Esempio n. 44
0
    def add(self, card, comment=''):
        i = self.i

        if self.model.cbaror.n > 0:
            cbaror = self.model.cbaror
            pid_default = cbaror.property_id
            is_g0_default = cbaror.is_g0
            x1_default = cbaror.x[0]
            x2_default = cbaror.x[1]
            x3_default = cbaror.x[2]
            g0_default = cbaror.g0
            offt_default = cbaror.offt
        else:
            pid_default = None
            is_g0_default = None
            x1_default = 0.0
            x2_default = 0.0
            x3_default = 0.0
            g0_default = None
            offt_default = 'GGG'

        eid = integer(card, 1, 'element_id')
        self.element_id[i] = eid
        if pid_default is not None:
            self.property_id[i] = integer_or_blank(card, 2, 'property_id', pid_default)
        else:
            self.property_id[i] = integer_or_blank(card, 2, 'property_id', eid)
        self.node_ids[i] = [integer(card, 3, 'GA'),
                            integer(card, 4, 'GB')]

        #---------------------------------------------------------
        # x / g0
        if g0_default is not None:
            field5 = integer_double_or_blank(card, 5, 'g0_x1', g0_default)
        else:
            field5 = integer_double_or_blank(card, 5, 'g0_x1', x1_default)

        if isinstance(field5, integer_types):
            self.is_g0[i] = True
            self.g0[i] = field5
        elif isinstance(field5, float):
            self.is_g0[i] = False
            x = array([field5,
                       double_or_blank(card, 6, 'x2', x2_default),
                       double_or_blank(card, 7, 'x3', x3_default)], dtype='float64')
            self.x[i, :] = x
            if norm(x) == 0.0:
                msg = 'G0 vector defining plane 1 is not defined on %s %s.\n' % (self.type, eid)
                msg += 'G0 = %s\n' % field5
                msg += 'X  = %s\n' % x
                msg += '%s' % card
                raise RuntimeError(msg)
        else:
            msg = ('field5 on %s (G0/X1) is the wrong type...id=%s field5=%s '
                   'type=%s' % (self.type, self.eid, field5, type(field5)))
            raise RuntimeError(msg)

        #---------------------------------------------------------
        # offt
        # bit doesn't exist on the CBAR
        offt = string_or_blank(card, 8, 'offt', offt_default)

        msg = 'invalid offt parameter of CBEAM...offt=%s' % offt
        assert offt[0] in ['G', 'B', 'O', 'E'], msg
        assert offt[1] in ['G', 'B', 'O', 'E'], msg
        assert offt[2] in ['G', 'B', 'O', 'E'], msg
        self.offt[i] = offt

        self.pin_flags[i, :] = [integer_or_blank(card, 9, 'pa', 0),
                                integer_or_blank(card, 10, 'pb', 0)]

        self.wa[i, :] = [double_or_blank(card, 11, 'w1a', 0.0),
                         double_or_blank(card, 12, 'w2a', 0.0),
                         double_or_blank(card, 13, 'w3a', 0.0),]

        self.wb[i, :] = [double_or_blank(card, 14, 'w1b', 0.0),
                         double_or_blank(card, 15, 'w2b', 0.0),
                         double_or_blank(card, 16, 'w3b', 0.0),]
        assert len(card) <= 17, 'len(CBAR card) = %i\ncard=%s' % (len(card), card)

        self.i += 1
Esempio n. 45
0
    def add_card(self, card, comment=''):
        #self.model.log.debug('RBE2.add')
        i = self.i
        #if comment:
        # self.comment = comment
        eid = integer(card, 1, 'element_id')
        #if comment:
        # self.comment = comment
        self.element_id[i] = integer(card, 1, 'eid')
        blank(card, 2, 'blank')
        self.refgrid[i] = integer(card, 3, 'refgrid')
        self.refc[i] = components_or_blank(card, 4, 'refc', 0)
        #iUM = fields.index('UM')

        fields = [
            field.upper() if isinstance(field, string_types) else field
            for field in card[5:]
        ]
        iOffset = 5
        iWtMax = len(fields) + iOffset
        try:
            iAlpha = fields.index('ALPHA') + iOffset
            iWtMax = iAlpha  # the index to start parsing UM
            iUmStop = iAlpha  # the index to stop  parsing UM
        except ValueError:
            iAlpha = None
            iUmStop = iWtMax
        #print("iAlpha = %s" % iAlpha)
        try:
            iUm = fields.index('UM') + iOffset
            iWtMax = iUm
        except ValueError:
            iUm = None
        #print("iAlpha=%s iUm=%s" % (iAlpha, iUm))
        #print("iAlpha=%s iWtMax=%s" % (iAlpha, iWtMax))

        #print("iUM = %s" % iUM)
        WtCG_groups = []

        i = iOffset
        n = 1
        while i < iWtMax:
            Gij = []
            wtname = 'wt' + str(n)
            wt = double_or_blank(card, i, wtname)
            if wt is not None:
                cname = 'c' + str(n)
                ci = components_or_blank(card, i + 1, cname)

                #print("%s=%s %s=%s" % (wtname, wt, cname, ci))
                i += 2
                gij = 0

                j = 0
                while isinstance(gij, int) and i < iWtMax:
                    j += 1
                    gij_name = 'g%s,%s' % (n, j)
                    gij = integer_double_or_blank(card, i, gij_name)
                    if isinstance(gij, float):
                        break
                    #print("%s = %s" % (gij_name, gij))
                    if gij is not None:
                        Gij.append(gij)
                    i += 1
                wtCG_group = [wt, ci, Gij]
                WtCG_groups.append(wtCG_group)
                #print('----finished a group=%r----' % wtCG_group)
            else:
                i += 1
        self.WtCG_groups[i] = WtCG_groups
        Gmi = []
        Cmi = []
        #print("")
        if iUm:
            #print('UM = %s' % card.field(iUm))  # UM
            i = iUm + 1
            n = 1
            #print("i=%s iUmStop=%s" % (i, iUmStop))
            for j in range(i, iUmStop, 2):

                gm_name = 'gm' + str(n)
                cm_name = 'cm' + str(n)
                gmi = integer_or_blank(card, j, gm_name)
                if gmi is not None:
                    cmi = components(card, j + 1, cm_name)
                    #print("gmi=%s cmi=%s" % (gmi, cmi))
                    Gmi.append(gmi)
                    Cmi.append(cmi)
        self.Gmi[i] = Gmi
        self.Cmi[i] = Cmi
        if iAlpha:
            alpha = double_or_blank(card, iAlpha + 1, 'alpha', 0.0)
        else:
            alpha = 0.0
        self.alpha[i] = alpha
Esempio n. 46
0
    def add_card(cls, card, comment=''):
        eid = integer(card, 1, 'eid')
        blank(card, 2, 'blank')
        refgrid = integer(card, 3, 'refgrid')
        refc = components_or_blank(card, 4, 'refc')

        fields = [field.upper() if isinstance(field, string_types) else field for field in card[5:]]
        ioffset = 5
        iwt_max = len(fields) + ioffset
        try:
            ialpha = fields.index('ALPHA') + ioffset
            iwt_max = ialpha  # the index to start parsing UM
            ium_stop = ialpha  # the index to stop  parsing UM
        except ValueError:
            ialpha = None
            ium_stop = iwt_max

        try:
            ium = fields.index('UM') + ioffset
            iwt_max = ium
        except ValueError:
            ium = None

        i = ioffset
        n = 1
        weights = []
        comps = []
        Gijs = []
        while i < iwt_max:
            Gij = []
            wtname = 'wt' + str(n)
            wt = double_or_blank(card, i, wtname)
            if wt is not None:
                cname = 'c'+str(n)
                compi = components_or_blank(card, i + 1, cname)

                #print("%s=%s %s=%s" % (wtname, wt, cname, compi))
                i += 2
                gij = 0

                j = 0
                while isinstance(gij, int) and i < iwt_max:
                    j += 1
                    gij_name = 'g%s,%s' % (n, j)
                    gij = integer_double_or_blank(card, i, gij_name)
                    if isinstance(gij, float):
                        break
                    #print("%s = %s" % (gij_name, gij))
                    if gij is not None:
                        Gij.append(gij)
                    i += 1
                assert compi is not None
                assert len(Gij) > 0, Gij
                assert Gij[0] is not None, Gij
                weights.append(wt)
                comps.append(compi)
                Gijs.append(Gij)
                #print('----finished a group=%r----' % weight_cg_group)
            else:
                i += 1

        Gmi = []
        Cmi = []
        if ium:
            #print('UM = %s' % card.field(ium))  # UM
            i = ium + 1
            n = 1
            #print("i=%s iUmStop=%s" % (i, iUmStop))
            for j in range(i, ium_stop, 2):

                gm_name = 'gm' + str(n)
                cm_name = 'cm' + str(n)
                gmi = integer_or_blank(card, j, gm_name)
                if gmi is not None:
                    cmi = components(card, j + 1, cm_name)
                    #print("gmi=%s cmi=%s" % (gmi, cmi))
                    Gmi.append(gmi)
                    Cmi.append(cmi)

        if ialpha:
            alpha = double_or_blank(card, ialpha + 1, 'alpha')
        else:
            #: thermal expansion coefficient
            alpha = 0.0
        return RBE3(eid, refgrid, refc, weights, comps, Gijs,
                    Gmi=Gmi, Cmi=Cmi, alpha=alpha, comment=comment)
Esempio n. 47
0
    def add_card(self, card, comment=""):
        # self.model.log.debug('RBE2.add')
        i = self.i
        # if comment:
        # self.comment = comment
        eid = integer(card, 1, "element_id")
        # if comment:
        # self.comment = comment
        self.element_id[i] = integer(card, 1, "eid")
        blank(card, 2, "blank")
        self.refgrid[i] = integer(card, 3, "refgrid")
        self.refc[i] = components_or_blank(card, 4, "refc", 0)
        # iUM = fields.index('UM')

        fields = [field.upper() if isinstance(field, string_types) else field for field in card[5:]]
        iOffset = 5
        iWtMax = len(fields) + iOffset
        try:
            iAlpha = fields.index("ALPHA") + iOffset
            iWtMax = iAlpha  # the index to start parsing UM
            iUmStop = iAlpha  # the index to stop  parsing UM
        except ValueError:
            iAlpha = None
            iUmStop = iWtMax
        # print("iAlpha = %s" % iAlpha)
        try:
            iUm = fields.index("UM") + iOffset
            iWtMax = iUm
        except ValueError:
            iUm = None
        # print("iAlpha=%s iUm=%s" % (iAlpha, iUm))
        # print("iAlpha=%s iWtMax=%s" % (iAlpha, iWtMax))

        # print("iUM = %s" % iUM)
        WtCG_groups = []

        i = iOffset
        n = 1
        while i < iWtMax:
            Gij = []
            wtname = "wt" + str(n)
            wt = double_or_blank(card, i, wtname)
            if wt is not None:
                cname = "c" + str(n)
                ci = components_or_blank(card, i + 1, cname)

                # print("%s=%s %s=%s" % (wtname, wt, cname, ci))
                i += 2
                gij = 0

                j = 0
                while isinstance(gij, int) and i < iWtMax:
                    j += 1
                    gij_name = "g%s,%s" % (n, j)
                    gij = integer_double_or_blank(card, i, gij_name)
                    if isinstance(gij, float):
                        break
                    # print("%s = %s" % (gij_name, gij))
                    if gij is not None:
                        Gij.append(gij)
                    i += 1
                wtCG_group = [wt, ci, Gij]
                WtCG_groups.append(wtCG_group)
                # print('----finished a group=%r----' % wtCG_group)
            else:
                i += 1
        self.WtCG_groups[i] = WtCG_groups
        Gmi = []
        Cmi = []
        # print("")
        if iUm:
            # print('UM = %s' % card.field(iUm))  # UM
            i = iUm + 1
            n = 1
            # print("i=%s iUmStop=%s" % (i, iUmStop))
            for j in range(i, iUmStop, 2):

                gm_name = "gm" + str(n)
                cm_name = "cm" + str(n)
                gmi = integer_or_blank(card, j, gm_name)
                if gmi is not None:
                    cmi = components(card, j + 1, cm_name)
                    # print("gmi=%s cmi=%s" % (gmi, cmi))
                    Gmi.append(gmi)
                    Cmi.append(cmi)
        self.Gmi[i] = Gmi
        self.Cmi[i] = Cmi
        if iAlpha:
            alpha = double_or_blank(card, iAlpha + 1, "alpha", 0.0)
        else:
            alpha = 0.0
        self.alpha[i] = alpha
Esempio n. 48
0
    def add_card(cls, card, comment=''):
        """
        Adds a RBE3 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        eid = integer(card, 1, 'eid')
        blank(card, 2, 'blank')
        refgrid = integer(card, 3, 'refgrid')
        refc = components_or_blank(card, 4, 'refc')

        fields = [
            field.upper() if isinstance(field, string_types) else field
            for field in card[5:]
        ]
        ioffset = 5
        iwt_max = len(fields) + ioffset
        try:
            ialpha = fields.index('ALPHA') + ioffset
            iwt_max = ialpha  # the index to start parsing UM
            ium_stop = ialpha  # the index to stop  parsing UM
        except ValueError:
            ialpha = None
            ium_stop = iwt_max

        try:
            ium = fields.index('UM') + ioffset
            iwt_max = ium
        except ValueError:
            ium = None

        i = ioffset
        n = 1
        weights = []
        comps = []
        Gijs = []
        while i < iwt_max:
            Gij = []
            wtname = 'wt' + str(n)
            wt = double_or_blank(card, i, wtname)
            if wt is not None:
                cname = 'c' + str(n)
                compi = components_or_blank(card, i + 1, cname)

                #print("%s=%s %s=%s" % (wtname, wt, cname, compi))
                i += 2
                gij = 0

                j = 0
                while isinstance(gij, int) and i < iwt_max:
                    j += 1
                    gij_name = 'g%s,%s' % (n, j)
                    gij = integer_double_or_blank(card, i, gij_name)
                    if isinstance(gij, float):
                        break
                    #print("%s = %s" % (gij_name, gij))
                    if gij is not None:
                        Gij.append(gij)
                    i += 1
                assert compi is not None
                assert len(Gij) > 0, Gij
                assert Gij[0] is not None, Gij
                weights.append(wt)
                comps.append(compi)
                Gijs.append(Gij)
                #print('----finished a group=%r----' % weight_cg_group)
            else:
                i += 1

        Gmi = []
        Cmi = []
        if ium:
            #print('UM = %s' % card.field(ium))  # UM
            i = ium + 1
            n = 1
            #print("i=%s iUmStop=%s" % (i, iUmStop))
            for j in range(i, ium_stop, 2):

                gm_name = 'gm' + str(n)
                cm_name = 'cm' + str(n)
                gmi = integer_or_blank(card, j, gm_name)
                if gmi is not None:
                    cmi = parse_components(card, j + 1, cm_name)
                    #print("gmi=%s cmi=%s" % (gmi, cmi))
                    Gmi.append(gmi)
                    Cmi.append(cmi)

        if ialpha:
            alpha = double_or_blank(card, ialpha + 1, 'alpha')
        else:
            #: thermal expansion coefficient
            alpha = 0.0
        return RBE3(eid,
                    refgrid,
                    refc,
                    weights,
                    comps,
                    Gijs,
                    Gmi=Gmi,
                    Cmi=Cmi,
                    alpha=alpha,
                    comment=comment)
Esempio n. 49
0
    def add_card(cls, card, comment=''):
        """
        Adds a BCTPARA card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card

        """
        csid = integer(card, 1, 'csid')
        i = 2
        j = 1
        params = {}
        while i < card.nfields:
            param = string(card, i, 'param%s' % j)
            i += 1
            if param == 'TYPE':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [0, 1, 2], 'TYPE must be [0, 1, 2]; TYPE=%r' % value
            #elif param == 'TYPE': # NX
                #value = string_or_blank(card, i, 'value%s' % j, 'FLEX').upper()
                #assert value in ['FLEX', 'RIGID', 'COATING'], 'TYPE must be [FLEX, RIGID, COATING.]; CSTIFF=%r' % value

            elif param == 'NSIDE':
                value = integer_or_blank(card, i, 'value%s' % j, 1)
                assert value in [1, 2], 'NSIDE must be [1, 2]; NSIDE=%r' % value
            elif param == 'TBIRTH':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)
            elif param == 'TDEATH':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)
            elif param == 'INIPENE':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [0, 1, 2, 3], 'INIPENE must be [0, 1, 2]; INIPENE=%r' % value
            elif param == 'PDEPTH':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)
            elif param == 'SEGNORM':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [-1, 0, 1], 'SEGNORM must be [-1, 0, 1]; SEGNORM=%r' % value
            elif param == 'OFFTYPE':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [0, 1, 2], 'OFFTYPE must be [0, 1, 2]; OFFTYPE=%r' % value
            elif param == 'OFFSET':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)
            elif param == 'TZPENE':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)

            elif param == 'CSTIFF':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [0, 1], 'CSTIFF must be [0, 1]; CSTIFF=%r' % value
            elif param == 'TIED':
                value = integer_or_blank(card, i, 'value%s' % j, 0)
                assert value in [0, 1], 'TIED must be [0, 1]; TIED=%r' % value
            elif param == 'TIEDTOL':
                value = double_or_blank(card, i, 'value%s' % j, 0.0)
            elif param == 'EXTFAC':
                value = double_or_blank(card, i, 'value%s' % j, 0.001)
                assert 1.0E-6 <= value <= 0.1, 'EXTFAC must be 1.0E-6 < EXTFAC < 0.1; EXTFAC=%r' % value
            else:
                # FRICMOD, FPARA1/2/3/4/5, EPSN, EPST, CFACTOR1, PENETOL
                # NCMOD, TCMOD, RFORCE, LFORCE, RTPCHECK, RTPMAX, XTYPE
                # ...
                value = integer_double_or_blank(card, i, 'value%s' % j)
                assert value is not None, '%s%i must not be None' % (param, j)

            params[param] = value
            i += 1
            j += 1
            if j == 4:
                i += 1
        return BCTPARA(csid, params, comment=comment)
Esempio n. 50
0
    def add_card(self, card, comment=''):
        i = self.i
        sid = integer(card, 1, 'sid')
        excite_id = integer(card, 2, 'excite_id')
        delay = integer_double_or_blank(card, 3, 'delay', 0.)
        dphase = integer_double_or_blank(card, 4, 'dphase', 0.)
        tc = integer_double_or_blank(card, 5, 'tc', 0)
        td = integer_double_or_blank(card, 6, 'td', 0)
        Type = integer_string_or_blank(card, 7, 'Type', 'LOAD')

        if Type in [0, 'L', 'LO', 'LOA', 'LOAD']:
            Type = 'LOAD'
        elif Type in [1, 'D', 'DI', 'DIS', 'DISP']:
            Type = 'DISP'
        elif Type in [2, 'V', 'VE', 'VEL', 'VELO']:
            Type = 'VELO'
        elif Type in [3, 'A', 'AC', 'ACC', 'ACCE']:
            Type = 'ACCE'
        elif Type in [5, 6, 7, 12, 13]:
            pass
        else:
            msg = 'invalid TLOAD2 type  Type=%r' % Type
            raise RuntimeError(msg)
        assert len(card) <= 13, 'len(TLOAD2 card) = %i\ncard=%s' % (len(card),
                                                                    card)

        self.sid[i] = sid
        self.excite_id[i] = excite_id
        if isinstance(delay, int):
            self.delay_id[i] = delay
            self.is_delay_table[i] = 1
        elif isinstance(delay, float):
            self.delay_tau[i] = delay
            self.is_delay_table[i] = 0
        else:
            raise NotImplementedError(delay)

        if isinstance(dphase, int):
            self.dphase_id[i] = dphase
            self.is_dphase_table[i] = 1
        elif isinstance(dphase, float):
            self.dphase_lead[i] = dphase
            self.is_dphase_table[i] = 0
        else:
            raise NotImplementedError(dphase)

        self.Type[i] = Type
        if isinstance(tc, int):
            self.table_c[i] = tc
        elif isinstance(tc, float):
            self.constant_c[i] = tc
        else:
            raise NotImplementedError('tc=%r' % tc)

        if isinstance(td, int):
            self.table_d[i] = td
        elif isinstance(td, float):
            self.constant_d[i] = td
        else:
            raise NotImplementedError('tc=%r' % tc)
        self.i += 1
Esempio n. 51
0
    def add_card(self, card, comment=''):
        i = self.i
        eid = integer(card, 1, 'element_id')
        self.element_id[i] = eid
        self.property_id[i] = integer_or_blank(card, 2, 'property_id', eid)
        self.node_ids[i] = [integer(card, 3, 'GA'),
                            integer(card, 4, 'GB')]

        #---------------------------------------------------------
        # x / g0
        field5 = integer_double_or_blank(card, 5, 'g0_x1', 0.0)
        if isinstance(field5, integer_types):
            self.is_g0[i] = True
            self.g0[i] = field5
        elif isinstance(field5, float):
            self.is_g0[i] = False
            x = array([field5,
                       double_or_blank(card, 6, 'x2', 0.0),
                       double_or_blank(card, 7, 'x3', 0.0)])
            self.x[i, :] = x
            if norm(x) == 0.0:
                msg = 'G0 vector defining plane 1 is not defined on %s %s.\n' % (self.type, eid)
                msg += 'G0 = %s\n' % field5
                msg += 'X  = %s\n' % x
                msg += '%s' % card
                raise RuntimeError(msg)
        else:
            msg = ('field5 on %s (G0/X1) is the wrong type...id=%s field5=%s '
                   'type=%s' % (self.type, self.eid, field5, type(field5)))
            raise RuntimeError(msg)

        #---------------------------------------------------------
        # offt/bit
        field8 = double_string_or_blank(card, 8, 'offt/bit', 'GGG')
        if isinstance(field8, float):
            self.is_offt[i] = False
            self.bit[i] = field8
        elif isinstance(field8, string_types):
            self.is_offt[i] = True
            offt = field8
            msg = 'invalid offt parameter of CBEAM...offt=%s' % offt
            assert offt[0] in ['G', 'B', 'O', 'E'], msg
            assert offt[1] in ['G', 'B', 'O', 'E'], msg
            assert offt[2] in ['G', 'B', 'O', 'E'], msg
            self.offt[i] = offt
        else:
            msg = ('field8 on %s (offt/bit) is the wrong type...id=%s field5=%s '
                   'type=%s' % (self.type, self.eid, field8, type(field8)))
            raise RuntimeError(msg)

        self.pin_flags[i, :] = [integer_or_blank(card, 9, 'pa', 0),
                                integer_or_blank(card, 10, 'pb', 0)]

        self.wa[i, :] = [double_or_blank(card, 11, 'w1a', 0.0),
                         double_or_blank(card, 12, 'w2a', 0.0),
                         double_or_blank(card, 13, 'w3a', 0.0),]

        self.wb[i, :] = [double_or_blank(card, 14, 'w1b', 0.0),
                         double_or_blank(card, 15, 'w2b', 0.0),
                         double_or_blank(card, 16, 'w3b', 0.0),]
        self.sa[i] = integer_or_blank(card, 17, 'sa', 0)
        self.sb[i] = integer_or_blank(card, 18, 'sb', 0)
        assert len(card) <= 19, 'len(CBEAM card) = %i\ncard=%s' % (len(card), card)
        self.i += 1
Esempio n. 52
0
    def __init__(self, card=None, data=None, comment=''):
        if comment:
            self._comment = comment
        if card:
            #: Contact set ID. Parameters defined in this command apply to
            #: contact set CSID defined by a BCTSET entry. (Integer > 0)
            self.csid = integer(card, 1, 'csid')
            i = 2
            j = 1
            self.params = {}
            while i < card.nfields:
                param = string(card, i, 'param%s' % j)
                i += 1
                if param == 'TYPE':
                    value = integer_or_blank(card, i, 'value%s' % j, 0)
                    assert value in [0, 1, 2], 'TYPE must be [0, 1, 2]; TYPE=%r' % value
                elif param == 'NSIDE':
                    value = integer_or_blank(card, i, 'value%s' % j, 1)
                    assert value in [1, 2], 'NSIDE must be [1, 2]; NSIDE=%r' % value
                elif param == 'TBIRTH':
                    value = double_or_blank(card, i, 'value%s' % j, 0.0)
                elif param == 'TDEATH':
                    value = double_or_blank(card, i, 'value%s' % j, 0.0)
                elif param == 'INIPENE':
                    value = integer_or_blank(card, i, 'value%s' % j, 0)
                    assert value in [0, 1, 2, 3], 'INIPENE must be [0, 1, 2]; INIPENE=%r' % value
                elif param == 'PDEPTH':
                    value = double_or_blank(card, i, 'value%s' % j, 0.0)
                elif param == 'SEGNORM':
                    value = integer_or_blank(card, i, 'value%s' % j, 0)
                    assert value in [-1, 0, 1], 'SEGNORM must be [-1, 0, 1]; SEGNORM=%r' % value
                elif param == 'OFFTYPE':
                    value = integer_or_blank(card, i, 'value%s' % j, 0)
                    assert value in [0, 1, 2], 'OFFTYPE must be [0, 1, 2]; OFFTYPE=%r' % value
                elif param == 'OFFSET':
                    value = double_or_blank(card, i, 'value%s' % j, 0.0)
                elif param == 'TZPENE':
                    value = double_or_blank(card, i, 'value%s' % j, 0.0)

                elif param == 'CSTIFF':
                    value = integer_or_blank(card, i, 'value%s' % j, 0)
                    assert value in [0, 1], 'CSTIFF must be [0, 1]; CSTIFF=%r' % value
                elif param == 'TIED':
                    value = integer_or_blank(card, i, 'value%s' % j, 0)
                    assert value in [0, 1], 'TIED must be [0, 1]; TIED=%r' % value
                elif param == 'TIEDTOL':
                    value = double_or_blank(card, i, 'value%s' % j, 0.0)
                elif param == 'EXTFAC':
                    value = double_or_blank(card, i, 'value%s' % j, 0.001)
                    assert 1.0E-6 <= value <= 0.1, 'EXTFAC must be 1.0E-6 < EXTFAC < 0.1; EXTFAC=%r' % value
                else:
                    # FRICMOD, FPARA1/2/3/4/5, EPSN, EPST, CFACTOR1, PENETOL
                    # NCMOD, TCMOD, RFORCE, LFORCE, RTPCHECK, RTPMAX, XTYPE
                    # ...
                    value = integer_double_or_blank(card, i, 'value%s' % j)
                    assert value is not None, '%s%i must not be None' % (param, j)

                self.params[param] = value
                i += 1
                j += 1
                if j == 4:
                    i += 1
        else:
            msg = '%s has not implemented data parsing' % self.type
            raise NotImplementedError(msg)