How to use the pyansys.examples.hexarchivefile function in pyansys

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 / test_write_archive.py View on Github external
def test_writehex(tmpdir):
    archive = pyansys.ReadArchive(examples.hexarchivefile)
    grid = archive.ParseVTK()

    temp_archive = str(tmpdir.mkdir("tmpdir").join('tmp.cdb'))
    pyansys.WriteArchive(temp_archive, grid)

    archive2 = pyansys.ReadArchive(temp_archive)
    grid2 = archive.ParseVTK()

    assert np.allclose(grid.points, grid2.points)
    assert np.allclose(grid.cells, grid2.cells)
github akaszynski / pyansys / tests / test_solid186.py View on Github external
def archive():
    return pyansys.Archive(examples.hexarchivefile)
github akaszynski / pyansys / tests / test_misc.py View on Github external
def test_quality():
    archive = pyansys.Archive(examples.hexarchivefile)
    grid = archive.grid
    qual = pyansys.quality(grid)
    assert (qual == 1).all()
github akaszynski / pyansys / tests / archive / test_archive.py View on Github external
def hex_archive():
    return pyansys.Archive(examples.hexarchivefile)
github akaszynski / pyansys / tests / test_database.py View on Github external
import pytest
import numpy as np
import pyansys

archive = pyansys.Archive(pyansys.examples.hexarchivefile)
d_v150 = pyansys.read_binary(pyansys.examples.hex_database_v150, debug=True)
d_v194 = pyansys.read_binary(pyansys.examples.hex_database_v194, debug=True)


@pytest.mark.parametrize('database', [d_v150, d_v194])
def test_nodes(database):
    assert np.allclose(database.nodes, archive.nodes[:, :3])


@pytest.mark.parametrize('database', [d_v150, d_v194])
def test_node_num(database):
    assert np.allclose(database.nnum, archive.nnum)


@pytest.mark.parametrize('database', [d_v150, d_v194])
def test_enum(database):
github akaszynski / pyansys / _downloads / 6200d60057fdffd1ad95288dc09aba29 / mapdl_3d_beam.py View on Github external
~~~~~~~~~~~~~~~~~~~~~

This is a simple example that loads an archive file containing a beam
and then runs a modal analysis using the simplified ``modal_analysis``
method.

"""

import os
from pyansys import examples
import pyansys

os.environ['I_MPI_SHM_LMT'] = 'shm'  # necessary on ubuntu
mapdl = pyansys.launch_mapdl(override=True)

mapdl.cdread('db', examples.hexarchivefile)
mapdl.esel('s', 'ELEM', vmin=5, vmax=20)
mapdl.cm('ELEM_COMP', 'ELEM')
mapdl.nsel('s', 'NODE', vmin=5, vmax=20)
mapdl.cm('NODE_COMP', 'NODE')

# boundary conditions
mapdl.allsel()

# dummy steel properties
mapdl.prep7()
mapdl.mp('EX', 1, 200E9)  # Elastic moduli in Pa (kg/(m*s**2))
mapdl.mp('DENS', 1, 7800)  # Density in kg/m3
mapdl.mp('NUXY', 1, 0.3)  # Poissons Ratio
mapdl.emodif('ALL', 'MAT', 1)

# fix one end of the beam
github akaszynski / pyansys / docs / index_functions.py View on Github external
# Load this from vtk
import vtki
grid = vtki.LoadGrid('hex.vtk')
grid.Plot()


#==============================================================================
# load beam results
#==============================================================================
# Load the reader from pyansys
import pyansys
from pyansys import examples

# Sample result file and associated archive file
rstfile = examples.rstfile
hexarchivefile = examples.hexarchivefile


# Create result reader object by loading the result file
result = pyansys.open_result(rstfile)

# Get beam natural frequencies
freqs = result.GetTimeValues()

# Get the node numbers in this result file
nnum = result.nnum

# Get the 1st bending mode shape.  Nodes are ordered according to nnum.
disp = result.GetResult(0, True) # uses 0 based indexing 

# Load CDB (necessary for display)
result.LoadArchive(hexarchivefile)
github akaszynski / pyansys / docs / index_functions.py View on Github external
#==============================================================================
# load a beam and write it
#==============================================================================
import pyansys
from pyansys import examples

# Sample *.cdb
filename = examples.hexarchivefile

# Read ansys archive file
archive = pyansys.Archive(filename)

# Print raw data from cdb
for key in archive.raw:
   print "%s : %s" % (key, archive.raw[key])

# Create a vtk unstructured grid from the raw data and plot it
archive.ParseFEM()
archive.uGrid.Plot()

# write this as a vtk xml file 
archive.save_as_vtk('hex.vtu')
github akaszynski / pyansys / examples / 01-mapdl-examples / mapdl_3d_beam.py View on Github external
~~~~~~~~~~~~~~~~~~~~~

This is a simple example that loads an archive file containing a beam
and then runs a modal analysis using the simplified ``modal_analysis``
method.

"""

import os
from pyansys import examples
import pyansys

os.environ['I_MPI_SHM_LMT'] = 'shm'  # necessary on ubuntu
mapdl = pyansys.launch_mapdl(override=True)

mapdl.cdread('db', examples.hexarchivefile)
mapdl.esel('s', 'ELEM', vmin=5, vmax=20)
mapdl.cm('ELEM_COMP', 'ELEM')
mapdl.nsel('s', 'NODE', vmin=5, vmax=20)
mapdl.cm('NODE_COMP', 'NODE')

# boundary conditions
mapdl.allsel()

# dummy steel properties
mapdl.prep7()
mapdl.mp('EX', 1, 200E9)  # Elastic moduli in Pa (kg/(m*s**2))
mapdl.mp('DENS', 1, 7800)  # Density in kg/m3
mapdl.mp('NUXY', 1, 0.3)  # Poissons Ratio
mapdl.emodif('ALL', 'MAT', 1)

# fix one end of the beam
github akaszynski / pyansys / pyansys / examples / examples.py View on Github external
# System natural frequencies
    f = (np.real(w))**0.5 / (2 * np.pi)

    # %% Plot result

    # Get the 4th mode shape
    full_mode_shape = v[:, 3]  # x, y, z displacement for each node

    # reshape and compute the normalized displacement
    disp = full_mode_shape.reshape((-1, 3))
    n = (disp * disp).sum(1)**0.5
    n /= n.max()  # normalize

    # load an archive file and create a vtk unstructured grid
    archive = pyansys.Archive(pyansys.examples.hexarchivefile)
    grid = archive.grid

    # Fancy plot the displacement
    pl = pv.Plotter()

    # add two meshes to the plotting class
    pl.add_mesh(grid.copy(), color='w', style='wireframe')
    pl.add_mesh(grid, scalars=n, stitle='Normalized\nDisplacement',
                flip_scalars=True, cmap='jet')
    # Update the coordinates by adding the mode shape to the grid
    pl.update_coordinates(grid.points + disp / 80, render=False)
    pl.add_text('Cantliver Beam 4th\nMode Shape at\n{:.4f}'.format(f[3]),
                font_size=30)
    pl.plot()