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


Python BDF.set_dynamic_syntax方法代码示例

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


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

示例1: run_model

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import set_dynamic_syntax [as 别名]
    def run_model(self, bdf_name=None, f06_name=None, op2_name=None,
                  op4_name=None, dynamic_vars=None, f06_has_weight=True):
        outputs = []
        if bdf_name:
            bdf = BDF(debug=False, log=None)
            if dynamic_vars is not None:
                bdf.set_dynamic_syntax(dynamic_vars)
            bdf.read_bdf(bdf_name)
            bdf.write_bdf(bdf_name+'.out', interspersed=False)
            bdf.write_bdf(bdf_name+'.out', interspersed=True)
            outputs.append(bdf)

        if op2_name:
            op2 = OP2(debug=False)
            op2.read_op2(op2_name, vectorized=False)
            op2.write_f06(op2_name[:-4] + '.test_op2.out')
            outputs.append(op2)

        if f06_name:
            f06 = F06(debug=False, log=None)
            f06.read_f06(f06_name)
            f06.write_f06(f06_name[:-4] + '.test_f06.out')
            outputs.append(f06)
            if f06_has_weight:
                assert f06.grid_point_weight.reference_point is not None
            else:
                assert f06.grid_point_weight.reference_point is None

        if op4_name:
            op4 = OP4()
            op4.read_op4(op4_name, matrixNames=None, precision='default')

        assert len(outputs) > 0
        if len(outputs) == 1: return outputs[0]
        return outputs
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:37,代码来源:f06_unit_tests.py

示例2: test_openmaod_bad_3

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import set_dynamic_syntax [as 别名]
    def test_openmaod_bad_3(self):
        params_bad = {1 : '10'}
        params_good = {'cat' : '10'}
        model = BDF()

        with self.assertRaises(TypeError):
            model.set_dynamic_syntax(params_bad)

        model.set_dynamic_syntax(params_good)
        val = model._parse_dynamic_syntax('cat')
        self.assertEqual('10', val)
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:13,代码来源:test_openmdao.py

示例3: main

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import set_dynamic_syntax [as 别名]
def main():
    vars = {
        'bar1_a' : 1.0,
        'bar2_a' : 2.0,
        'bar3_a' : 3.0,
        'loadx' : 50000.0,
        'loady' : 100000.0,
        'loadmag': 1.,
        'rho'   : 0.284,
        'youngs': 30000000.0,

    }
    model = BDF()
    model.set_dynamic_syntax(vars)
    model.read_bdf('vared_bar3.bdf')
    out_bdf = 'out.bdf'
    out_f06 = 'out.f06'
    out_op2 = 'out.op2'

    if 'POST' in model.params:
        # change "PARAM, POST, 0"  to "PARAM, POST, -1"

        # option 1
        #model.params['POST'].update_field(2, -1)

        # option 2
        model.params['POST'].update_values(value1=-1, value2=None)

    model.write_bdf(out_bdf, size=16, precision='double')
    os.system('nastran scr=yes bat=no news=no old=no %s' % out_bdf)

    model2 = F06(out_f06)
    if 0:
        model2.markerMap = {
            'O U T P U T   F R O M   G R I D   P O I N T   W E I G H T   G E N E R A T O R': model2._grid_point_weight_generator,
        }
        model2.markers = model2.markerMap.keys()

    if 0:
        model2.stop_after_reading_grid_point_weight(stop=True)
    model2.read_f06()

    #print '\n'.join(dir(subcase1))
    print ""
    print "mass = %s" % model2.grid_point_weight.mass

    #========================================
    model3 = OP2(out_op2)
    model3.read_op2()
    #========================================
    for form, modeli in [('f06', model2), ('op2', model3)]:
        print "---%s---" % form
        subcase1 = modeli.rodStress[1]

        eid = 2
        print 'axial   stress[%s] = %s' % (eid, subcase1.axial[eid])
        print 'torsion stress[%s] = %s' % (eid, subcase1.torsion[eid])
        print '        stress[%s] = %s\n' % (eid, calculate_stress(subcase1.axial[eid], subcase1.torsion[eid]))

        eid = 3
        print 'axial   stress[%s] = %s' % (eid, subcase1.axial[eid])
        print 'torsion stress[%s] = %s' % (eid, subcase1.torsion[eid])
        print '        stress[%s] = %s\n' % (eid, calculate_stress(subcase1.axial[eid], subcase1.torsion[eid]))
开发者ID:sukhbinder,项目名称:cyNastran,代码行数:65,代码来源:dynamic_syntax.py

示例4: main

# 需要导入模块: from pyNastran.bdf.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.bdf.BDF import set_dynamic_syntax [as 别名]
def main():
    vars = {
        'bar1_a' : 1.0,
        'bar2_a' : 2.0,
        'bar3_a' : 3.0,
        'loadx' : 50000.0,
        'loady' : 100000.0,
        'loadmag': 1.,
        'rho'   : 0.284,
        'youngs': 30000000.0,

    }
    model = BDF(debug=False)
    model.set_dynamic_syntax(vars)
    model.read_bdf('vared_bar3.bdf')
    out_bdf = 'out.bdf'
    out_f06 = 'out.f06'
    out_op2 = 'out.op2'

    if 'POST' in model.params:
        # change "PARAM, POST, 0"  to "PARAM, POST, -1"

        # option 1
        #model.params['POST'].update_field(2, -1)

        # option 2
        model.params['POST'].update_values(value1=-1, value2=None)

    model.write_bdf(out_bdf, size=16, is_double=True)
    os.system('nastran scr=yes bat=no news=no old=no %s' % out_bdf)

    if is_f06:
        model2 = F06()
        model2.read_f06(out_f06)
        print("")
        print("mass = %s" % model2.grid_point_weight.mass)
    else:
        model2 = None

    #========================================
    model3 = OP2()
    model3.read_op2(out_op2, vectorized=False)
    model4 = OP2()
    model4.read_op2(out_op2, vectorized=True)

    eids = [2, 3]
    #========================================
    for form, modeli, exists in [('f06', model2, is_f06), ('op2', model3, is_op2)]:
        if exists:
            print("---%s---" % form)
            subcase1 = modeli.crod_stress[1]
            for eid in eids:
                eid = 2
                print('axial   stress[%s] = %s' % (eid, subcase1.axial[eid]))
                print('torsion stress[%s] = %s' % (eid, subcase1.torsion[eid]))
                print('        stress[%s] = %s\n' % (eid, calculate_stress(subcase1.axial[eid], subcase1.torsion[eid])))
    #========================================
    subcase1 = model4.crod_stress[1]
    combined_stress = calculate_stress(subcase1.data[0, :, 0], subcase1.data[0, :, 1])

    search = searchsorted(subcase1.element, eids)

    print("---op2 vectorized---")
    #[axial, torsion, SMa, SMt]
    for i, j in enumerate(search):
        eid = eids[i]
        axial = subcase1.data[0, j, 0]
        torsion = subcase1.data[0, j, 1]
        combined = combined_stress[i]
        print('axial   stress[%s] = %s' % (eid, axial))
        print('torsion stress[%s] = %s' % (eid, torsion))
        print('        stress[%s] = %s\n' % (eid, combined))
开发者ID:EmanueleCannizzaro,项目名称:pyNastran,代码行数:74,代码来源:dynamic_syntax.py


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