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


Python bdf.BDF类代码示例

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


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

示例1: test_op2_bcell_01

    def test_op2_bcell_01(self):
        folder = os.path.abspath(os.path.join(test_path, '..', 'models'))
        bdf_filename = os.path.join(folder, 'other', 'bcell9p0.bdf')
        op2_filename = os.path.join(folder, 'other', 'bcell9p0.op2')
        make_geom = False
        write_bdf = False
        write_f06 = True
        debug = False
        op2file = os.path.join(folder, op2_filename)
        bdf = BDF(debug=False)
        bdf.read_bdf(bdf_filename, xref=False)

        debug = False
        debug_file = 'debug.out'
        op2 = OP2(debug=debug, debug_file=debug_file)
        op2.read_op2(op2_filename)
        assert os.path.exists(debug_file), os.listdir('.')

        self._verify_ids(bdf, op2, isubcase=1)

        msg = ''
        for isubcase, keys in sorted(iteritems(op2.subcase_key)):
            if len(keys) != 1:
                msg += 'isubcase=%s keys=%s len(keys) != 1\n' % (isubcase, keys)
                if len(keys) == 0:
                    continue
            if isubcase != keys[0]:
                msg += 'isubcase=%s != key0=%s keys=%s\n' % (isubcase, keys[0], keys)
        if msg:
            assert msg == '', msg
        op2.write_f06('junk.f06')
        os.remove('junk.f06')
开发者ID:HibernantBear,项目名称:pyNastran,代码行数:32,代码来源:op2_unit_tests.py

示例2: test_include_end_02

    def test_include_end_02(self):
        with codec_open('a.bdf', 'w') as f:
            f.write('CEND\n')
            f.write('BEGIN BULK\n')
            f.write('GRID,1,,1.0\n')
            f.write("INCLUDE 'b.bdf'\n\n")
            f.write('GRID,4,,4.0\n')

        with codec_open('b.bdf', 'w') as f:
            f.write('GRID,2,,2.0\n')
            f.write("INCLUDE 'c.bdf'\n\n")
            f.write('GRID,5,,5.0\n')

        with codec_open('c.bdf', 'w') as f:
            f.write('GRID,3,,3.0\n\n')

        model = BDF(log=log, debug=False)
        model.read_bdf('a.bdf')
        model.write_bdf('a.out.bdf')

        os.remove('a.bdf')
        os.remove('b.bdf')
        os.remove('c.bdf')
        os.remove('a.out.bdf')
        self.assertEqual(len(model.nodes), 5)
        self.assertEqual(model.nnodes, 5, 'nnodes=%s' % model.nnodes)
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:26,代码来源:test_read_write.py

示例3: test_disable_cards

 def test_disable_cards(self):
     bdf_filename = os.path.join(root_path, '..', 'models',
         'solid_bending', 'solid_bending.bdf')
     model = BDF(debug=False)
     model.disable_cards(['CTETRA'])
     model.read_bdf(bdf_filename)
     assert len(model.elements) == 0, len(model.elements)
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:7,代码来源:test_read_write.py

示例4: __init__

    def __init__(self, make_geom=True,
                 debug=False, log=None, debug_file=None):
        """
        Initializes the OP2 object

        :param make_geom: reads the BDF tables (default=False)
        :param debug: enables the debug log and sets the debug in the logger (default=False)
        :param log: a logging object to write debug messages to
         (.. seealso:: import logging)
        :param debug_file: sets the filename that will be written to (default=None -> no debug)
        """
        assert make_geom == True, make_geom

        BDF.__init__(self, debug=debug, log=log)
        GEOM1.__init__(self)
        GEOM2.__init__(self)
        GEOM3.__init__(self)
        GEOM4.__init__(self)

        EPT.__init__(self)
        MPT.__init__(self)
        DIT.__init__(self)
        DYNAMICS.__init__(self)

        OP2.__init__(self, debug, log=log, debug_file=debug_file)
        self.make_geom = make_geom
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:26,代码来源:op2_geom.py

