Note
Click here to download the full example code
Extract stress/strain invariants - Static Simulation#
In this script a static simulation is used as an example to show how to extract tensor’s invariants.
Perform required imports#
Perform required imports. # This example uses a supplied file that you can
get by importing the DPF examples
package.
from ansys.dpf import post
from ansys.dpf.post import examples
Get Simulation
object#
Get the Simulation
object that allows access to the result. The Simulation
object must be instantiated with the path for the result file. For example,
"C:/Users/user/my_result.rst"
on Windows or "/home/user/my_result.rst"
on Linux.
example_path = examples.download_crankshaft()
simulation = post.load_simulation(example_path)
# for no autocompletion, this line is equivalent to:
simulation = post.StaticMechanicalSimulation(example_path)
# print the simulation to get an overview of what's available
print(simulation)
Static Mechanical Simulation.
Data Sources
------------------------------
/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/ansys/dpf/core/examples/crankshaft/crankshaft.rst
DPF Model
------------------------------
Static analysis
Unit system: MKS: m, kg, N, s, V, A, degC
Physics Type: Mechanical
Available results:
- displacement: Nodal Displacement
- velocity: Nodal Velocity
- acceleration: Nodal Acceleration
- reaction_force: Nodal Force
- stress: ElementalNodal Stress
- elemental_volume: Elemental Volume
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
- artificial_hourglass_energy: Elemental Hourglass Energy
- thermal_dissipation_energy: Elemental thermal dissipation energy
- kinetic_energy: Elemental Kinetic Energy
- co_energy: Elemental co-energy
- incremental_energy: Elemental incremental energy
- elastic_strain: ElementalNodal Strain
- structural_temperature: ElementalNodal Temperature
------------------------------
DPF Meshed Region:
69762 nodes
39315 elements
Unit: m
With solid (3D) elements
------------------------------
DPF Time/Freq Support:
Number of sets: 3
Cumulative Time (s) LoadStep Substep
1 1.000000 1 1
2 2.000000 1 2
3 3.000000 1 3
Extract elemental nodal stress and strain#
stress = simulation.stress(all_sets=True)
print(stress)
strain = simulation.elastic_strain(all_sets=True)
print(strain)
results S
set_ids 1 2 3
element_ids components
18357 XX (1) 2.7979e+06 4.3949e+06 4.6183e+06
YY (1) 8.6092e+06 2.8565e+07 5.9405e+07
ZZ (1) -1.0166e+07 -2.6681e+06 2.2825e+07
XY (1) 5.9477e+05 7.8847e+05 -3.5088e+05
YZ (1) -1.9866e+08 -3.9727e+08 -5.9452e+08
XZ (1) -6.6205e+06 -4.0082e+06 7.6945e+06
...
results EPEL
set_ids 1 2 3
element_ids components
18357 XX (1) 1.6326e-05 -1.6871e-05 -1.0025e-04
YY (1) 5.4098e-05 1.4024e-04 2.5586e-04
ZZ (1) -6.7943e-05 -6.2781e-05 1.8092e-05
XY (1) 7.7320e-06 1.0250e-05 -4.5614e-06
YZ (1) -2.5826e-03 -5.1645e-03 -7.7287e-03
XZ (1) -8.6066e-05 -5.2106e-05 1.0003e-04
...