.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/05-Legacy/05-transient-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_05-transient-analysis.py: .. _ref_trasient_analysis: Transient analysis ================== This example shows how you can post-process a result file for a transient 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 transient analysis computed in Ansys Mechanical. .. GENERATED FROM PYTHON SOURCE LINES 23-27 .. code-block:: Python solution = post.load_solution(examples.msup_transient) print(solution) .. rst-class:: sphx-glr-script-out .. code-block:: none Transient 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/msup_transient_plate1.rst Secondary files: DPF Model ------------------------------ Transient 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 ------------------------------ DPF Meshed Region: 393 nodes 40 elements Unit: m With solid (3D) elements ------------------------------ DPF Time/Freq Support: Number of sets: 20 Cumulative Time (s) LoadStep Substep 1 0.010000 1 1 2 0.020000 1 2 3 0.030000 1 3 4 0.040000 1 4 5 0.050000 1 5 6 0.060000 1 6 7 0.070000 1 7 8 0.080000 1 8 9 0.090000 1 9 10 0.100000 1 10 11 0.110000 1 11 12 0.120000 1 12 13 0.130000 1 13 14 0.140000 1 14 15 0.150000 1 15 16 0.160000 1 16 17 0.170000 1 17 18 0.180000 1 18 19 0.190000 1 19 20 0.200000 1 20 .. GENERATED FROM PYTHON SOURCE LINES 28-30 Get ``Result`` objects ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 32-35 Get displacement result ~~~~~~~~~~~~~~~~~~~~~~~ Get the displacement ``Result`` object. .. GENERATED FROM PYTHON SOURCE LINES 35-39 .. code-block:: Python disp_result = solution.displacement() disp = disp_result.vector .. GENERATED FROM PYTHON SOURCE LINES 40-43 Check number of fields ~~~~~~~~~~~~~~~~~~~~~~ Check the number of fields. .. GENERATED FROM PYTHON SOURCE LINES 43-46 .. code-block:: Python disp.num_fields .. rst-class:: sphx-glr-script-out .. code-block:: none 1 .. GENERATED FROM PYTHON SOURCE LINES 47-50 Get data from field ~~~~~~~~~~~~~~~~~~~ Get data from a field. .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python disp.get_data_at_field(0) .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([[ 5.61632273e-13, 3.10611157e-03, 5.94938168e-05], [-1.05541516e-06, 3.10082257e-03, 5.95757695e-05], [-8.84684396e-07, 3.71348576e-03, 6.27895677e-05], ..., [ 6.28518184e-13, 4.03518595e-03, -6.41156710e-05], [ 8.04525074e-07, 4.03115424e-03, 6.41884022e-05], [-8.04523717e-07, 4.03115424e-03, -6.41884020e-05]]) .. GENERATED FROM PYTHON SOURCE LINES 54-57 Get maximum data value over all fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the maximum data value over all fields. .. GENERATED FROM PYTHON SOURCE LINES 57-60 .. code-block:: Python disp.max_data .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([[2.45659911e-06, 1.07453069e-02, 7.28477714e-05]]) .. GENERATED FROM PYTHON SOURCE LINES 61-64 Get minimum data value over all fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the minimum data value over all fields. .. GENERATED FROM PYTHON SOURCE LINES 64-67 .. code-block:: Python disp.min_data .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([[-2.45659907e-06, 0.00000000e+00, -7.28477714e-05]]) .. GENERATED FROM PYTHON SOURCE LINES 68-71 Get maximum data value over targeted field ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the maximum data value over a targeted field. .. GENERATED FROM PYTHON SOURCE LINES 71-74 .. code-block:: Python disp.get_max_data_at_field(0) .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([2.45659911e-06, 1.07453069e-02, 7.28477714e-05]) .. GENERATED FROM PYTHON SOURCE LINES 75-78 Get minimum data value over all fields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the minimum data value over all fields. .. GENERATED FROM PYTHON SOURCE LINES 78-81 .. code-block:: Python disp.get_min_data_at_field(0) .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([-2.45659907e-06, 0.00000000e+00, -7.28477714e-05]) .. GENERATED FROM PYTHON SOURCE LINES 82-85 Get stress result ----------------- Get the stress ``Result`` object for a tensor. .. GENERATED FROM PYTHON SOURCE LINES 85-89 .. code-block:: Python stress_result = solution.stress() stress = stress_result.tensor .. GENERATED FROM PYTHON SOURCE LINES 90-93 Check number of fields ~~~~~~~~~~~~~~~~~~~~~~ Check the number of shell and solid elements in distinct fields. .. GENERATED FROM PYTHON SOURCE LINES 93-96 .. code-block:: Python stress.num_fields .. rst-class:: sphx-glr-script-out .. code-block:: none 1 .. GENERATED FROM PYTHON SOURCE LINES 97-100 Get shell field ~~~~~~~~~~~~~~~ Get the shell field. .. GENERATED FROM PYTHON SOURCE LINES 100-104 .. code-block:: Python shell_field = stress[0] shell_field.shell_layers .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 105-108 Get solid field ~~~~~~~~~~~~~~~ Get the solid field. .. GENERATED FROM PYTHON SOURCE LINES 108-111 .. code-block:: Python solid_field = stress[0] .. GENERATED FROM PYTHON SOURCE LINES 112-115 Plot contour ~~~~~~~~~~~~ Plot the contour. .. GENERATED FROM PYTHON SOURCE LINES 115-118 .. code-block:: Python stress.plot_contour() .. image-sg:: /examples/05-Legacy/images/sphx_glr_05-transient-analysis_001.png :alt: 05 transient analysis :srcset: /examples/05-Legacy/images/sphx_glr_05-transient-analysis_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 119-122 Get elastic strain result ------------------------- Get an elastic strain result. .. GENERATED FROM PYTHON SOURCE LINES 122-128 .. code-block:: Python elastic_strain_result = solution.elastic_strain() elastic_strain = elastic_strain_result.tensor # shell and solid elements are in distinct fields. elastic_strain.num_fields .. rst-class:: sphx-glr-script-out .. code-block:: none 1 .. GENERATED FROM PYTHON SOURCE LINES 129-131 If the result file contains results, you can use this method to get the elastic strain result. .. GENERATED FROM PYTHON SOURCE LINES 131-133 .. code-block:: Python print(solution.elastic_strain()) .. rst-class:: sphx-glr-script-out .. code-block:: none Tensor object. Object properties: - location : Nodal Elastic strain object. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.575 seconds) .. _sphx_glr_download_examples_05-Legacy_05-transient-analysis.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 05-transient-analysis.ipynb <05-transient-analysis.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 05-transient-analysis.py <05-transient-analysis.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_