.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\01-Detailed-Examples\02-modal-extract-sub-results.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_02-modal-extract-sub-results.py: .. _ref_modal_sub_results_example: Extract components of results - Modal Simulation ================================================ **提取部分结果 - 模态分析** 在该脚本中,将对模态模拟进行处理,以提取弹性应变和位移等结果的子组件。 .. GENERATED FROM PYTHON SOURCE LINES 12-15 Perform required imports ------------------------ **执行所需的导入** .. GENERATED FROM PYTHON SOURCE LINES 17-18 本示例使用了一个提供的文件,您可以通过导入 DPF ``examples`` 包获得该文件。 .. GENERATED FROM PYTHON SOURCE LINES 18-22 .. code-block:: Python from ansys.dpf import post from ansys.dpf.post import examples .. GENERATED FROM PYTHON SOURCE LINES 23-26 Get the ``Simulation`` object ----------------------------- **获取允许访问结果的 ``Simulation`` 对象** .. GENERATED FROM PYTHON SOURCE LINES 28-29 必须使用结果文件的路径实例化 ``Simulation`` 对象。例如,Windows 下为 ``"C:/Users/user/my_result.rst"`` 或 Linux 下为 ``"/home/user/my_result.rst"`` 。 .. GENERATED FROM PYTHON SOURCE LINES 29-42 .. code-block:: Python example_path = examples.download_all_kinds_of_complexity_modal() # 自动检测模拟类型,请使用 simulation = post.load_simulation(example_path) # 要启用 auto-completion 功能,请使用等效的命令: simulation = post.ModalMechanicalSimulation(example_path) # 打印 simulation ,了解可用内容的概况 print(simulation) .. rst-class:: sphx-glr-script-out .. code-block:: none Modal Mechanical Simulation. Data Sources ------------------------------ C:\Users\ff\AppData\Roaming\Python\Python310\site-packages\ansys\dpf\core\examples\result_files\testing\modal_allKindOfComplexity.rst 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 - 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 - 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 - structural_temperature: ElementalNodal Temperature ------------------------------ DPF Meshed Region: 2388 nodes 1824 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 .. GENERATED FROM PYTHON SOURCE LINES 43-46 Extract X displacement over a list modes ---------------------------------------- 提取列表模态的 X 位移 .. GENERATED FROM PYTHON SOURCE LINES 48-49 打印time-freq支持有助于选择正确的模态 .. GENERATED FROM PYTHON SOURCE LINES 49-60 .. code-block:: Python print(simulation.time_freq_support) # 获取前 2 阶模态的 X 位移 x_displacement = simulation.displacement(modes=[1, 2], components=["X"]) # equivalent to # x_displacement = simulation.displacement(set_ids=[1, 2], components=["X"]) print(x_displacement) x_displacement.plot(set_id=1) .. image-sg:: /examples/01-Detailed-Examples/images/sphx_glr_02-modal-extract-sub-results_001.png :alt: 02 modal extract sub results :srcset: /examples/01-Detailed-Examples/images/sphx_glr_02-modal-extract-sub-results_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 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 results U_X (m) set_ids 1 2 node_ids 289 -1.1710e+00 3.0726e+00 573 -1.6975e+00 3.1432e+00 589 -2.2447e+00 3.3385e+00 591 -1.5945e+00 3.6033e+00 324 0.0000e+00 0.0000e+00 579 0.0000e+00 0.0000e+00 ... ... ... .. GENERATED FROM PYTHON SOURCE LINES 61-64 Extract XX and XY elastic strain over a list modes -------------------------------------------------- 提取模态列表中的 XX 和 XY 弹性应变 .. GENERATED FROM PYTHON SOURCE LINES 64-70 .. code-block:: Python # 获取第 3 阶模态的 XX 和 XY 弹性应变 XX_XY_elastic_strain = simulation.elastic_strain_nodal( modes=[3], components=["XX", "XY"] ) print(XX_XY_elastic_strain) .. rst-class:: sphx-glr-script-out .. code-block:: none results EPEL set_ids 3 elshape 1 node_ids components 289 XX XY 573 XX XY 589 XX XY ... ... ... .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.418 seconds) .. _sphx_glr_download_examples_01-Detailed-Examples_02-modal-extract-sub-results.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 02-modal-extract-sub-results.ipynb <02-modal-extract-sub-results.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 02-modal-extract-sub-results.py <02-modal-extract-sub-results.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_