How do I Plot Stress Gradient on a Path Normal to the Selected Face at the Selected Node Using PyDPF?

Ansys Developer
Ansys Developer
Published in
1 min readOct 7, 2022

Today’s Script Tip comes from Ayush Kumar, Senior Applications Engineer at Ansys.

Sometimes for a better engineering decision, it is important to analyze results along the normal to a face. This PyDPF example shows you how to plot a stress gradient normal at a selected node on a face.

# Import necessary modules: 
###############################################################################
# First, import the DPF-Core module as ``dpf`` and import the
# included examples file and ``DpfPlotter``

import matplotlib.pyplot as plt
from ansys.dpf import core as dpf
from ansys.dpf.core import operators as ops
from ansys.dpf.core.plotter import DpfPlotter
from ansys.dpf.core import examples
###############################################################################
# Next, link your result file(.rst) and print out the ``model`` object. The
# :class:`Model <ansys.dpf.core.model.Model>` class helps to organize access
# methods for the result by keeping track of the operators and data sources
# used by the result file.
path = r”\Path\to\file.rst”
model = dpf.Model(path)
print(model)



###############################################################################
# Define the `node_id` normal to which a stress gradient should be plotted.
node_id = 1928
###############################################################################

--

--

Ansys Developer
Ansys Developer

The Ansys Developer Team writes about a variety of topics related to physics, engineering simulation, Python, AI/ML, and other developer topics.