In an active MAPDL session, you can postprocess using the
an attribute of an instance of
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.
Perhaps 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.
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.
Enriched command output#
Mapdl class commands output
a string object that can be parsed to obtain specific data from it.
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
Extra methods available
Boundary Conditions Listing
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
You would typically request nodal results from MAPDL using the
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
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:
You can select entities such as nodes, or lines using the following methods:
These methods returns the ids of the selected entities. For example:
>>> selected_nodes = mapdl.nsel("S", "NODE", vmin=1, vmax=2000) >>> print(selected_nodes) array([ 1 2 3 ... 1998 1999 2000])
>>> mapdl.ksel("all") array([1, 2, 3, ..., 1998, 1999, 2000])
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
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 full list of all available postprocessing methods, see PostProcessing class.