当前位置: 首页>>代码示例>>Python>>正文


Python assign_type.string函数代码示例

本文整理汇总了Python中pyNastran.bdf.bdf_interface.assign_type.string函数的典型用法代码示例。如果您正苦于以下问题:Python string函数的具体用法?Python string怎么用?Python string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    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_or_string(card, n, 'x' + str(i + 1))
                y = double_or_string(card, n + 1, 'y' + str(i + 1))
                if x == 'SKIP' or y == 'SKIP':
                    continue
                xy += [x, y]
            string(card, nfields, 'ENDT')
            is_data = False
        else:
            self.tid = data[0]
            xy = data[1:]
            is_data = True
        self.parse_fields(xy, nrepeated=2, is_data=is_data)
开发者ID:watkinrt,项目名称:pyNastran,代码行数:28,代码来源:bdf_tables.py

示例2: add_card

    def add_card(cls, card, comment=''):
        k_fields = []
        b_fields = []
        ge_fields = []
        rcv_fields = [None, None, None, None]

        pid = integer(card, 1, 'pid')

        nfields = card.nfields
        istart = 2
        while istart < nfields:
            pname = string(card, istart, 'pname')
            if   pname == 'K':
                k_fields = cls._read_k(card, istart)
            elif pname == 'B':
                b_fields = cls._read_b(card, istart)
            elif pname == 'GE':
                ge_fields = cls._read_ge(card, istart)
            elif pname == 'RCV':
                rcv_fields = cls._read_rcv(card, istart)
            else:
                break
            istart += 8
        return PBUSH(pid, k_fields, b_fields, ge_fields, rcv_fields,
                     comment=comment)
开发者ID:hurlei,项目名称:pyNastran,代码行数:25,代码来源:bush.py

示例3: add_card

    def add_card(cls, card, comment=''):
        name = string(card, 1, 'name')
        #zero

        #: 4-Lower Triangular; 5=Upper Triangular; 6=Symmetric; 8=Identity (m=nRows, n=m)
        ifo = integer(card, 3, 'ifo')
        #: 1-Real, Single Precision; 2=Real,Double Precision;
        #  3=Complex, Single; 4=Complex, Double
        tin = integer(card, 4, 'tin')
        #: 0-Set by cell precision
        tout = integer_or_blank(card, 5, 'tout', 0)

        #: Input format of Ai, Bi. (Integer=blank or 0 indicates real, imaginary format;
        #: Integer > 0 indicates amplitude, phase format.)
        polar = integer_or_blank(card, 6, 'polar', 0)
        if ifo == 1: # square
            ncols = integer_or_blank(card, 8, 'ifo=%s; ncol' % (ifo))
        elif ifo == 6: # symmetric
            ncols = integer_or_blank(card, 8, 'ifo=%s; ncol' % (ifo))
        elif ifo in [2, 9]: # rectangular
            ncols = integer(card, 8, 'ifo=%s; ncol' % (ifo))
        else:
            # technically right, but nulling this will fix bad decks
            #self.ncols = blank(card, 8, 'ifo=%s; ncol' % self.ifo)
            raise NotImplementedError('ifo=%s is not supported' % ifo)

        GCj = []
        GCi = []
        Real = []
        Complex = []
        return cls(name, ifo, tin, tout, polar, ncols,
                   GCj, GCi, Real, Complex, comment=comment)
开发者ID:saullocastro,项目名称:pyNastran,代码行数:32,代码来源:dmig.py

示例4: add_card

 def add_card(cls, card, icard=0, comment=''):
     noffset = 2 * icard
     sid = integer(card, 1, 'sid')
     Type = string(card, 2, 'Type')
     id = integer(card, 3 + noffset, 'id')
     value = double(card, 4 + noffset, 'value')
     return NSM(sid, Type, id, value, comment=comment)
开发者ID:saullocastro,项目名称:pyNastran,代码行数:7,代码来源:mass.py

示例5: __init__

    def __init__(self, card, comment=''):
        self.pid = integer(card, 1, 'property_id')
        self.sets = []
        self.Types = []
        self.gammas = []
        self._cps = []
        #self.set = integer(card, 2, 'set_id')
        #self.Type = string(card, 3, 'Type')
        #if self.Type not in ['NEWTON','PRANDTL-MEYER', 'CP']:
        #    raise RuntimeError('Type=%r' % Type)
        #self.gamma = double_or_blank(card, 4, 'gamma', 1.4)

        i = 2
        while i < len(card):
            self.sets.append(integer(card, i, 'set_id'))
            Type = string(card, i+1, 'Type')
            self.Types.append(Type)
            #if self.Type not in ['NEWTON','PRANDTL-MEYER', 'CP']:
                #raise RuntimeError('Type=%r' % Type)
            self.gammas.append(double_or_blank(card, i+2, 'gamma', 1.4))

            _cp = None
            if Type == 'CP':
                _cp = double(card, i+3, 'Cp')
            elif Type == 'NEWTON':
                _cp = double_or_blank(card, i+3, 'Cp_nominal', 2.0)
            self._cps.append(_cp)
            i += 7
