コード例 #1
0
ファイル: dynamic.py プロジェクト: ClaesFredo/pyNastran
    def __init__(self, card=None, data=None, comment=''):
        if comment:
            self._comment = comment
        self.sid = integer(card, 1, 'sid')
        self.nid0 = integer(card, 2, 'nid0')
        self.c = components(card, 3, 'components_0')
        self.b0 = double_or_blank(card, 4, 'b0', 0.)
        self.b1 = double_or_blank(card, 5, 'b1', 0.)
        self.b2 = double_or_blank(card, 6, 'b2', 0.)

        nfields = len(card) - 9
        nrows = nfields // 8
        if nfields % 8 > 0:
            nrows += 1

        self.grids1 = []
        self.components1 = []
        self.a = []
        for irow in range(nrows):
            j = irow * 8 + 9
            ifield = (irow + 1)
            grid1 = integer(card, j, 'grid_%i' % (irow + 1))
            component1 = components(card, j + 1, 'components_%i' % (irow + 1))
            a0 = double_or_blank(card, j + 2, 'a0_%i' % (irow + 1), 0.)
            a1 = double_or_blank(card, j + 3, 'a1_%i' % (irow + 1), 0.)
            a2 = double_or_blank(card, j + 4, 'a2_%i' % (irow + 1), 0.)
            self.grids1.append(grid1)
            self.components1.append(component1)
            self.a.append([a0, a1, a2])
        assert len(self.grids1) > 0, len(self.grids1)
コード例 #2
0
    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment

        #:  Identifiers of grids points. (Integer > 0)
        self.components = []
        self.IDs = []

        #fields = str(card.fields(1))
        nsets = (len(card) - 1) // 2
        for n in range(nsets):
            i = n * 2 + 1
            component = components(card, i, 'component' + str(n))
            ID = components(card, i + 1, 'ID' + str(n))
            self.components.append(component)
            self.IDs.append(ID)
コード例 #3
0
ファイル: sets.py プロジェクト: anick107/von_mises_rms
    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment

        #:  Identifiers of grids points. (Integer > 0)
        self.components = []
        self.IDs = []

        #fields = str(card.fields(1))
        nsets = (len(card) - 1 ) // 2
        for n in range(nsets):
            i = n * 2 + 1
            component = components(card, i, 'component' + str(n))
            ID = components(card, i + 1, 'ID' + str(n))
            self.components.append(component)
            self.IDs.append(ID)
コード例 #4
0
ファイル: sets.py プロジェクト: anick107/von_mises_rms
    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment

        #:  Identifiers of grids points. (Integer > 0)
        self.IDs = []
        self.components = components(card, 1, 'components')
        IDs = fields(integer_or_string, card, i=2, j=len(card))
        self.IDs = expand_thru(IDs)
コード例 #5
0
    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment

        #:  Identifiers of grids points. (Integer > 0)
        self.IDs = []
        self.components = components(card, 1, 'components')
        IDs = fields(integer_or_string, card, i=2, j=len(card))
        self.IDs = expand_thru(IDs)
コード例 #6
0
    def __init__(self, card=None, data=None, comment=''):
        Constraint.__init__(self, card, data)

        if comment:
            self._comment = comment
        if card:
            self.conid = integer(card, 1, 'sid')
            self.components = components(card, 2, 'components')
            self.entity = string(card, 3, 'entity')
            self.entity_id = integer(card, 4, 'entity_id')
        else:
            raise NotImplementedError('GMSPC')
コード例 #7
0
    def addColumn(self, card=None, data=None, comment=''):
        if comment:
            if hasattr(self, '_comment'):
                self._comment += comment
            else:
                self._comment = comment
        Gj = integer(card, 2, 'Gj')
        Cj = components(card, 3, 'Cj')

        nfields = len(card)
        nloops = (nfields - 5) // 4
        minLoops = nloops - 1
        if minLoops <= 0:
            minLoops = 1
        #assert nFields <= 8,'nFields=%s' %(nFields)

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

        if self.isComplex():
            for i in range(minLoops):
                n = 5 + 4 * i
                Gi = integer(card, n, 'Gi')
                Ci = components(card, n + 1, 'Ci')
                self.GCi.append((Gi, Ci))
                self.Real.append(double(card, n + 2, 'real'))
                self.Complex.append(double(card, n + 3, 'complex'))
        else:
            for i in range(minLoops):
                n = 5 + 4 * i
                Gi = integer(card, n, 'Gi')
                Ci = components(card, n + 1, 'Ci')
                self.GCi.append((Gi, Ci))
                self.Real.append(double(card, n + 2, 'real'))

        assert len(self.GCj) == len(
            self.GCi), '(len(GCj)=%s len(GCi)=%s' % (len(
                self.GCj), len(self.GCi))
