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


Python BDF.read_bdf方法代码示例

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


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

示例1: run_fem2

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import read_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: test_combo_1

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import read_bdf [as 别名]
    def test_combo_1(self):
        model = BDF(debug=False, log=None)
        bdfname = os.path.join(testpath, 'test_mass.dat')
        model.read_bdf(bdfname, include_dir=None, xref=True)

        # these are valid
        eids, mass = model.elements.get_mass_by_element_id([8, 9])
        print('massA = %s' % mass)
        eids, mass = model.elements.get_mass_by_element_id(range(1, 10))
        print('massB = %s' % mass)

        # no analysis - out of range
        elements = model.elements[[100000, 100001]]
        eids, mass = model.elements.get_mass_by_element_id(range(100000, 100005))
        print('elementsC = %s' % eids)
        print('massC = %s' % mass)

        eids, mass = model.elements.get_mass_by_element_id(range(-10, -5))
        print('elementsD = %s' % eids)
        print('massD = %s' % mass)

        print('-------------------------')
        eids, mass = model.elements.get_mass_by_element_id(range(-3, 20))
        print('massE = %s' % mass)
        print('eidsE = %s' % eids)
        print('\neid   mass')
        print('----------')
        for eidi, massi in zip(eids, mass):
            print('%-5s %-5s' % (eidi, massi))
开发者ID:umvarma,项目名称:pynastran,代码行数:31,代码来源:test_mass.py

示例3: test_bad_01

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import read_bdf [as 别名]
    def test_bad_01(self):
        model = BDF(debug=False, log=None)
        bdfname = os.path.join(testpath, 'test_mass.dat')
        model.read_bdf(bdfname, include_dir=None, xref=True)

        # this passes silently
        print(model.elements[['cat']])

        # this does not
        with self.assertRaises(TypeError):
            print(model.elements[None])

        #print(model.get_elements('cat'))
        with self.assertRaises(KeyError):
            model.get_elements('cat')
开发者ID:umvarma,项目名称:pynastran,代码行数:17,代码来源:test_mass.py

示例4: test_mass_solid_1

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import read_bdf [as 别名]
    def test_mass_solid_1(self):  # passes
        model = BDF(debug=False, log=None)
        bdfname = os.path.join(testpath, 'test_mass.dat')
        model.read_bdf(bdfname, xref=True)

        # hexa - psolid - nsm = 0
        #print(model.elements[7:8])
        #print(model.elements[[7,8]])
        model.elements[7:9]
        model.elements[7:9:2]
        model.elements[1:100]
        #hexa = model.get_elements(7)
        #hexa = model.get_elements(7)
        #print(hexa)
        hexa = model.elements[7]
        print('hexa =', hexa)
        mass = 0.2
        volume = 2. # l * w * h = 1 * 1 * 2
        rho = 0.1
        E = 1.0
        G = 2.0
        nu = 3.0
        centroid = array([0.5, 0.5, 1.0])
        self.verify_psolid_element(hexa, mass, volume, centroid, rho, E, G, nu)

        # tetra - psolid
        tetra = model.elements[8]
        mass = 1/30.
        volume = 1/3. # 1/3 * b * h = 1/3 * 0.5 * 2.0
        rho = 0.1
        E = 1.0
        G = 2.0
        nu = 3.0
        centroid = array([0.5, 0.25, 0.5])
        self.verify_psolid_element(tetra, mass, volume, centroid, rho, E, G, nu)

        # penta - psolid
        penta = model.elements[9]
        mass = 0.1
        volume = 1.0 # b * h = 0.5 * 2
        rho = 0.1
        E = 1.0
        G = 2.0
        nu = 3.0
        centroid = array([2/3., 1/3., 1.])
        self.verify_psolid_element(penta, mass, volume, centroid, rho, E, G, nu)
开发者ID:hurlei,项目名称:pyNastran,代码行数:48,代码来源:test_mass.py

示例5: run_fem2

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import read_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

示例6: bdf_renumber

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

