コード例 #1
0
    def test_integer_double_string_or_blank(self):
        """tests the integer_double_string_or_blank function"""
        # out of range
        self.assertEqual(
            None, integer_double_string_or_blank(BDFCard([1.]), 1, 'field'))
        #with self.assertRaises(SyntaxError):
        #print(integer_double_string_or_blank(BDFCard(['1b']), 0, 'field'))

        # integer
        self.check_integer(integer_double_string_or_blank)

        # float
        self.check_double(integer_double_string_or_blank)

        # string
        self.assertEqual(
            'LOAD',
            integer_double_string_or_blank(BDFCard(['load']), 0, 'field'))
        self.assertEqual(
            'MN-MM',
            integer_double_string_or_blank(BDFCard(['MN-MM']), 0, 'field'))
        #self.assertEqual(-1, integer_double_string_or_blank(BDFCard(['-1']), 0, 'field'))
        self.assertEqual(
            1000, integer_double_string_or_blank(BDFCard([1000]), 0, 'field'))
        self.assertEqual(
            'CAT',
            integer_double_string_or_blank(BDFCard([100]), 1, 'field', 'CAT'))
コード例 #2
0
def _init_offt_bit(card, unused_eid, offt_default):
    """
    offt doesn't exist in NX nastran
    """
    field8 = integer_double_string_or_blank(card, 8, 'field8', offt_default)
    if isinstance(field8, float):
        offt = None
        bit = field8
    elif field8 is None:
        offt = 'GGG'  # default
        bit = None
    elif isinstance(field8, integer_types):
        bit = None
        offt = field8
    elif isinstance(field8, str):
        bit = None
        offt = field8
        msg = 'invalid offt parameter of CBEAM...offt=%s' % offt
        assert offt[0] in ['G', 'B', 'O', 'E'], msg
        assert offt[1] in ['G', 'B', 'O', 'E'], msg
        assert offt[2] in ['G', 'B', 'O', 'E'], msg
    else:
        msg = ('field8 on %s card is not a string(offt) or bit '
               '(float)...field8=%s\n' % (card.field(0), field8))
        raise SyntaxError("Card Instantiation: %s" % msg)
    return offt, bit
コード例 #3
0
ファイル: beam.py プロジェクト: marcinch18/pyNastran
 def _init_offt_bit(cls, card, eid):
     """
     offt doesn't exist in NX nastran
     """
     field8 = integer_double_string_or_blank(card, 8, 'field8')
     if isinstance(field8, float):
         is_offt = False
         offt = None
         bit = field8
     elif field8 is None:
         is_offt = True
         offt = 'GGG'  # default
         bit = None
     elif isinstance(field8, string_types):
         is_offt = True
         bit = None
         offt = field8
         msg = 'invalid offt parameter of CBEAM...offt=%s' % offt
         assert offt[0] in ['G', 'B', 'O', 'E'], msg
         assert offt[1] in ['G', 'B', 'O', 'E'], msg
         assert offt[2] in ['G', 'B', 'O', 'E'], msg
     else:
         msg = ('field8 on %s card is not a string(offt) or bit '
                '(float)...field8=%s\n' % (cls.type, field8))
         raise RuntimeError("Card Instantiation: %s" % msg)
     return is_offt, offt, bit
コード例 #4
0
    def test_integer_double_or_string(self):
        # out of range
        with self.assertRaises(SyntaxError):
            integer_or_double(BDFCard([1.]), 1, 'field')
        with self.assertRaises(SyntaxError):
            integer_double_or_string(BDFCard(['1b']), 0, 'field')

        # integer
        self.check_integer(integer_double_or_string)

        # float
        self.check_double(integer_double_or_string)

        # string
        self.assertEqual('LOAD', integer_double_or_string(BDFCard(['load']), 0, 'field'))
        self.assertEqual('MN-MM', integer_double_string_or_blank(BDFCard(['MN-MM']), 0, 'field'))
        #self.assertEqual(-1, integer_double_string_or_blank(BDFCard(['-1']), 0, 'field'))
        self.assertEqual(1000, integer_double_string_or_blank(BDFCard([1000]), 0, 'field'))
