.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/05-Legacy/00-overview_example.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_00-overview_example.py: .. _ref_overview_example: PyDPF-Post overview =================== This example provides an overview of how you use PyDPF-Post. .. GENERATED FROM PYTHON SOURCE LINES 10-14 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 14-18 .. code-block:: Python from ansys.dpf import post from ansys.dpf.post import examples .. GENERATED FROM PYTHON SOURCE LINES 19-25 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 25-28 .. code-block:: Python solution = post.load_solution(examples.multishells_rst) .. GENERATED FROM PYTHON SOURCE LINES 29-33 Get mesh and time frequency support ----------------------------------- Get the mesh and time frequency support. The mesh is the support of the model. The time frequency support is the time/frequency representation of the model. .. GENERATED FROM PYTHON SOURCE LINES 33-37 .. code-block:: Python mesh = solution.mesh time_freq_support = solution.time_freq_support .. GENERATED FROM PYTHON SOURCE LINES 38-42 Get ``Result`` object --------------------- Get a ``Result`` object from the ``Solution`` object. The ``Result`` object can be a stress, plastic strain, elastic strain, temperature, or displacement. .. GENERATED FROM PYTHON SOURCE LINES 42-54 .. code-block:: Python post.print_available_keywords() stress = solution.stress(location=post.locations.nodal, time_scoping=[1]) # Both location and ``time_scoping`` are available in the definition of # the stress result. stress.definition.location stress.definition.time_scoping print(stress) .. rst-class:: sphx-glr-script-out .. code-block:: none element_scoping: list, int or dpf.core.Scoping grouping: str. Use post.grouping.(...) as helper. location: str. Use post.locations.(...) as helper. mapdl_grouping: int. Write 186 to get mapdl_elements solid_186. named_selection: str. Name of named_selection. node_scoping: list, int or dpf.core.Scoping path: DpfPath object that contains a list of coordinates, e.g. [[0.1, 0.0, 0.0], [0.0, 0.1, 0.0]]. set: int time: float time_scoping: list, int or dpf.core.Scoping Stress Tensor object. Object properties: - location : Nodal - time_scoping : [1] .. GENERATED FROM PYTHON SOURCE LINES 55-62 Compute data ------------ Compute data. **SX subresult** This code gets the subresult ``SX``, which is the stress tensor in the XX direction. .. GENERATED FROM PYTHON SOURCE LINES 62-74 .. code-block:: Python sx = stress.xx sx.num_fields sx_field = sx[0] sx_data = sx.get_data_at_field(0) print("Length of the data:", len(sx_data)) print() print("Maximum Stress Field:\n", sx.max) print() print("Maximum data at stress field:", sx.max_data) print("Maximum SX at Field 0:", sx.get_max_data_at_field(0)) .. rst-class:: sphx-glr-script-out .. code-block:: none Length of the data: 6854 Maximum Stress Field: DPF stress_1.s0 Field Location: Nodal Unit: Pa 2 entities Data: 1 components and 2 elementary data IDs data(Pa) ------------ ---------- 0 6.676153e+11 1 1.536714e+13 Maximum data at stress field: [6.67615284e+11 1.53671424e+13] Maximum SX at Field 0: 667615283882.6666 .. GENERATED FROM PYTHON SOURCE LINES 75-79 **Stress tensor result** This code gets the minimum and maximum stresses at a field for all directions (``XX``, ``XY``, ``XZ``, ``XY``, ``YZ``, and ``XZ``. .. GENERATED FROM PYTHON SOURCE LINES 79-96 .. code-block:: Python s = stress.tensor s_field = s[0] s_data = sx.get_data_at_field(0) print("Length of the data:", len(s_data)) print() print("Maximum stress field:\n", s.max) print() print("Maximum data at stress field:", s.max_data) print("Maximum stress tensors at field 0:\n", s.get_max_data_at_field(0)) print("Minimum stress field:\n", s.min) print() print("Minimum data at stress field:", s.min_data) print("Minimum stress tensors at field 0:\n", s.get_min_data_at_field(0)) .. rst-class:: sphx-glr-script-out .. code-block:: none Length of the data: 6854 Maximum stress field: DPF stress_1.s Field Location: Nodal Unit: Pa 2 entities Data: 6 components and 2 elementary data IDs data(Pa) ------------ ---------- 0 6.676153e+11 8.744609e+11 4.953944e+11 6.018891e+11 1.103258e+11 1.855802e+11 1 1.536714e+13 4.217815e+08 3.782022e+12 2.079505e+11 1.579960e+11 1.099721e+12 Maximum data at stress field: [[6.67615284e+11 8.74460905e+11 4.95394439e+11 6.01889079e+11 1.10325826e+11 1.85580244e+11] [1.53671424e+13 4.21781549e+08 3.78202198e+12 2.07950475e+11 1.57995981e+11 1.09972131e+12]] Maximum stress tensors at field 0: [6.67615284e+11 8.74460905e+11 4.95394439e+11 6.01889079e+11 1.10325826e+11 1.85580244e+11] Minimum stress field: DPF stress_1.s Field Location: Nodal Unit: Pa 2 entities Data: 6 components and 2 elementary data IDs data(Pa) ------------ ---------- 0 -5.779078e+11 -7.356049e+11 -2.412009e+11 -2.981459e+11 -2.421431e+11 -3.091386e+11 1 -1.496015e+13 -2.636956e+08 -3.779456e+12 -3.354327e+11 -1.571902e+11 -9.661232e+11 Minimum data at stress field: [[-5.77907764e+11 -7.35604867e+11 -2.41200931e+11 -2.98145939e+11 -2.42143056e+11 -3.09138563e+11] [-1.49601458e+13 -2.63695614e+08 -3.77945626e+12 -3.35432675e+11 -1.57190152e+11 -9.66123233e+11]] Minimum stress tensors at field 0: [-5.77907764e+11 -7.35604867e+11 -2.41200931e+11 -2.98145939e+11 -2.42143056e+11 -3.09138563e+11] .. GENERATED FROM PYTHON SOURCE LINES 97-100 Plot result ----------- Plot a result by using the ``plot_contour()`` method. .. GENERATED FROM PYTHON SOURCE LINES 100-102 .. code-block:: Python s.plot_contour() .. image-sg:: /examples/05-Legacy/images/sphx_glr_00-overview_example_001.png :alt: 00 overview example :srcset: /examples/05-Legacy/images/sphx_glr_00-overview_example_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.768 seconds) .. _sphx_glr_download_examples_05-Legacy_00-overview_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 00-overview_example.ipynb <00-overview_example.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 00-overview_example.py <00-overview_example.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_