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 solution object.


Data Sources
------------------------------
DPF  DataSources:
  Result files:
     result key: rst and path: c:\hostedtoolcache\windows\python\3.8.10\x64\lib\site-packages\ansys\dpf\core\examples\complex.rst
  Secondary files:


DPF Model
------------------------------
DPF Result Info
  Analysis: harmonic
  Physics Type: mecanic
  Unit system: MKS: m, kg, N, s, V, A, degC
  Available results:
    U Displacement :nodal displacements
    RF Force :nodal reaction forces
    S Stress :element nodal component stresses
    ENG_VOL Volume :element volume
    ENG_SE Energy-stiffness matrix :element energy associated with the stiffness matrix
    ENG_AHO Hourglass Energy :artificial hourglass energy
    ENG_TH thermal dissipation energy :thermal dissipation energy
    ENG_KE Kinetic Energy :kinetic energy
    ENG_CO co-energy :co-energy (magnetics)
    ENG_INC incremental energy :incremental energy (magnetics)
    EPEL Strain :element nodal component elastic strains
    BFE Temperature :element structural nodal temperatures
    VOLT Electric Potential :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.)
es_at_phase.max_data
es_at_phase.num_fields
real_field = elastic_strain_result.tensor_at_phase(0.)
img_field = elastic_strain_result.tensor_at_phase(90.)

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.668 seconds)

Gallery generated by Sphinx-Gallery