Shaft Modal Analysis#

Visualize a shaft modal analysis

# sphinx_gallery_thumbnail_number = 6

from ansys.mapdl.reader import examples

# Download an example shaft modal analysis result file
shaft = examples.download_shaft_modal()

Mesh is stored within the result object

print(shaft.mesh)
ANSYS Mesh
  Number of Nodes:              27132
  Number of Elements:           25051
  Number of Element Types:      6
  Number of Node Components:    4
  Number of Element Components: 3

…and contains a VTK unstructured grid

print(shaft.mesh._grid)
None

Plot the shaft

cpos = shaft.plot()

# list shaft node components
load shaft result
print(shaft.element_components.keys())
dict_keys(['EBC1', 'EBC2', 'SHAFT_MESH'])

Plot a node component

This camera angle was saved interactively from shaft.plot

cpos = [
    (-115.35773008378118, 285.36602704380107, -393.9029392590675),
    (126.12852038381345, 0.2179228023931401, 5.236408799851887),
    (0.37246222812978824, 0.8468424028124546, 0.37964435122285495),
]
shaft.plot(element_components=["SHAFT_MESH"], cpos=cpos)
# get cpos from cpos = shaft.plot()
load shaft result

Plot a node component as a wireframe

shaft.plot(
    element_components=["SHAFT_MESH"], cpos=cpos, style="wireframe", lighting=False
)
load shaft result

Plot the shaft with edges and with a blue color

shaft.plot(show_edges=True, color="cyan")
load shaft result

Plot the shaft without lighting but with edges and with a blue color

shaft.plot(lighting=False, show_edges=True, color="cyan")
load shaft result

plot a mode shape without contours using the “bwr” color map

shaft.plot_nodal_solution(
    9,
    element_components=["SHAFT_MESH"],
    show_displacement=True,
    cmap="bwr",
    displacement_factor=0.3,
    stitle=None,
    overlay_wireframe=True,
    cpos=cpos,
)
load shaft result
/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/pyvista/plotting/_plotting.py:286: PyVistaDeprecationWarning:
"stitle" is a deprecated keyword argument and will be removed in a future
release.

Use ``scalar_bar_args`` instead.  For example:

scalar_bar_args={'title': 'Scalar Bar Title'}

  warnings.warn(USE_SCALAR_BAR_ARGS, PyVistaDeprecationWarning)

plot a mode shape with contours and the default colormap

shaft.plot_nodal_solution(
    1,
    element_components=["SHAFT_MESH"],
    n_colors=10,
    show_displacement=True,
    displacement_factor=1,
    stitle=None,
    overlay_wireframe=True,
    cpos=cpos,
)
load shaft result
/opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/pyvista/plotting/_plotting.py:286: PyVistaDeprecationWarning:
"stitle" is a deprecated keyword argument and will be removed in a future
release.

Use ``scalar_bar_args`` instead.  For example:

scalar_bar_args={'title': 'Scalar Bar Title'}

  warnings.warn(USE_SCALAR_BAR_ARGS, PyVistaDeprecationWarning)

Animate a mode of a component the shaft

Set loop==True to plot continuously. Disable movie_filename and increase n_frames for a smoother plot

shaft.animate_nodal_solution(
    5,
    element_components="SHAFT_MESH",
    comp="norm",
    displacement_factor=1,
    show_edges=True,
    cpos=cpos,
    loop=False,
    movie_filename="demo.gif",
    n_frames=30,
)
load shaft result
[(-115.35773008378118, 285.36602704380107, -393.9029392590675),
 (126.12852038381345, 0.2179228023931401, 5.236408799851887),
 (0.3724622281297882, 0.8468424028124544, 0.37964435122285484)]

Total running time of the script: (0 minutes 12.087 seconds)

Gallery generated by Sphinx-Gallery