.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/05-Legacy/02-static-analysis.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_02-static-analysis.py: .. _ref_static_analysis: Static analysis =============== This example shows how you can post-process a result file for a static analysis using PyDPF-Post. .. GENERATED FROM PYTHON SOURCE LINES 11-14 Perform required imports ------------------------ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 14-18 .. code-block:: Python from ansys.dpf import post from ansys.dpf.post import examples .. GENERATED FROM PYTHON SOURCE LINES 19-23 Get ``Solution`` object ----------------------- Get the ``Solution`` object. This example loads a result file for a static analysis computed in Ansys Mechanical. .. GENERATED FROM PYTHON SOURCE LINES 23-29 .. code-block:: Python example_path = examples.download_all_kinds_of_complexity() solution = post.load_solution(example_path) print(solution) .. rst-class:: sphx-glr-script-out .. code-block:: none Static Analysis Solution object. 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/testing/allKindOfComplexity.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 - elemental_summable_miscellaneous_data: Elemental Elemental Summable Miscellaneous Data - 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 - thermal_strain: ElementalNodal Thermal Strains - thermal_strains_eqv: ElementalNodal Thermal Strains eqv - swelling_strains: ElementalNodal Swelling Strains - element_euler_angles: ElementalNodal Element Euler Angles - elemental_non_summable_miscellaneous_data: Elemental Elemental Non Summable Miscellaneous Data - structural_temperature: ElementalNodal Structural temperature - contact_status: ElementalNodal Contact Status - contact_penetration: ElementalNodal Contact Penetration - contact_pressure: ElementalNodal Contact Pressure - contact_friction_stress: ElementalNodal Contact Friction Stress - contact_total_stress: ElementalNodal Contact Total Stress - contact_sliding_distance: ElementalNodal Contact Sliding Distance - contact_gap_distance: ElementalNodal Contact Gap Distance - total_heat_flux_at_contact_surface: ElementalNodal Total heat flux at contact surface - contact_status_changes: ElementalNodal Contact status changes - fluid_penetration_pressure: ElementalNodal Fluid Penetration Pressure ------------------------------ DPF Meshed Region: 15129 nodes 10292 elements Unit: m With solid (3D) elements, shell (2D) elements, shell (3D) elements, beam (1D) elements ------------------------------ DPF Time/Freq Support: Number of sets: 1 Cumulative Time (s) LoadStep Substep 1 1.000000 1 1 .. GENERATED FROM PYTHON SOURCE LINES 30-32 Get ``Result`` objects ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 34-37 Get displacement result ~~~~~~~~~~~~~~~~~~~~~~~ Get the displacement ``Result`` object. .. GENERATED FROM PYTHON SOURCE LINES 37-42 .. code-block:: Python disp_result = solution.displacement() disp = disp_result.vector print(disp) .. rst-class:: sphx-glr-script-out .. code-block:: none Displacement result. This result has been computed using dpf.core.Operator objects, which have been chained together according to the following list: - U: Result operator. Compute the desired result. .. GENERATED FROM PYTHON SOURCE LINES 43-46 Check number of fields ~~~~~~~~~~~~~~~~~~~~~~ Check the number of fields. .. GENERATED FROM PYTHON SOURCE LINES 46-49 .. code-block:: Python print(disp.num_fields) .. rst-class:: sphx-glr-script-out .. code-block:: none 1 .. GENERATED FROM PYTHON SOURCE LINES 50-53 Get data from field ~~~~~~~~~~~~~~~~~~~ Get data from a field. .. GENERATED FROM PYTHON SOURCE LINES 53-56 .. code-block:: Python print(disp.get_data_at_field(0)) .. rst-class:: sphx-glr-script-out .. code-block:: none [[ 9.84182297e-06 5.13025031e-06 -6.66435651e-07] [ 9.95996777e-06 4.93526360e-06 -6.25236961e-07] [ 9.93154893e-06 5.88552090e-06 -7.83251832e-07] ... [ 5.00000000e-03 -1.54556837e-04 0.00000000e+00] [ 5.00000000e-03 -1.56813550e-04 0.00000000e+00] [ 5.00000000e-03 -1.66125455e-04 0.00000000e+00]] .. GENERATED FROM PYTHON SOURCE LINES 57-60 Get maximum data value over all fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the maximum data value over all fields. .. GENERATED FROM PYTHON SOURCE LINES 60-63 .. code-block:: Python print(disp.max_data) .. rst-class:: sphx-glr-script-out .. code-block:: none [[8.50619058e+04 1.04659292e+01 3.73620870e+05]] .. GENERATED FROM PYTHON SOURCE LINES 64-67 Get minimum data value over all fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the minimum data value over all fields. .. GENERATED FROM PYTHON SOURCE LINES 67-70 .. code-block:: Python print(disp.min_data) .. rst-class:: sphx-glr-script-out .. code-block:: none [[-1.82645944e-06 -1.04473039e+01 -2.94677257e-04]] .. GENERATED FROM PYTHON SOURCE LINES 71-74 Get maximum data value over targeted field ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the maximum data value over a targeted field. .. GENERATED FROM PYTHON SOURCE LINES 74-77 .. code-block:: Python print(disp.get_max_data_at_field(0)) .. rst-class:: sphx-glr-script-out .. code-block:: none [8.50619058e+04 1.04659292e+01 3.73620870e+05] .. GENERATED FROM PYTHON SOURCE LINES 78-81 Get minimum data value over all fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the minimum data value over all fields. .. GENERATED FROM PYTHON SOURCE LINES 81-84 .. code-block:: Python print(disp.get_min_data_at_field(0)) .. rst-class:: sphx-glr-script-out .. code-block:: none [-1.82645944e-06 -1.04473039e+01 -2.94677257e-04] .. GENERATED FROM PYTHON SOURCE LINES 85-88 Get stress result ----------------- Get the stress ``Result`` object for a tensor. .. GENERATED FROM PYTHON SOURCE LINES 88-92 .. code-block:: Python stress_result = solution.stress() stress = stress_result.tensor .. GENERATED FROM PYTHON SOURCE LINES 93-96 Check number of fields ~~~~~~~~~~~~~~~~~~~~~~ Check the number of shell and solid elements in distinct fields. .. GENERATED FROM PYTHON SOURCE LINES 96-99 .. code-block:: Python print(stress.num_fields) .. rst-class:: sphx-glr-script-out .. code-block:: none 2 .. GENERATED FROM PYTHON SOURCE LINES 100-103 Get shell field ~~~~~~~~~~~~~~~ Get the shell field. .. GENERATED FROM PYTHON SOURCE LINES 103-107 .. code-block:: Python shell_field = stress[0] print(shell_field.shell_layers) .. rst-class:: sphx-glr-script-out .. code-block:: none shell_layers.nonelayer .. GENERATED FROM PYTHON SOURCE LINES 108-111 Get solid field ~~~~~~~~~~~~~~~ Get the solid field. .. GENERATED FROM PYTHON SOURCE LINES 111-114 .. code-block:: Python solid_field = stress[1] .. GENERATED FROM PYTHON SOURCE LINES 115-118 Plot contour ~~~~~~~~~~~~ Plot the contour. .. GENERATED FROM PYTHON SOURCE LINES 118-121 .. code-block:: Python stress.plot_contour() .. image-sg:: /examples/05-Legacy/images/sphx_glr_02-static-analysis_001.png :alt: 02 static analysis :srcset: /examples/05-Legacy/images/sphx_glr_02-static-analysis_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 122-125 Get elastic strain result ------------------------- Get an elastic strain result. .. GENERATED FROM PYTHON SOURCE LINES 125-129 .. code-block:: Python elastic_strain_result = solution.elastic_strain() elastic_strain = elastic_strain_result.tensor .. GENERATED FROM PYTHON SOURCE LINES 130-133 Check number of fields ~~~~~~~~~~~~~~~~~~~~~~ Check the number of shell and solid elements in distinct fields. .. GENERATED FROM PYTHON SOURCE LINES 133-135 .. code-block:: Python print(elastic_strain.num_fields) .. rst-class:: sphx-glr-script-out .. code-block:: none 2 .. GENERATED FROM PYTHON SOURCE LINES 136-138 If the result file contains results, you can use this method to get the elastic strain result. .. GENERATED FROM PYTHON SOURCE LINES 138-141 .. code-block:: Python print(solution.plastic_strain()) .. rst-class:: sphx-glr-script-out .. code-block:: none Tensor object. Object properties: - location : Nodal Plastic strain object. .. GENERATED FROM PYTHON SOURCE LINES 142-143 You can also use this method to get the temperature result. .. GENERATED FROM PYTHON SOURCE LINES 143-145 .. code-block:: Python print(solution.structural_temperature()) .. rst-class:: sphx-glr-script-out .. code-block:: none Scalar object. Object properties: - location : Nodal Structural temperature object. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.244 seconds) .. _sphx_glr_download_examples_05-Legacy_02-static-analysis.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 02-static-analysis.ipynb <02-static-analysis.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 02-static-analysis.py <02-static-analysis.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_