Skip to main content

Reconstructing specific APDL results with DPF

| 09.02.2022

This week’s Script Tip comes from Pierre Thieffry, Senior Principal R&D Engineer at Ansys.

While Mechanical offers a wide coverage of the capabilities available in our Structural solver, there are occasions where you will not find a specific result. Recently, a customer was asking for the ability to display SDSG results in Mechanical.

What is SDSG? Well, the documentation says, ‘Absolute value of the maximum variation of any nodal stress component’. In other words, SDSG is an element quantity that is the maximum difference between the nodal average value and the elemental nodal value for all nodes of the element (for all components of stress). This could for example help assess how well your results are converged and where you need to pay attention to your results

This very specific result is not available in standard. But DPF (the Data Processing Framework I was mentioning in an earlier Script Tip Friday) is there to help in such situations.

If we look at the definition of SDSG, we see two components in it: the nodal averaged values and the elemental nodal value for all nodes. Both results are standard results available through DPF (the following example is meant to be run in Mechanical):

dataSource = dpf.DataSources(your_result_file)

# Elemental nodal

stresses = 


# Nodal averaged



So we just need to get the difference between both fields and we’ll be done. Yet this is not as simple as computing stresses_field-stresses_nodal_field since one field carries one value per node per element (so multiple values for a given node) and the other one carries one value per node. To work around this, we are going to create a new tensor field that will have the values of the nodal averaged field but defined on each node of each element. Then we’ll just have to perform the subtraction.

# New field to compute difference




# Loop over elements and their corner nodes

for el in elems:


# for each node, get nodal averaged value and affect it to new tensor field

for nid in nodes:



# compute stress difference


Are we done? Not entirely. SDSG is an elemental quantity — so one value per element. There is a final step to take: for each element, compute the maximum (absolute) value of the above difference. Here again, we create a new scalar field on elemental location and simply find the value we are looking for.

# sdsg to compute difference



for el in elems:





Et voilà! We’ve reconstructed our results. Checking on a very simple model shows that both APDL results and our DPF result match.

Static structural Python result and SDSG test
Static Structural Python Result and SDSG Test