.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/05-Legacy/07-result_keywords.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_07-result_keywords.py: .. _ref_result_keywords: Result keywords =============== This example shows how to you can get more precise result with keywords while calling a ``Result`` object from a ``Solution`` object. .. 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-22 Get ``Solution`` object ----------------------- Get the ``Solution`` object. .. GENERATED FROM PYTHON SOURCE LINES 22-25 .. code-block:: Python solution = post.load_solution(examples.multishells_rst) .. GENERATED FROM PYTHON SOURCE LINES 26-29 Get keyword list ~~~~~~~~~~~~~~~~ Get the keyword list. .. GENERATED FROM PYTHON SOURCE LINES 29-33 .. code-block:: Python post.print_available_keywords() .. 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 .. GENERATED FROM PYTHON SOURCE LINES 34-36 Get ``Result`` objects ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 38-42 Get displacement result using scoping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Get the displacement ``Result`` object using scoping. The default location is nodal. .. GENERATED FROM PYTHON SOURCE LINES 42-48 .. code-block:: Python displacement_result = solution.displacement( location=post.locations.nodal, node_scoping=[1, 2, 3] ) displacement = displacement_result.vector .. GENERATED FROM PYTHON SOURCE LINES 49-52 Get information on result ~~~~~~~~~~~~~~~~~~~~~~~~~ Get information on the displacement result. .. GENERATED FROM PYTHON SOURCE LINES 52-62 .. code-block:: Python displacement.get_data_at_field(0) stress_with_elem_scop_result = solution.stress( location=post.locations.elemental_nodal, element_scoping=[1] ) stress_with_elem_scop = stress_with_elem_scop_result.tensor stress_with_elem_scop.get_data_at_field(0) .. rst-class:: sphx-glr-script-out .. code-block:: none DPFArray([[-1.89351567e+10, -1.76835359e+10, -1.23315384e+10, 1.27527844e+10, 5.75103130e+09, 4.30928026e+09], [ 2.26888166e+09, -1.98936699e+10, -4.28985472e+09, 3.73483930e+10, 1.28815250e+07, 2.29405491e+09], [ 4.62267494e+09, 4.15775621e+10, 1.28377395e+10, 1.36264980e+10, 5.61091738e+09, 4.14261606e+09], [ 3.07029586e+10, 6.01620111e+10, 9.52341402e+09, 2.26091377e+10, -1.73616087e+10, -4.64480973e+09], [ 3.09432279e+10, -2.77392410e+09, -6.13098650e+09, 9.00784538e+09, 3.47990848e+08, -2.41304392e+10], [ 2.80970793e+10, 5.10227200e+09, 4.87711840e+08, 1.04294881e+10, 1.77319514e+09, -3.26250573e+09], [-3.35771187e+09, -7.58900634e+09, -5.19623475e+09, -9.62379008e+08, 7.06462080e+07, -8.84417984e+08], [-1.66533110e+10, -5.39330662e+09, -1.18382500e+10, -3.91451443e+09, 7.81984448e+08, 1.12681376e+08]]) .. GENERATED FROM PYTHON SOURCE LINES 63-66 Use named selection on result ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use a named selection on the displacement result. .. GENERATED FROM PYTHON SOURCE LINES 66-74 .. code-block:: Python stress_on_ns_result = solution.stress( location=post.locations.elemental_nodal, named_selection="SELECTION" ) stress_on_ns = stress_on_ns_result.tensor stress_on_ns.num_fields len(stress_on_ns[0]) .. rst-class:: sphx-glr-script-out .. code-block:: none 5040 .. GENERATED FROM PYTHON SOURCE LINES 75-78 Get a subresult ~~~~~~~~~~~~~~ Get a subresult. .. GENERATED FROM PYTHON SOURCE LINES 78-86 .. code-block:: Python disp_x = displacement_result.x stress_yz = stress_with_elem_scop_result.yz stress_principal_1 = stress_on_ns_result.principal_3 stress_principal_1 .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 87-90 Filter result ~~~~~~~~~~~~~ Filter the result on a time, time scoping, and a set. .. GENERATED FROM PYTHON SOURCE LINES 90-103 .. code-block:: Python print(solution.time_freq_support) stress_on_time_1s_result = solution.stress(time=1.0) stress_on_time_1s = stress_on_time_1s_result.tensor displacement_on_set_1_result = solution.displacement(set=1) displacement_on_set_1 = displacement_on_set_1_result.vector elastic_strain_with_time_scoping_result = solution.elastic_strain(time_scoping=[1, 3]) elastic_strain_with_time_scoping = elastic_strain_with_time_scoping_result.tensor elastic_strain_with_time_scoping .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Time/Freq Support: Number of sets: 1 Cumulative Time (s) LoadStep Substep 1 1.000000 1 1 .. GENERATED FROM PYTHON SOURCE LINES 104-107 Make grouping ~~~~~~~~~~~~~ Make a grouping. .. GENERATED FROM PYTHON SOURCE LINES 107-111 .. code-block:: Python displacement_result = solution.displacement(grouping=post.grouping.by_el_shape) displacement_by_el_shape = displacement_result.vector .. GENERATED FROM PYTHON SOURCE LINES 112-115 Filter MAPDL elements ~~~~~~~~~~~~~~~~~~~~~ Filter for only MAPDL elements of type solid 186. .. GENERATED FROM PYTHON SOURCE LINES 115-120 .. code-block:: Python stress_result = solution.stress(mapdl_grouping=186) stress_on_solid_186 = stress_result.tensor stress_on_solid_186 .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 121-124 Manipulate result and change its definition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Manipulate the result and change its definition. .. GENERATED FROM PYTHON SOURCE LINES 124-134 .. code-block:: Python print(stress_on_ns_result) print(stress_on_ns_result.definition.location) stress_on_ns_result.definition.location = post.locations.elemental stress_on_ns_result.definition.time = 1.0 stress_on_ns_elemental = stress_on_ns_result.tensor print(stress_on_ns_result) .. rst-class:: sphx-glr-script-out .. code-block:: none Stress Tensor object. Object properties: - location : ElementalNodal - named_selection : SELECTION ElementalNodal Stress Tensor object. Object properties: - location : Elemental - named_selection : SELECTION - time : 1.0 .. GENERATED FROM PYTHON SOURCE LINES 135-139 Use miscellaneous results ~~~~~~~~~~~~~~~~~~~~~~~~~ Use miscellaneous results. You can use the same keywords here. For a complex result, you can also use the keyword ``phase``, which has a float value. .. GENERATED FROM PYTHON SOURCE LINES 139-142 .. code-block:: Python stress_ratio = solution.misc.elemental_stress_ratio(node_scoping=[1, 32], time=1.0) print(stress_ratio) .. rst-class:: sphx-glr-script-out .. code-block:: none Stress result. This result has been computed using dpf.core.Operator objects, which have been chained together according to the following list: - ENL_SRAT: Result operator. Compute the desired result. - to_elemental_fc: This operator computes the elemental averaging of a fields container. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.085 seconds) .. _sphx_glr_download_examples_05-Legacy_07-result_keywords.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 07-result_keywords.ipynb <07-result_keywords.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 07-result_keywords.py <07-result_keywords.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_