.. 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 a static simulation ================================= This example shows how to get 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 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-48 Get ``Solution`` object ----------------------- Get the ``Solution`` object that allows access to the result. The ``Solution`` 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 48-52 .. code-block:: Python simulation = post.load_simulation(examples.static_rst) print(simulation) .. rst-class:: sphx-glr-script-out .. code-block:: none Static Mechanical Simulation. Data Sources ------------------------------ /opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/static.rst 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 - 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 - 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 53-55 Get and plot displacements -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 55-57 .. code-block:: Python displacement = simulation.displacement() .. GENERATED FROM PYTHON SOURCE LINES 58-59 Print information .. GENERATED FROM PYTHON SOURCE LINES 59-61 .. 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 62-63 Plot displacements .. GENERATED FROM PYTHON SOURCE LINES 63-65 .. 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 .. rst-class:: sphx-glr-script-out .. code-block:: none (None, ) .. GENERATED FROM PYTHON SOURCE LINES 66-69 Get and plot stresses --------------------- Get the "XY" stress component averaged on nodes. .. GENERATED FROM PYTHON SOURCE LINES 69-71 .. code-block:: Python stress = simulation.stress_nodal(components="XY") .. GENERATED FROM PYTHON SOURCE LINES 72-73 Print information. .. GENERATED FROM PYTHON SOURCE LINES 73-75 .. 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 76-77 Plot available stresses. .. GENERATED FROM PYTHON SOURCE LINES 77-79 .. 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 .. rst-class:: sphx-glr-script-out .. code-block:: none (None, ) .. GENERATED FROM PYTHON SOURCE LINES 80-83 Get stresses at only five nodes ------------------------------ Get stresses at only the first five nodes using their IDs. .. GENERATED FROM PYTHON SOURCE LINES 83-85 .. code-block:: Python stress_nodes = simulation.stress_nodal(node_ids=range(1, 6)) .. GENERATED FROM PYTHON SOURCE LINES 86-87 Print information. .. GENERATED FROM PYTHON SOURCE LINES 87-89 .. 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 90-91 Plot stresses. .. GENERATED FROM PYTHON SOURCE LINES 91-93 .. 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 .. rst-class:: sphx-glr-script-out .. code-block:: none (None, ) .. GENERATED FROM PYTHON SOURCE LINES 94-97 Get stresses in a named selection --------------------------------- Get the name of the first named selection in the simulation. .. GENERATED FROM PYTHON SOURCE LINES 97-101 .. code-block:: Python ns = simulation.named_selections[0] # Get nodal stresses for this named selection stress_named_sel = simulation.stress_nodal(named_selections=ns) .. GENERATED FROM PYTHON SOURCE LINES 102-103 Print information. .. GENERATED FROM PYTHON SOURCE LINES 103-105 .. 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 106-107 Plot stresses. .. GENERATED FROM PYTHON SOURCE LINES 107-109 .. 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 .. rst-class:: sphx-glr-script-out .. code-block:: none (None, ) .. GENERATED FROM PYTHON SOURCE LINES 110-113 Get stresses in a few elements ------------------------------ Get stresses only for a few elements selected by their IDs. .. GENERATED FROM PYTHON SOURCE LINES 113-115 .. code-block:: Python stress_elements = simulation.stress_nodal(element_ids=[1, 2, 3]) .. GENERATED FROM PYTHON SOURCE LINES 116-117 Print information. .. GENERATED FROM PYTHON SOURCE LINES 117-119 .. 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 120-121 Plot stresses. .. GENERATED FROM PYTHON SOURCE LINES 121-123 .. 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 .. rst-class:: sphx-glr-script-out .. code-block:: none (None, ) .. GENERATED FROM PYTHON SOURCE LINES 124-127 Get elemental streses and raw stresses -------------------------------------- Get elemental stresses and print information. .. GENERATED FROM PYTHON SOURCE LINES 127-130 .. 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 131-132 Get raw stresses (ElementalNodal) and print information. .. GENERATED FROM PYTHON SOURCE LINES 132-134 .. 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.565 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>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 01-get_data_from_static_simulation.zip <01-get_data_from_static_simulation.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_