コード例 #5
0
    def test_integer_double_or_string(self):
        # out of range
        with self.assertRaises(SyntaxError):
            integer_or_double(BDFCard([1.]), 1, 'field')

        # integer
        self.check_integer(integer_double_or_string)

        # float
        self.check_double(integer_double_or_string)

        # string
        self.assertEqual('LOAD', integer_double_or_string(BDFCard(['load']), 0, 'field'))
        self.assertEqual('MN-MM', integer_double_string_or_blank(BDFCard(['MN-MM']), 0, 'field'))
コード例 #6
0
    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'sid')
        method = string(card, 2, 'method')
        assert method in ['ARNO', 'INV', 'HESS', 'CLAN', 'ISRR', 'IRAM'], (
            'method=%s is not ARNO, INV, HESS, CLAN, ISRR, IRAM' % method)

        norm = string_or_blank(card, 3, 'norm')
        if norm == 'POINT':
            G = integer(card, 4, 'G')
            C = components(card, 5, 'C')
        else:
            G = blank(card, 4, 'G')
            C = blank(card, 5, 'C')

        E = double_or_blank(card, 6, 'E')
        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:]]

        alphaAjs = []
        omegaAjs = []
        nfields = len(fields)
        nrows = nfields // 8
        if nfields % 8 > 0:
            nrows += 1
        #if nrows == 0:
            #msg = 'invalid row count=0; nfields=%s \ncard=%s\nfields=%s' % (
                #nfields, card, fields)
            #raise RuntimeError(msg)

        if method == 'CLAN':
            alphaAjs, omegaAjs, mblkszs, iblkszs, ksteps, NJIs = cls._load_clan(nrows, card)
        elif method in ['HESS', 'INV']:  # HESS, INV
            cls._load_hess_inv(nrows, method, card)
        elif method == 'ISRR':
            cls._load_isrr(nrows, card)
        else:
            msg = 'invalid EIGC method...method=%r' % method
            raise RuntimeError(msg)
        #assert card.nFields() < 8, 'card = %s' % card
        return EIGC(sid, method, norm, G, C, E, ndo, comment=comment)
