How to use pyansys - 10 common examples

To help you get started, we’ve selected a few pyansys examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github akaszynski / pyansys / tests / elements / shell181 / test_shell181.py View on Github external
def result():
    test_path = os.path.dirname(os.path.abspath(__file__))
    return pyansys.read_binary(os.path.join(test_path, 'shell181.rst'))
github akaszynski / pyansys / tests / test_rst.py View on Github external
try:
    pontoon = pyansys.download_pontoon()
except:
    pontoon = None


test_path = os.path.dirname(os.path.abspath(__file__))
testfiles_path = os.path.join(test_path, 'testfiles')

is16_filename = os.path.join(testfiles_path, 'is16.rst')
is16_known_result = os.path.join(testfiles_path, 'is16.npz')
if os.path.isfile(is16_filename):

    is16 = pyansys.read_binary(is16_filename)
else:
    is16 = None

temperature_rst = os.path.join(testfiles_path, 'temp_v13.rst')
temperature_known_result = os.path.join(testfiles_path, 'temp_v13.npz')

@pytest.fixture(scope='module')
def hex_rst():
    filename = os.path.join(testfiles_path, 'hex_201.rst')
    return pyansys.read_binary(filename)


@pytest.mark.skipif(vm33 is None, reason="Requires example files")
def test_write_tables(tmpdir):
    filename = str(tmpdir.mkdir("tmpdir").join('vm33.txt'))
    vm33.write_tables(filename)
github akaszynski / pyansys / tests / test_pyansys.py View on Github external
def test_loadbeam():
    linkresult_path = os.path.join(testfiles_path, 'link1.rst')
    linkresult = pyansys.read_binary(linkresult_path)
    assert np.any(linkresult.grid.cells)
github akaszynski / pyansys / tests / test_pyansys.py View on Github external
def result():
    return pyansys.read_binary(rstfile)
github akaszynski / pyansys / tests / test_emat.py View on Github external
def emat():
    emat_bin = pyansys.read_binary(emat_filename)
    assert isinstance(emat_bin, EmatFile)
    return emat_bin
github akaszynski / pyansys / tests / elements / shell181 / test_shell181_element_coord.py View on Github external
def test_shell_stress_element_cs():
    result = pyansys.read_binary(result_file_name)
    stress, enum, enode = result.element_stress(0, in_element_coord_sys=True)

    idx = np.where(enum == 118223)[0][0]
    assert np.allclose(KNOWN_RESULT_ENODE, enode[idx][:4])
    assert np.allclose(KNOWN_RESULT_STRESS, stress[idx], rtol=1E-4)
github akaszynski / pyansys / tests / test_cyclic.py View on Github external
ansys.Header('OFF', 'OFF', 'OFF', 'OFF', 'OFF', 'OFF')
    ansys.Format('', 'E', 80, 20)
    ansys.Page(1E9, '', -1)

    msg = ansys.Presol('S').splitlines()
    ansys_element_stress = []
    for line in msg:
        if len(line) == 201:
            ansys_element_stress.append(line)
    ansys_element_stress = np.genfromtxt(ansys_element_stress)
    ansys_enode = ansys_element_stress[:, 0].astype(np.int)
    ansys_element_stress = ansys_element_stress[:, 1:]

    """
    ansys_result_file = os.path.join(cyclic_testfiles_path, 'cyclic_v182.rst')
    result = pyansys.read_binary(ansys_result_file)

    element_stress, elemnum, enode = result.element_stress(0, False, False)
    assert np.allclose(np.sort(elemnum), elemnum), 'elemnum must be sorted'

    element_stress = np.vstack(element_stress)
    enode = np.hstack(enode)

    # cyclic model will only output the master sector
    from_ansys = np.load(os.path.join(cyclic_testfiles_path, 'v182_presol.npz'))
    assert np.allclose(from_ansys['enode'], enode)
    assert np.allclose(from_ansys['element_stress'], element_stress)
github akaszynski / pyansys / tests / plane_182_183 / test_archive_182_183.py View on Github external
def archive():
    filename = os.path.join(testfiles_path, 'archive.cdb')
    return pyansys.Archive(filename)
github akaszynski / pyansys / tests / archive / test_archive.py View on Github external
def test_read_mesh200():
    archive = pyansys.Archive(os.path.join(testfiles_path, 'mesh200.cdb'))
    assert archive.grid.n_cells == 1000
github akaszynski / pyansys / tests / test_corba.py View on Github external
def test_nodes(cleared, mapdl):
    mapdl.prep7()
    mapdl.cdread('db', pyansys.examples.sector_archive_file)
    archive = pyansys.Archive(pyansys.examples.sector_archive_file, parse_vtk=False)
    mapdl.nwrite('/tmp/ansys/tmp.nodes')
    assert np.allclose(mapdl.nodes, archive.nodes)