.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\00-basic\07-use_result_helpers.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_00-basic_07-use_result_helpers.py: .. _ref_use_result_helpers: Use result helpers to load custom data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The :class:`Result ` class, which is an instance created by the :class:`Model `, gives access to helpers for requesting results on specific mesh and time scopings. With these helpers, working on a custom spatial and temporal subset of the model is straightforward. .. GENERATED FROM PYTHON SOURCE LINES 15-20 .. code-block:: Python # Import necessary modules from ansys.dpf import core as dpf from ansys.dpf.core import examples .. GENERATED FROM PYTHON SOURCE LINES 21-22 Create a model object to establish a connection with an example result file: .. GENERATED FROM PYTHON SOURCE LINES 22-25 .. code-block:: Python model = dpf.Model(examples.download_multi_stage_cyclic_result()) print(model) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Model ------------------------------ Modal analysis Unit system: MKS: m, kg, N, s, V, A, degC Physics Type: Mechanical Available results: - displacement: Nodal Displacement - stress: ElementalNodal Stress - elastic_strain: ElementalNodal Strain - element_euler_angles: ElementalNodal Element Euler Angles - structural_temperature: ElementalNodal Structural temperature ------------------------------ DPF Meshed Region: 3595 nodes 1557 elements Unit: m With solid (3D) elements ------------------------------ DPF Time/Freq Support: Number of sets: 6 Cumulative Frequency (Hz) LoadStep Substep Harmonic index 1 188.385357 1 1 0.000000 2 325.126418 1 2 0.000000 3 595.320548 1 3 0.000000 4 638.189511 1 4 0.000000 5 775.669703 1 5 0.000000 6 928.278013 1 6 0.000000 .. GENERATED FROM PYTHON SOURCE LINES 26-29 Visualize specific mode shapes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Choose the modes to visualize: .. GENERATED FROM PYTHON SOURCE LINES 29-33 .. code-block:: Python modes = [1, 5, 6] disp = model.results.displacement.on_time_scoping(modes) .. GENERATED FROM PYTHON SOURCE LINES 34-37 Choose a spatial subset ~~~~~~~~~~~~~~~~~~~~~~~ Work on only a named selection (or component). .. GENERATED FROM PYTHON SOURCE LINES 39-40 Print the available named selection: .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: Python print(model.metadata.available_named_selections) .. rst-class:: sphx-glr-script-out .. code-block:: none ['BC', 'ELM', 'STAG1', 'STAG1HIGH', 'STAG1LOW', 'STAG2', 'STAG2HIGH', 'STAG2LOW', '_BC_NOD', '_FIXEDSU', '_INTF_ELM', '_INTF_NOD', '_NOD', '_STAG1_BASE_ELM', '_STAG1_BASE_NOD', '_STAG1_CYCHIGH_NOD', '_STAG1_CYCLOW_NOD', '_STAG2_BASE_ELM', '_STAG2_BASE_NOD', '_STAG2_CYCHIGH_NOD', '_STAG2_CYCLOW_NOD'] .. GENERATED FROM PYTHON SOURCE LINES 43-44 Specify to the result that you want to work on a specific named selection: .. GENERATED FROM PYTHON SOURCE LINES 44-53 .. code-block:: Python disp.on_named_selection("_STAG1_BASE_NOD") op = disp() op.inputs.read_cyclic(2) # expand cyclic results = op.outputs.fields_container() # plot for mode in modes: results[0].meshed_region.plot(results.get_fields_by_time_complex_ids(mode, 0)[0]) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/00-basic/images/sphx_glr_07-use_result_helpers_001.png :alt: 07 use result helpers :srcset: /examples/00-basic/images/sphx_glr_07-use_result_helpers_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/00-basic/images/sphx_glr_07-use_result_helpers_002.png :alt: 07 use result helpers :srcset: /examples/00-basic/images/sphx_glr_07-use_result_helpers_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/00-basic/images/sphx_glr_07-use_result_helpers_003.png :alt: 07 use result helpers :srcset: /examples/00-basic/images/sphx_glr_07-use_result_helpers_003.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 54-55 Specify to the result that you want to work on specific nodes: .. GENERATED FROM PYTHON SOURCE LINES 55-64 .. code-block:: Python disp = model.results.displacement.on_time_scoping(modes) disp.on_mesh_scoping(list(range(1, 200))) op = disp() op.inputs.read_cyclic(2) # expand cyclic results = op.outputs.fields_container() # plot for mode in modes: results[0].meshed_region.plot(results.get_fields_by_time_complex_ids(mode, 0)[0]) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/00-basic/images/sphx_glr_07-use_result_helpers_004.png :alt: 07 use result helpers :srcset: /examples/00-basic/images/sphx_glr_07-use_result_helpers_004.png :class: sphx-glr-multi-img * .. image-sg:: /examples/00-basic/images/sphx_glr_07-use_result_helpers_005.png :alt: 07 use result helpers :srcset: /examples/00-basic/images/sphx_glr_07-use_result_helpers_005.png :class: sphx-glr-multi-img * .. image-sg:: /examples/00-basic/images/sphx_glr_07-use_result_helpers_006.png :alt: 07 use result helpers :srcset: /examples/00-basic/images/sphx_glr_07-use_result_helpers_006.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.456 seconds) .. _sphx_glr_download_examples_00-basic_07-use_result_helpers.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 07-use_result_helpers.ipynb <07-use_result_helpers.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 07-use_result_helpers.py <07-use_result_helpers.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_