开发者ID:FrankNaets,项目名称:pyNastran,代码行数:28,代码来源:cards.py

示例6: __init__

    def __init__(self, card, comment=''):
        ThermalElement.__init__(self, card)
        if comment:
            self._comment = comment
        #: Surface element ID
        self.eid = integer(card, 1, 'eid')
        # no field 2

        #: Surface type
        self.Type = string(card, 3, 'Type')
        assert self.Type in ['REV', 'AREA3', 'AREA4', 'AREA6', 'AREA8']

        #: A VIEW entry identification number for the front face
        self.iViewFront = integer_or_blank(card, 4, 'iViewFront', 0)

        #: A VIEW entry identification number for the back face
        self.iViewBack = integer_or_blank(card, 8, 'iViewBack', 0)

        #: RADM identification number for front face of surface element
        #: (Integer > 0)
        self.radMidFront = integer_or_blank(card, 6, 'radMidFront', 0)

        #: RADM identification number for back face of surface element
        #: (Integer > 0)
        self.radMidBack = integer_or_blank(card, 7, 'radMidBack', 0)
        # no field 8

        #: Grid point IDs of grids bounding the surface (Integer > 0)
        self.nodes = []
        n = 1
        for i in range(9, len(card)):
            grid = integer_or_blank(card, i, 'grid%i' % n)
            if grid is not None:
                self.nodes.append(grid)
        assert len(self.nodes) > 0, 'card=%s' % card
开发者ID:watkinrt,项目名称:pyNastran,代码行数:35,代码来源:thermal.py

示例7: add_card

    def add_card(cls, card, comment=''):
        mid = integer(card, 1, 'mid')
        tid = integer_or_blank(card, 2, 'tid')
        Type = string(card, 3, 'Type')

        if Type not in ['NLELAST', 'PLASTIC']:
            raise ValueError('MATS1 Type must be [NLELAST, PLASTIC]; Type=%r' % Type)
        if Type == 'NLELAST':
            # should we even read these?
            h = None
            hr = None
            yf = None
            limit1 = None
            limit2 = None
            #h = blank(card, 4, 'h')
            #hr = blank(card, 6, 'hr')
            #yf = blank(card, 5, 'yf')
            #limit1 = blank(card, 7, 'yf')
            #limit2 = blank(card, 8, 'yf')
        else:
            h = double_or_blank(card, 4, 'H')
            yf = integer_or_blank(card, 5, 'yf', 1)
            hr = integer_or_blank(card, 6, 'hr', 1)
            limit1 = double(card, 7, 'limit1')

            if yf in [3, 4]:
                limit2 = double(card, 8, 'limit2')
            else:
                #limit2 = blank(card, 8, 'limit2')
                limit2 = None
        assert len(card) <= 9, 'len(MATS1 card) = %i\ncard=%s' % (len(card), card)
        return MATS1(mid, tid, Type, h, hr, yf, limit1, limit2, comment=comment)
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:32,代码来源:material_deps.py

示例8: add_card

    def add_card(cls, card, comment=''):
        eid = integer(card, 1, 'eid')
        pid = integer(card, 2, 'pid')

        Type = string(card, 3, 'Type')
        #print("self.Type = %s" % self.Type)
        # msg = 'CHBDYP Type=%r' % self.Type
        #assert self.Type in ['POINT','LINE','ELCYL','FTUBE','TUBE'], msg

        iViewFront = integer_or_blank(card, 4, 'iViewFront', 0)
        iViewBack = integer_or_blank(card, 5, 'iViewBack', 0)
        g1 = integer(card, 6, 'g1')

        if Type != 'POINT':
            g2 = integer(card, 7, 'g2')
        else:
            g2 = blank(card, 7, 'g2')

        g0 = integer_or_blank(card, 8, 'g0', 0)
        radMidFront = integer_or_blank(card, 9, 'radMidFront', 0)
        radMidBack = integer_or_blank(card, 10, 'radMidBack', 0)
        gmid = integer_or_blank(card, 11, 'gmid')
        ce = integer_or_blank(card, 12, 'ce', 0)
        e1 = double_or_blank(card, 13, 'e3')
        e2 = double_or_blank(card, 14, 'e3')
        e3 = double_or_blank(card, 15, 'e3')
        assert len(card) <= 16, 'len(CHBDYP card) = %i\ncard=%s' % (len(card), card)
        return CHBDYP(eid, pid, Type, g1, g2, g0=g0, gmid=gmid, ce=ce,
                      iViewFront=iViewFront, iViewBack=iViewBack,
                      radMidFront=radMidFront, radMidBack=radMidBack,
                      e1=e1, e2=e2, e3=e3, comment=comment)
