.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\00-basic\08-results_over_time_subset.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_08-results_over_time_subset.py: .. _ref_results_over_time: Scope results over custom time domains ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The :class:`Result ` class, which are instances created by the :class:`Model `, give access to helpers for requesting results on specific mesh and time scopings. With these helpers, working on a temporal subset of the model is straightforward. In this example, different ways to choose the temporal subset to evaluate a result are exposed. This example can be extended to frequency subsets. .. GENERATED FROM PYTHON SOURCE LINES 16-21 .. code-block:: Python # Import necessary modules from ansys.dpf import core as dpf from ansys.dpf.core import examples .. GENERATED FROM PYTHON SOURCE LINES 22-23 Create a model object to establish a connection with an example result file: .. GENERATED FROM PYTHON SOURCE LINES 23-26 .. code-block:: Python model = dpf.Model(examples.download_transient_result()) print(model) .. rst-class:: sphx-glr-script-out .. code-block:: none 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 - structural_temperature: ElementalNodal Structural temperature ------------------------------ DPF Meshed Region: 3820 nodes 789 elements Unit: m With solid (3D) elements, shell (2D) elements, shell (3D) elements ------------------------------ DPF Time/Freq Support: Number of sets: 35 Cumulative Time (s) LoadStep Substep 1 0.000000 1 1 2 0.019975 1 2 3 0.039975 1 3 4 0.059975 1 4 5 0.079975 1 5 6 0.099975 1 6 7 0.119975 1 7 8 0.139975 1 8 9 0.159975 1 9 10 0.179975 1 10 11 0.199975 1 11 12 0.218975 1 12 13 0.238975 1 13 14 0.258975 1 14 15 0.278975 1 15 16 0.298975 1 16 17 0.318975 1 17 18 0.338975 1 18 19 0.358975 1 19 20 0.378975 1 20 21 0.398975 1 21 22 0.417975 1 22 23 0.437975 1 23 24 0.457975 1 24 25 0.477975 1 25 26 0.497975 1 26 27 0.517975 1 27 28 0.537550 1 28 29 0.557253 1 29 30 0.577118 1 30 31 0.597021 1 31 32 0.616946 1 32 33 0.636833 1 33 34 0.656735 1 34 35 0.676628 1 35 .. GENERATED FROM PYTHON SOURCE LINES 27-31 Request specific time sets ~~~~~~~~~~~~~~~~~~~~~~~~~~ If specific time sets are of interest, looking into the ``TimeFreqSupport`` and connect a given ``time_scoping`` accordingly to the cumulative indexes can be useful. .. GENERATED FROM PYTHON SOURCE LINES 31-45 .. code-block:: Python print(model.metadata.time_freq_support) time_sets = [1, 3, 10] disp = model.results.displacement.on_time_scoping(time_sets).eval() print(disp) # Or using a scoping time_sets_scoping = dpf.time_freq_scoping_factory.scoping_by_sets([1, 3, 10]) disp = model.results.displacement.on_time_scoping(time_sets_scoping).eval() print(disp) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF Time/Freq Support: Number of sets: 35 Cumulative Time (s) LoadStep Substep 1 0.000000 1 1 2 0.019975 1 2 3 0.039975 1 3 4 0.059975 1 4 5 0.079975 1 5 6 0.099975 1 6 7 0.119975 1 7 8 0.139975 1 8 9 0.159975 1 9 10 0.179975 1 10 11 0.199975 1 11 12 0.218975 1 12 13 0.238975 1 13 14 0.258975 1 14 15 0.278975 1 15 16 0.298975 1 16 17 0.318975 1 17 18 0.338975 1 18 19 0.358975 1 19 20 0.378975 1 20 21 0.398975 1 21 22 0.417975 1 22 23 0.437975 1 23 24 0.457975 1 24 25 0.477975 1 25 26 0.497975 1 26 27 0.517975 1 27 28 0.537550 1 28 29 0.557253 1 29 30 0.577118 1 30 31 0.597021 1 31 32 0.616946 1 32 33 0.636833 1 33 34 0.656735 1 34 35 0.676628 1 35 DPF displacement(s)Fields Container with 3 field(s) defined on labels: time with: - field 0 {time: 1} with Nodal location, 3 components and 3820 entities. - field 1 {time: 3} with Nodal location, 3 components and 3820 entities. - field 2 {time: 10} with Nodal location, 3 components and 3820 entities. DPF displacement(s)Fields Container with 3 field(s) defined on labels: time with: - field 0 {time: 1} with Nodal location, 3 components and 3820 entities. - field 1 {time: 3} with Nodal location, 3 components and 3820 entities. - field 2 {time: 10} with Nodal location, 3 components and 3820 entities. .. GENERATED FROM PYTHON SOURCE LINES 46-47 Equivalent to: .. GENERATED FROM PYTHON SOURCE LINES 47-51 .. code-block:: Python disp_op = model.results.displacement() disp_op.inputs.time_scoping(time_sets) disp = disp_op.outputs.fields_container() .. GENERATED FROM PYTHON SOURCE LINES 52-53 Equivalent to: .. GENERATED FROM PYTHON SOURCE LINES 53-55 .. code-block:: Python disp = model.results.displacement(time_scoping=time_sets_scoping).eval() .. GENERATED FROM PYTHON SOURCE LINES 56-60 Request specific time steps ~~~~~~~~~~~~~~~~~~~~~~~~~~~ If specific time steps or load steps are of interest, looking into the ``TimeFreqSupport`` and connect a given ``time_scoping`` located on steps can be done. .. GENERATED FROM PYTHON SOURCE LINES 60-65 .. code-block:: Python time_steps_scoping = dpf.time_freq_scoping_factory.scoping_by_load_step(1) disp = model.results.displacement.on_time_scoping(time_steps_scoping).eval() print(disp) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF displacement(s)Fields Container with 35 field(s) defined on labels: time with: - field 0 {time: 1} with Nodal location, 3 components and 3820 entities. - field 1 {time: 2} with Nodal location, 3 components and 3820 entities. - field 2 {time: 3} with Nodal location, 3 components and 3820 entities. - field 3 {time: 4} with Nodal location, 3 components and 3820 entities. - field 4 {time: 5} with Nodal location, 3 components and 3820 entities. - field 5 {time: 6} with Nodal location, 3 components and 3820 entities. - field 6 {time: 7} with Nodal location, 3 components and 3820 entities. - field 7 {time: 8} with Nodal location, 3 components and 3820 entities. - field 8 {time: 9} with Nodal location, 3 components and 3820 entities. - field 9 {time: 10} with Nodal location, 3 components and 3820 entities. - field 10 {time: 11} with Nodal location, 3 components and 3820 entities. - field 11 {time: 12} with Nodal location, 3 components and 3820 entities. - field 12 {time: 13} with Nodal location, 3 components and 3820 entities. - field 13 {time: 14} with Nodal location, 3 components and 3820 entities. - field 14 {time: 15} with Nodal location, 3 components and 3820 entities. - field 15 {time: 16} with Nodal location, 3 components and 3820 entities. - field 16 {time: 17} with Nodal location, 3 components and 3820 entities. - field 17 {time: 18} with Nodal location, 3 components and 3820 entities. - field 18 {time: 19} with Nodal location, 3 components and 3820 entities. - field 19 {time: 20} with Nodal location, 3 components and 3820 entities. - field 20 {time: 21} with Nodal location, 3 components and 3820 entities. - field 21 {time: 22} with Nodal location, 3 components and 3820 entities. - field 22 {time: 23} with Nodal location, 3 components and 3820 entities. - field 23 {time: 24} with Nodal location, 3 components and 3820 entities. - field 24 {time: 25} with Nodal location, 3 components and 3820 entities. - field 25 {time: 26} with Nodal location, 3 components and 3820 entities. - field 26 {time: 27} with Nodal location, 3 components and 3820 entities. - field 27 {time: 28} with Nodal location, 3 components and 3820 entities. - field 28 {time: 29} with Nodal location, 3 components and 3820 entities. - field 29 {time: 30} with Nodal location, 3 components and 3820 entities. - field 30 {time: 31} with Nodal location, 3 components and 3820 entities. - field 31 {time: 32} with Nodal location, 3 components and 3820 entities. - field 32 {time: 33} with Nodal location, 3 components and 3820 entities. - field 33 {time: 34} with Nodal location, 3 components and 3820 entities. - field 34 {time: 35} with Nodal location, 3 components and 3820 entities. .. GENERATED FROM PYTHON SOURCE LINES 66-67 Equivalent to: .. GENERATED FROM PYTHON SOURCE LINES 67-71 .. code-block:: Python disp_op = model.results.displacement() disp_op.inputs.time_scoping(time_steps_scoping) disp = disp_op.outputs.fields_container() .. GENERATED FROM PYTHON SOURCE LINES 72-75 Using helpers ~~~~~~~~~~~~~ Evaluate at all times. .. GENERATED FROM PYTHON SOURCE LINES 75-78 .. code-block:: Python disp = model.results.displacement.on_all_time_freqs().eval() .. GENERATED FROM PYTHON SOURCE LINES 79-80 Evaluate at first and last times .. GENERATED FROM PYTHON SOURCE LINES 80-84 .. code-block:: Python disp = model.results.displacement.on_first_time_freq().eval() print(disp) disp = model.results.displacement.on_last_time_freq().eval() print(disp) .. rst-class:: sphx-glr-script-out .. code-block:: none DPF displacement(s)Fields Container with 1 field(s) defined on labels: time with: - field 0 {time: 1} with Nodal location, 3 components and 3820 entities. DPF displacement(s)Fields Container with 1 field(s) defined on labels: time with: - field 0 {time: 35} with Nodal location, 3 components and 3820 entities. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.704 seconds) .. _sphx_glr_download_examples_00-basic_08-results_over_time_subset.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 08-results_over_time_subset.ipynb <08-results_over_time_subset.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 08-results_over_time_subset.py <08-results_over_time_subset.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_