コード例 #8
0
    def __init__(self, card=None, data=None, comment=''):
        Method.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Set identification number. (Unique Integer > 0)
            self.sid = integer(card, 1, 'sid')

            #: Method of eigenvalue extraction. (Character: 'INV' for inverse
            #: power method or 'SINV' for enhanced inverse power method.)
            self.method = string_or_blank(card, 2, 'method', 'LAN')
            assert self.method in [
                'LAN', 'AHOU', 'INV', 'SINV', 'GIV', 'MGIV', 'HOU', 'MHOU',
                'AGIV'
            ], 'method=%s' % self.method

            #: Frequency range of interest
            self.f1 = double_or_blank(card, 3, 'f1')
            self.f2 = double_or_blank(card, 4, 'f2')

            #: Estimate of number of roots in range (Required for
            #: METHOD = 'INV'). Not used by 'SINV' method.
            self.ne = integer_or_blank(card, 5, 'ne')

            #: Desired number of roots (default=600 for SINV 3*ne for INV)
            if self.method in ['SINV']:
                self.nd = integer_or_blank(card, 6, 'nd', 600)
            if self.method in ['INV']:
                self.nd = integer_or_blank(card, 6, 'nd', 3 * self.ne)
            elif self.method in ['GIV', 'MGIV', 'HOU', 'MHOU']:
                self.nd = integer_or_blank(card, 6, 'nd', 0)
            else:
                self.nd = integer(card, 6, 'nd')
            #: Method for normalizing eigenvectors. ('MAX' or 'POINT';
            #: Default='MAX')
            self.norm = string_or_blank(card, 9, 'norm', 'MASS')
            assert self.norm in ['POINT', 'MASS', 'MAX']

            if self.method == 'POINT':
                #: Grid or scalar point identification number. Required only if
                #: NORM='POINT'. (Integer>0)
                self.G = integer(card, 10, 'G')

                #: Component number. Required only if NORM='POINT' and G is a
                #: geometric grid point. (1<Integer<6)
                self.C = components(card, 11, 'C')
            else:
                self.G = blank(card, 10, 'G')
                self.C = blank(card, 11, 'C')
            assert len(card) <= 12, 'len(EIGR card) = %i' % len(card)
        else:
            raise NotImplementedError('EIGR')
コード例 #9
0
    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment

        #:  Identifiers of grids points. (Integer > 0)
        self.IDs = []
        if string_or_blank(card, 2, 'C') == 'ALL':
            self.components = '123456'
        else:
            self.components = components(card, 1, 'components')
            IDs = fields(integer_or_string, 'ID', i=2, j=len(card))
            self.IDs = expand_thru(IDs)
コード例 #10
0
 def __init__(self, card=None, data=None, comment=''):
     Constraint.__init__(self, card, data)
     if comment:
         self._comment = comment
     if card:
         self.conid = integer(card, 1, 'conid')
         self.constraints = components(card, 2, 'constraints')  # 246 = y; dx, dz dir
         nodes = card.fields(3)
         self.nodes = expand_thru(nodes)
         self.nodes.sort()
     else:
         msg = '%s has not implemented data parsing' % self.type
         raise NotImplementedError(msg)
コード例 #11
0
ファイル: sets.py プロジェクト: anick107/von_mises_rms
    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment

        #:  Identifiers of grids points. (Integer > 0)
        self.IDs = []
        if string_or_blank(card, 2, 'C') == 'ALL':
            self.components = '123456'
        else:
            self.components = components(card, 1, 'components')
            IDs = fields(integer_or_string, 'ID', i=2, j=len(card))
            self.IDs = expand_thru(IDs)
