.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/geometry-mechanical-dpf/wf_gmd_03_dpf.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_geometry-mechanical-dpf_wf_gmd_03_dpf.py: .. _ref_geometry_mech_dpf_03-dpf: Post-processing ############### This examples shows how dataprocessing framework can be used to extract results and analyze them. .. GENERATED FROM PYTHON SOURCE LINES 32-38 .. code-block:: Python import os from pathlib import Path from ansys.dpf import core as dpf .. GENERATED FROM PYTHON SOURCE LINES 45-50 Parameters for the script ------------------------- The following parameters are used to control the script execution. You can modify these parameters to suit your needs. .. GENERATED FROM PYTHON SOURCE LINES 50-55 .. code-block:: Python GRAPHICS_BOOL = False # Set to True to display the graphics OUTPUT_DIR = Path(Path(__file__).parent, "outputs") # Output directory .. GENERATED FROM PYTHON SOURCE LINES 60-63 Finding necessary files for dpf ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 63-93 .. code-block:: Python def find_files(directory, extension): rst_files = [] for root, _, files in os.walk(directory): for file in files: if file.endswith(extension): rst_files.append(os.path.join(root, file)) return rst_files extension_to_find = ".rth" # Mechanical poject directory project_directory = os.path.join(OUTPUT_DIR, "pcb_Mech_Files") steady_state_rth_file = find_files( os.path.join(project_directory, "SteadyStateThermal"), extension_to_find ) transient_rth_file = find_files( os.path.join(project_directory, "TransientThermal"), extension_to_find ) if steady_state_rth_file and transient_rth_file: print(f"Found {extension_to_find} files.") else: print("No .rst files found.") print(steady_state_rth_file) print(transient_rth_file) .. rst-class:: sphx-glr-script-out .. code-block:: none Found .rth files. ['/__w/pyansys-workflows/pyansys-workflows/geometry-mechanical-dpf/outputs/pcb_Mech_Files/SteadyStateThermal/file.rth'] ['/__w/pyansys-workflows/pyansys-workflows/geometry-mechanical-dpf/outputs/pcb_Mech_Files/TransientThermal/file.rth'] .. GENERATED FROM PYTHON SOURCE LINES 94-97 DPF workflow ------------ .. GENERATED FROM PYTHON SOURCE LINES 97-101 .. code-block:: Python # Result precision decimal_precision = 6 .. GENERATED FROM PYTHON SOURCE LINES 102-105 Steady state thermal results ---------------------------- Create model .. GENERATED FROM PYTHON SOURCE LINES 105-117 .. code-block:: Python steady_state_model = dpf.Model(steady_state_rth_file[0]) print(steady_state_model) # Get temperature distribution temp = steady_state_model.results.temperature.on_last_time_freq.eval()[0] # Plot the temperature for ic-6 if GRAPHICS_BOOL: temp.plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/geometry-mechanical-dpf/images/sphx_glr_wf_gmd_03_dpf_001.png :alt: wf gmd 03 dpf :srcset: /examples/geometry-mechanical-dpf/images/sphx_glr_wf_gmd_03_dpf_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: ./images//sphx_glr_wf_gmd_03_dpf_001.vtksz .. 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: Thermal Available results: - temperature: Nodal Temperature - elemental_summable_miscellaneous_data: Elemental Elemental Summable Miscellaneous Data - 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 - element_euler_angles: ElementalNodal Element Euler Angles - elemental_non_summable_miscellaneous_data: Elemental Elemental Non Summable Miscellaneous Data - contact_status: ElementalNodal Contact Status - contact_penetration: ElementalNodal Contact Penetration - contact_pressure: ElementalNodal Contact Pressure - contact_friction_stress: ElementalNodal Contact Friction Stress - contact_total_stress: ElementalNodal Contact Total Stress - contact_sliding_distance: ElementalNodal Contact Sliding Distance - contact_gap_distance: ElementalNodal Contact Gap Distance - total_heat_flux_at_contact_surface: ElementalNodal Total heat flux at contact surface - contact_status_changes: ElementalNodal Contact status changes - fluid_penetration_pressure: ElementalNodal Fluid Penetration Pressure - heat_flux: ElementalNodal Heat flux ------------------------------ DPF Meshed Region: 8274 nodes 2051 elements Unit: m With solid (3D) elements, shell (2D) elements, shell (3D) elements ------------------------------ DPF Time/Freq Support: Number of sets: 1 Cumulative Time (s) LoadStep Substep 1 1.000000 1 1 .. GENERATED FROM PYTHON SOURCE LINES 118-121 Transient thermal results ------------------------- Create model .. GENERATED FROM PYTHON SOURCE LINES 121-131 .. code-block:: Python model = dpf.Model(transient_rth_file[0]) print(steady_state_model) # Get temperature distribution temp = model.results.temperature.on_last_time_freq.eval()[0] # Plot the the temperature for ic-1 if GRAPHICS_BOOL: temp.plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/geometry-mechanical-dpf/images/sphx_glr_wf_gmd_03_dpf_002.png :alt: wf gmd 03 dpf :srcset: /examples/geometry-mechanical-dpf/images/sphx_glr_wf_gmd_03_dpf_002.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: ./images//sphx_glr_wf_gmd_03_dpf_002.vtksz .. 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: Thermal Available results: - temperature: Nodal Temperature - elemental_summable_miscellaneous_data: Elemental Elemental Summable Miscellaneous Data - 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 - element_euler_angles: ElementalNodal Element Euler Angles - elemental_non_summable_miscellaneous_data: Elemental Elemental Non Summable Miscellaneous Data - contact_status: ElementalNodal Contact Status - contact_penetration: ElementalNodal Contact Penetration - contact_pressure: ElementalNodal Contact Pressure - contact_friction_stress: ElementalNodal Contact Friction Stress - contact_total_stress: ElementalNodal Contact Total Stress - contact_sliding_distance: ElementalNodal Contact Sliding Distance - contact_gap_distance: ElementalNodal Contact Gap Distance - total_heat_flux_at_contact_surface: ElementalNodal Total heat flux at contact surface - contact_status_changes: ElementalNodal Contact status changes - fluid_penetration_pressure: ElementalNodal Fluid Penetration Pressure - heat_flux: ElementalNodal Heat flux ------------------------------ DPF Meshed Region: 8274 nodes 2051 elements Unit: m With solid (3D) elements, shell (2D) elements, shell (3D) elements ------------------------------ DPF Time/Freq Support: Number of sets: 1 Cumulative Time (s) LoadStep Substep 1 1.000000 1 1 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 7.107 seconds) .. _sphx_glr_download_examples_geometry-mechanical-dpf_wf_gmd_03_dpf.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: wf_gmd_03_dpf.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: wf_gmd_03_dpf.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: wf_gmd_03_dpf.zip `