Plot results#

PyDPF-Post provides functionality for plotting results. Here is a summary of the steps:

  1. Load the Simulation object with the result file.

  2. Request a DataFrame object to obtain the scalar field of interest.

  3. Use the plotting methods of the DataFrame object to render it.

Subsequent sections provide some plotting examples.

Total deformation#

You can plot the total deformation (norm of the displacement vector field) with:

Instantiate the solution object

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.download_crankshaft())

Instantiate a DataFrame object containing the displacement norm data

>>> displacement_norm = simulation.displacement(norm=True)

Plot the data and save the image

>>> displacement_norm.plot(screenshot="crankshaft_disp.png")
../_images/crankshaft_disp.png

Normal stresses#

Plotting of raw data at Gauss points is not available yet. You can however plot data averaged at nodes or elements. You can plot the nodal xx-component of stress with:

Instantiate the simulation object

>>> from ansys.dpf import post
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.download_crankshaft())

Extract the XX stress data

>>> stress_xx = simulation.stress_nodal(components=["XX"])

Plot the data and save the image

>>> stress_xx.plot(screenshot="crankshaft_stress_xx.png")
../_images/crankshaft_stress_xx.png