.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/01-Detailed-Examples/04-invariants.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_04-invariants.py: .. _ref_invariants_example: Extract stress/strain invariants - Static Simulation ===================================================================== In this script a static simulation is used as an example to show how to extract tensor's invariants. .. 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-37 .. code-block:: Python example_path = examples.download_crankshaft() # 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) .. rst-class:: sphx-glr-script-out .. code-block:: none Static Mechanical Simulation. Data Sources ------------------------------ /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/ansys/dpf/core/examples/result_files/crankshaft/crankshaft.rst DPF Model ------------------------------ Static analysis Unit system: MKS: m, kg, N, s, V, A, degC Physics Type: Mechanical Available results: - displacement: Nodal Displacement - velocity: Nodal Velocity - acceleration: Nodal Acceleration - 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: 69762 nodes 39315 elements Unit: m With solid (3D) elements ------------------------------ DPF Time/Freq Support: Number of sets: 3 Cumulative Time (s) LoadStep Substep 1 1.000000 1 1 2 2.000000 1 2 3 3.000000 1 3 .. GENERATED FROM PYTHON SOURCE LINES 38-40 Extract elemental nodal stress and strain ----------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 40-47 .. code-block:: Python stress = simulation.stress(all_sets=True) print(stress) strain = simulation.elastic_strain(all_sets=True) print(strain) .. rst-class:: sphx-glr-script-out .. code-block:: none results S (Pa) ... set_ids 1 2 ... node 0 1 2 3 1 ... element_ids components ... 18357 XX 2.7979e+06 4.7003e+05 -1.8736e+06 -3.3334e+06 4.3949e+06 -2.4906e+04 ... YY 8.6092e+06 5.5603e+06 2.3814e+07 -2.2182e+07 2.8565e+07 2.1156e+07 ... ZZ -1.0166e+07 1.1400e+06 3.2169e+07 -6.2071e+07 -2.6681e+06 1.4945e+07 ... XY 5.9477e+05 1.0214e+07 5.3788e+07 5.2463e+07 7.8847e+05 1.9763e+07 ... YZ -1.9866e+08 -1.6437e+08 -1.7338e+08 -1.5419e+08 -3.9727e+08 -3.2839e+08 ... XZ -6.6205e+06 1.3030e+06 8.4608e+06 -9.4029e+06 -4.0082e+06 9.3691e+06 ... ... ... ... ... ... ... ... ... ... results EPEL ... set_ids 1 2 ... node 0 1 2 3 1 ... element_ids components ... 18357 XX 1.6326e-05 -7.7003e-06 -9.3343e-05 1.0971e-04 -1.6871e-05 -5.4276e-05 ... YY 5.4098e-05 2.5387e-05 7.3628e-05 -1.2802e-05 1.4024e-04 8.3400e-05 ... ZZ -6.7943e-05 -3.3456e-06 1.2793e-04 -2.7208e-04 -6.2781e-05 4.3027e-05 ... XY 7.7320e-06 1.3278e-04 6.9924e-04 6.8201e-04 1.0250e-05 2.5692e-04 ... YZ -2.5826e-03 -2.1368e-03 -2.2539e-03 -2.0045e-03 -5.1645e-03 -4.2691e-03 ... XZ -8.6066e-05 1.6939e-05 1.0999e-04 -1.2224e-04 -5.2106e-05 1.2180e-04 ... ... ... ... ... ... ... ... ... ... .. GENERATED FROM PYTHON SOURCE LINES 48-50 Compute principal invariant averaged and unaveraged on stress and strain ------------------------------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 50-63 .. code-block:: Python princ_stress_1 = simulation.stress_principal(components=[1]) print(princ_stress_1) nodal_princ_stress_2 = simulation.stress_principal_nodal(components=[2]) print(nodal_princ_stress_2) nodal_princ_stress_2.plot() nodal_princ_strain_2 = simulation.elastic_strain_principal_nodal(components=[2]) print(nodal_princ_strain_2) nodal_princ_strain_2.plot() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/01-Detailed-Examples/images/sphx_glr_04-invariants_001.png :alt: 04 invariants :srcset: /examples/01-Detailed-Examples/images/sphx_glr_04-invariants_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/01-Detailed-Examples/images/sphx_glr_04-invariants_002.png :alt: 04 invariants :srcset: /examples/01-Detailed-Examples/images/sphx_glr_04-invariants_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none results S (Pa) set_ids 3 node 0 1 2 3 element_ids components 18357 1 6.3596e+08 5.3499e+08 6.6581e+08 4.2794e+08 22264 3.6762e+08 2.3020e+08 3.1258e+08 4.0098e+08 30223 3.0154e+08 1.9624e+08 4.1080e+08 2.1359e+08 18352 3.7559e+08 4.9030e+08 4.3722e+08 4.0711e+08 18358 7.8922e+08 6.0867e+08 7.8301e+08 6.0954e+08 5717 7.6761e+08 5.9538e+08 7.0780e+08 8.0592e+08 ... ... ... ... ... ... results S (Pa) set_ids 3 node_ids components 4872 2 -1.4818e+06 9005 3.1627e+05 9373 4.0889e+07 9372 -3.2059e+07 4876 1.9911e+07 9781 -1.1439e+08 ... ... ... results EPEL set_ids 3 node_ids components 4872 2 -1.2351e-04 9005 -1.2034e-04 9373 -1.4734e-04 9372 1.8417e-05 4876 6.4584e-04 9781 7.0507e-05 ... ... ... .. GENERATED FROM PYTHON SOURCE LINES 64-66 Compute von Mises eqv averaged and unaveraged on stress and strain ------------------------------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 66-75 .. code-block:: Python stress_eqv = simulation.stress_eqv_von_mises(set_ids=[1]) print(stress_eqv) nodal_stress_eqv = simulation.stress_eqv_von_mises_nodal(set_ids=[1]) nodal_stress_eqv.plot() nodal_strain_eqv = simulation.elastic_strain_eqv_von_mises_nodal(set_ids=[1]) nodal_strain_eqv.plot() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/01-Detailed-Examples/images/sphx_glr_04-invariants_003.png :alt: 04 invariants :srcset: /examples/01-Detailed-Examples/images/sphx_glr_04-invariants_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/01-Detailed-Examples/images/sphx_glr_04-invariants_004.png :alt: 04 invariants :srcset: /examples/01-Detailed-Examples/images/sphx_glr_04-invariants_004.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none results S_VM (Pa) set_ids 1 node 0 1 2 3 element_ids 18357 3.4469e+08 2.8529e+08 3.1625e+08 2.8731e+08 22264 3.3939e+08 2.7271e+08 2.5695e+08 2.8499e+08 30223 2.5691e+08 1.0116e+08 2.7858e+08 2.6944e+08 18352 3.2719e+08 3.1796e+08 3.1697e+08 3.0841e+08 18358 3.4067e+08 3.0051e+08 3.4558e+08 3.1530e+08 5717 3.4715e+08 3.0372e+08 3.0057e+08 3.3268e+08 ... ... ... ... ... .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.954 seconds) .. _sphx_glr_download_examples_01-Detailed-Examples_04-invariants.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 04-invariants.ipynb <04-invariants.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 04-invariants.py <04-invariants.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_