Esempio n. 1
0
    def __init__(self, card=None, data=None, comment=''):
        RandomTable.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.tid = integer(card, 1, 'tid')
            self.xaxis = string_or_blank(card, 2, 'xaxis', 'LINEAR')
            self.yaxis = string_or_blank(card, 3, 'yaxis', 'LINEAR')

            nfields = len(card) - 1
            nterms = (nfields - 9) // 2
            if nterms < 0:
                raise SyntaxError('%r card is too short' % self.type)
            xy = []
            for i in range(nterms):
                n = 9 + i * 2
                if card.field(n) == 'ENDT':
                    break
                x = double_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]
            self.xaxis = self.map_axis(data[1])
            self.yaxis = self.map_axis(data[2])
            xy = data[3:]
            is_data = True
        assert self.xaxis in ['LINEAR', 'LOG'], 'xaxis=%r' % (self.xaxis)
        assert self.yaxis in ['LINEAR', 'LOG'], 'yaxis=%r' % (self.yaxis)
        self.parse_fields(xy, nrepeated=2, is_data=is_data)
Esempio n. 2
0
    def add_card(cls, card, comment=''):
        """
        Adds a TABLED1 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        tid = integer(card, 1, 'tid')
        xaxis = string_or_blank(card, 2, 'xaxis', 'LINEAR')
        yaxis = string_or_blank(card, 3, 'yaxis', 'LINEAR')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            xi = double_or_string(card, n, 'x' + str(i + 1))
            yi = double_or_string(card, n + 1, 'y' + str(i + 1))
            if xi == 'SKIP' or yi == 'SKIP':
                continue
            xy.append([xi, yi])
        string(card, nfields, 'ENDT')
        x, y = make_xy(tid, 'TABLED1', xy)
        return TABLED1(tid, x, y, xaxis=xaxis, yaxis=yaxis, comment=comment)
Esempio n. 3
0
    def add_card(cls, card, comment=''):
        """
        Adds a TABLEM4 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        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_or_blank(card, i, 'a%i' % (j), 0.0)
            a.append(ai)
            j += 1
        string(card, nfields, 'ENDT')
        return TABLEM4(tid, x1, x2, x3, x4, a, comment=comment)
Esempio n. 4
0
    def add_card(cls, card, comment=''):
        """
        Adds a TABLEM3 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        tid = integer(card, 1, 'tid')
        x1 = double(card, 2, 'x1')
        x2 = double(card, 3, 'x2')

        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, 'TABLEM3', xy)
        return TABLEM3(tid, x1, x2, x, y, comment=comment)
Esempio n. 5
0
    def __init__(self, card=None, data=None, comment=''):
        Table.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            self.tid = integer(card, 1, 'tid')

            nfields = len(card) - 1
            nterms = (nfields - 9) // 2
            if nterms < 0:
                raise SyntaxError('%r card is too short' % self.type)
            xy = []
            for i in range(nterms):
                n = 9 + i * 2
                if card.field(n) == 'ENDT':
                    break
                x = double_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)
Esempio n. 6
0
    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)
Esempio n. 7
0
 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)
Esempio n. 8
0
    def add_card(cls, card, comment=''):
        k_tables = []
        b_tables = []
        ge_tables = []
        kn_tables = []

        pid = integer(card, 1, 'pid')
        nfields = len(card) - 1
        nrows = nfields // 8
        if nfields % 8 != 0:
            nrows += 1

        for irow in range(nrows):
            ifield = 1 + irow * 8
            param = string(card, ifield + 1, 'param_type')
            table = []
            for j in range(6):
                table_value = integer_or_blank(card, ifield + j + 2, param + '%i' % (j+1))
                table.append(table_value)
            if param == 'K':
                k_tables = table
            elif param == 'B':
                b_tables = table
            elif param == 'GE':
                ge_tables = table
            elif param == 'KN':
                kn_tables = table
            else:
                raise ValueError(param)
        return PBUSHT(pid, k_tables, b_tables, ge_tables, kn_tables,
                      comment=comment)
Esempio n. 9
0
 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)
Esempio n. 10
0
    def add_card(cls, card, comment=''):
        eid = integer(card, 1, 'eid')
        # no field 2

        Type = string(card, 3, 'Type')
        iViewFront = integer_or_blank(card, 4, 'iViewFront', 0)
        iViewBack = integer_or_blank(card, 8, 'iViewBack', 0)
        radMidFront = integer_or_blank(card, 6, 'radMidFront', 0)
        radMidBack = integer_or_blank(card, 7, 'radMidBack', 0)
        # no field 8

        n = 1
        nodes = []
        for i in range(9, len(card)):
            grid = integer_or_blank(card, i, 'grid%i' % n)
            if grid is not None:
                nodes.append(grid)
        assert len(nodes) > 0, 'card=%s' % card
        return CHBDYG(eid,
                      Type,
                      nodes,
                      iViewFront=iViewFront,
                      iViewBack=iViewBack,
                      radMidFront=radMidFront,
                      radMidBack=radMidBack,
                      comment=comment)
Esempio n. 11
0
    def add_card(cls, card, comment=''):
        name = string(card, 1, 'name')
        #zero

        ifo = integer(card, 3, 'ifo')
        tin = integer(card, 4, 'tin')
        tout = integer_or_blank(card, 5, 'tout', 0)
        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)
Esempio n. 12
0
    def add_card(cls, card, comment=''):
        """
        Adds a CGEN card from ``BDF.add_card(...)``

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

        Type = string(card, 1, 'Type')
        feid = integer(card, 2, 'feid')
        pid = integer(card, 3, 'pid')
        fid = integer(card, 4, 'fid')
        direction = string_or_blank(card, 5, 'direction', 'L')
        th = integer_or_blank(card, 6, 'th')
        eidl = integer(card, 7, 'eidl')
        eidh = integer(card, 8, 'eidh')
        t_abcd = [
            double_or_blank(card, 9, 'ta', 0.),
            double_or_blank(card, 10, 'tb', 0.),
            double_or_blank(card, 11, 'tc', 0.),
            double_or_blank(card, 12, 'td', 0.),
        ]
        return CGEN(Type, feid, pid, fid, th, eidl, eidh,
                    t_abcd=t_abcd, direction=direction,
                    comment=comment)