开发者ID:FrankNaets,项目名称:pyNastran,代码行数:31,代码来源:thermal.py

示例9: add_card

    def add_card(self, card, comment=''):
        if comment:
            self._comment = comment
        pid = integer(card, 1, 'pid')
        k = double_or_blank(card, 2, 'k', 0.0)
        c = double_or_blank(card, 3, 'c', 0.0)
        m = double_or_blank(card, 4, 'm', 0.0)

        sa = double_or_blank(card, 6, 'sa', 0.0)
        se = double_or_blank(card, 7, 'se', 0.0)

        nfields = card.nfields
        self.vars = []
        istart = 9
        while istart < nfields:
            pname = string(card, istart, 'pname')
            if pname == 'SHOCKA':
                istart = self._read_shock(card, istart)
            elif pname == 'SPRING':
                self._read_spring(card, istart)
            elif pname == 'DAMPER':
                self._read_damper(card, istart)
            elif pname == 'GENER':
                self._read_gener(card, istart)
            else:
                break
            istart += 8

        self.pid = pid
        self.k = k
        self.c = c
        self.m = m

        self.sa = sa
        self.se = se
开发者ID:marcinch18,项目名称:pyNastran,代码行数:35,代码来源:bush.py

示例10: add_card

    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)
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:58,代码来源:contact.py

示例11: add_card

    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')
        x1 = double(card, 2, 'x1')
        x2 = double(card, 3, 'x2')
        x3 = double(card, 4, 'x3')
        x4 = double(card, 5, 'x4')

        nfields = len(card) - 1
        nterms = nfields - 9
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)

        a = []
        j = 0
        for i in range(9, nfields):
            ai = double(card, i, 'a%i' % (j))
            a.append(ai)
            j += 1
        string(card, nfields, 'ENDT')
        return TABLEM4(tid, x1, x2, x3, x4, a, comment=comment)
开发者ID:marcinch18,项目名称:pyNastran,代码行数:20,代码来源:bdf_tables.py

示例12: add

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

        if self.Type[i] == 'NLELAST':
            self.h[i] = blank(card, 4, 'h')
            self.hr[i] = blank(card, 6, 'hr')
            self.yf[i] = blank(card, 5, 'yf')
            self.limit1[i] = blank(card, 7, 'yf')
            self.limit2[i] = blank(card, 8, 'yf')
        else:
            #: Work hardening slope (slope of stress versus plastic strain) in
            #: units of stress. For elastic-perfectly plastic cases, H=0.0.
            #: For more than a single slope in the plastic range, the
            #: stress-strain data must be supplied on a TABLES1 entry
            #: referenced by TID, and this field must be blank
            h = double_or_blank(card, 4, 'H')
            self.h[i] = h
            if h is None:
                self.hflag[i] = False
            else:
                self.hflag[i] = True

            #: Yield function criterion, selected by one of the following
            #: values (1) Von Mises (2) Tresca (3) Mohr-Coulomb
            #: (4) Drucker-Prager
            self.yf[i] = integer_or_blank(card, 5, 'yf', 1)

            #: Hardening Rule, selected by one of the following values
            #: (Integer): (1) Isotropic (Default) (2) Kinematic
            #: (3) Combined isotropic and kinematic hardening
            self.hr[i] = integer_or_blank(card, 6, 'hr', 1)
            #: Initial yield point
            self.limit1[i] = double(card, 7, 'limit1')

            if self.yf[i] == 3 or self.yf[i] == 4:
                #: Internal friction angle, measured in degrees, for the
                #: Mohr-Coulomb and Drucker-Prager yield criteria
                self.limit2[i] = double(card, 8, 'limit2')
            else:
                #self.limit2[i] = blank(card, 8, 'limit2')
                #self.limit2[i] = None
                pass
        assert len(card) <= 9, 'len(MATS1 card) = %i\ncard=%s' % (len(card), card)
        self.i += 1
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:54,代码来源:mats1.py

