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


Python BDF.write_bdf方法代码示例

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


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

示例1: run_fem2

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import write_bdf [as 别名]
def run_fem2(bdf_model, out_model, xref, punch, sum_load, size, is_double, reject, debug=False, log=None):
    """
    Reads/writes the BDF to verify nothing has been lost

    Parameters
    ----------
    bdf_model : str
        the filename to run
    xref : bool
       xrefs
    punch : bool
       punches
    """
    assert os.path.exists(bdf_model), bdf_model
    assert os.path.exists(out_model), out_model
    fem2 = BDF(debug=debug, log=log)
    fem2.log.info("starting fem2")
    sys.stdout.flush()
    try:
        fem2.read_bdf(out_model, xref=xref, punch=punch)
    except:
        print("failed reading %r" % out_model)
        raise

    # fem2.sumForces()
    # fem2.sumMoments()
    out_model2 = bdf_model + "_out2"
    fem2.write_bdf(out_model2, interspersed=True)
    # fem2.writeAsCTRIA3(out_model_2)
    os.remove(out_model2)
    return fem2
开发者ID:hurlei,项目名称:pyNastran,代码行数:33,代码来源:test_bdf_vectorized2.py

示例2: run_fem2

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import write_bdf [as 别名]
def run_fem2(bdf_model, out_model, xref, punch,
             sum_load, size, precision,
             reject, debug=False, log=None):
    assert os.path.exists(bdf_model), bdf_model
    assert os.path.exists(out_model), out_model
    fem2 = BDF(debug=debug, log=log)
    fem2.log.info('starting fem2')
    sys.stdout.flush()
    try:
        fem2.read_bdf(out_model, xref=xref, punch=punch)
    except:
        print("failed reading %r" % out_model)
        raise

    #fem2.sumForces()
    #fem2.sumMoments()
    out_model2 = bdf_model + '_out2'
    fem2.write_bdf(out_model2, interspersed=True)
    #fem2.writeAsCTRIA3(out_model_2)
    os.remove(out_model2)
    return fem2
开发者ID:hurlei,项目名称:pyNastran,代码行数:23,代码来源:test_bdf.py

示例3: bdf_renumber

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import write_bdf [as 别名]

#.........这里部分代码省略.........
        paeros.sort()
        npaeros = len(paeros)
        paero_map = {paeros[i] : (i+1) for i in range(npaeros)}

    aefact_map = {}
    if model.aefacts:
        aefacts = model.aefacts.keys()
        aefacts.sort()
        naefacts = len(aefacts)
        aefact_map = {aefacts[i] : (i+1) for i in range(naefacts)}

    spline_map = {}
    #if model.splines:
        #splines = model.splines.keys()
        #splines.sort()
        #nsplines = len(splines)
        #spline_map = {splines[i] : (i+1) for i in range(nsplines)}

    set_map = {}
    if model.sets:
        sets = model.sets.keys()
        sets.sort()
        nsets = len(sets)
        set_map = {sets[i] : (i+1) for i in range(nsets)}

    #load_map = {}
    maps = {
        'node' : nid_map,
        'coord' : cid_map,
        'property' : pid_map,
        'element' : eid_map,
        'load' : load_map,
        'material' : mid_map,

        'caero' : caero_map, # ???
        'paero' : paero_map, # PAEROx
        'aefact' : aefact_map, # ???
        'spline' : spline_map, # SPLINE1-SPLINE5
        'set' : set_map,
    }

    model.grid.update(maps)
    model.coords.update(maps)
    for elem in elements:
        elem.update(maps)

    rigid_elements2 = {}
    for eid, elem in iteritems(model.rigid_elements):
        eid2 = eid_map[eid]
        rigid_elements2[eid2] = eid_map[eid]
        elem.update(maps)

    for prop in props:
        prop.update(maps)
    for mat in materials:
        mat.update(maps)
    for spc_dict in spcs:
        for spc_id, spc in iteritems(spc_dict):
            spc.update(maps)

    if model.aero is not None:
        model.aero.update(maps)
    if model.aeros is not None:
        model.aeros.update(maps)

    for caero in itervalues(model.caeros):
        caero.update(maps)
    for spline in itervalues(model.splines):
        spline.update(model, maps)
    for flutter in itervalues(model.flutters):
        flutter.update(maps)
    for flfact in itervalues(model.flfacts):
        flfact.update(maps)
    for flutter in itervalues(model.flutters):
        flutter.update(maps)

    for desvar in itervalues(model.desvars):
        desvar.update(maps)
    for dconstr in itervalues(model.dconstrs):
        dconstr.update(maps)
    for dresp in itervalues(model.dresps):
        dresp.update(maps)
    for dconadd in itervalues(model.dconadds):
        dconadd.update(maps)
    for dvgrid in itervalues(model.dvgrids):
        dvgrid.update(maps)
    for dvcrel in itervalues(model.dvcrels):
        dvcrel.update(maps)
    for dvmrel in itervalues(model.dvmrels):
        dvmrel.update(maps)
    for dvprel in itervalues(model.dvprels):
        dvprel.update(maps)

    model.darea.update(maps)
    model.dphase.update(maps)

    if bdf_filename_out is not None:
        model.write_bdf(bdf_filename_out, size=size, is_double=is_double,
                        interspersed=False)
    return model
开发者ID:hurlei,项目名称:pyNastran,代码行数:104,代码来源:bdf_renumber.py