Esempio n. 13
0
    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
Esempio n. 14
0
    def __init__(self, card=None, data=None, comment=''):
        ThermalElement.__init__(self, card)
        if comment:
            self._comment = comment
        if card:
            #: Surface element ID
            self.eid = integer(card, 1, 'eid')

            #: PHBDY property entry identification numbers. (Integer > 0)
            self.pid = integer(card, 2, 'pid')
            assert self.pid > 0

            self.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

            #: 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, 5, 'iViewBack', 0)

            #: Grid point identification numbers of grids bounding the surface.
            #: (Integer > 0)
            self.g1 = integer(card, 6, 'g1')
            #: Grid point identification numbers of grids bounding the surface.
            #: (Integer > 0)
            if self.Type != 'POINT':
                self.g2 = integer(card, 7, 'g2')
            else:
                self.g2 = blank(card, 7, 'g2')

            #: Orientation grid point. (Integer > 0; Default = 0)
            self.g0 = integer_or_blank(card, 8, 'g0', 0)

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

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

            #: Grid point identification number of a midside node if it is used
            #: with the line type surface element.
            self.gmid = integer_or_blank(card, 11, 'gmid')
            #: Coordinate system for defining orientation vector.
            #: (Integer > 0; Default = 0
            self.ce = integer_or_blank(card, 12, 'ce', 0)

            #: Components of the orientation vector in coordinate system CE.
            #: The origin of the orientation vector is grid point G1.
            #: (Real or blank)
            self.e1 = double_or_blank(card, 13, 'e3')
            self.e2 = double_or_blank(card, 14, 'e3')
            self.e3 = double_or_blank(card, 15, 'e3')
            assert len(card) <= 16, 'len(CHBDYP card) = %i' % len(card)
        else:
            raise NotImplementedError(data)
Esempio n. 15
0
    def add_card(cls, card, comment=''):  # TODO: not done...
        """
        Adds a TRIM2 card from ``BDF.add_card(...)``

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

        """
        sid = integer(card, 1, 'sid')
        mach = double(card, 2, 'mach')
        q = double(card, 3, 'q')
        aeqr = double_or_blank(card, 8, 'aeqr', 1.0)

        i = 9
        n = 3
        labels = []
        uxs = []
        while i < len(card):
            label = string(card, i, 'label%i' % n)
            ux = double(card, i + 1, 'ux%i' % n)
            labels.append(label)
            uxs.append(ux)
            i += 2
        return TRIM2(sid, mach, q, labels, uxs, aeqr, comment=comment)
