Harmonic Simulation#

In this script harmonic simulation is processed and complex results are used.

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_harmonic_clamped_pipe()
# to automatically detect the simulation type, use:
simulation = post.load_simulation(example_path)

# to enable auto-completion, use the equivalent:
simulation = post.HarmonicMechanicalSimulation(example_path)

# print the simulation to get an overview of what's available

print(simulation)
Harmonic Mechanical Simulation.


Data Sources
------------------------------
/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/harmonic/clamped_pipe.rst

DPF Model
------------------------------
Msup analysis
Unit system: NMM: mm, ton, N, s, mV, mA, degC
Physics Type: Mechanical
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
     -  element_euler_angles: ElementalNodal Element Euler Angles
     -  contact_status: ElementalNodal Contact Status
     -  contact_penetration: ElementalNodal Contact Penetration
     -  contact_pressure: ElementalNodal Contact Pressure
     -  contact_friction_stress: ElementalNodal Contact Friction Stress
     -  contact_total_stress: ElementalNodal Contact Total Stress
     -  contact_sliding_distance: ElementalNodal Contact Sliding Distance
     -  contact_gap_distance: ElementalNodal Contact Gap Distance
     -  total_heat_flux_at_contact_surface: ElementalNodal Total heat flux at contact surface
     -  contact_status_changes: ElementalNodal Contact status changes
     -  fluid_penetration_pressure: ElementalNodal Fluid Penetration Pressure
------------------------------
DPF  Meshed Region:
  9943 nodes
  5732 elements
  Unit: mm
  With solid (3D) elements, shell (2D) elements, shell (3D) elements
------------------------------
DPF  Time/Freq Support:
  Number of sets: 5
  With complex values

Cumulative     Frequency (Hz) LoadStep       Substep        RPM
1              2000.000000    1              1              0.000000
2              4000.000000    1              2              0.000000
3              6000.000000    1              3              0.000000
4              8000.000000    1              4              0.000000
5              10000.000000   1              5              0.000000

Extract displacement over a list of frequencies sets#

Printing the time freq support can help pick the right frequencies

print(simulation.time_freq_support)

displacement = simulation.displacement(set_ids=[1, 2])
print(displacement)

subdisp = displacement.select(complex=0, set_ids=1)
print(subdisp)
subdisp.plot(title="U tot real")

subdisp = displacement.select(complex=1, set_ids=1)
print(subdisp)
subdisp.plot(title="U tot imaginary")

subdisp = displacement.select(complex=0, set_ids=2)
print(subdisp)
subdisp.plot(title="U tot real")
  • 04 harmonic complex results
  • 04 harmonic complex results
  • 04 harmonic complex results
DPF  Time/Freq Support:
  Number of sets: 5
  With complex values

Cumulative     Frequency (Hz) LoadStep       Substep        RPM
1              2000.000000    1              1              0.000000
2              4000.000000    1              2              0.000000
3              6000.000000    1              3              0.000000
4              8000.000000    1              4              0.000000
5              10000.000000   1              5              0.000000


             results           U
             set_ids           1                      2
             complex           0          1           0          1
 node_ids components
     3548          X  9.3929e+01 0.0000e+00 -5.2330e+01 0.0000e+00
                   Y -4.3312e+02 0.0000e+00  1.8810e+02 0.0000e+00
                   Z  9.6172e-01 0.0000e+00 -1.3049e+01 0.0000e+00
     3656          X  1.0516e+02 0.0000e+00 -5.8461e+01 0.0000e+00
                   Y -4.6059e+02 0.0000e+00  2.0315e+02 0.0000e+00
                   Z  9.4728e-01 0.0000e+00 -1.3728e+01 0.0000e+00
      ...        ...         ...        ...         ...        ...


             results           U
             set_ids           1
             complex           0
 node_ids components
     3548          X  9.3929e+01
                   Y -4.3312e+02
                   Z  9.6172e-01
     3656          X  1.0516e+02
                   Y -4.6059e+02
                   Z  9.4728e-01
      ...        ...         ...


             results          U
             set_ids          1
             complex          1
 node_ids components
     3548          X 0.0000e+00
                   Y 0.0000e+00
                   Z 0.0000e+00
     3656          X 0.0000e+00
                   Y 0.0000e+00
                   Z 0.0000e+00
      ...        ...        ...


             results           U
             set_ids           2
             complex           0
 node_ids components
     3548          X -5.2330e+01
                   Y  1.8810e+02
                   Z -1.3049e+01
     3656          X -5.8461e+01
                   Y  2.0315e+02
                   Z -1.3728e+01
      ...        ...         ...

Extract stress eqv over a list of frequencies sets#

stress_eqv = simulation.stress_eqv_von_mises_nodal(set_ids=[1, 2])
print(stress_eqv)

sub_eqv = stress_eqv.select(complex=0, set_ids=1)
print(sub_eqv)
sub_eqv.plot(title="S_eqv real")

sub_eqv = stress_eqv.select(complex=1, set_ids=1)
print(sub_eqv)
sub_eqv.plot(title="S_eqv imaginary")

sub_eqv = stress_eqv.select(complex=0, set_ids=2)
print(sub_eqv)
sub_eqv.plot(title="S_eqv real")
  • 04 harmonic complex results
  • 04 harmonic complex results
  • 04 harmonic complex results
 results       S_VM
 set_ids          1                     2
 complex          0          1          0          1
node_ids
    3548 2.3945e+04 0.0000e+00 4.3578e+04 0.0000e+00
    3656 8.7565e+03 0.0000e+00 3.0708e+04 0.0000e+00
    4099 3.0310e+04 0.0000e+00 4.3383e+04 0.0000e+00
    3760 1.3355e+04 0.0000e+00 3.2525e+04 0.0000e+00
    3387 5.1281e+03 0.0000e+00 2.0660e+04 0.0000e+00
    3549 5.8202e+03 0.0000e+00 1.9550e+04 0.0000e+00
     ...        ...        ...        ...        ...


 results       S_VM
 set_ids          1
 complex          0
node_ids
    3548 2.3945e+04
    3656 8.7565e+03
    4099 3.0310e+04
    3760 1.3355e+04
    3387 5.1281e+03
    3549 5.8202e+03
     ...        ...


 results       S_VM
 set_ids          1
 complex          1
node_ids
    3548 0.0000e+00
    3656 0.0000e+00
    4099 0.0000e+00
    3760 0.0000e+00
    3387 0.0000e+00
    3549 0.0000e+00
     ...        ...


 results       S_VM
 set_ids          2
 complex          0
node_ids
    3548 4.3578e+04
    3656 3.0708e+04
    4099 4.3383e+04
    3760 3.2525e+04
    3387 2.0660e+04
    3549 1.9550e+04
     ...        ...

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

Gallery generated by Sphinx-Gallery