示例13: add_card

    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            x = double_or_string(card, n, 'x' + str(i + 1))
            y = double_or_string(card, n + 1, 'y' + str(i + 1))
            if x == 'SKIP' or y == 'SKIP':
                continue
            xy.append([x, y])
        string(card, nfields, 'ENDT')
        x, y = make_xy(tid, 'TABLEST', xy)
        return TABLEST(tid, x, y, comment=comment)
开发者ID:saullocastro,项目名称:pyNastran,代码行数:20,代码来源:bdf_tables.py

示例14: build

    def build(self):
        #if comment:
            #self._comment = comment
        cards = self._cards
        ncards = len(cards)

        float_fmt = self.model.float
        self.load_id = zeros(ncards, 'int32')
        self.element_id = zeros(ncards, 'int32')
        self.Type = array([''] * ncards, '|S4')
        self.scale = array([''] * ncards, '|S4')
        self.x1 = zeros(ncards, float_fmt)
        self.x2 = zeros(ncards, float_fmt)
        self.p1 = zeros(ncards, float_fmt)
        self.p2 = zeros(ncards, float_fmt)

        self.n = ncards
        for i, card in enumerate(cards):
            self.load_id[i] = integer(card, 1, 'load_id')
            self.element_id[i] = integer(card, 2, 'eid')
            Type = string(card, 3, 'Type ("%s")' % '",  "'.join(self.valid_types))
            scale = string(card, 4, 'scale ("%s")' % '", "'.join(self.valid_scales))
            self.x1[i] = double(card, 5, 'x1')
            self.p1[i] = double(card, 6, 'p1')
            self.x2[i] = double_or_blank(card, 7, 'x2', self.x1)
            self.p2[i] = double_or_blank(card, 8, 'p2', self.p1)
            assert len(card) <= 9, 'len(PLOAD1 card) = %i' % len(card)

            if Type not in self.valid_types:
                msg = '%r is an invalid type on the PLOAD1 card' % Type
                raise RuntimeError(msg)
            self.Type[i] = Type

            assert 0.0 <= self.x1[i] <= self.x2[i]
            if scale in ['FR', 'FRPR']:
                assert self.x1[i] <= 1.0, 'x1=%r' % self.x1[i]
                assert self.x2[i] <= 1.0, 'x2=%r' % self.x2[i]
            assert scale in self.valid_scales, '%s is an invalid scale on the PLOAD1 card' % scale
            self.scale[i] = scale
            self._cards = []
            self._comments = []
开发者ID:marcinch18,项目名称:pyNastran,代码行数:41,代码来源:pload1.py

示例15: add_card

    def add_card(cls, card, comment=''):
        eid = integer(card, 1, 'eid')
        ium = card.index('UM')
        if ium > 0:
            assert string(card, ium, 'UM') == 'UM'

        #assert isinstance(card[-1], string_types), 'card[-1]=%r type=%s' %(card[-1], type(card[-1]))
        alpha_last = integer_double_or_string(card, -1, 'alpha_last')
        if isinstance(alpha_last, float):
            alpha = alpha_last
            card.pop()  # remove the last field so len(card) will not include alpha
        else:
            alpha = 0.

        # loop till UM, no field9,field10
        n = 1
        i = 0
        offset = 2
        Gni = []
        Cni = []
        Gmi = []
        Cmi = []
        while offset + i < ium - 1:
            #print('field(%s) = %s' % (offset + i, card.field(offset + i)))
            gni = integer_or_blank(card, offset + i, 'gn%i' % n)
            cni = components_or_blank(card, offset + i + 1, 'cn%i' % n)

            if gni:
                #print("gni=%s cni=%s" % (gni ,cni))
                Gni.append(gni)
                Cni.append(cni)
                n += 1
            else:
                assert cni is None
            i += 2

        # loop till alpha, no field9,field10
        n = 1
        offset = ium + 1
        i = 0

        # dont grab alpha
        while offset + i < len(card):
            gmi = integer_or_blank(card, offset + i, 'gm%i' % n)
            cmi = components_or_blank(card, offset + i + 1, 'cm%i' % n)
            if gmi:
                Gmi.append(gmi)
                Cmi.append(cmi)
                n += 1
            else:
                assert cmi is None
            i += 2
        return RBE1(eid, Gni, Cni, Gmi, Cmi, alpha=alpha, comment=comment)
开发者ID:saullocastro,项目名称:pyNastran,代码行数:53,代码来源:rigid.py


注:本文中的pyNastran.bdf.bdf_interface.assign_type.string函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。