コード例 #7
0
    def add_card(cls, card, comment=''):
        """
        Adds an EIGC 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')
        assert method in ['ARNO', 'INV', 'HESS', 'CLAN', 'ISRR', 'IRAM', 'DET'], (
            'method=%s is not ARNO, INV, HESS, CLAN, ISRR, IRAM, DET' % method)

        norm = string_or_blank(card, 3, 'norm', 'MAX')
        if norm == 'POINT':
            grid = integer(card, 4, 'G')
            component = parse_components(card, 5, 'C')
        else:
            grid = blank(card, 4, 'G')
            component = blank(card, 5, 'C')

        epsilon = double_or_blank(card, 6, 'epsilon')
        neigenvalues = integer_double_string_or_blank(card, 7, 'ND0/neigenvalues')

        # ALPHAAJ OMEGAAJ ALPHABJ OMEGABJ LJ NEJ NDJ
        fields = [interpret_value(field) for field in card[9:]]

        #-------CLAN--------------
        mblkszs = []
        iblkszs = []
        ksteps = []
        NJIs = []
        #-------CLAN--------------

        #-------HESS--------------
        alphaAjs = []
        alphaBjs = []
        omegaAjs = []
        omegaBjs = []
        mblkszs = []
        iblkszs = []
        ksteps = []
        LJs = []
        NEJs = []
        NDJs = []
        #-------HESS--------------

        #-------ISRR--------------
        shift_r1 = 0.0
        shift_i1 = 0.0
        isrr_flag = 0
        nd1 = None
        #-------ISRR--------------
        nfields = len(fields)
        nrows = nfields // 8
        if nfields % 8 > 0:
            nrows += 1
        #if nrows == 0:
            #msg = 'invalid row count=0; nfields=%s \ncard=%s\nfields=%s' % (
                #nfields, card, fields)
            #raise RuntimeError(msg)

        if method == 'CLAN':
            alphaAjs, omegaAjs, mblkszs, iblkszs, ksteps, NJIs = cls._load_clan(nrows, card)
        elif method in ['HESS', 'INV', 'DET']:  # HESS, INV
            alphaAjs, omegaAjs, alphaBjs, omegaBjs, LJs, NEJs, NDJs = cls._load_hess_inv(
                nrows, method, card)
        elif method == 'ISRR':
            shift_r1, shift_i1, isrr_flag, nd1 = cls._load_isrr(nrows, card)
        else:
            msg = 'invalid EIGC method...method=%r' % method
            raise RuntimeError(msg)
        #assert card.nfields() < 8, 'card = %s' % card
        return EIGC(sid, method, grid, component, epsilon, neigenvalues,
                    norm, # common
                    mblkszs, iblkszs, ksteps, NJIs, # CLAN
                    alphaAjs, omegaAjs, alphaBjs, omegaBjs, LJs, NEJs, NDJs, # HESS/INV
                    shift_r1, shift_i1, isrr_flag, nd1, # ISRR
                    comment=comment)
コード例 #8
0
ファイル: params.py プロジェクト: yqliaohk/pyNastran
    def add_card(cls, card, comment=''):
        """
        Adds a PARAM card from ``BDF.add_card(...)``

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

        """
        key = string(card, 1, 'key')

        n = 1
        value = None
        if key == 'ACOUT':
            value = string_or_blank(card, 2, 'value', 'PEAK')
        elif key == 'ACOWEAK':
            value = string_or_blank(card, 2, 'value', 'NO')
        elif key == 'ADJMETH':
            value = integer_or_blank(card, 2, 'value', 0)
        elif key == 'ADPCON':
            value = double_or_blank(card, 2, 'value', 1.0)
        #elif key == 'ADMPOST':
        #value = string_or_blank(card, 2, 'value', 0) ## TODO: 0 is not a string
        elif key == 'ADSDISC':
            value = double_or_blank(card, 2, 'value', 1e-8)
        elif key == 'AESMAXIT':
            value = integer_or_blank(card, 2, 'value', 15)
        elif key == 'AESMETH':
            value = string_or_blank(card, 2, 'value', 'SELECT')
            assert value in ['SELECT', 'AUTO', 'DIRECT', 'RITZ',
                             'ITER'], 'value=%s' % value
        elif key == 'AESTOL':
            value = double_or_blank(card, 2, 'value', 1e-10)
        elif key in ['ALPHA1FL', 'ALPHA2FL']:  # check alpha1/alpha1FL
            value1 = double_or_blank(card, 2, 'value1', 0.0)
            value2 = double_or_blank(card, 3, 'value2', 0.0)
            n = 2
        elif key == 'COMPMATT':
            #('COMPMATT', 'NO', ['YES', 'NO', 'NONSMEAR']), # MSC only: 'NONSMEAR'
            value = string_or_blank(card, 2, 'value1', 'NO')
            if value == 'NONS':  # assume
                value = 'NONSMEAR'
            if value == 'SMEAR':  # assume
                value = 'YES'
            assert value in ['YES', 'NO', 'NONSMEAR'], 'value=%r' % value

        elif key == 'POST':
            value = integer_or_blank(card, 2, 'value', 1)
        elif key == 'UNITSYS':
            value = string(card, 2, 'value')

        #-------------------------------------------------------------
        # strings; has defaults
        elif key in string_params:
            default, allowed_values = string_params[key]
            value = string_or_blank(card, 2, 'value', default=default)
            assert value in allowed_values, 'value=%s allowed=%s' % (
                value, allowed_values)

        # ints; has defaults
        elif key in int_params:
            default = int_params[key]
            value = integer_or_blank(card, 2, 'value', default=default)
        elif key in int_params_allowed:
            default, allowed_values = int_params_allowed[key]
            value = integer_or_blank(card, 2, 'value', default=default)
            assert value in allowed_values, 'value=%s allowed=%s' % (
                value, allowed_values)

        # floats; has defaults
        elif key in float_params:
            default = float_params[key]
            value = double_or_blank(card, 2, 'value', default=default)
        elif key in float2_params:
            defaults = float2_params[key]
            value = double_or_blank(card, 2, 'value', default=defaults[0])
            value = double_or_blank(card, 2, 'value', default=defaults[1])
            n = 2

        # unchecked catch all
        elif key in STR_WORDS_1:
            value = string(card, 2, 'value')
        elif key in INT_WORDS_1:
            value = integer(card, 2, 'value')
        elif key in FLOAT_PARAMS:
            value = double(card, 2, 'value')
        elif key in FLOAT2_PARAMS:
            value1 = double(card, 2, 'value1')
            value2 = double(card, 3, 'value2')
            values = [value1, value2]
            n = 2

        #-------------------------------------------------------------
        else:
            #raise NotImplementedError(card)
            n = 2
            value1 = integer_double_string_or_blank(card, 2, 'value1')
            value2 = integer_double_string_or_blank(card, 3, 'value2')
            if value2 is None:
                value = value1
                n = 1

        if value is None:
            # n=2 or blank
            if isinstance(value1, str):
                assert ' ' not in value1, 'PARAM value1=%r' % value1
            if isinstance(value2, str):
                assert ' ' not in value2, 'PARAM value2=%r' % value2
            values = [value1, value2]
        else:
            # n=1
            if isinstance(value, str):
                assert ' ' not in value, 'PARAM value=%r' % value
            values = [value]

        if n == 1:
            assert len(card) <= 3, 'len(PARAM card)=%i card=%r' % (len(card),
                                                                   card)
        else:
            assert len(card) <= 4, 'len(PARAM card)=%i card=%r' % (len(card),
                                                                   card)
        return PARAM(key, values, comment=comment)
コード例 #9
0
    def add_card(cls, card, comment=''):
        """
        Creates a PARAM card.

        Parameters
        ----------
        card : BDFCard(); default=None
            BDFCard object
        comment : str; default=''
            a comment for the card
        """
        key = string(card, 1, 'key')

        n = 1
        value = None
        if key == 'ACOUT':
            value = string_or_blank(card, 2, 'value', 'PEAK')
        elif key == 'ACOWEAK':
            value = string_or_blank(card, 2, 'value', 'NO')
        elif key == 'ACSYM':
            value = string_or_blank(card, 2, 'value', 'YES')
        elif key == 'ADJMETH':
            value = integer_or_blank(card, 2, 'value', 0)
        elif key == 'ADPCON':
            value = double_or_blank(card, 2, 'value', 1.0)
        #elif key == 'ADMPOST':
        #value = string_or_blank(card, 2, 'value', 0) ## TODO: 0 is not a string
        elif key == 'ADSDISC':
            value = double_or_blank(card, 2, 'value', 1e-8)
        elif key == 'AESMAXIT':
            value = integer_or_blank(card, 2, 'value', 15)
        elif key == 'AESMETH':
            value = string_or_blank(card, 2, 'value', 'SELECT')
            assert value in ['SELECT', 'AUTO', 'DIRECT', 'RITZ',
                             'ITER'], 'value=%s' % value
        elif key == 'AESTOL':
            value = double_or_blank(card, 2, 'value', 1e-10)
        elif key == 'ADSTAT':
            value = string_or_blank(card, 2, 'value', 'YES')
        elif key in ['ALPHA1', 'ALPHA2', 'ALPHA1FL',
                     'ALPHA2FL']:  # check alpha1/alpha1FL
            value1 = double_or_blank(card, 2, 'value1', 0.0)
            value2 = double_or_blank(card, 3, 'value2', 0.0)
            n = 2
        elif key in [
                'CB1', 'CB2', 'CK1', 'CK2', 'CK3', 'CK41', 'CK42', 'CM1',
                'CM2', 'CP1', 'CP2'
        ]:
            value1 = double_or_blank(card, 2, 'value1', 1.0)
            value2 = double_or_blank(card, 3, 'value2', 0.0)
            n = 2
        elif key == 'POST':
            value = integer_or_blank(card, 2, 'value', 1)
        elif key == 'UNITSYS':
            value = string(card, 2, 'value')
        else:
            value1 = integer_double_string_or_blank(card, 2, 'value1')
            value2 = integer_double_string_or_blank(card, 3, 'value2')
            if value2 is None:
                value = value1

        if value is None:
            if isinstance(value1, string_types):
                assert ' ' not in value1, 'PARAM value1=%r' % value1
            if isinstance(value2, string_types):
                assert ' ' not in value2, 'PARAM value2=%r' % value2
            values = [value1, value2]
        else:
            if isinstance(value, string_types):
                assert ' ' not in value, 'PARAM value=%r' % value
            values = [value]

        if n == 1:
            assert len(card) <= 3, 'len(PARAM card)=%i card=%r' % (len(card),
                                                                   card)
        else:
            assert len(card) <= 4, 'len(PARAM card)=%i card=%r' % (len(card),
                                                                   card)
        return PARAM(key, values, comment=comment)
コード例 #10
0
ファイル: params.py プロジェクト: watkinrt/pyNastran
    def __init__(self, card, data=None, comment=''):
        """
        Creates a PARAM card.

        Parameters
        ----------
        card : BDFCard(); default=None
            BDFCard object
        data : List[int/float/str]; default=None
            list of PARAM entries not including 'PARAM';
            intended to be used by OP2 Reader
        comment : str; default=''
            optional string
        """
        if comment:
            self._comment = comment
        if data:
            card = BDFCard(['PARAM'] + data)

        self.key = string(card, 1, 'key')
        n = 1
        value = None
        if self.key == 'ACOUT':
            value = string_or_blank(card, 2, 'value', 'PEAK')
        elif self.key == 'ACOWEAK':
            value = string_or_blank(card, 2, 'value', 'NO')
        elif self.key == 'ACSYM':
            value = string_or_blank(card, 2, 'value', 'YES')
        elif self.key == 'ADJMETH':
            value = integer_or_blank(card, 2, 'value', 0)
        elif self.key == 'ADPCON':
            value = double_or_blank(card, 2, 'value', 1.0)
        #elif self.key == 'ADMPOST':
            #value = string_or_blank(card, 2, 'value', 0) ## TODO: 0 is not a string
        elif self.key == 'ADSDISC':
            value = double_or_blank(card, 2, 'value', 1e-8)
        elif self.key == 'AESMAXIT':
            value = integer_or_blank(card, 2, 'value', 15)
        elif self.key == 'AESMETH':
            value = string_or_blank(card, 2, 'value', 'SELECT')
            assert value in ['SELECT', 'AUTO', 'DIRECT', 'RITZ', 'ITER'], 'value=%s' % value
        elif self.key == 'AESTOL':
            value = double_or_blank(card, 2, 'value', 1e-10)
        elif self.key == 'ADSTAT':
            value = string_or_blank(card, 2, 'value', 'YES')
        elif self.key in ['ALPHA1', 'ALPHA2', 'ALPHA1FL', 'ALPHA2FL']:  # check alpha1/alpha1FL
            value1 = double_or_blank(card, 2, 'value1', 0.0)
            value2 = double_or_blank(card, 3, 'value2', 0.0)
            n = 2
        elif self.key in ['CB1', 'CB2', 'CK1', 'CK2', 'CK3', 'CK41', 'CK42',
                          'CM1', 'CM2', 'CP1', 'CP2']:
            value1 = double_or_blank(card, 2, 'value1', 1.0)
            value2 = double_or_blank(card, 3, 'value2', 0.0)
            n = 2
        elif self.key == 'POST':
            value = integer_or_blank(card, 2, 'value', 1)
        else:
            value1 = integer_double_string_or_blank(card, 2, 'value1')
            value2 = integer_double_string_or_blank(card, 3, 'value2')
            if value2 is None:
                value = value1

        if value is None:
            if isinstance(value1, string_types):
                assert ' ' not in value1, 'PARAM value1=%r' % value1
            if isinstance(value2, string_types):
                assert ' ' not in value2, 'PARAM value2=%r' % value2
            self.values = [value1, value2]
        else:
            if isinstance(value, string_types):
                assert ' ' not in value, 'PARAM value=%r' % value
            self.values = [value]

        if n == 1:
            assert len(card) <= 3, 'len(PARAM card)=%i card=%r' % (len(card), card)
        else:
            assert len(card) <= 4, 'len(PARAM card)=%i card=%r' % (len(card), card)
コード例 #11
0
ファイル: methods.py プロジェクト: watkinrt/pyNastran
    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
            #:   MSC 2014 = [INV, HESS, CLAN, IRAM]
            #:   NX 8.5 = [INV, HESS, CLAN, ISRR]
            #:   Autodesk 2015 = [ARNO, HESS, CLAN]
            self.method = string(card, 2, 'method')
            assert self.method in ['ARNO', 'INV', 'HESS', 'CLAN', 'ISRR', 'IRAM'], (
                'method=%s is not ARNO, INV, HESS, CLAN, ISRR, IRAM' % 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^-8 for METHOD = "CLAN",
            #: 10^-8 for METHOD = "ISRR",
            #: 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 % 8 > 0:
                nrows += 1
            #if nrows == 0:
                #raise RuntimeError('invalid row count=0; nfields=%s \ncard=%s\nfields=%s' % (nfields, card, fields))

            if self.method == 'CLAN':
                self.loadCLAN(nrows, card)
            elif self.method in ['HESS', 'INV']:  # HESS, INV
                self.loadHESS_INV(nrows, card)
            elif self.method == 'ISRR':
                self._load_isrr(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')
コード例 #12
0
    def add_card(cls, card, comment=''):
        key = string(card, 1, 'key')

        n = 1
        value = None
        if key == 'ACOUT':
            value = string_or_blank(card, 2, 'value', 'PEAK')
        elif key == 'ACOWEAK':
            value = string_or_blank(card, 2, 'value', 'NO')
        elif key == 'ACSYM':
            value = string_or_blank(card, 2, 'value', 'YES')
        elif key == 'ADJMETH':
            value = integer_or_blank(card, 2, 'value', 0)
        elif key == 'ADPCON':
            value = double_or_blank(card, 2, 'value', 1.0)
        #elif key == 'ADMPOST':
            #value = string_or_blank(card, 2, 'value', 0) ## TODO: 0 is not a string
        elif key == 'ADSDISC':
            value = double_or_blank(card, 2, 'value', 1e-8)
        elif key == 'AESMAXIT':
            value = integer_or_blank(card, 2, 'value', 15)
        elif key == 'AESMETH':
            value = string_or_blank(card, 2, 'value', 'SELECT')
            assert value in ['SELECT', 'AUTO', 'DIRECT', 'RITZ', 'ITER'], 'value=%s' % value
        elif key == 'AESTOL':
            value = double_or_blank(card, 2, 'value', 1e-10)
        elif key == 'ADSTAT':
            value = string_or_blank(card, 2, 'value', 'YES')
        elif key in ['ALPHA1', 'ALPHA2', 'ALPHA1FL', 'ALPHA2FL']:  # check alpha1/alpha1FL
            value1 = double_or_blank(card, 2, 'value1', 0.0)
            value2 = double_or_blank(card, 3, 'value2', 0.0)
            n = 2
        elif key in ['CB1', 'CB2', 'CK1', 'CK2', 'CK3', 'CK41', 'CK42',
                          'CM1', 'CM2', 'CP1', 'CP2']:
            value1 = double_or_blank(card, 2, 'value1', 1.0)
            value2 = double_or_blank(card, 3, 'value2', 0.0)
            n = 2
        elif key == 'POST':
            value = integer_or_blank(card, 2, 'value', 1)
        else:
            value1 = integer_double_string_or_blank(card, 2, 'value1')
            value2 = integer_double_string_or_blank(card, 3, 'value2')
            if value2 is None:
                value = value1

        if value is None:
            if isinstance(value1, string_types):
                assert ' ' not in value1, 'PARAM value1=%r' % value1
            if isinstance(value2, string_types):
                assert ' ' not in value2, 'PARAM value2=%r' % value2
            values = [value1, value2]
        else:
            if isinstance(value, string_types):
                assert ' ' not in value, 'PARAM value=%r' % value
            values = [value]

        if n == 1:
            assert len(card) <= 3, 'len(PARAM card)=%i card=%r' % (len(card), card)
        else:
            assert len(card) <= 4, 'len(PARAM card)=%i card=%r' % (len(card), card)
        return PARAM(key, values, comment=comment)
コード例 #13
0
    def add_card(cls, card, comment=''):
        sid = integer(card, 1, 'sid')
        method = string(card, 2, 'method')
        assert method in [
            'ARNO', 'INV', 'HESS', 'CLAN', 'ISRR', 'IRAM'
        ], ('method=%s is not ARNO, INV, HESS, CLAN, ISRR, IRAM' % method)

        norm = string_or_blank(card, 3, 'norm')
        if norm == 'POINT':
            G = integer(card, 4, 'G')
            C = components(card, 5, 'C')
        else:
            G = blank(card, 4, 'G')
            C = blank(card, 5, 'C')

        E = double_or_blank(card, 6, 'E')
        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:]]

        #-------CLAN--------------
        mblkszs = []
        iblkszs = []
        ksteps = []
        NJIs = []
        #-------CLAN--------------

        #-------HESS--------------
        alphaAjs = []
        alphaBjs = []
        omegaAjs = []
        omegaBjs = []
        mblkszs = []
        iblkszs = []
        ksteps = []
        LJs = []
        NEJs = []
        NDJs = []
        #-------HESS--------------

        #-------ISRR--------------
        shift_r1 = 0.0
        shift_i1 = 0.0
        isrr_flag = 0
        nd1 = None
        #-------ISRR--------------
        nfields = len(fields)
        nrows = nfields // 8
        if nfields % 8 > 0:
            nrows += 1
        #if nrows == 0:
        #msg = 'invalid row count=0; nfields=%s \ncard=%s\nfields=%s' % (
        #nfields, card, fields)
        #raise RuntimeError(msg)

        if method == 'CLAN':
            alphaAjs, omegaAjs, mblkszs, iblkszs, ksteps, NJIs = cls._load_clan(
                nrows, card)
        elif method in ['HESS', 'INV']:  # HESS, INV
            alphaAjs, omegaAjs, alphaBjs, omegaBjs, LJs, NEJs, NDJs = cls._load_hess_inv(
                nrows, method, card)
        elif method == 'ISRR':
            shift_r1, shift_i1, isrr_flag, nd1 = cls._load_isrr(nrows, card)
        else:
            msg = 'invalid EIGC method...method=%r' % method
            raise RuntimeError(msg)
        #assert card.nFields() < 8, 'card = %s' % card
        return EIGC(
            sid,
            method,
            norm,
            G,
            C,
            E,
            ndo,
            mblkszs,
            iblkszs,
            ksteps,
            NJIs,  # CLAN
            alphaAjs,
            omegaAjs,
            alphaBjs,
            omegaBjs,
            LJs,
            NEJs,
            NDJs,  # HESS/INV
            shift_r1,
            shift_i1,
            isrr_flag,
            nd1,  # ISRR
            comment=comment)