示例5: test_dmig_4

    def test_dmig_4(self):
        model = BDF(debug=False)
        bdf_name = os.path.join(test_path, 'dmig.bdf')
        model.read_bdf(bdf_name, xref=False, punch=True)

        out = model.dmigs['IMAGS'].get_matrix(is_sparse=False)
        IMAGS_actual, rows_reversed, cols_reversed = out
        #print "---IMAGS_actual---\n", IMAGS_actual
        IMAGS_expected_real = [
            [1.0, 0.5, 0.25],
            [0.5, 2.0, 0.75],
            [0.25, 0.75, 3.0],
        ]
        IMAGS_expected_imag = [
            [1.1, 0.51, 0.251],
            [0.51, 2.1, 0.751],
            [0.251, 0.751, 3.1],
        ]
        a_matrix = model.dmigs['IMAGS']
        assert len(a_matrix.GCi) == 6, 'len(GCi)=%s GCi=%s matrix=\n%s' % (len(a_matrix.GCi), a_matrix.GCi, a_matrix)
        assert len(a_matrix.GCj) == 6, 'len(GCj)=%s GCj=%s matrix=\n%s' % (len(a_matrix.GCj), a_matrix.GCj, a_matrix)

        IMAGS_expected = array(IMAGS_expected_real) + array(IMAGS_expected_imag)*1j
        msg = '\n%s_actual\n%s\n\n----' % ('IMAGS', IMAGS_actual)
        msg += '\n%s_expected\n%s\n----' % ('IMAGS', IMAGS_expected)
        msg += '\n%s_delta\n%s\n----' % ('IMAGS', IMAGS_actual-IMAGS_expected)
        self.assertTrue(array_equal(IMAGS_expected, IMAGS_actual), msg)
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:27,代码来源:test_dmig.py

示例6: test_pbeam_11

 def test_pbeam_11(self):
     model = BDF()
     lines = [
         #'PBEAM         1       1    1.e8    1.e8    1.e8              10.      1.',
         #'             NO      1.    3.e5    3.e8    3.e8              10.      1.',
         'PBEAM          1       1    1.+8    1.+8    1.+8             10.      1.',
         '              NO      1. 300000.    3.+8    3.+8             10.      1.',
     ]
     model.add_card(lines, 'PBEAM', is_list=False)
     lines_expected = [
         'PBEAM          1       1    1.+8    1.+8    1.+8             10.      1.',
         '+',
         '              NO      1. 300000.    3.+8    3.+8             10.      1.',
     ]
     prop = model.properties[1]
     #print(prop.raw_fields())
     lines_actual = prop.write_card().split('\n')
     msgA = ''
     for line_expected, line_actual in zip(lines_expected, lines_actual):
         #assert line_expected == line_actual, line_actual
         actual = str(line_actual)
         expected = str(line_expected)
         msg = msgA + '\nactual   = %r\n' % actual
         msg += 'expected = %r' % expected
         self.assertEqual(actual, expected, msg)
开发者ID:HibernantBear,项目名称:pyNastran,代码行数:25,代码来源:test_beams.py

示例7: test_include_05

    def test_include_05(self):
        with codec_open('include5.bdf', 'w') as bdf_file:
            bdf_file.write('$ pyNastran: punch=True\n')
            bdf_file.write('$ pyNastran: dumplines=True\n')
            bdf_file.write("INCLUDE 'include5b.inc'\n\n")

        with codec_open('include5b.inc', 'w') as bdf_file:
            bdf_file.write('ECHOON\n')
            bdf_file.write('$ GRID comment\n')
            bdf_file.write('GRID,2,,2.0\n')
            bdf_file.write('ECHOOFF\n')
            bdf_file.write('GRID,3,,3.0\n')
            bdf_file.write('grid,4,,4.0\n')
            bdf_file.write('grid ,5,,5.0\n')

        model = BDF(log=log, debug=False)
        model.read_bdf('include5.bdf')
        assert model.echo is False, model.echo
        #model.write_bdf('include5.out.bdf')

        # os.remove('c.bdf')
        # os.remove('executive_control.inc')
        # os.remove('case_control.inc')

        self.assertEqual(len(model.nodes), 4)
        self.assertEqual(model.nnodes, 4, 'nnodes=%s' % model.nnodes)

        model2 = read_bdf(bdf_filename='include5.bdf', xref=True, punch=False,
                          log=log, encoding=None)
        self.assertEqual(len(model2.nodes), 4)
        self.assertEqual(model2.nnodes, 4, 'nnodes=%s' % model.nnodes)
        os.remove('include5.bdf')
        #os.remove('include5.out.bdf')
        os.remove('include5b.inc')
开发者ID:hurlei,项目名称:pyNastran,代码行数:34,代码来源:test_read_write.py

示例8: example4

def example4():
    """
    Example 4: Get Element ID & Type - Level 2
    """
    # Print the Element ID and its type(e.g. CQUAD4, CTRIA3, etc.) to a file

    # note this skips rigidElements

    # this example will demonstate:
    #  - accessing element type information

    # our model
    import pyNastran
    pkg_path = pyNastran.__path__[0]
    test_path = os.path.join(pkg_path, '..', 'models', 'solid_bending')
    bdf_filename = os.path.join(test_path, 'solid_bending.bdf')

    # instantiate the model
    from pyNastran.bdf.bdf import BDF
    model = BDF()
    model.read_bdf(bdf_filename, xref=True)
    f = open('junk.out', 'w')

    ####
    ####Method 1 - using objects
    ####---------------------------------
    ####
    for eid,element in sorted(model.elements.items()):
        msg = 'eid=%s type=%s\n' %(eid, element.type)
    f.write(msg)
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:30,代码来源:bdf_doc.py

