.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/01-Detailed-Examples/01-named-selections-modal-simulation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_01-Detailed-Examples_01-named-selections-modal-simulation.py: .. _ref_ns_modal_example: Extract results on named selections - Modal Simulation ======================================================= In this script static simulation is processed to extract results like stress, displacement. Selecting sub parts of the results by scoping on specific nodes, elements is also displayed here. .. GENERATED FROM PYTHON SOURCE LINES 11-15 Perform required imports ------------------------ Perform required imports. # This example uses a supplied file that you can get by importing the DPF ``examples`` package. .. GENERATED FROM PYTHON SOURCE LINES 15-19 .. code-block:: Python from ansys.dpf import post from ansys.dpf.post import examples .. GENERATED FROM PYTHON SOURCE LINES 20-26 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. .. GENERATED FROM PYTHON SOURCE LINES 26-37 .. code-block:: Python example_path = examples.download_modal_frame() # to automatically detect the simulation type, use: simulation = post.load_simulation(example_path) # to enable auto-completion, use the equivalent: simulation = post.ModalMechanicalSimulation(example_path) # print the simulation to get an overview of what's available print(simulation) .. rst-class:: sphx-glr-script-out .. code-block:: none Modal Mechanical Simulation. Data Sources ------------------------------ /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/modal/frame.rst DPF Model ------------------------------ Modal analysis Unit system: NMM: mm, ton, N, s, mV, mA, degC Physics Type: Mechanical Available results: - displacement: Nodal Displacement - stress: ElementalNodal Stress - elastic_strain: ElementalNodal Strain - element_euler_angles: ElementalNodal Element Euler Angles ------------------------------ DPF Meshed Region: 5886 nodes 2842 elements Unit: mm With solid (3D) elements ------------------------------ 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 .. GENERATED FROM PYTHON SOURCE LINES 38-40 Get the available named selections ---------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: Python print(simulation.named_selections) .. rst-class:: sphx-glr-script-out .. code-block:: none ['BAR_1', 'BAR_2', 'FACES_INTERIOR_PINS', '_FIXEDSU'] .. GENERATED FROM PYTHON SOURCE LINES 44-46 Extract displacements on named selections ----------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 46-62 .. code-block:: Python bar1_tot_displacement = simulation.displacement(named_selections=["BAR_1"], norm=True) print(bar1_tot_displacement) bar1_tot_displacement.plot() bar2_tot_displacement = simulation.displacement(named_selections=["BAR_2"], norm=True) print(bar2_tot_displacement) bar2_tot_displacement.plot() # both tot_displacement = simulation.displacement( named_selections=["BAR_1", "BAR_2"], norm=True ) print(tot_displacement) tot_displacement.plot() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/01-Detailed-Examples/images/sphx_glr_01-named-selections-modal-simulation_001.png :alt: 01 named selections modal simulation :srcset: /examples/01-Detailed-Examples/images/sphx_glr_01-named-selections-modal-simulation_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/01-Detailed-Examples/images/sphx_glr_01-named-selections-modal-simulation_002.png :alt: 01 named selections modal simulation :srcset: /examples/01-Detailed-Examples/images/sphx_glr_01-named-selections-modal-simulation_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/01-Detailed-Examples/images/sphx_glr_01-named-selections-modal-simulation_003.png :alt: 01 named selections modal simulation :srcset: /examples/01-Detailed-Examples/images/sphx_glr_01-named-selections-modal-simulation_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none results U_N (mm) set_ids 1 node_ids 72 6.2179e-01 73 5.0563e-01 74 2.4093e-01 75 2.2909e-01 76 4.8153e-01 77 4.7876e+00 ... ... results U_N (mm) set_ids 1 node_ids 17 5.0483e-01 18 7.7196e-01 19 1.2061e+00 20 2.1481e+00 21 3.3862e+00 22 0.0000e+00 ... ... results U_N (mm) set_ids 1 node_ids 72 6.2179e-01 73 5.0563e-01 74 2.4093e-01 75 2.2909e-01 76 4.8153e-01 77 4.7876e+00 ... ... .. GENERATED FROM PYTHON SOURCE LINES 63-65 Extract stress and averaged stress on named selections ------------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 65-72 .. code-block:: Python eqv_stress = simulation.stress_eqv_von_mises_nodal(named_selections=["_FIXEDSU"]) print(eqv_stress) # without selection elemental_stress = simulation.stress_elemental(named_selections=["BAR_1"]) print(elemental_stress) elemental_stress.plot() .. image-sg:: /examples/01-Detailed-Examples/images/sphx_glr_01-named-selections-modal-simulation_004.png :alt: 01 named selections modal simulation :srcset: /examples/01-Detailed-Examples/images/sphx_glr_01-named-selections-modal-simulation_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none results S_VM (MPa) set_ids 1 node_ids 22 8.0765e+02 349 1.0934e+03 15 1.0859e+03 371 7.3710e+02 406 3.4030e+02 408 4.1398e+02 ... ... results S (MPa) set_ids 1 element_ids components 1137 XX 2.1033e+02 YY 1.4585e+02 ZZ 6.4862e+02 XY 7.8062e+00 YZ 3.9888e+01 XZ 1.3070e+01 ... ... ... .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.786 seconds) .. _sphx_glr_download_examples_01-Detailed-Examples_01-named-selections-modal-simulation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 01-named-selections-modal-simulation.ipynb <01-named-selections-modal-simulation.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01-named-selections-modal-simulation.py <01-named-selections-modal-simulation.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_