#.........这里部分代码省略.........
            suport_id = int(value)
        elif key == 'suport1_id':
            suport1_id = int(value)
        elif key == 'tf_id':
            tf_id = int(value)
        else:
            raise NotImplementedError('key=%r' % key)

    # build the maps
    #eid_map = {}
    #nid_map = {}
    #reverse_nid_map = {}
    #pid_map = {}
    #mid_map = {}
    #mpc_map = {}
    #spc_map = {}
    dload_map = {}
    load_map = {}

    cmethod_map = {}
    method_map = {}
    #flfact_map = {}
    #flutter_map = {}
    #aefact_map = {}
    #freq_map = {}
    tstep_map = {}
    tstepnl_map = {}
    suport_map = {}
    suport1_map = {}

    if isinstance(bdf_filename, string_types):
        model = BDF(debug=False)
        model.disable_cards(cards_to_skip)
        model.read_bdf(bdf_filename)
    else:
        model = bdf_filename

    elements = [
        model.celas1,
        model.celas2,
        model.celas3,
        model.celas4,
        #model.cdamp1,
        #model.cdamp2,
        #model.cdamp3,
        #model.cdamp4,
        model.conrod,
        model.crod,
        model.ctube,
        model.cbar,
        model.cbeam,
        model.cshear,

        model.cquad4,
        model.ctria3,
        model.cquad8,
        model.ctria6,
        #model.ctriax,
        model.ctriax6,
        model.ctetra4, model.ctetra10,
        model.cpenta6, model.cpenta15,
        #model.cpyram5, model.cpyram13,
        model.chexa8, model.chexa20,
    ]
    props = [
        model.pelas,
开发者ID:hurlei,项目名称:pyNastran,代码行数:70,代码来源:bdf_renumber.py

示例7: test_mass_shell_1

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import read_bdf [as 别名]
    def test_mass_shell_1(self):  # passes
        model = BDF(debug=False, log=None)
        bdfname = os.path.join(testpath, 'test_mass.dat')
        model.read_bdf(bdfname, include_dir=None, xref=True)

        ###########
        # QUADS
        centroid = array([.5, .5, 0.])
        normal = array([.0, .0, 1.])
        ###########
        # quad - pcomp
        quad = model.elements[1]
        prop = model.properties_shell.pcomp[quad.property_id]
        #mat = model.properties_shell.pshell[prop.material_id]
        mass = 0.12
        area = 1.0
        nsm = 0.
        thickness = 0.7
        rho1 = 0.1
        rho10 = 0.2
        t1 = 0.1
        t10 = 0.5
        # there are two layers of t1
        mpa = (2. * rho1 * t1 + rho10 * t10) + nsm
        mass2 = mpa * area
        assert allclose(mass, mass2), 'mass=%s mass2=%s diff=%s' % (mass, mass2, abs(mass - mass2))
        self.verify_pcomp_element(quad, prop, nsm, thickness, mass, area, centroid, normal)

        rho = None

        # quad - pshell, nsm=0
        eid = 3
        pid = 2
        quad = model.elements[eid]
        prop = model.properties_shell.pshell[pid]
        mat = model.materials[prop.material_id]
        rho = 0.1
        mass = 0.0125
        t = 0.125
        nsm = 0.
        area = 1.
        mass2 = area * (rho * t + nsm)
        assert allclose(mass, mass2), 'eid=%s pid=%s mass=%s mass2=%s diff=%s\n%s%s%s\nrho=%s A=%s t=%s nsm=%s' % (
            eid, pid, mass, mass2, abs(mass - mass2), quad, prop, mat, rho, area, t, nsm)
        centroid = array([.5, .5, 0.])
        normal = array([.0, .0, 1.])
        self.verify_pshell_element(quad, prop, mat, rho, mass, area, centroid, normal, nsm)

        # quad - pshell, nsm=1
        quad = model.elements[5]
        prop = model.properties_shell.pshell[quad.property_id]
        mat = model.properties_shell.pshell[prop.material_id]
        mass = 1.0125 # mass w/o nsm + 1.0 b/c area=1
        nsm = 1.
        self.verify_pshell_element(quad, prop, mat, rho, mass, area, centroid, normal, nsm)

        ###########
        # TRIS
        centroid = array([2., 1., 0.]) / 3.
        normal   = array([.0, .0, 1.])
        ###########
        # tri - pcomp
        tri = model.elements[2]
        prop = model.properties_shell.pcomp[tri.property_id]
        #mat = model.properties_shell.pshell[prop.material_id]
        mass = 0.06
        area = 0.5
        nsm = 0.
        thickness = 0.7
        self.verify_pcomp_element(tri, prop, nsm, thickness, mass, area, centroid, normal)

        # tri - pshell, nsm=0
        tri = model.elements[4]
        prop = model.properties_shell.pshell[tri.property_id]
        mat = model.properties_shell.pshell[prop.material_id]
        mass = 0.00625
        nsm = 0.
        self.verify_pshell_element(tri, prop, mat, rho, mass, area, centroid, normal, nsm)

        # tri - pshell, nsm=1
        tri = model.elements[6]
        prop = model.properties_shell.pshell[tri.property_id]
        mat = model.properties_shell.pshell[prop.material_id]
        mass = 0.50625 # mass w/o nsm + 0.5 b/c area=0.5
        nsm = 1.
        self.verify_pshell_element(tri, prop, mat, rho, mass, area, centroid, normal, nsm)
开发者ID:umvarma,项目名称:pynastran,代码行数:88,代码来源:test_mass.py

示例8: run

# 需要导入模块: from pyNastran.bdf.dev_vectorized.bdf import BDF [as 别名]
# 或者: from pyNastran.bdf.dev_vectorized.bdf.BDF import read_bdf [as 别名]
def run(bdf_filename):
    # http://www.3dpanelmethod.com/documents/Graduate%20Work.pdf
    model = BDF()
    model.read_bdf(bdf_filename)


    grids = model.grid
    #print(list(grids.node_id))
    xyz_global = grids.get_position_by_node_index()

    tris = model.elements.elements_shell.ctria3
    quads = model.elements.elements_shell.cquad4

    if tris.n:
        et = tris.element_id
        pt = tris.property_id
        At = tris.get_area_by_element_index()
        nt = tris.get_normal_by_element_index()
        ct = tris.get_centroid_by_element_index()

        #i = arange(tris.n)
        #n1, n2, n3 = tris._node_locations(xyz_cid0, i)
        # n3 = n4
        # is this right?
        #ut = (n1 + n2 - 2 * n3) / 2.
        #pt = (n2 - n1) / 2.
        #ot = cross(nt, ut)
    if quads.n:
        eq = quads.element_id
        pq = quads.property_id
        Aq = quads.get_area_by_element_index()
        nq = quads.get_normal_by_element_index()
        cq = quads.get_centroid_by_element_index()

        i = arange(quads.n)
        #n1, n2, n3, n4 = quads._node_locations(xyz_cid0, i)
        #uq = (n1 + n2 - n3 - n4) / 2.
        #pq = (n2 + n3 - n4 - n1) / 2.
        #oq = cross(nq, uq)

    if tris.n and quads.n:
        e = hstack([et, eq])
        p = hstack([pt, pq])
        A = hstack([At, Aq])
        n = hstack([nt, nq])
        c = hstack([ct, cq])
        o = hstack([ot, oq])
    elif tris.n:
        e = et
        p = pt
        A = At
        n = nt
        c = ct
        #o = ot
    elif quads.n:
        e = eq
        p = pq
        A = Aq
        n = nq
        c = cq
        #o = oq

    bcs = {}
    for key, set3i in iteritems(model.set3):
        if set3i.desc == 'ELEM':
            bcs[key] = set3i.IDs

    #A = array([1, 2, 3, 4, 5], dtype='float32')
    nelements = len(e)
    #print('c.shape', c.shape)

    # could we take advantage of upper triangular matrix?
    # it's a factor of 2 speedup, which is pretty minor relative to the
    # added code complexity
    #
    # we split the x, y, z components to make it easier to run our calculations
    csquarex = repeat(c[:, 0], nelements).reshape(nelements, nelements)
    csquarey = repeat(c[:, 1], nelements).reshape(nelements, nelements)
    csquarez = repeat(c[:, 2], nelements).reshape(nelements, nelements)

    csquarex -= c[:, 0]
    csquarey -= c[:, 1]
    csquarez -= c[:, 2]

    # 2-norm
    dist = sqrt(csquarex**2 + csquarey**2 + csquarez**2)

    print('dist', dist, dist.shape)
开发者ID:ClaesFredo,项目名称:pyNastran,代码行数:90,代码来源:sub_vector.py


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