コード例 #12
0
ファイル: dmig.py プロジェクト: anick107/von_mises_rms
    def addColumn(self, card=None, data=None, comment=''):
        if comment:
            if hasattr(self, '_comment'):
                self._comment += comment
            else:
                self._comment = comment
        Gj = integer(card, 2, 'Gj')
        Cj = components(card, 3, 'Cj')

        nfields = len(card)
        nloops = (nfields - 5) // 4
        minLoops = nloops - 1
        if minLoops <= 0:
            minLoops = 1
        #assert nFields <= 8,'nFields=%s' %(nFields)

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

        if self.isComplex():
            for i in range(minLoops):
                n = 5 + 4 * i
                Gi = integer(card, n, 'Gi')
                Ci = components(card, n + 1, 'Ci')
                self.GCi.append((Gi, Ci))
                self.Real.append(double(card, n + 2, 'real'))
                self.Complex.append(double(card, n + 3, 'complex'))
        else:
            for i in range(minLoops):
                n = 5 + 4 * i
                Gi = integer(card, n, 'Gi')
                Ci = components(card, n + 1, 'Ci')
                self.GCi.append((Gi, Ci))
                self.Real.append(double(card, n + 2, 'real'))

        assert len(self.GCj) == len(self.GCi), '(len(GCj)=%s len(GCi)=%s' % (
            len(self.GCj), len(self.GCi))
コード例 #13
0
 def __init__(self, card=None, data=None, comment=''):
     Constraint.__init__(self, card, data)
     if comment:
         self._comment = comment
     if card:
         self.conid = integer(card, 1, 'conid')
         self.constraints = components(card, 2, 'constraints')  # 246 = y; dx, dz dir
         nodes = card.fields(3)
         self.nodes = expand_thru(nodes)
         self.nodes.sort()
     else:
         self.conid = data[0]
         self.constraints = data[1]
         self.nodes = data[2:]
コード例 #14
0
 def __init__(self, card=None, data=None, comment=''):
     Constraint.__init__(self, card, data)
     if comment:
         self._comment = comment
     if card:
         self.conid = integer(card, 1, 'conid')
         self.constraints = components(card, 2, 'constraints')  # 246 = y; dx, dz dir
         nodes = card.fields(3)
         self.nodes = expand_thru(nodes)
         self.nodes.sort()
     else:
         self.conid = data[0]
         self.constraints = data[1]
         self.nodes = data[2:]
コード例 #15
0
ファイル: methods.py プロジェクト: sukhbinder/cyNastran
    def __init__(self, card=None, data=None, comment=''):
        Method.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Set identification number. (Unique Integer > 0)
            self.sid = integer(card, 1, 'sid')

            #: Method of eigenvalue extraction. (Character: 'INV' for inverse
            #: power method or 'SINV' for enhanced inverse power method.)
            self.method = string_or_blank(card, 2, 'method', 'LAN')
            assert self.method in ['LAN', 'AHOU', 'INV', 'SINV', 'GIV', 'MGIV', 'HOU', 'MHOU', 'AGIV'], 'method=%s' % self.method

            #: Frequency range of interest
            self.f1 = double_or_blank(card, 3, 'f1')
            self.f2 = double_or_blank(card, 4, 'f2')

            #: Estimate of number of roots in range (Required for
            #: METHOD = 'INV'). Not used by 'SINV' method.
            self.ne = integer_or_blank(card, 5, 'ne')

            #: Desired number of roots (default=600 for SINV 3*ne for INV)
            if self.method in ['SINV']:
                self.nd = integer_or_blank(card, 6, 'nd', 600)
            if self.method in ['INV']:
                self.nd = integer_or_blank(card, 6, 'nd', 3 * self.ne)
            elif self.method in ['GIV', 'MGIV', 'HOU', 'MHOU']:
                self.nd = integer_or_blank(card, 6, 'nd', 0)
            else:
                self.nd = integer(card, 6, 'nd')
            #: Method for normalizing eigenvectors. ('MAX' or 'POINT';
            #: Default='MAX')
            self.norm = string_or_blank(card, 9, 'norm', 'MASS')
            assert self.norm in ['POINT', 'MASS', 'MAX']

            if self.method == 'POINT':
                #: Grid or scalar point identification number. Required only if
                #: NORM='POINT'. (Integer>0)
                self.G = integer(card, 10, 'G')

                #: Component number. Required only if NORM='POINT' and G is a
                #: geometric grid point. (1<Integer<6)
                self.C = components(card, 11, 'C')
            else:
                self.G = blank(card, 10, 'G')
                self.C = blank(card, 11, 'C')
            assert len(card) <= 12, 'len(EIGR card) = %i' % len(card)
        else:
            raise NotImplementedError('EIGR')