Esempio n. 16
0
    def add_card(cls, card, comment=''):
        name = string(card, 1, 'name')
        #zero

        #: Form of the matrix:  1=Square (not symmetric); 2=Rectangular;
        #: 3=Diagonal (m=nRows,n=1);  4=Lower Triangular; 5=Upper Triangular;
        #: 6=Symmetric; 8=Identity (m=nRows, n=m)
        form = integer(card, 3, 'form')

        #: 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)

        nrows = integer(card, 7, 'nrows')
        ncols = integer(card, 8, 'ncols')

        assert len(card) == 9, 'len(DMI card) = %i\ncard=%s' % (len(card), card)

        GCj = []
        GCi = []
        Real = []
        Complex = []
        return DMI(name, form, tin, tout, nrows, ncols,
                   GCj, GCi, Real, Complex, comment=comment)
Esempio n. 17
0
    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)
Esempio n. 18
0
    def add_card(cls, card, comment=''):
        """
        Adds a AXIF card from ``BDF.add_card(...)``

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

        """
        cid = integer(card, 1, 'cid')
        g = double(card, 2, 'g')
        drho = double(card, 3, 'drho')
        db = double_or_blank(card, 4, 'db')
        no_sym = string(card, 5, 'no_sym')
        f = string_or_blank(card, 6, 'f')
        n = fields(integer_or_string, card, 'n', i=9, j=len(card))
        #cid : int
        #G : float
        #drho : float
        #db : float
        #no_sym : str
        #F : str
        #Ni : List[int]

        assert len(card) >= 7, 'len(AXIF card) = %i\ncard=%s' % (len(card),
                                                                 card)
        return AXIF(cid, g, drho, db, no_sym, f, n, comment=comment)
Esempio n. 19
0
 def add_card(cls, card, comment=''):
     eid = integer(card, 1, 'eid')
     pid = integer_or_blank(card, 2, 'pid', eid)
     Type = string(card, 3, 'Type')
     ida = integer(card, 4, 'ida')
     idb = integer(card, 5, 'idb')
     gs = integer_or_blank(card, 6, 'gs')
     ga = integer_or_blank(card, 7, 'ga')
     gb = integer_or_blank(card, 8, 'gb')
     xs = double_or_blank(card, 9, 'xs')
     ys = double_or_blank(card, 10, 'ys')
     zs = double_or_blank(card, 11, 'zs')
     assert len(card) <= 12, 'len(CFAST card) = %i\ncard=%s' % (len(card),
                                                                card)
     #if self.Type=='PROP': # PSHELL/PCOMP  ida & idb
     return CFAST(eid,
                  pid,
                  Type,
                  ida,
                  idb,
                  gs,
                  ga,
                  gb,
                  xs,
                  ys,
                  zs,
                  comment=comment)
Esempio n. 20
0
    def add_card_nx(cls, card, comment=''):
        #
        infor = string(card, 2, 'infor')
        fset = integer(card, 3, 'fset')
        sset = integer(card, 4, 'sset')
        normal = double_or_blank(card, 5, 'normal', 0.5)
        #
        olvpang = double_or_blank(card, 7, 'olvpang', 60.0)
        search_unit = string_or_blank(card, 8, 'search_unit', 'REL')
        intol = double_or_blank(card, 9, 'intol', 0.2)
        area_op = integer_or_blank(card, 10, 'area_op', 0)
        ctype = string_or_blank(card, 11, 'ctype', 'STRONG')
        assert len(card) <= 8, f'len(ACMODL card) = {len(card):d}\ncard={card}'

        return ACMODL(infor,
                      fset,
                      sset,
                      normal=normal,
                      olvpang=olvpang,
                      search_unit=search_unit,
                      intol=intol,
                      area_op=area_op,
                      ctype=ctype,
                      nastran_version='nx',
                      comment=comment)
