Skip to main content
This Script Tip Friday is brought to you by Ayush Kumar who is a Senior Application Engineer here at Ansys. Ayush will cover how to plot Stress Gradient on a path normal to the selected face at the selected node using PyDPF. 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
Next, link your result file(.rst) and print out the model object. The :class:Model class helps to organize access methods for the result by keeping track of the operators and data sources # used by the result file.
Define the node_id normal to which a stress gradient should be plotted.
The following command prints the mesh unit
depth defines the path length / depth to which the path will penetrate. While defining depth make sure you use the correct mesh unit. delta defines distance between consecutive points on the path.
Get the meshed region
Get Equivalent stress fields container.
Define Nodal scoping. Make sure to define "Nodal" as the requested location, important for the normals operator.
Get Skin Mesh because normals operator requires Shells as input.
Get normal at a node using normals operator.
Normal vector is along the surface normal. We need to invert the vector using math.scale operator inwards in the geometry, to get the path direction.
Get Nodal coordinates, they serve as the first point on the line.
Create 3D line equation.
Create coordinates using 3D line equation.
Create Field for coordinates of the path.
Let’s now map results on the path.
Here, we request the mapped field data and its mesh
Create stress vs length chart.
To create a plot, we need to add both the meshes mesh_m - mapped mesh # mesh - original mesh