コード例 #16
0
ファイル: sets.py プロジェクト: anick107/von_mises_rms
    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment

        #:  Identifiers of grids points. (Integer > 0)
        self.IDs = []
        self.components = []

        nterms = len(card) // 2
        for n in range(nterms):
            i = n * 2 + 1
            ID = integer(card, i, 'ID' + str(n))
            component = components(card, i + 1, 'component' + str(n))
            self.IDs.append(ID)
            self.components.append(component)
コード例 #17
0
    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment

        #:  Identifiers of grids points. (Integer > 0)
        self.IDs = []
        self.components = []

        nterms = len(card) // 2
        for n in range(nterms):
            i = n * 2 + 1
            ID = integer(card, i, 'ID' + str(n))
            component = components(card, i + 1, 'component' + str(n))
            self.IDs.append(ID)
            self.components.append(component)
コード例 #18
0
ファイル: methods.py プロジェクト: ClaesFredo/pyNastran
    def __init__(self, card=None, data=None, comment=''):
        Method.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Set identification number. (Unique Integer > 0)
            self.sid = integer(card, 1, 'sid')

            #: Method of eigenvalue extraction. (Character: 'INV' for inverse
            #: power method or 'SINV' for enhanced inverse power method.)
            #: apparently it can also be blank...
            self.method = string_or_blank(card, 2, 'method')

            if self.method not in ['INV', 'SINV', None]:
                msg = 'method must be INV or SINV.  method=|%s|' % self.method
                raise RuntimeError(msg)

            #: Eigenvalue range of interest. (Real, L1 < L2)
            self.L1 = double(card, 3, 'L1')
            self.L2 = double(card, 4, 'L2')
            if not self.L1 < self.L2:
                msg = 'L1=%s L2=%s; L1<L2 is requried' % (self.L1, self.L2)
                raise RuntimeError(msg)

            #: Estimate of number of roots in positive range not used for
            #: METHOD = 'SINV'. (Integer > 0)
            self.nep = integer_or_blank(card, 5, 'nep', 0)

            #: Desired number of positive and negative roots.
            #: (Integer>0; Default = 3*NEP)
            self.ndp = integer_or_blank(card, 6, 'ndp', 3 * self.nep)
            self.ndn = integer_or_blank(card, 7, 'ndn', 3 * self.nep)

            #: Method for normalizing eigenvectors.
            #: ('MAX' or 'POINT';Default='MAX')
            self.norm = string_or_blank(card, 9, 'norm', 'MAX')
            if self.norm == 'POINT':
                self.G = integer(card, 10, 'G')
                self.C = components(card, 11, 'C')
            else:
                self.G = integer_or_blank(card, 10, 'G')
                self.C = components_or_blank(card, 11, 'C')
            assert len(card) <= 12, 'len(EIGB card) = %i' % len(card)
        else:
            raise NotImplementedError('EIGB')
コード例 #19
0
ファイル: bdf_sets.py プロジェクト: HibernantBear/pyNastran
    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment

        self.name = string(card, 1, 'name')

        #:  Identifiers of grids points. (Integer > 0)
        self.components = []
        self.IDs = []

        nsets = (len(card) - 1) // 2
        for n in range(nsets):
            i = n * 2 + 2
            ID = integer(card, i, 'node_id' + str(n))
            component = components(card, i + 1, 'component' + str(n))
            self.components.append(component)
            self.IDs.append(ID)
コード例 #20
0
ファイル: bdf_sets.py プロジェクト: HibernantBear/pyNastran
    def __init__(self, card=None, data=None, comment=''):
        Set.__init__(self, card, data)
        if comment:
            self._comment = comment

        #:  Identifiers of grids points. (Integer > 0)
        self.IDs = []
        if string_or_blank(card, 2, 'C') == 'ALL':
            self.components = '123456'
        else:
            self.components = components(card, 1, 'components')

        IDs2 = []
        ii = 1
        for ifield in range(2, len(card)):
            integer_or_string(card, ifield, 'ID' % ii)
            ii += 1
        self.IDs = expand_thru(IDs)