Esempio n. 21
0
    def add_card(cls, card, comment=''):
        """
        Adds a NSM1/NSML1 card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        sid = integer(card, 1, 'sid')
        nsm_type = string(card, 2, 'Type')
        value = double(card, 3, 'value')

        # TODO: doesn't support 1 THRU 11 BY 2
        ids = []
        _id = 1
        nfields = len(card)
        if nfields == 5:
            id1 = integer_or_string(card, 4, 'ID_1')
            if id1 != 'ALL' and not isinstance(id1, int):
                msg = (
                    '*ID_1 = %r (field #4) on card must be an integer or ALL.\n'
                    'card=%s' % (id1, card))
                raise SyntaxError(msg)
            ids = id1
        else:
            # we'll handle expansion in the init
            ids = card[4:]
        return cls(sid, nsm_type, value, ids, comment=comment)
Esempio n. 22
0
    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
Esempio n. 23
0
    def add_card(cls, card, comment=''):
        """
        Adds a CFAST 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)
        Type = string(card, 3, 'Type')
        ida = integer(card, 4, 'ida')
        idb = integer(card, 5, 'idb')
        gs = integer_or_blank(card, 6, 'gs')
        ga = integer_or_blank(card, 7, 'ga')
        gb = integer_or_blank(card, 8, 'gb')
        xs = double_or_blank(card, 9, 'xs')
        ys = double_or_blank(card, 10, 'ys')
        zs = double_or_blank(card, 11, 'zs')
        assert len(card) <= 12, 'len(CFAST card) = %i\ncard=%s' % (len(card), card)
        #if self.Type=='PROP': # PSHELL/PCOMP  ida & idb
        return CFAST(eid, pid, Type, ida, idb, gs=gs, ga=ga, gb=gb,
                     xs=xs, ys=ys, zs=zs, comment=comment)