示例4: get_mass

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import write_bdf [as 别名]
    def get_mass(self, nid1, nid2, xyz1, xyz2, eid, pid, mid, A, J, c, nsm, E, G, nu, rho, L):
        """tests a CROD and a CONROD"""
        card_count = {"CONROD": 1, "CTUBE": 1, "PTUBE": 1, "CROD": 1, "PROD": 1, "GRID": 2, "MAT1": 1}
        model = BDF(debug=debug)
        model.allocate(card_count)
        lines = ["conrod,%i, %i, %i, %i, %f, %f, %f, %f" % (eid, nid1, nid2, mid, A, J, c, nsm)]
        model.add_card(lines, "conrod", is_list=False)

        lines = ["crod,%i, %i, %i, %i" % (eid + 1, pid, nid1, nid2)]
        model.add_card(lines, "crod", is_list=False)

        lines = ["ctube,%i, %i, %i, %i" % (eid + 2, pid + 1, nid1, nid2)]
        model.add_card(lines, "ctube", is_list=False)

        lines = ["prod,%i, %i, %f, %f, %f, %f" % (pid, mid, A, J, c, nsm)]
        model.add_card(lines, "prod", is_list=False)

        OD1 = sqrt(4 * A / pi)
        t = 0.0
        OD2 = OD1
        lines = ["ptube,%i, %i, %f, %f, %f, %f" % (pid + 1, mid, OD1, t, nsm, OD2)]
        model.add_card(lines, "ptube", is_list=False)

        lines = ["mat1,%i, %.2e, %.2e, %f, %f" % (mid, E, G, nu, rho)]
        model.add_card(lines, "mat1", is_list=False)

        lines = ["grid,%i, %i, %f, %f, %f" % (nid1, 0, xyz1[0], xyz1[1], xyz1[2])]
        model.add_card(lines, "grid", is_list=False)

        lines = ["grid,%i, %i, %f, %f, %f" % (nid2, 0, xyz2[0], xyz2[1], xyz2[2])]
        model.add_card(lines, "grid", is_list=False)

        model.build()
        mass = L * (rho * A + nsm)

        f = StringIO()
        model.write_bdf(out_filename=f, interspersed=True, size=8, precision="single", enddata=None)
        print(f.getvalue())
        # positions = model.get_positions()
        grid_cid0 = None

        # conrod
        conrod = model.conrod.slice_by_element_id(eid)
        self.assertEquals(conrod.get_element_id_by_element_index(), eid)
        # self.assertEquals(conrod.get_property_id_by_element_id(), None)
        self.assertEquals(conrod.get_material_id_by_element_id(eid), mid)
        self.assertEquals(conrod.get_length_by_element_index(i=None, grid_cid0=grid_cid0), L)
        # self.assertEquals(conrod.Nsm(), nsm)

        rhoi = conrod.get_density_by_element_id(eid)
        Ai = conrod.get_area_by_element_id(eid)
        Li = conrod.get_length_by_element_id(eid, grid_cid0=grid_cid0)
        nsmi = conrod.get_non_structural_mass_by_element_id(eid)
        massa = conrod.get_mass_by_element_index()
        mass_msg_conrod = "mass = L * (rho * A + nsm)\n"
        mass_msg_conrod += "L=%s expected=%s\n" % (Li, L)
        mass_msg_conrod += "rho=%s expected=%s\n" % (rhoi, rho)
        mass_msg_conrod += "A=%s expected=%s\n" % (Ai, A)
        mass_msg_conrod += "nsm=%s expected=%s\n" % (nsmi, nsm)
        mass_msg_conrod += "mass=%s actual=%s expected=%s\n" % (Li * (rhoi * Ai + nsmi), massa, mass)
        # mass_msg_conrod += 'mass=%s expected=%s\n' % (Li * (rhoi*Ai + nsmi), mass)

        self.assertEquals(massa, mass, mass_msg_conrod)
        # self.assertEquals(conrod.E(), E)
        # self.assertEquals(conrod.G(), G)
        # self.assertEquals(conrod.area(), A)
        # self.assertEquals(conrod.J(), J)
        # self.assertEquals(conrod.C(), c)
        # self.assertEquals(conrod.Rho(), rho)

        # crod
        crod_eid = eid + 1
        crod = model.crod.slice_by_element_id([crod_eid])
        self.assertEquals(crod.get_element_id_by_element_index(), crod_eid)
        self.assertEquals(crod.get_property_id_by_element_id(crod_eid), pid)
        self.assertEquals(crod.get_material_id_by_element_id(crod_eid), mid)
        rhoi = crod.get_density_by_element_id(crod_eid)
        Ai = crod.get_area_by_element_id(crod_eid)
        Li = crod.get_length_by_element_id(crod_eid, grid_cid0=grid_cid0)
        nsmi = crod.get_non_structural_mass_by_element_id(crod_eid)
        self.assertEquals(Li, L)
        # self.assertEquals(crod.Nsm(), nsm)

        massa = crod.get_mass_by_element_id(crod_eid)
        mass_msg_crod = "mass = L * (rho * A + nsm)\n"
        mass_msg_crod += "L=%s expected=%s\n" % (Li, L)
        mass_msg_crod += "rho=%s expected=%s\n" % (rhoi, rho)
        mass_msg_crod += "A=%s expected=%s\n" % (Ai, A)
        mass_msg_crod += "nsm=%s expected=%s\n" % (nsmi, nsm)
        mass_msg_crod += "mass=%s actual=%s expected=%s\n" % (Li * (rhoi * Ai + nsmi), massa, mass)
        self.assertEquals(massa, mass, mass_msg_crod)
        # self.assertEquals(crod.E(), E)
        # self.assertEquals(crod.G(), G)
        # self.assertEquals(crod.area(), A)
        # self.assertEquals(crod.J(), J)
        # self.assertEquals(crod.C(), c)
        # self.assertEquals(crod.Rho(), rho)
        # self.assertEquals(crod.Nu(), nu)

        # prod
#.........这里部分代码省略.........
开发者ID:hurlei,项目名称:pyNastran,代码行数:103,代码来源:test_rods.py


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