コード例 #21
0
    def __init__(self, card=None, data=None, comment=''):
        Method.__init__(self, card, data)
        if comment:
            self._comment = comment
        if card:
            #: Set identification number. (Unique Integer > 0)
            self.sid = integer(card, 1, 'sid')

            #: Method of eigenvalue extraction. (Character: 'INV' for inverse
            #: power method or 'SINV' for enhanced inverse power method.)
            self.method = string(card, 2, 'method')

            if self.method not in ['INV', 'SINV']:
                msg = 'method must be INV or SINV.  method=|%s|' % self.method
                raise RuntimeError(msg)

            #: Eigenvalue range of interest. (Real, L1 < L2)
            self.L1 = double(card, 3, 'L1')
            self.L2 = double(card, 4, 'L2')
            if not (self.L1 < self.L2):
                msg = 'L1=%s L2=%s; L1<L2 is requried' % (self.L1, self.L2)
                raise RuntimeError(msg)

            #: Estimate of number of roots in positive range not used for
            #: METHOD = 'SINV'. (Integer > 0)
            self.nep = integer_or_blank(card, 5, 'nep', 0)

            #: Desired number of positive and negative roots.
            #: (Integer>0; Default = 3*NEP)
            self.ndp = integer_or_blank(card, 6, 'ndp', 3 * self.nep)
            self.ndn = integer_or_blank(card, 7, 'ndn', 3 * self.nep)

            #: Method for normalizing eigenvectors.
            #: ('MAX' or 'POINT';Default='MAX')
            self.norm = string_or_blank(card, 9, 'norm', 'MAX')
            if self.norm == 'POINT':
                self.G = integer(card, 10, 'G')
                self.C = components(card, 11, 'C')
            else:
                self.G = integer_or_blank(card, 10, 'G')
                self.C = components_or_blank(card, 11, 'C')
            assert len(card) <= 12, 'len(EIGB card) = %i' % len(card)
        else:
            raise NotImplementedError('EIGB')
コード例 #22
0
 def __init__(self, card=None, data=None, comment=''):
     # defines everything :) at least until cross-referencing methods are
     # implemented
     Constraint.__init__(self, card, data)
     if comment:
         self._comment = comment
     if card:
         #: Identification number of a single-point constraint set.
         self.conid = integer(card, 1, 'conid')
         #: Ring identification number. See RINGAX entry.
         self.rid = integer(card, 2, 'rid')
         #: Harmonic identification number. (Integer >= 0)
         self.hid = integer(card, 3, 'hid')
         #: Component identification number. (Any unique combination of the
         #: Integers 1 through 6.)
         self.c = components(card, 4, 'c')
         #: Enforced displacement value
         self.d = double(card, 5, 'd')
     else:
         msg = '%s has not implemented data parsing' % self.type
         raise NotImplementedError(msg)
コード例 #23
0
 def __init__(self, card=None, data=None, comment=''):
     # defines everything :) at least until cross-referencing methods are
     # implemented
     SPC.__init__(self, card, data)
     if comment:
         self._comment = comment
     if card:
         #: Identification number of a single-point constraint set.
         self.conid = integer(card, 1, 'conid')
         #: Ring identification number. See RINGAX entry.
         self.rid = integer(card, 2, 'rid')
         #: Harmonic identification number. (Integer >= 0)
         self.hid = integer(card, 3, 'hid')
         #: Component identification number. (Any unique combination of the
         #: Integers 1 through 6.)
         self.c = components(card, 4, 'c')
         #: Enforced displacement value
         self.d = double(card, 5, 'd')
     else:
         msg = '%s has not implemented data parsing' % self.type
         raise NotImplementedError(msg)
コード例 #24
0
 def __init__(self, card=None, data=None, comment=''):
     """
     Defines values for the initial conditions of variables used in
     structural transient analysis. Both displacement and velocity values
     may be specified at independent degrees-of-freedom. This entry may not
     be used for heat transfer analysis.
     """
     Table.__init__(self, card, data)
     if comment:
         self._comment = comment
     if card:
         self.sid = integer(card, 1, 'sid')
         self.G = integer(card, 2, 'G')
         assert self.G > 0
         self.C = components(card, 3, 'C')
         self.U0 = double(card, 4, 'U0')
         self.V0 = double(card, 5, 'V0')
     else:
         self.sid = data[0]
         self.G = data[1]
         self.C = data[2]
         self.U0 = data[3]
         self.V0 = data[4]