示例9: example5

def example5():
    """
    Example 5: Get Elements by Node ID - Level 2
    """

    # this example will demonstate:
    #  - getting the list of elements that share a certain node

    # our model
    import pyNastran
    pkg_path = pyNastran.__path__[0]
    test_path = os.path.join(pkg_path, '..', 'models', 'solid_bending')
    bdf_filename = os.path.join(test_path, 'solid_bending.bdf')

    # instantiate the model
    from pyNastran.bdf.bdf import BDF
    model = BDF()
    model.read_bdf(bdf_filename, xref=True)
    f = open('junk.out', 'w')

    # given a Node, get the Elements Attached to that Node
    # assume node 55
    # doesnt support 0d/1d elements yet
    nid_to_eids_map = model.get_node_id_to_element_ids_map()
    eids = nid_to_eids_map[55]

    # convert to elements instead of element IDs
    elements = []
    for eid in eids:
        elements.append(model.Element(eid))

    print("eids = %s" % eids)
    print("elements =\n %s" % elements)
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:33,代码来源:bdf_doc.py

示例10: test_solid_03

 def test_solid_03(self):
     """checks linear static solid material"""
     mid = 2
     pid = 4
     rho = 0.1
     cards = [
         # $ Solid Nodes
         ["GRID", 11, 0, 0.0, 0.0, 0.0, 0],
         ["GRID", 12, 0, 1.0, 0.0, 0.0, 0],
         ["GRID", 13, 0, 1.0, 1.0, 0.0, 0],
         ["GRID", 14, 0, 0.0, 1.0, 0.0, 0],
         ["GRID", 15, 0, 0.0, 0.0, 2.0, 0],
         ["GRID", 16, 0, 1.0, 0.0, 2.0, 0],
         ["GRID", 17, 0, 1.0, 1.0, 2.0, 0],
         ["GRID", 18, 0, 0.0, 1.0, 2.0, 0],
         # Solids
         ["CHEXA", 7, pid, 11, 12, 13, 14, 15, 16, 17, 18],
         ["CTETRA", 8, pid, 11, 12, 13, 15],
         # Solid Nodes
         ["GRID", 21, 0, 0.0, 0.0, 0.0, 0],
         ["GRID", 22, 0, 1.0, 0.0, 0.0, 0],
         ["GRID", 23, 0, 1.0, 1.0, 0.0, 0],
         ["GRID", 24, 0, 0.0, 0.0, 2.0, 0],
         ["GRID", 25, 0, 1.0, 0.0, 2.0, 0],
         ["GRID", 26, 0, 1.0, 1.0, 2.0, 0],
         ["CPENTA", 9, pid, 21, 22, 23, 24, 25, 26],
         # static
         ["PSOLID", pid, mid, 0],
         ["MAT1", mid, 1.0, 2.0, 3.0, rho],
         ["MATS1", mid, None, "PLASTIC", 0.0, 1, 1, 100000.0],
     ]
     model = BDF(debug=False)
     for fields in cards:
         model.add_card(fields, fields[0], is_list=True)
     model.cross_reference()
开发者ID:hurlei,项目名称:pyNastran,代码行数:35,代码来源:test_solids.py

示例11: test_pbeam_03

    def test_pbeam_03(self):
        bdf = BDF(debug=False)
        lines = [
            'PBEAM,39,6,2.9,3.5,5.97',
            '     ,  , ,2.0,-4.0',
            '     ,YES,1.0,5.3,56.2,78.6',
            '     ,   ,   ,2.5,-5.0',
            '     ,   ,   ,1.1,    ,2.1,,0.21',
            '     ,   ,   ,   ,    ,0.5,,0.0',
        ]

        card = bdf.process_card(lines)
        cardi = BDFCard(card)
        card2 = PBEAM.add_card(cardi)
        fields = card2.raw_fields()

        lines_expected = [
            'PBEAM         39       6     2.9     3.5    5.97      0.      0.      0.',
            '              0.      0.      2.     -4.      0.      0.      0.      0.',
            '             YES      1.     5.3    56.2    78.6      0.      0.      0.',
            '              0.      0.     2.5     -5.      0.      0.      0.      0.',
            '              1.      1.     1.1      0.     2.1     2.1     .21     .21',
            '              0.      0.      0.      0.      .5      .5      0.      0.',
        ]
        self._compare(fields, lines_expected)
开发者ID:saullocastro,项目名称:pyNastran,代码行数:25,代码来源:test_beams.py

