.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/05-Legacy/01-get_data_from_static_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_05-Legacy_01-get_data_from_static_simulation.py: .. _ref_get_data_from_static_simulation: Get data from static simulation =============================== This example shows how to request data from a previously stored static simulation. The available results can be listed to see what results can be retrieved. .. GENERATED FROM PYTHON SOURCE LINES 11-13 Imports and loading simulation ------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 13-19 .. code-block:: Python from ansys.dpf import post from ansys.dpf.post import examples simulation = post.load_simulation(examples.static_rst) print(simulation) .. rst-class:: sphx-glr-script-out .. code-block:: none Static Mechanical Simulation. Data Sources ------------------------------ DPF DataSources: Result files: result key: rst and path: /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/static.rst Secondary files: DPF Model ------------------------------ Static analysis Unit system: MKS: m, kg, N, s, V, A, 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 - structural_temperature: ElementalNodal Structural temperature ------------------------------ DPF Meshed Region: 81 nodes 8 elements Unit: m With solid (3D) elements ------------------------------ DPF Time/Freq Support: Number of sets: 1 Cumulative Time (s) LoadStep Substep 1 1.000000 1 1 .. GENERATED FROM PYTHON SOURCE LINES 20-22 Get and plot displacements -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 22-24 .. code-block:: Python displacement = simulation.displacement() .. GENERATED FROM PYTHON SOURCE LINES 25-26 Print information .. GENERATED FROM PYTHON SOURCE LINES 26-28 .. code-block:: Python print(displacement._fc) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF displacement(s)Fields Container with 1 field(s) defined on labels: time with: - field 0 {time: 1} with Nodal location, 3 components and 81 entities. .. GENERATED FROM PYTHON SOURCE LINES 29-30 Plot displacements .. GENERATED FROM PYTHON SOURCE LINES 30-32 .. code-block:: Python displacement._fc[0].plot() .. image-sg:: /examples/05-Legacy/images/sphx_glr_01-get_data_from_static_simulation_001.png :alt: 01 get data from static simulation :srcset: /examples/05-Legacy/images/sphx_glr_01-get_data_from_static_simulation_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 33-36 Get and plot stresses --------------------- Request "XY" stress component averaged on nodes .. GENERATED FROM PYTHON SOURCE LINES 36-38 .. code-block:: Python stress = simulation.stress_nodal(components="XY") .. GENERATED FROM PYTHON SOURCE LINES 39-40 Print information .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: Python print(stress._fc) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF stress(s)Fields Container with 1 field(s) defined on labels: time with: - field 0 {time: 1} with Nodal location, 1 components and 81 entities. .. GENERATED FROM PYTHON SOURCE LINES 43-44 Plot available stresses. .. GENERATED FROM PYTHON SOURCE LINES 44-46 .. code-block:: Python stress._fc[0].plot() .. image-sg:: /examples/05-Legacy/images/sphx_glr_01-get_data_from_static_simulation_002.png :alt: 01 get data from static simulation :srcset: /examples/05-Legacy/images/sphx_glr_01-get_data_from_static_simulation_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 47-50 Get stresses at only 5 nodes ------------------------------ Request stress only at the first 5 nodes using their IDs. .. GENERATED FROM PYTHON SOURCE LINES 50-52 .. code-block:: Python stress_nodes = simulation.stress_nodal(node_ids=range(1, 6)) .. GENERATED FROM PYTHON SOURCE LINES 53-54 Print information .. GENERATED FROM PYTHON SOURCE LINES 54-56 .. code-block:: Python print(stress_nodes._fc) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF stress(s)Fields Container with 1 field(s) defined on labels: time with: - field 0 {time: 1} with Nodal location, 6 components and 5 entities. .. GENERATED FROM PYTHON SOURCE LINES 57-58 Plot stresses .. GENERATED FROM PYTHON SOURCE LINES 58-60 .. code-block:: Python stress_nodes._fc[0].plot() .. image-sg:: /examples/05-Legacy/images/sphx_glr_01-get_data_from_static_simulation_003.png :alt: 01 get data from static simulation :srcset: /examples/05-Legacy/images/sphx_glr_01-get_data_from_static_simulation_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 61-64 Get stresses in a named selection --------------------------------- Get the name of the first named selection in the simulation .. GENERATED FROM PYTHON SOURCE LINES 64-68 .. code-block:: Python ns = simulation.named_selections[0] # Request nodal stresses for this named selection stress_named_sel = simulation.stress_nodal(named_selections=ns) .. GENERATED FROM PYTHON SOURCE LINES 69-70 Print information .. GENERATED FROM PYTHON SOURCE LINES 70-72 .. code-block:: Python print(stress_named_sel._fc) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF stress(s)Fields Container with 1 field(s) defined on labels: time with: - field 0 {time: 1} with Nodal location, 6 components and 21 entities. .. GENERATED FROM PYTHON SOURCE LINES 73-74 Plot stresses .. GENERATED FROM PYTHON SOURCE LINES 74-76 .. code-block:: Python stress_named_sel._fc[0].plot() .. image-sg:: /examples/05-Legacy/images/sphx_glr_01-get_data_from_static_simulation_004.png :alt: 01 get data from static simulation :srcset: /examples/05-Legacy/images/sphx_glr_01-get_data_from_static_simulation_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 77-80 Get stresses in a few elements ------------------------------ Request stress only for a few elements selected by their ID .. GENERATED FROM PYTHON SOURCE LINES 80-82 .. code-block:: Python stress_elements = simulation.stress_nodal(element_ids=[1, 2, 3]) .. GENERATED FROM PYTHON SOURCE LINES 83-84 Print information .. GENERATED FROM PYTHON SOURCE LINES 84-86 .. code-block:: Python print(stress_elements._fc) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF stress(s)Fields Container with 1 field(s) defined on labels: time with: - field 0 {time: 1} with Nodal location, 6 components and 44 entities. .. GENERATED FROM PYTHON SOURCE LINES 87-88 Plot stresses .. GENERATED FROM PYTHON SOURCE LINES 88-90 .. code-block:: Python stress_elements._fc[0].plot() .. image-sg:: /examples/05-Legacy/images/sphx_glr_01-get_data_from_static_simulation_005.png :alt: 01 get data from static simulation :srcset: /examples/05-Legacy/images/sphx_glr_01-get_data_from_static_simulation_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 91-94 Get elemental stress and raw stresses ------------------------------------- Request elemental stresses and print information .. GENERATED FROM PYTHON SOURCE LINES 94-97 .. code-block:: Python stress_elements = simulation.stress_elemental() print(stress_elements._fc) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF stress(s)Fields Container with 1 field(s) defined on labels: time with: - field 0 {time: 1} with Elemental location, 6 components and 8 entities. .. GENERATED FROM PYTHON SOURCE LINES 98-99 Request raw stresses ("ElementalNodal") and print information .. GENERATED FROM PYTHON SOURCE LINES 99-101 .. code-block:: Python stress_raw = simulation.stress() print(stress_raw._fc) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF stress(s)Fields Container with 1 field(s) defined on labels: time with: - field 0 {time: 1} with ElementalNodal location, 6 components and 8 entities. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.343 seconds) .. _sphx_glr_download_examples_05-Legacy_01-get_data_from_static_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-get_data_from_static_simulation.ipynb <01-get_data_from_static_simulation.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01-get_data_from_static_simulation.py <01-get_data_from_static_simulation.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_