コード例 #25
0
ファイル: bdf_tables.py プロジェクト: ClaesFredo/pyNastran
 def __init__(self, card=None, data=None, comment=''):
     """
     Defines values for the initial conditions of variables used in
     structural transient analysis. Both displacement and velocity values
     may be specified at independent degrees-of-freedom. This entry may not
     be used for heat transfer analysis.
     """
     Table.__init__(self, card, data)
     if comment:
         self._comment = comment
     if card:
         self.sid = integer(card, 1, 'sid')
         self.G = integer(card, 2, 'G')
         assert self.G > 0
         self.C = components(card, 3, 'C')
         self.U0 = double(card, 4, 'U0')
         self.V0 = double(card, 5, 'V0')
     else:
         self.sid = data[0]
         self.G = data[1]
         self.C = data[2]
         self.U0 = data[3]
         self.V0 = data[4]
コード例 #26
0
    def test_components(self):
        # single ints
        val = components(BDFCard([0]), 0, "field")
        self.assertEqual(val, "0")

        val = components(BDFCard([1]), 0, "field")
        self.assertEqual(val, "1")

        # single strings
        val = components(BDFCard(["0"]), 0, "field")
        self.assertEqual(val, "0")

        val = components(BDFCard(["1"]), 0, "field")
        self.assertEqual(val, "1")

        # double ints
        val = components(BDFCard(["123"]), 0, "field")
        self.assertEqual(val, "123")

        val = components(BDFCard([123]), 0, "field")
        self.assertEqual(val, "123")

        val = components(BDFCard([321]), 0, "field")
        self.assertEqual(val, "123")

        # embedded whiteshape
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(["12 3"]), 0, "field")

        # all numbers
        val = components(BDFCard(["123456"]), 0, "field")
        self.assertEqual(val, "123456")

        # invalid 0's defined with numbers
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(["0123456"]), 0, "field")

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(["01"]), 0, "field")

        # doubles
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(["4524"]), 0, "field")

        # only 0 to 6
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(["7"]), 0, "field")

        with self.assertRaises(SyntaxError):
            val = components(BDFCard([7]), 0, "field")

        # dumb input
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(["4.0"]), 0, "field")

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(["-4.0"]), 0, "field")

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(["asdf"]), 0, "field")

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(["-1"]), 0, "field")
コード例 #27
0
ファイル: rigid.py プロジェクト: umvarma/pynastran
    def __init__(self, card=None, data=None, comment=''):
        """
        eid
        refgrid
        refc
        WtCG_groups = [wt,ci,Gij]
        Gmi
        Cmi
        alpha
        """
        RigidElement.__init__(self, card, data)
        if comment:
            self._comment = comment
        self.eid = integer(card, 1, 'eid')
        blank(card, 2, 'blank')
        self.refgrid = integer(card, 3, 'refgrid')
        self.refc = components_or_blank(card, 4, 'refc')
        #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 = ", iUM)
        self.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]
                self.WtCG_groups.append(wtCG_group)
                #print('----finished a group=%r----' % wtCG_group)
            else:
                i += 1

        self.Gmi = []
        self.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)
                    self.Gmi.append(gmi)
                    self.Cmi.append(cmi)

        if iAlpha:
            self.alpha = double_or_blank(card, iAlpha + 1, 'alpha')
        else:
            #: thermal expansion coefficient
            self.alpha = 0.0
