.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/00-Different-analysis-types/01-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_00-Different-analysis-types_01-static-simulation.py: .. _ref_static_example: Static 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 or 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-41 .. code-block:: Python example_path = examples.find_static_rst() # to automatically detect the simulation type, use: simulation = post.load_simulation(example_path) # to enable auto-completion, use the equivalent: simulation = post.StaticMechanicalSimulation(example_path) # print the simulation to get an overview of what's available print(simulation) displacement = simulation.displacement() print(displacement) .. rst-class:: sphx-glr-script-out .. code-block:: none Static Mechanical Simulation. Data Sources ------------------------------ /opt/hostedtoolcache/Python/3.10.13/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 - 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 results U (m) set_ids 1 node_ids components 1 X -3.3190e-22 Y -6.9357e-09 Z -3.2862e-22 26 X 2.2303e-09 Y -7.1421e-09 Z -2.9208e-22 ... ... ... .. GENERATED FROM PYTHON SOURCE LINES 42-44 Select sub parts of displacement --------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 44-65 .. code-block:: Python # To get X displacements x_displacement = displacement.select(components="X") print(x_displacement) # equivalent to x_displacement = simulation.displacement(components=["X"]) print(x_displacement) # plot x_displacement.plot() # extract displacement on specific nodes nodes_displacement = displacement.select(node_ids=[1, 10, 100]) nodes_displacement.plot() # equivalent to: nodes_displacement = simulation.displacement(node_ids=[1, 10, 100]) print(nodes_displacement) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/00-Different-analysis-types/images/sphx_glr_01-static-simulation_001.png :alt: 01 static simulation :srcset: /examples/00-Different-analysis-types/images/sphx_glr_01-static-simulation_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/00-Different-analysis-types/images/sphx_glr_01-static-simulation_002.png :alt: 01 static simulation :srcset: /examples/00-Different-analysis-types/images/sphx_glr_01-static-simulation_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none results U (m) set_ids 1 node_ids components 1 X -3.3190e-22 26 2.2303e-09 14 0.0000e+00 12 0.0000e+00 2 -3.0117e-22 27 2.0908e-09 ... ... ... results U_X (m) set_ids 1 node_ids 1 -3.3190e-22 26 2.2303e-09 14 0.0000e+00 12 0.0000e+00 2 -3.0117e-22 27 2.0908e-09 ... ... results U (m) set_ids 1 node_ids components 1 X -3.3190e-22 Y -6.9357e-09 Z -3.2862e-22 10 X 0.0000e+00 Y 0.0000e+00 Z 0.0000e+00 .. GENERATED FROM PYTHON SOURCE LINES 66-69 Compute total displacement (norm) --------------------------------- Compute the norm of displacement on a selection of nodes .. GENERATED FROM PYTHON SOURCE LINES 69-77 .. code-block:: Python nodes_displacement = simulation.displacement( node_ids=simulation.mesh.node_ids[10:], norm=True ) print(nodes_displacement) nodes_displacement.plot() .. image-sg:: /examples/00-Different-analysis-types/images/sphx_glr_01-static-simulation_003.png :alt: 01 static simulation :srcset: /examples/00-Different-analysis-types/images/sphx_glr_01-static-simulation_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none results U_N (m) set_ids 1 node_ids 11 0.0000e+00 12 0.0000e+00 13 0.0000e+00 14 0.0000e+00 15 0.0000e+00 16 0.0000e+00 ... ... .. GENERATED FROM PYTHON SOURCE LINES 78-81 Extract tensor stress, apply averaging, compute equivalent ---------------------------------------------------------- Extract raw elemental nodal stresses from the rst file .. GENERATED FROM PYTHON SOURCE LINES 81-100 .. code-block:: Python elem_nodal_stress = simulation.stress() print(elem_nodal_stress) # Compute nodal stresses from the result file nodal_stress = simulation.stress_nodal() print(nodal_stress) # Compute elemental stresses from the result file elemental_stress = simulation.stress_elemental() print(elemental_stress) # Extract elemental stresses on specific elements elemental_stress = elemental_stress.select(element_ids=[5, 6, 7]) elemental_stress.plot() # Compute nodal eqv stresses from the result file eqv_stress = simulation.stress_eqv_von_mises_nodal() print(eqv_stress) eqv_stress.plot() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/00-Different-analysis-types/images/sphx_glr_01-static-simulation_004.png :alt: 01 static simulation :srcset: /examples/00-Different-analysis-types/images/sphx_glr_01-static-simulation_004.png :class: sphx-glr-multi-img * .. image-sg:: /examples/00-Different-analysis-types/images/sphx_glr_01-static-simulation_005.png :alt: 01 static simulation :srcset: /examples/00-Different-analysis-types/images/sphx_glr_01-static-simulation_005.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none results S (Pa) ... set_ids 1 ... node 0 1 2 3 4 5 ... element_ids components ... 5 XX -3.7836e+03 1.1793e+04 -3.2947e+04 -2.2019e+04 7.3721e+03 1.8301e+04 ... YY -1.2110e+05 -9.9179e+04 -1.0033e+05 -7.4344e+04 -9.9179e+04 -8.0542e+04 ... ZZ -3.7836e+03 7.3721e+03 -3.2461e+04 -2.2019e+04 1.1793e+04 1.8301e+04 ... XY 5.3318e+02 -9.7301e+03 2.6037e+04 -1.2541e+03 5.5354e+02 -1.1500e+04 ... YZ -5.3318e+02 -5.5354e+02 1.1343e+03 1.2541e+03 9.7301e+03 1.1500e+04 ... XZ -1.4540e+02 5.9879e+02 -2.4309e+02 -2.1037e-10 5.9879e+02 2.5527e+02 ... ... ... ... ... ... ... ... ... ... results S (Pa) set_ids 1 node_ids components 1 XX -4.8113e+03 YY -1.1280e+05 ZZ -4.8113e+03 XY 0.0000e+00 YZ 0.0000e+00 XZ 0.0000e+00 ... ... ... results S (Pa) set_ids 1 element_ids components 5 XX -1.2071e+04 YY -1.0000e+05 ZZ -1.2071e+04 XY 3.8006e+03 YZ -3.8006e+03 XZ 4.1885e+01 ... ... ... results S_VM (Pa) set_ids 1 node_ids 1 1.0799e+05 26 1.0460e+05 14 8.1283e+04 12 5.2324e+04 2 1.0460e+05 27 1.0006e+05 ... ... .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 11.251 seconds) .. _sphx_glr_download_examples_00-Different-analysis-types_01-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-static-simulation.ipynb <01-static-simulation.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01-static-simulation.py <01-static-simulation.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_