ANSYS DPF-Post: Harmonic Analysis

This tutorial shows how post-process a harmonic analysis result file using API of the DPF-POST module.

Get started

from ansys.dpf import post
from ansys.dpf.post import examples

Get the solution object

The following file is the result of a harmonic analysis computed using Ansys Mechanical.

Here we load the solution

solution = post.load_solution(examples.complex_rst)
print(solution)

Out:

Harmonic Analysis Solution object.


Data Sources
------------------------------
DPF  DataSources:
  Result files:
     result key: rst and path: /opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/site-packages/ansys/dpf/core/examples/complex.rst
  Secondary files:


DPF Model
------------------------------
Harmonic analysis
Unit system: Metric (m, kg, N, s, V, A)
Physics Type: Mecanic
Available results:
     -  displacement: Nodal Displacement
     -  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
     -  electric_potential: Nodal Electric Potential
------------------------------
DPF  Meshed Region:
  4802 nodes
  657 elements
  Unit: m
  With solid (3D) elements
------------------------------
DPF  Time/Freq Support:
  Number of sets: 1
  With complex values

Cumulative     Frequency (Hz) LoadStep       Substep        RPM
1              343478.200000  1              1              0.000000

This may contain complex results.

Get result objects

Get a displacement result

Get the result: it will contain a field for real values and a field for imaginary values.

disp_result = solution.displacement()
disp = disp_result.vector

Check the number of fields

disp.num_fields

Out:

2

Get data from a field

disp.get_data_at_field(0)

Out:

array([[ 2.65783929e-09, -5.98949034e-10,  8.34267891e-11],
       [ 2.63846617e-09, -3.00204960e-10,  8.27306877e-11],
       [ 2.50179982e-09, -2.86371281e-10,  6.29386453e-11],
       ...,
       [-1.70840238e-09, -2.73504676e-09,  3.48706947e-11],
       [-1.57038405e-09, -2.71125223e-09,  6.79105278e-11],
       [-1.57311157e-09, -2.71904943e-09,  0.00000000e+00]])

Get maximum data value over all fields

disp.max_data

Out:

array([[2.76941713e-09, 2.76940199e-09, 4.10914311e-10],
       [6.53706736e-13, 6.53416337e-13, 9.25220948e-14]])

Get minimum data value over all fields

disp.min_data

Out:

array([[-2.76946046e-09, -2.76952549e-09,  0.00000000e+00],
       [-6.53727285e-13, -6.53452004e-13, -1.66091913e-13]])

Get maximum data value over a targeted field

disp.get_max_data_at_field(0)

Out:

array([2.76941713e-09, 2.76940199e-09, 4.10914311e-10])

Get minimum data value over all fields

disp.get_min_data_at_field(0)

Out:

array([-2.76946046e-09, -2.76952549e-09,  0.00000000e+00])

Get a stress result and deals with amplitude

Get the result

stress_result = solution.stress()

Check if the support has complex frequencies

stress_result.has_complex_frequencies()

Out:

True

Get the tensor result

stress = stress_result.tensor
# shell and solid elements are in distinct fields.
# so we have four fields : the solid-real one, the solid-imaginary one,
# the shell-real one and the shell_imaginary one.
stress.num_fields

Out:

2

Get the shell field

shell_field = stress[0]
shell_field.shell_layers

Out:

<shell_layers.nonelayer: 5>

Get the solid field field

solid_field = stress[1]

Plot the amplitude contour

amplitude = stress_result.tensor_amplitude
amplitude.plot_contour()
03 harmonic analysis

Get an elastic_strain result and deals with phase

Get the result: it will contain a field for real values and a field for imaginary values.

elastic_strain_result = solution.elastic_strain()
elastic_strain = elastic_strain_result.tensor
# shell and solid elements are in distinct fields.
elastic_strain.num_fields

Out:

2

Deal with phase: phase unit is degree, phase must be a float.

es_at_phase = elastic_strain_result.tensor_at_phase(39.0)
es_at_phase.max_data
es_at_phase.num_fields
real_field = elastic_strain_result.tensor_at_phase(0.0)
img_field = elastic_strain_result.tensor_at_phase(90.0)

It is also possible to deal with plastic_strain and temperature this way. The result file must contain those results.

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

Gallery generated by Sphinx-Gallery