Note
Go to the end to download the full example code.
Use result helpers to load custom data#
The Result class, which is an instance
created by the Model, gives
access to helpers for requesting results on specific mesh and time scopings.
With these helpers, working on a custom spatial and temporal subset of the
model is straightforward.
# Import necessary modules
from ansys.dpf import core as dpf
from ansys.dpf.core import examples
Create a model object to establish a connection with an example result file:
DPF Model
------------------------------
Modal analysis
Unit system: MKS: m, kg, N, s, V, A, degC
Physics Type: Mechanical
Available results:
- node_orientations: Nodal Node Euler Angles
- displacement: Nodal Displacement
- stress: ElementalNodal Stress
- elastic_strain: ElementalNodal Strain
- elastic_strain_eqv: ElementalNodal Strain eqv
- element_orientations: ElementalNodal Element Euler Angles
- structural_temperature: ElementalNodal Structural temperature
------------------------------
DPF Meshed Region:
3595 nodes
1557 elements
Unit: m
With solid (3D) elements
------------------------------
DPF Time/Freq Support:
Number of sets: 6
Cumulative Frequency (Hz) LoadStep Substep Harmonic index
1 188.385357 1 1 0.000000
2 325.126418 1 2 0.000000
3 595.320548 1 3 0.000000
4 638.189511 1 4 0.000000
5 775.669703 1 5 0.000000
6 928.278013 1 6 0.000000
Visualize specific mode shapes#
Choose the modes to visualize:
Choose a spatial subset#
Work on only a named selection (or component).
Print the available named selection:
print(model.metadata.available_named_selections)
['BC', 'ELM', 'STAG1', 'STAG1HIGH', 'STAG1LOW', 'STAG2', 'STAG2HIGH', 'STAG2LOW', '_BC_NOD', '_FIXEDSU', '_INTF_ELM', '_INTF_NOD', '_NOD', '_STAG1_BASE_ELM', '_STAG1_BASE_NOD', '_STAG1_CYCHIGH_NOD', '_STAG1_CYCLOW_NOD', '_STAG2_BASE_ELM', '_STAG2_BASE_NOD', '_STAG2_CYCHIGH_NOD', '_STAG2_CYCLOW_NOD']
Specify to the result that you want to work on a specific named selection:



Specify to the result that you want to work on specific nodes:



Total running time of the script: (0 minutes 5.320 seconds)