.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/05-Legacy/03-modal-analysis.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_05-Legacy_03-modal-analysis.py: .. _ref_modal_analysis: Postprocess the result file for a modal analysis ================================================ This example shows how to use the legacy PyDPF-Post API to postprocess the result file for a modal analysis. .. GENERATED FROM PYTHON SOURCE LINES 33-37 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 37-41 .. code-block:: Python from ansys.dpf import post from ansys.dpf.post import examples .. GENERATED FROM PYTHON SOURCE LINES 42-46 Get ``Solution`` object ----------------------- Get the ``Solution`` object. This example loads a result file for a modal analysis computed in Ansys Mechanical. .. GENERATED FROM PYTHON SOURCE LINES 46-53 .. code-block:: Python example_path = examples.download_all_kinds_of_complexity_modal() solution = post.load_solution(example_path) print(solution) .. rst-class:: sphx-glr-script-out .. code-block:: none Modal Analysis Solution object. Data Sources ------------------------------ DPF DataSources: Result files: result key: rst and path: /opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/testing/modal_allKindOfComplexity.rst Secondary files: DPF Model ------------------------------ Modal analysis Unit system: MKS: m, kg, N, s, V, A, degC Physics Type: Mechanical Available results: - displacement: Nodal Displacement - reaction_force: Nodal Force - smisc: Elemental Elemental Summable Miscellaneous Data - element_nodal_forces: ElementalNodal Element nodal Forces - stress: ElementalNodal Stress - elemental_volume: Elemental Volume - stiffness_matrix_energy: Elemental Energy-stiffness matrix - artificial_hourglass_energy: Elemental Hourglass Energy - kinetic_energy: Elemental Kinetic Energy - co_energy: Elemental co-energy - incremental_energy: Elemental incremental energy - thermal_dissipation_energy: Elemental thermal dissipation energy - elastic_strain: ElementalNodal Strain - elastic_strain_eqv: ElementalNodal Strain eqv - element_orientations: ElementalNodal Element Euler Angles - nmisc: Elemental Elemental Non Summable Miscellaneous Data - structural_temperature: ElementalNodal Structural temperature ------------------------------ DPF Meshed Region: 2388 nodes 1836 elements Unit: m With solid (3D) elements, shell (2D) elements, shell (3D) elements, beam (1D) elements ------------------------------ DPF Time/Freq Support: Number of sets: 45 Cumulative Frequency (Hz) LoadStep Substep 1 4800.665229 1 1 2 6472.119402 1 2 3 10094.813112 1 3 4 15408.070193 1 4 5 19935.616102 1 5 6 30659.224027 1 6 7 33485.028985 1 7 8 40514.020302 1 8 9 41144.836724 1 9 10 41696.364343 1 10 11 42568.142453 1 11 12 48803.935725 1 12 13 51557.014600 1 13 14 54829.807966 1 14 15 55121.065060 1 15 16 55481.661956 1 16 17 55779.054274 1 17 18 56346.453210 1 18 19 56598.396154 1 19 20 57504.056787 1 20 21 57768.209089 1 21 22 60135.893137 1 22 23 62336.016111 1 23 24 62809.029190 1 24 25 64186.171203 1 25 26 64911.479227 1 26 27 66488.724651 1 27 28 66728.182829 1 28 29 67521.333063 1 29 30 68699.230845 1 30 31 70108.268581 1 31 32 71432.124756 1 32 33 71784.765113 1 33 34 73189.275762 1 34 35 74862.553459 1 35 36 75051.318416 1 36 37 76335.025905 1 37 38 76631.728520 1 38 39 76956.786796 1 39 40 77754.144888 1 40 41 78460.122703 1 41 42 78721.878185 1 42 43 79330.520798 1 43 44 80301.992725 1 44 45 80835.840814 1 45 This may contain complex results. .. GENERATED FROM PYTHON SOURCE LINES 54-56 Get ``Result`` objects ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 58-62 Get displacement result ~~~~~~~~~~~~~~~~~~~~~~~ The displacement result contains a field for real values and a field for imaginary values. .. GENERATED FROM PYTHON SOURCE LINES 62-66 .. code-block:: Python disp_result = solution.displacement() disp = disp_result.vector .. GENERATED FROM PYTHON SOURCE LINES 67-69 Get number of fields ~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 69-72 .. code-block:: Python disp.num_fields .. rst-class:: sphx-glr-script-out .. code-block:: none 1 .. GENERATED FROM PYTHON SOURCE LINES 73-75 Get data from a field ~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 75-78 .. code-block:: Python disp.get_data_at_field(0) .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([[-1.17102876, -1.30206342, -1.1938849 ], [-1.69750554, -1.68258886, -0.76327262], [-2.24465543, -2.66699745, -1.36365734], ..., [ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]], shape=(2352, 3)) .. GENERATED FROM PYTHON SOURCE LINES 79-81 Get maximum data value over all fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 81-84 .. code-block:: Python disp.max_data .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([[3.63870030e+05, 8.31378342e+20, 5.99358159e+21]]) .. GENERATED FROM PYTHON SOURCE LINES 85-87 Get minimum data value over all fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 87-90 .. code-block:: Python disp.min_data .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([[-3.55151557e+05, -8.31378342e+20, -5.99358159e+21]]) .. GENERATED FROM PYTHON SOURCE LINES 91-93 Get maximum data value over targeted field ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 93-96 .. code-block:: Python disp.get_max_data_at_field(0) .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([3.63870030e+05, 8.31378342e+20, 5.99358159e+21]) .. GENERATED FROM PYTHON SOURCE LINES 97-99 Get minimum data value over all fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 99-102 .. code-block:: Python disp.get_min_data_at_field(0) .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([-3.55151557e+05, -8.31378342e+20, -5.99358159e+21]) .. GENERATED FROM PYTHON SOURCE LINES 103-107 Get stress result ~~~~~~~~~~~~~~~~~ Get a stress result that deals with amplitude. It contains a field for real values and a field for imaginary values. .. GENERATED FROM PYTHON SOURCE LINES 107-110 .. code-block:: Python stress_result = solution.stress() .. GENERATED FROM PYTHON SOURCE LINES 111-113 Check if support has complex frequencies ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 113-116 .. code-block:: Python stress_result.has_complex_frequencies() .. rst-class:: sphx-glr-script-out .. code-block:: none False .. GENERATED FROM PYTHON SOURCE LINES 117-119 Get tensor result ~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 119-123 .. code-block:: Python stress = stress_result.tensor stress.num_fields .. rst-class:: sphx-glr-script-out .. code-block:: none 2 .. GENERATED FROM PYTHON SOURCE LINES 124-126 Get shell field ~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 126-130 .. code-block:: Python shell_field = stress[0] shell_field.shell_layers .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 131-133 Get solid field ~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 133-136 .. code-block:: Python solid_field = stress[1] .. GENERATED FROM PYTHON SOURCE LINES 137-139 Plot amplitude contour ~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 139-143 .. code-block:: Python amplitude = stress_result.tensor_amplitude stress.plot_contour() .. image-sg:: /examples/05-Legacy/images/sphx_glr_03-modal-analysis_001.png :alt: 03 modal analysis :srcset: /examples/05-Legacy/images/sphx_glr_03-modal-analysis_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 144-148 Get elastic strain result ~~~~~~~~~~~~~~~~~~~~~~~~~ Get an elastic strain result that deals with phase. It contains a field for real values and a field for imaginary values. .. GENERATED FROM PYTHON SOURCE LINES 148-158 .. code-block:: Python elastic_strain_result = solution.elastic_strain() elastic_strain = elastic_strain_result.tensor # Get number of fields # ~~~~~~~~~~~~~~~~~~~~~~ # Get the number of shell and solid elements in distinct fields. elastic_strain.num_fields .. rst-class:: sphx-glr-script-out .. code-block:: none 2 .. GENERATED FROM PYTHON SOURCE LINES 159-161 If the result file contains results, use this method to get the elastic strain result. .. GENERATED FROM PYTHON SOURCE LINES 161-163 .. code-block:: Python print(solution.plastic_strain()) .. rst-class:: sphx-glr-script-out .. code-block:: none Complex tensor object. Tensor object. Object properties: - location : Nodal Complex plastic strain object. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.128 seconds) .. _sphx_glr_download_examples_05-Legacy_03-modal-analysis.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 03-modal-analysis.ipynb <03-modal-analysis.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 03-modal-analysis.py <03-modal-analysis.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 03-modal-analysis.zip <03-modal-analysis.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_