コード例 #28
0
ファイル: test_assign_type.py プロジェクト: umvarma/pynastran
    def test_components(self):
        # single ints
        val = components(BDFCard([0]), 0, 'field')
        self.assertEquals(val, '0')

        val = components(BDFCard([1]), 0, 'field')
        self.assertEquals(val, '1')

        # single strings
        val = components(BDFCard(['0']), 0, 'field')
        self.assertEquals(val, '0')

        val = components(BDFCard(['1']), 0, 'field')
        self.assertEquals(val, '1')

        # double ints
        val = components(BDFCard(['123']), 0, 'field')
        self.assertEquals(val, '123')

        val = components(BDFCard([123]), 0, 'field')
        self.assertEquals(val, '123')

        val = components(BDFCard([321]), 0, 'field')
        self.assertEquals(val, '123')

        # embedded whiteshape
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['12 3']), 0, 'field')

        # all numbers
        val = components(BDFCard(['123456']), 0, 'field')
        self.assertEquals(val, '123456')

        # invalid 0's defined with numbers
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['0123456']), 0, 'field')

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['01']), 0, 'field')

        # doubles
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['4524']), 0, 'field')

        # only 0 to 6
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['7']), 0, 'field')

        with self.assertRaises(SyntaxError):
            val = components(BDFCard([7]), 0, 'field')

        # dumb input
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['4.0']), 0, 'field')

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['-4.0']), 0, 'field')

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['asdf']), 0, 'field')

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['-1']), 0, 'field')
コード例 #29
0
ファイル: rbe3.py プロジェクト: ClaesFredo/pyNastran
    def add(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
コード例 #30
0
    def __init__(self, card=None, data=None, comment=''):
        Method.__init__(self, card, data)
        if comment:
            self._comment = comment
        # CLAN
        self.mblkszs = []
        self.iblkszs = []
        self.ksteps = []
        self.NJIs = []

        # HESS
        self.alphaBjs = []
        self.omegaBjs = []
        self.LJs = []
        self.NEJs = []
        self.NDJs = []

        if card:
            #: Set identification number. (Unique Integer > 0)
            self.sid = integer(card, 1, 'sid')
            #: Method of complex eigenvalue extraction
            self.method = string(card, 2, 'method')
            assert self.method in [
                'INV', 'HESS', 'CLAN'
            ], ('method=%s is not INV, HESS, CLAN' % (self.method))
            #: Method for normalizing eigenvectors
            self.norm = string_or_blank(card, 3, 'norm')
            if self.norm == 'POINT':
                #: Grid or scalar point identification number. Required only if
                #: NORM='POINT'. (Integer>0)
                self.G = integer(card, 4, 'G')

                #: Component number. Required only if NORM='POINT' and G is a
                #: geometric grid point. (1<Integer<6)
                self.C = components(card, 5, 'C')
            else:
                self.G = blank(card, 4, 'G')
                self.C = blank(card, 5, 'C')

            #: Convergence criterion. (Real > 0.0. Default values are:
            #: 10^-4 for METHOD = "INV",
            #: 10^-15 for METHOD = "HESS",
            #: E is machine dependent for METHOD = "CLAN".)
            self.E = double_or_blank(card, 6, 'E')
            self.ndo = integer_double_string_or_blank(card, 7, 'ND0')

            # ALPHAAJ OMEGAAJ ALPHABJ OMEGABJ LJ NEJ NDJ
            fields = card[9:]
            self.alphaAjs = []
            self.omegaAjs = []
            nFields = len(fields)
            nRows = nFields // 8
            if nFields % 7 > 0:
                nRows += 1

            if self.method == 'CLAN':
                self.loadCLAN(nRows, card)
            elif self.method in ['HESS', 'INV']:  # HESS, INV
                self.loadHESS_INV(nRows, card)
            else:
                msg = 'invalid EIGC method...method=|%r|' % (self.method)
                raise RuntimeError(msg)
            #assert card.nFields() < 8, 'card = %s' % card
        else:
            raise NotImplementedError('EIGC')
コード例 #31
0
ファイル: rigid.py プロジェクト: umvarma/pynastran
    def __init__(self, card=None, data=None, comment=''):
        """
        eid
        refgrid
        refc
        WtCG_groups = [wt,ci,Gij]
        Gmi
        Cmi
        alpha
        """
        RigidElement.__init__(self, card, data)
        if comment:
            self._comment = comment
        self.eid = integer(card, 1, 'eid')
        blank(card, 2, 'blank')
        self.refgrid = integer(card, 3, 'refgrid')
        self.refc = components_or_blank(card, 4, 'refc')
        #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 = ", iUM)
        self.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]
                self.WtCG_groups.append(wtCG_group)
                #print('----finished a group=%r----' % wtCG_group)
            else:
                i += 1

        self.Gmi = []
        self.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)
                    self.Gmi.append(gmi)
                    self.Cmi.append(cmi)

        if iAlpha:
            self.alpha = double_or_blank(card, iAlpha + 1, 'alpha')
        else:
            #: thermal expansion coefficient
            self.alpha = 0.0