示例12: test_strain

 def test_strain(self):
     for folder, prefix, subcase in CASES:
         bdf = BDF(debug=False)
         op2 = OP2(debug=False)
         basepath = os.path.join(pkg_path, 'op2', 'test', folder)
         bdf.read_bdf(os.path.join(basepath, prefix + '.bdf'))
         op2.read_op2(os.path.join(basepath, prefix + '.op2'))
         op2_new = data_in_material_coord(bdf, op2)
         for vecname in strain_vectors:
             vector = getattr(op2_new, vecname).get(subcase)
             if vector is None:
                 continue
             name = os.path.join(basepath, '{0}_subcase_{1:02d}.txt'.format(vecname, subcase))
             if not os.path.isfile(name):
                 raise AssertionError('Not found reference result {0}'.format(name))
             ref_result = np.loadtxt(name)
             data = vector.data
             eids = get_eids_from_op2_vector(vector)
             check = eids != 0
             if 'cquad8' in vecname:
                 assert np.allclose(data[:, check][:, 0::10, :], ref_result[0::10], rtol=RTOL, atol=ATOL)
                 assert np.allclose(data[:, check][:, 1::10, :], ref_result[1::10], rtol=RTOL, atol=ATOL)
             else:
                 assert np.allclose(data[:, check], ref_result, rtol=RTOL, atol=ATOL)
         print('OK')
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:25,代码来源:test_op2_in_material_coord.py

示例13: run

    def run(self, bdfName):
        model = BDF()
        model.cardsToRead = get_cards()
        model.readBDF(bdfName)
        cc = model.caseControlDeck
        #print cc.subcases
        analysisCases = []
        for (isub, subcase) in sorted(cc.subcases.iteritems()):
            if subcase.hasParameter('LOAD'):
                analysisCases.append(subcase)

        #print analysisCases
        for case in analysisCases:
            print(case)
            (value, options) = case.get_parameter('STRESS')
            print("STRESS value   = %s" % (value))
            print("STRESS options = %s" % (options))

            if case.hasParameter('TEMPERATURE(INITIAL)'):
                (value, options) = case.get_parameter('TEMPERATURE(INITIAL)')
                print('value   = %s' % (value))
                print('options = %s' % (options))
                raise NotImplementedError('TEMPERATURE(INITIAL) not supported')
                #integrate(B.T*E*alpha*dt*Ads)
            #sys.exit('starting case')
            self.runCase(model, case)
开发者ID:xirxa,项目名称:pynastran-locr,代码行数:26,代码来源:pyNastranSolver.py

示例14: test_cpenta_01

    def test_cpenta_01(self):
        """tests a cpenta15"""
        lines = [
            'CPENTA,85,22,201,202,203,205,206,207,+PN2',
            '+PN2,209,210,217,  ,  ,  ,213,214,',
            ',218'
        ]
        bdf = BDF(debug=False)
        card = bdf.process_card(lines)
        card = BDFCard(card)

        solid = CPENTA15.add_card(card, comment='cpenta15')
        solid.write_card(size=8, is_double=False)
        solid.write_card(size=16, is_double=False)
        solid.raw_fields()

        node_ids = solid.node_ids
        assert node_ids == [201, 202, 203, 205, 206, 207,
                            209, 210, 217, None, None, None, 213, 214, 218], node_ids
        nids = [201, 202, 203, 205, 206, 207,
                209, 210, 217, None, None, None, 213, 214, 218]
        CPENTA.add_card(card, comment='spike')
        eid = 85
        pid = 22
        bdf.add_cpenta(eid, pid, nids, comment='spike')
开发者ID:saullocastro,项目名称:pyNastran,代码行数:25,代码来源:test_solids.py

示例15: add_card

    def add_card(self, card_lines, card_name, comment='', is_list=True):
        card_name = card_name.upper()
        self._increase_card_count(card_name)
        if card_name in ['DEQATN']:
            card_obj = card_lines
            card = card_lines
        else:
            if is_list:
                fields = card_lines
            else:
                fields = to_fields(card_lines, card_name)

            # apply OPENMDAO syntax
            if self._is_dynamic_syntax:
                fields = [self._parse_dynamic_syntax(field) if '%' in
                          field[0:1] else field for field in fields]

                card = wipe_empty_fields([interpret_value(field, fields)
                                          if field is not None
                                          else None for field in fields])
            else:  # leave everything as strings
                card = wipe_empty_fields(fields)
            card_obj = BDFCard(card)

        if card_name == 'HYPER':
            hyper = HYPER(card_obj, comment)
            self.hyper[hyper.pid] = hyper
            return
        elif card_name == 'FLOW':
            flow = FLOW(card_obj, comment)
            self.flow[flow.flow_id] = flow
            return
        BDF.add_card(self, card, card_name, comment=comment, is_list=True)
开发者ID:FrankNaets,项目名称:pyNastran,代码行数:33,代码来源:hyper.py


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