Postprocessing#

In an active MAPDL session, you can postprocess using the Mapdl.post_processing class, an attribute of an instance of Mapdl. One advantage of this approach is that it integrates well with existing MAPDL scripting or automation. This approach can also be used on result files generated from other programs, including ANSYS Mechanical.

One of the biggest advantages of gRPC-based postprocessing is that it can be done remotely without any file exchange. Multi gigabyte result files can remain remote, with only the necessary data being streamed back to the client for review or visualization.

Note

You are encouraged to use the Data Processing Framework (DPF) modules at DPF-Core and DPF-Post because they provide a modern interface to Ansys result files using a client-server interface. They use the same software that is used within Ansys Workbench but via a Python client.

You would typically request nodal results from MAPDL using the PRNSOL command:

POST1:
PRNSOL, U, X

PRINT U    NODAL SOLUTION PER NODE

 ***** POST1 NODAL DEGREE OF FREEDOM LISTING *****

 LOAD STEP=     1  SUBSTEP=     1
  TIME=    1.0000      LOAD CASE=   0

 THE FOLLOWING DEGREE OF FREEDOM RESULTS ARE IN THE GLOBAL COORDINATE SYSTEM

   NODE       UX
      1  0.10751E-003
      2  0.85914E-004
      3  0.57069E-004
      4  0.13913E-003
      5  0.35621E-004
      6  0.52186E-004
      7  0.30417E-004
      8  0.36139E-004
      9  0.15001E-003
MORE (YES,NO OR CONTINUOUS)=

However, using an instance of the Mapdl class, you can instead request the nodal displacement:

>>> mapdl.set(1, 1)
>>> disp_x = mapdl.post_processing.nodal_displacement("X")
array([1.07512979e-04, 8.59137773e-05, 5.70690047e-05, ...,
       5.70333124e-05, 8.58600402e-05, 1.07445726e-04])

You could also plot the nodal displacement with this code:

>>> mapdl.post_processing.plot_nodal_displacement("X")
../_images/post_norm_disp.png

Normalized Displacement of a Cylinder from MAPDL#

Selecting entities#

The MAPDL database processes some results independently if nodes or elements are selected. If you have subselected a certain component and want to also limit the result of a certain output (nodal_displacement()), use the selected_nodes attribute to get a mask of the currently selected nodes:

>>> mapdl.nsel("S", "NODE", vmin=1, vmax=2000)
>>> mapdl.esel("S", "ELEM", vmin=500, vmax=2000)
>>> mask = mapdl.post_processing.selected_nodes

Postprocessing object methods#

For a list of all postprocessing methods, see PostProcessing class.

Enriched command output#

All Mapdl class commands output a string object that can be parsed to obtain specific data from it.

In certain Mapdl class commands the returned string contains some methods to process the output. These commands are listed in Table-1.

Table 1. Commands with extra processing methods in the output

Warning

If you use methods like Mapdl.nlist() , you might obtain a lower precision than using Mesh methods.

Here’s a simple example that demonstrates usage:

>>> from ansys.mapdl.core import launch_mapdl
>>> from ansys.mapdl.core import examples

>>> mapdl = launch_mapdl()
>>> example = examples.vmfiles["vm10"]
>>> mapdl.input(example)

>>> mapdl.slashsolu()
>>> mapdl.solve()

>>> mapdl.post1()
>>> cmd = mapdl.prnsol("U", "X")

# Output as a list.

>>> cmd.to_list()
[['1', '0.0000'], ['2', '0.0000']]

# Output as array.

>>> cmd.to_array()
array([[1., 0.],
       [2., 0.]])

# Output as dataframe.

>>> cmd.to_dataframe()
NODE   UX
0      1.0
1      2.0