コード例 #32
0
    def test_components(self):
        # single ints
        val = components(BDFCard([0]), 0, 'field')
        self.assertEquals(val, '0')

        val = components(BDFCard([1]), 0, 'field')
        self.assertEquals(val, '1')

        # single strings
        val = components(BDFCard(['0']), 0, 'field')
        self.assertEquals(val, '0')

        val = components(BDFCard(['1']), 0, 'field')
        self.assertEquals(val, '1')

        # double ints
        val = components(BDFCard(['123']), 0, 'field')
        self.assertEquals(val, '123')

        val = components(BDFCard([123]), 0, 'field')
        self.assertEquals(val, '123')

        val = components(BDFCard([321]), 0, 'field')
        self.assertEquals(val, '123')

        # embedded whiteshape
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['12 3']), 0, 'field')

        # all numbers
        val = components(BDFCard(['123456']), 0, 'field')
        self.assertEquals(val, '123456')

        # invalid 0's defined with numbers
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['0123456']), 0, 'field')

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['01']), 0, 'field')

        # doubles
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['4524']), 0, 'field')

        # only 0 to 6
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['7']), 0, 'field')

        with self.assertRaises(SyntaxError):
            val = components(BDFCard([7]), 0, 'field')

        # dumb input
        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['4.0']), 0, 'field')

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['-4.0']), 0, 'field')

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['asdf']), 0, 'field')

        with self.assertRaises(SyntaxError):
            val = components(BDFCard(['-1']), 0, 'field')
コード例 #33
0
ファイル: methods.py プロジェクト: sukhbinder/cyNastran
    def __init__(self, card=None, data=None, comment=''):
        Method.__init__(self, card, data)
        if comment:
            self._comment = comment
        # CLAN
        self.mblkszs = []
        self.iblkszs = []
        self.ksteps = []
        self.NJIs = []

        # HESS
        self.alphaBjs = []
        self.omegaBjs = []
        self.LJs = []
        self.NEJs = []
        self.NDJs = []

        if card:
            #: Set identification number. (Unique Integer > 0)
            self.sid = integer(card, 1, 'sid')
            #: Method of complex eigenvalue extraction
            self.method = string(card, 2, 'method')
            assert self.method in ['INV', 'HESS', 'CLAN'],(
                    'method=%s is not INV, HESS, CLAN' % (self.method))
            #: Method for normalizing eigenvectors
            self.norm = string_or_blank(card, 3, 'norm')
            if self.norm == 'POINT':
                #: Grid or scalar point identification number. Required only if
                #: NORM='POINT'. (Integer>0)
                self.G = integer(card, 4, 'G')

                #: Component number. Required only if NORM='POINT' and G is a
                #: geometric grid point. (1<Integer<6)
                self.C = components(card, 5, 'C')
            else:
                self.G = blank(card, 4, 'G')
                self.C = blank(card, 5, 'C')

            #: Convergence criterion. (Real > 0.0. Default values are:
            #: 10^-4 for METHOD = "INV",
            #: 10^-15 for METHOD = "HESS",
            #: E is machine dependent for METHOD = "CLAN".)
            self.E = double_or_blank(card, 6, 'E')
            self.ndo = integer_double_string_or_blank(card, 7, 'ND0')

            # ALPHAAJ OMEGAAJ ALPHABJ OMEGABJ LJ NEJ NDJ
            fields = [interpret_value(field) for field in card[9:] ]
            self.alphaAjs = []
            self.omegaAjs = []
            nFields = len(fields)
            nRows = nFields // 8
            if nFields % 7 > 0:
                nRows += 1

            if self.method == 'CLAN':
                self.loadCLAN(nRows, card)
            elif self.method in ['HESS', 'INV']:  # HESS, INV
                self.loadHESS_INV(nRows, card)
            else:
                msg = 'invalid EIGC method...method=|%r|' % (self.method)
                raise RuntimeError(msg)
            #assert card.nFields() < 8, 'card = %s' % card
        else:
            raise NotImplementedError('EIGC')