Ansys MAPDL Reader

raw JSON →
0.55.2 verified Fri May 01 auth: no python

Pythonic interface to read binary and ASCII result files (RST, RTH, etc.) generated by Ansys MAPDL. Version 0.55.2 supports Python 3.10+ and integrates with PyVista for 3D visualization. Active development under the PyAnsys project, with monthly releases.

pip install ansys-mapdl-reader
error ModuleNotFoundError: No module named 'ansys.mapdl'
cause Library not installed or conflicting with old 'pymapdl-reader' package.
fix
Run pip install ansys-mapdl-reader. If you had the old pymapdl-reader, uninstall first: pip uninstall pymapdl-reader.
error AttributeError: 'NoneType' object has no attribute 'nodal_displacement'
cause Trying to access results on an unread or empty result set.
fix
Ensure the file exists and is not corrupted. Check rst.n_results > 0 before accessing results.
error ValueError: could not convert string to float: '...'
cause Incorrect file format or corrupted header in ASCII result files (e.g., .rst converted incorrectly).
fix
Verify the file is a valid MAPDL binary result file. If it's ASCII, use ResultFile('file.rst', mode='ascii').
gotcha Reading files generated by MAPDL versions prior to 2021 R1 may require explicit encoding or handling of legacy binary formats. Use `ResultFile('file.rst', read_mesh=True)` to force mesh reading.
fix Pass `read_mesh=True` to constructor for older files.
deprecated The `save_as_vtk` method is deprecated in favor of using PyVista's `save` functionality. Direct VTK file export via this method may be removed in future releases.
fix Use `rst.plot()` or `rst.to_pyvista().save('output.vtk')` instead.
gotcha Plotting with Trame (web-based) requires additional setup. Ensure you have `trame` and `trame-vtk` installed, and set `PV_PLOT_USE_TRAME=true` or use the `use_trame` parameter.
fix Install with `pip install trame trame-vtk` and either set environment variable or pass `use_trame=True` to plotting functions.

Open a MAPDL result file and inspect basic properties.

from ansys.mapdl.reader import ResultFile

# Replace with your MAPDL result file path
rst = ResultFile('file.rst')
print(rst)
print('Number of results:', rst.n_results)

# Get mesh and solution at a specific result set
mesh = rst.mesh
result = rst.result(0)  # first set
print('Nodal displacements shape:', result.nodal_displacement.shape)