Esempio n. 24
0
    def add_card(cls, card, comment=''):
        """
        Adds a CBARAO card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        eid = integer(card, 1, 'eid')
        scale = string(card, 2, 'scale')
        x1_npoints = integer_or_double(card, 3, 'x1/npoints')
        if isinstance(x1_npoints, integer_types):
            npoints = x1_npoints
            x1 = double_or_blank(card, 4, 'x1')
            delta_x = double_or_blank(card, 4, 'delta_x')
            x = np.arange(x1, npoints, delta_x)
            raise NotImplementedError('card=%s x=%s' % (card, x))

        else:
            x = [
                x1_npoints,
                double_or_blank(card, 4, 'x2'),
                double_or_blank(card, 5, 'x3'),
                double_or_blank(card, 6, 'x4'),
                double_or_blank(card, 7, 'x5'),
                double_or_blank(card, 8, 'x6'),
            ]
        assert len(card) <= 9, 'len(CBARAO card) = %i\ncard=%s' % (len(card), card)
        return CBARAO(eid, scale, x, comment=comment)
Esempio n. 25
0
    def add_card(cls, card, comment=''):
        """
        Adds a CBARAO card from ``BDF.add_card(...)``

        Parameters
        ----------
        card : BDFCard()
            a BDFCard object
        comment : str; default=''
            a comment for the card
        """
        eid = integer(card, 1, 'eid')
        scale = string(card, 2, 'scale')
        x1_npoints = integer_or_double(card, 3, 'x1/npoints')
        if isinstance(x1_npoints, integer_types):
            npoints = x1_npoints
            assert 0 < npoints < 7, 'CBARAO npoints=%r must be 1-6' % npoints
            x1 = double(card, 4, 'x1')
            delta_x = double(card, 5, 'delta_x')
            x = np.linspace(x1, x1 + delta_x * (npoints-1), num=npoints)
            assert len(x) == npoints, x
        else:
            x = [
                x1_npoints,
                double_or_blank(card, 4, 'x2'),
                double_or_blank(card, 5, 'x3'),
                double_or_blank(card, 6, 'x4'),
                double_or_blank(card, 7, 'x5'),
                double_or_blank(card, 8, 'x6'),
            ]
            x = [xi for xi in x if xi is not None]
        assert len(card) <= 9, 'len(CBARAO card) = %i\ncard=%s' % (len(card), card)
        return CBARAO(eid, scale, x, comment=comment)
Esempio n. 26
0
    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)
    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)
Esempio n. 28
0
    def add_card(cls, card, comment=''):
        """
        Adds a QHBDY card from ``BDF.add_card(...)``

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

        """
        sid = integer(card, 1, 'eid')
        flag = string(card, 2, 'flag')

        q0 = double(card, 3, 'q0')
        af = double_or_blank(card, 4, 'af')
        nnodes_required, nnodes_max = cls.flag_to_nnodes[flag]

        grids = []
        if nnodes_required == nnodes_max:
            for i in range(nnodes_required):
                grid = integer(card, 5 + i, 'grid%i' % (i + 1))
                grids.append(grid)
        else:
            int_node_count = 0
            for i in range(nnodes_max):
                grid = integer_or_blank(card, 5 + i, 'grid%i' % (i + 1))
                if grid is not None:
                    int_node_count += 1
                grids.append(grid)
            if int_node_count < nnodes_required:
                msg = 'int_node_count=%s nnodes_required=%s' % (int_node_count, nnodes_required)
                raise RuntimeError(msg)
        return QHBDY(sid, flag, q0, grids, af=af, comment=comment)
Esempio n. 29
0
    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)
Esempio n. 30
0
    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
Esempio n. 31
0
    def add_card(cls, card, comment=''):
        """
        Adds a DTABLE card from ``BDF.add_card(...)``

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

        """
        nfields = len(card) - 1
        assert nfields % 2 == 0, nfields

        default_values = {}
        j = 1
        for i in range(1, nfields + 1, 2):
            label = string(card, i, 'label_%i' % j)
            value = double(card, i + 1, 'value_%i' % j)
            assert label not in default_values, 'label_%i=%r is not unique' % (
                j, label)
            default_values[label] = value
            j += 1
        assert j >= 2, j
        return DTABLE(default_values, comment=comment)
Esempio n. 32
0
    def add_card(cls, card, comment=''):
        """
        Adds a PBUSH1D card from ``BDF.add_card(...)``

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

        """
        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
        optional_vars = {}
        istart = 9
        while istart < nfields:
            pname = string(card, istart, 'pname')
            if pname == 'SHOCKA':
                istart, out = cls._read_shock(card, istart)
                optional_vars['SHOCKA'] = out

            elif pname == 'SPRING':
                out = cls._read_spring(card, istart)
                optional_vars['SPRING'] = out

            elif pname == 'DAMPER':
                out = cls._read_damper(card, istart)
                optional_vars['DAMPER'] = out

            elif pname == 'GENER':
                out = cls._read_gener(card, istart)
                optional_vars['GENER'] = out
            else:
                break
            istart += 8

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

        #self.sa = sa
        #self.se = se
        return PBUSH1D(pid,
                       k=k,
                       c=c,
                       m=m,
                       sa=sa,
                       se=se,
                       optional_vars=optional_vars,
                       comment=comment)
Esempio n. 33
0
 def add_card(cls, card_lines, comment=''):
     card = BDFCard(to_fields([card_lines[0]], 'GMSURF'))
     surf_id = integer(card, 1, 'surf_id')
     group = string(card, 2, 'group')
     cid_in = integer_or_blank(card, 3, 'cid_in', 0)
     cid_bc = integer_or_blank(card, 4, 'cid_bc', 0)
     data = card_lines[1:]
     return GMSURF(surf_id, group, data, cid_in=cid_in, cid_bc=cid_bc, comment=comment)
Esempio n. 34
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. 35
0
 def add_card(cls, card, comment=''):
     seid = integer(card, 1, 'lid_s0')
     plane = string(card, 2, 'seid')
     p1 = integer(card, 3, 'p1')
     p2 = integer(card, 4, 'p2')
     p3 = integer(card, 5, 'p3')
     assert plane == 'PLANE', plane
     assert len(card) <= 6, f'len(SEMPLN card) = {len(card):d}\ncard={card}'
     return SEMPLN(seid, p1, p2, p3, comment=comment)
Esempio n. 36
0
    def build(self):
        #if comment:
        # self.comment = comment
        cards = self._cards
        ncards = len(cards)

        float_fmt = self.model.float_fmt
        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\ncard=%s' % (
                len(card), 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 = []
Esempio n. 37
0
    def add_card(self, card=None, comment=''):
        if comment:
            self.set_comment(mid, 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
Esempio n. 38
0
    def add_card(cls, card, comment=''):
        """
        Adds a FLUTTER card from ``BDF.add_card(...)``

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

        """
        sid = integer(card, 1, 'sid')
        method = string(card, 2, 'method (K, KE, PKS, PKNLS, PKNL, PK)')
        density_id = integer(card, 3, 'density')
        mach_id = integer(card, 4, 'mach')
        reduced_freq_velocity_id = integer(card, 5, 'reduced_freq_velocity')

        if method in ['K', 'KE']:
            imethod = string_or_blank(card, 6, 'imethod', 'L')
            nvalue = integer_or_blank(card, 7, 'nvalue')
            omax = None
            assert imethod in ['L', 'S', 'TCUB'
                               ], 'imethod = %s' % imethod  # linear-surface
        elif method in ['PKS', 'PKNLS']:
            imethod = None
            nvalue = None
            omax = double_or_blank(card, 7, 'omax')
        elif method == 'PKNL':
            nvalue = integer_or_blank(card, 7, 'nvalue')
            omax = None
            imethod = None
        elif method == 'PK':
            nvalue = integer_or_blank(card, 7, 'nvalue')
            omax = None
            imethod = None
        else:
            raise NotImplementedError('FLUTTER method=%r' % method)

        assert method in ['K', 'KE', 'PK', 'PKS', 'PKNL', 'PKNLS',
                          None], method
        epsilon = double_or_blank(card, 8, 'epsilon',
                                  1e-3)  # not defined in QRG
        assert len(
            card) <= 9, f'len(FLUTTER card) = {len(card):d}\ncard={card}'
        return FLUTTER(sid,
                       method,
                       density_id,
                       mach_id,
                       reduced_freq_velocity_id,
                       imethod=imethod,
                       nvalue=nvalue,
                       omax=omax,
                       epsilon=epsilon,
                       comment=comment)
Esempio n. 39
0
    def add(self, card=None, comment=''):
        if comment:
            self._comment = comment
        i = self.i
        #: Identification number of a MAT1, MAT2, or MAT9 entry.
        self.material_id[i] = integer(card, 1, 'mid')
        #: Identification number of a TABLES1 or TABLEST entry. If H is
        #: given, then this field must be blank.
        self.table_id[i] = integer_or_blank(card, 2, 'tid', 0)
        #: Type of material nonlinearity. ('NLELAST' for nonlinear elastic
        #: or 'PLASTIC' for elastoplastic.)
        self.Type[i] = string(card, 3, 'Type')

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

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

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

            if self.yf[i] == 3 or self.yf[i] == 4:
                #: Internal friction angle, measured in degrees, for the
                #: Mohr-Coulomb and Drucker-Prager yield criteria
                self.limit2[i] = double(card, 8, 'limit2')
            else:
                #self.limit2[i] = blank(card, 8, 'limit2')
                #self.limit2[i] = None
                pass
        assert len(card) <= 9, 'len(MATS1 card) = %i\ncard=%s' % (len(card), card)
        self.i += 1
Esempio n. 40
0
    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)
Esempio n. 41
0
def read_table(card, table_id, table_type):
    """common method for reading tables that handles SKIP"""
    nfields = len(card) - 1
    nterms = (nfields - 9) // 2
    if nterms < 0:
        raise SyntaxError('%r card is too short' % table_type)

    xy = []
    for i in range(nterms):
        n = 9 + i * 2
        if card.field(n) == 'ENDT':
            break
        xi = double_or_string(card, n, 'x' + str(i + 1))
        yi = double_or_string(card, n + 1, 'y' + str(i + 1))
        if xi == 'SKIP' or yi == 'SKIP':
            continue
        xy.append([xi, yi])
    string(card, nfields, 'ENDT')
    x, y = make_xy(table_id, table_type, xy)
    return x, y
Esempio n. 42
0
 def add_card(cls, card, comment=''):
     seid = integer(card, 1, 'seid')
     superelement_type = string(card, 2, 'superelement_type')
     rseid = integer_or_blank(card, 3, 'rseid', 0)
     method = string_or_blank(card, 4, 'method', 'AUTO')
     tol = double_or_blank(card, 5, 'tol', 1e-5)
     loc = string_or_blank(card, 6, 'loc', 'YES')
     unitno = integer_or_blank(card, 7, 'seid')
     assert len(card) <= 8, f'len(SEBULK card) = {len(card):d}\ncard={card}'
     return SEBULK(seid, superelement_type, rseid, method=method, tol=tol,
                   loc=loc, unitno=unitno, comment=comment)
Esempio n. 43
0
    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)
Esempio n. 44
0
    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)
Esempio n. 45
0
    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)
Esempio n. 46
0
    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)
Esempio n. 47
0
    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 = []
Esempio n. 48
0
    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)
Esempio n. 49
0
    def add_card(cls, card, comment=''):
        nfields = len(card) - 1
        assert nfields % 2 == 0, nfields

        default_values = {}
        j = 1
        for i in range(1, nfields + 1, 2):
            label = string(card, i, 'label_%i' % j)
            value = double(card, i + 1, 'value_%i' % j)
            assert label not in default_values, 'label_%i=%r is not unique' % (j, label)
            default_values[label] = value
            j += 1
        return DTABLE(default_values, comment=comment)
Esempio n. 50
0
    def add_card(cls, card, comment=''):
        name = string(card, 1, 'name')
        components = []
        ids = []

        nsets = (len(card) - 1) // 2
        for iset in range(nsets):
            i = iset * 2 + 2
            idi = integer(card, i, 'node_id' + str(iset))
            component = fcomponents(card, i + 1, 'component' + str(iset))
            components.append(component)
            ids.append(idi)
        return USET(name, components, ids, comment=comment)
Esempio n. 51
0
    def add_card(cls, card, comment=''):
        name = string(card, 1, 'name')
        components = fcomponents_or_blank(card, 2, 'components', 0)

        nfields = len(card)
        ids = []
        i = 1
        for ifield in range(3, nfields):
            idi = integer_string_or_blank(card, ifield, 'ID%i' % i)
            if idi:
                i += 1
                ids.append(idi)
        return USET1(name, components, ids, comment=comment)
Esempio n. 52
0
    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')
        xaxis = string_or_blank(card, 2, 'xaxis', 'LINEAR')
        yaxis = string_or_blank(card, 3, 'yaxis', 'LINEAR')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % cls.type)
        xy = []
        for i in range(nterms):
            n = 9 + i * 2
            if card.field(n) == 'ENDT':
                break
            xi = double_or_string(card, n, 'x' + str(i + 1))
            yi = double_or_string(card, n + 1, 'y' + str(i + 1))
            if xi == 'SKIP' or yi == 'SKIP':
                continue
            xy.append([xi, yi])
        string(card, nfields, 'ENDT')
        x, y = make_xy(tid, 'TABLED1', xy)
        return TABLED1(tid, x, y, xaxis=xaxis, yaxis=yaxis, comment=comment)
Esempio n. 53
0
    def __init__(self, card=None, data=None, comment=''):
        if comment:
            self._comment = comment
        #self.ifo = ifo
        #self.tin = tin
        #self.tout = tout
        #self.polar = polar
        #self.ncols = ncols
        #self.GCj = GCj
        #self.GCi = GCi
        #self.Real = Real
        #if self.is_complex():
            #self.Complex = []

    #def add_card_init(self, card, data, comment=''):
        if card is not None:
            self.name = string(card, 1, 'name')
            #zero

            #: 4-Lower Triangular; 5=Upper Triangular; 6=Symmetric; 8=Identity (m=nRows, n=m)
            self.ifo = integer(card, 3, 'ifo')
            #: 1-Real, Single Precision; 2=Real,Double Precision;
            #  3=Complex, Single; 4=Complex, Double
            self.tin = integer(card, 4, 'tin')
            #: 0-Set by cell precision
            self.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.)
            self.polar = integer_or_blank(card, 6, 'polar', 0)
            if self.ifo == 1: # square
                self.ncols = integer_or_blank(card, 8, 'ifo=%s; ncol' % (self.ifo))
            elif self.ifo == 6: # symmetric
                self.ncols = integer_or_blank(card, 8, 'ifo=%s; ncol' % (self.ifo))
            elif self.ifo in [2, 9]: # rectangular
                self.ncols = integer(card, 8, 'ifo=%s; ncol' % (self.ifo))
            else:
                # technically right, but nulling this will fix bad decks
                #self.ncols = blank(card, 8, 'ifo=%s; ncol' % self.ifo)
                raise NotImplementedError('self.ifo=%s is not supported' % self.ifo)
        else:
            raise NotImplementedError(data)

        self.GCj = []
        self.GCi = []
        self.Real = []
        if self.is_complex():
            self.Complex = []
        assert isinstance(self.ifo, integer_types), 'ifo=%r type=%s' % (self.ifo, type(self.ifo))
        assert not isinstance(self.ifo, bool), 'ifo=%r type=%s' % (self.ifo, type(self.ifo))
Esempio n. 54
0
    def __init__(self, card=None, data=None, comment=''):
        if comment:
            self._comment = comment
        nfields = len(card) - 1
        assert nfields % 2 == 0, nfields

        self.default_values = {}
        j = 1
        for i in range(1, nfields + 1, 2):
            label = string(card, i, 'label_%i' % j)
            value = double(card, i + 1, 'value_%i' % j)
            assert label not in self.default_values, 'label_%i=%r is not unique' % (j, label)
            self.default_values[label] = value
            j += 1
Esempio n. 55
0
    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')
        Type = integer_or_blank(card, 2, 'Type', 1)

        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')
        xy = np.array(xy)
        x = xy[:, 0]
        y = xy[:, 1]
        return TABLES1(tid, Type, x, y, comment=comment)
Esempio n. 56
0
    def add_card(self, card, comment=''):
        if comment:
            self._comment = comment
        #: Property ID
        self.pid = integer(card, 1, 'pid')
        #: Material ID
        self.mid = integer(card, 2, 'mid')
        self.group = string_or_blank(card, 3, 'group', 'MSCBMLO')
        #: Section Type (e.g. 'ROD', 'TUBE', 'I', 'H')
        self.Type = string(card, 4, 'Type')

        # determine the number of required dimensions on the PBEAM
        ndim = self.valid_types[self.Type]
        #nAll = ndim + 1

        #: dimension list
        self.dim = []
        Dim = []

        #: Section position
        self.xxb = [0.]

        #: Output flag
        self.so = ['YES']

        #: non-structural mass :math:`nsm`
        self.nsm = []

        i = 9
        n = 0
        while i < len(card):
            if n > 0:
                so = string_or_blank(card, i, 'so_n=%i' % n, 'YES')
                xxb = double_or_blank(card, i + 1, 'xxb_n=%i' % n, 1.0)
                self.so.append(so)
                self.xxb.append(xxb)
                i += 2

            Dim = []
            for ii in range(ndim):
                dim = double(card, i, 'dim_n=%i_ii=%i' % (n, ii))
                Dim.append(dim)
                i += 1
            self.dim.append(Dim)

            nsm = double_or_blank(card, i, 'nsm_n=%i' % n, 0.0)
            self.nsm.append(nsm)
            n += 1
            i += 1
Esempio n. 57
0
    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')
        xaxis = string_or_blank(card, 2, 'xaxis', 'LINEAR')
        yaxis = string_or_blank(card, 3, 'yaxis', 'LINEAR')

        nfields = len(card) - 1
        nterms = (nfields - 9) // 2
        if nterms < 0:
            raise SyntaxError('%r card is too short' % 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')
        xy = np.array(xy, dtype='float64')
        x = xy[:, 0]
        y = xy[:, 1]
        return TABRND1(tid, x, y, xaxis=xaxis, yaxis=yaxis, comment=comment)
Esempio n. 58
0
    def add_card(cls, card, comment=''):
        tid = integer(card, 1, 'tid')
        x1 = double(card, 2, 'x1')
        x2 = double(card, 3, 'x2')

        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 += [x, y]
        string(card, nfields, 'ENDT')
        xy = np.array(xy)
        x = xy[:, 0]
        y = xy[:, 1]
        return TABLEM3(tid, x1, x2, x, y, comment=comment)
Esempio n. 59
0
    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'eid')

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

        Q0 = double(card, 3, 'Q0')
        af = double_or_blank(card, 4, 'af')
        nnodes = cls.flag_to_nnodes[flag]

        grids = []
        for i in range(nnodes):
            grid = integer(card, 5 + i, 'grid%i' % (i + 1))
            grids.append(grid)
        return QHBDY(sid, flag, Q0, af, grids, comment=comment)