Skip to main content
Ctrl+K
Logo image Logo image

Site Navigation

  • Getting started
  • User guide
  • API reference
  • Examples
  • Contribute

Navigation

  • PyAnsys »
  • PyDPF-Post »
  • Examples »
  • PyDPF-Post analysis types »
  • Modal Simulation

Site Navigation

  • Getting started
  • User guide
  • API reference
  • Examples
  • Contribute

Section Navigation

  • PyDPF-Post analysis types
    • Static Simulation
    • Modal Simulation
    • Transient Simulation with Animation
    • Harmonic Simulation
  • PyDPF-Post feature examples
  • PyDPF-Post legacy examples

Note

Click here to download the full example code

Modal Simulation#

Simple post processing operations like viewing the different mode shapes is displayed in this example.

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_modal_frame()
simulation = post.load_simulation(example_path)

# for no autocompletion, this line is equivalent to:
simulation = post.ModalMechanicalSimulation(example_path)

View the frequency domain#

Printing the time freq support can help pick the right modes

print(simulation.time_freq_support)

# set_ids returns the unique identifiers for the modes
print(simulation.set_ids)
DPF  Time/Freq Support:
  Number of sets: 6
Cumulative     Frequency (Hz) LoadStep       Substep
1              253.615690     1              1
2              317.918491     1              2
3              329.825709     1              3
4              575.619678     1              4
5              621.973976     1              5
6              667.364882     1              6

[1, 2, 3, 4, 5, 6]

Extract all mode shapes and view them one by one#

displacement_norm = simulation.displacement(all_sets=True, norm=True)
print(displacement_norm)

for set_id in simulation.set_ids:
    displacement_norm.plot(set_ids=set_id)
  • 02 modal simulation
  • 02 modal simulation
  • 02 modal simulation
  • 02 modal simulation
  • 02 modal simulation
  • 02 modal simulation
             results           U
             set_ids           1           2           3           4           5           6
node_ids  components
     367           X  1.3730e+00  1.8709e+00  2.0199e+00  2.2695e+00  2.9911e+00  1.2970e+00
                   Y  1.9036e+00  2.5893e+00  2.5942e+00  3.0953e+00  4.0005e+00  1.2648e+00
                   Z  1.0166e+00  1.4147e+00  1.5069e+00  1.8534e+00  2.3165e+00  7.5843e-01
     509           X  1.0461e+00  1.4141e+00  1.4841e+00  1.8647e+00  2.2996e+00  8.1520e-01
                   Y  1.6226e+00  2.2226e+00  2.2954e+00  2.6685e+00  3.4864e+00  1.2905e+00
                   Z  1.4089e+00  1.9743e+00  1.9950e+00  2.4323e+00  3.1554e+00  9.2167e-01
     ...

Extract a selection of mode shapes and view them one by one#

modes = [1, 2, 3]

displacement_norm = simulation.displacement(modes=modes, norm=True)
print(displacement_norm)

for set_id in modes:
    displacement_norm.plot(set_ids=set_id)
  • 02 modal simulation
  • 02 modal simulation
  • 02 modal simulation
             results           U
             set_ids           1           2           3
node_ids  components
     367           X  1.3730e+00  1.8709e+00  2.0199e+00
                   Y  1.9036e+00  2.5893e+00  2.5942e+00
                   Z  1.0166e+00  1.4147e+00  1.5069e+00
     509           X  1.0461e+00  1.4141e+00  1.4841e+00
                   Y  1.6226e+00  2.2226e+00  2.2954e+00
                   Z  1.4089e+00  1.9743e+00  1.9950e+00
     ...

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

Download Python source code: 02-modal-simulation.py

Download Jupyter notebook: 02-modal-simulation.ipynb

Gallery generated by Sphinx-Gallery

On this page
  • Perform required imports
  • Get Simulation object
  • View the frequency domain
  • Extract all mode shapes and view them one by one
  • Extract a selection of mode shapes and view them one by one
Show Source

© Copyright (c) 2023 ANSYS, Inc. All rights reserved.

Built with the PyData Sphinx Theme 0.12.0.

Created using Sphinx 5.3.0.