.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/020-trackers-viewport-options.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_020-trackers-viewport-options.py: .. _trackers_viewport_options_example: Work with contact and convergence trackers =========================================== This example demonstrates how to work with tracker viewports in Result Explorer: - **Convergence trackers** to monitor solver convergence across iterations. - **Contact trackers** to visualize and analyze contact behavior in transient simulations. - **Tracker viewport metadata** to read and display properties of tracker visualizations. - **Active series configuration** for contact trackers to select specific analysis types. - **Display options** to customize tracker visualization (legend, table, split direction). This example uses a transient contact analysis result with convergence and contact tracking data. .. GENERATED FROM PYTHON SOURCE LINES 36-37 Import the Result Explorer dependencies. .. GENERATED FROM PYTHON SOURCE LINES 37-47 .. code-block:: Python from ansys.result_explorer.core import ( ContactTrackersViewportMetadata, launch_result_explorer, ) from ansys.result_explorer.core.examples import ( ExampleKeys, get_example_file, get_example_snapshot_settings, ) .. GENERATED FROM PYTHON SOURCE LINES 48-51 Launch Result Explorer ---------------------- Start a Result Explorer instance for this example. .. GENERATED FROM PYTHON SOURCE LINES 51-53 .. code-block:: Python rx = launch_result_explorer() .. GENERATED FROM PYTHON SOURCE LINES 54-57 Load example data ------------------ Create a solution from the transient contact analysis. .. GENERATED FROM PYTHON SOURCE LINES 57-66 .. code-block:: Python rst_path = get_example_file(ExampleKeys.RST_CP_TRANSIENT) sol = rx.create_solution( name="Contact Transient Analysis", file_path=rst_path, ) print(f"Created solution: {sol.name}") print(f" Elements: {sol.n_elements}, Nodes: {sol.n_nodes}") .. rst-class:: sphx-glr-script-out .. code-block:: none Created solution: Contact Transient Analysis Elements: 122, Nodes: 406 .. GENERATED FROM PYTHON SOURCE LINES 67-70 Find tracker views ------------------- Locate convergence and contact trackers views in the solution. .. GENERATED FROM PYTHON SOURCE LINES 70-79 .. code-block:: Python convergence_view = sol.convergence_trackers_view contact_view = sol.contact_trackers_view assert convergence_view is not None, "Convergence trackers view not found in solution" assert contact_view is not None, "Contact trackers view not found in solution" print(f"Found convergence trackers view: {convergence_view.name}") print(f"Found contact trackers view: {contact_view.name}") .. rst-class:: sphx-glr-script-out .. code-block:: none Found convergence trackers view: Convergence Trackers Found contact trackers view: Contact Trackers .. GENERATED FROM PYTHON SOURCE LINES 80-83 Create workspace with grid layout ----------------------------------- Create a workspace with a 2x1 grid for tracker viewports. .. GENERATED FROM PYTHON SOURCE LINES 83-86 .. code-block:: Python workspace = rx.create_workspace(name="Tracker Viewports", rows=2, cols=1) print(f"Created workspace with {len(workspace.viewport_ids)} viewports (2x1 grid)") .. rst-class:: sphx-glr-script-out .. code-block:: none Created workspace with 2 viewports (2x1 grid) .. GENERATED FROM PYTHON SOURCE LINES 87-90 Configure convergence trackers viewport ---------------------------------------- Assign and configure the convergence trackers view. .. GENERATED FROM PYTHON SOURCE LINES 90-101 .. code-block:: Python conv_viewport = workspace.viewports[0] conv_viewport.set_view(convergence_view, wait=True) conv_opts = conv_viewport.display_options print("\nConfiguring convergence trackers viewport:") print(f" Selected tracker: {conv_opts.selected_tracker_name}") conv_viewport.save_snapshot( file_path="020-convergence-trackers.png", settings=get_example_snapshot_settings() ) .. image-sg:: /examples/images/sphx_glr_020-trackers-viewport-options_001.png :alt: 020 trackers viewport options :srcset: /examples/images/sphx_glr_020-trackers-viewport-options_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Configuring convergence trackers viewport: Selected tracker: Force Convergence .. GENERATED FROM PYTHON SOURCE LINES 102-105 Configure contact trackers viewport ------------------------------------ Assign and configure the contact trackers view with available options. .. GENERATED FROM PYTHON SOURCE LINES 105-131 .. code-block:: Python contact_viewport = workspace.viewports[1] contact_viewport.set_view(contact_view, wait=True) contact_meta: ContactTrackersViewportMetadata = contact_viewport.metadata print("\nConfiguring contact trackers viewport:") # Show available trackers trackers = contact_meta.contact_tracker_names print(f" Available contact trackers: {len(trackers)}") for tracker in trackers: print(f" - {tracker}") # Configure active trackers contact_opts = contact_viewport.display_options contact_opts.active_contact_trackers = trackers # Show available series series = contact_meta.series_names print(f" Available data series: {len(series)}") for s in series: print(f" - {s}") contact_viewport.save_snapshot( file_path="020-contact-trackers.png", settings=get_example_snapshot_settings() ) .. image-sg:: /examples/images/sphx_glr_020-trackers-viewport-options_002.png :alt: 020 trackers viewport options :srcset: /examples/images/sphx_glr_020-trackers-viewport-options_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Configuring contact trackers viewport: Available contact trackers: 2 - (ID: 3) Frictional - Solid1 To Solid2 - (ID: 4) Frictional - Solid1 To Solid2 Available data series: 46 - Number of Contact Elements in Contact - Number of Contact Elements in Contact (Sticking) - Max. Chattering Level - Max. Penetration/Min. Gap - Max. Geometric Gap - Max. Normal Stiffness - Min. Normal Stiffness - Max. Resulting Pinball - Max. Elastic Slip Distance - Max. Tangential Stiffness - Min. Tangential Stiffness - Max. Sliding Distance of Entire Solution - Max. Contact Pressure - Max. Friction Stress - Average Contact Depth - Max. Geometric Penetration - Number of Contact Points Have Too Much Penetration - Contacting Area - Max. Contact Damping Pressure - Max. Contact Damping Tangential stress - Max. Sliding Distance including near field - Min. Sliding Distance including near field - Max. normal fluid penetration pressure on contact surface - Max. normal fluid penetration pressure on target surface - Total volume loss due to wear on contact surface - Total strain energy due to contact - Frictional dissipation energy - Contact damping dissipation energy - WB contact pair ID - Total contact force due to pressure -x component - Total contact force due to pressure -y component - Total contact force due to pressure -z component - Total contact force due to tangential stress -x component - Total contact force due to tangential stress -y component - Total contact force due to tangential stress -z component - Number of Contact Points Have Too Much sliding - Contact pair force convergence norm - Contact pair force criterion - Max. tangential fluid penetration pressure on contact surface - Max. tangential fluid penetration pressure on target surface - Max. sliding distance of current substep for closed contact - load_step - substep - iteration - Time - Cumulative Iteration .. GENERATED FROM PYTHON SOURCE LINES 132-135 Set display options -------------------- Configure active series and display options for the contact viewport. .. GENERATED FROM PYTHON SOURCE LINES 135-148 .. code-block:: Python contact_opts.active_series = ["Max. Normal Stiffness"] print(f"\n Active series set to: {contact_opts.active_series}") with contact_viewport.update_display_options() as contact_opts: contact_opts.show_legend = True contact_opts.show_table = True contact_opts.split_direction = "horizontal" print(" Legend enabled, table enabled, split direction: horizontal") print("\nViewport configuration complete!") print(f"Workspace '{workspace.name}' is ready with tracker views configured.") rx.stop() .. rst-class:: sphx-glr-script-out .. code-block:: none Active series set to: ['Max. Normal Stiffness'] Legend enabled, table enabled, split direction: horizontal Viewport configuration complete! Workspace 'Tracker Viewports' is ready with tracker views configured. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 21.896 seconds) .. _sphx_glr_download_examples_020-trackers-viewport-options.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 020-trackers-viewport-options.ipynb <020-trackers-viewport-options.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 020-trackers-viewport-options.py <020-trackers-viewport-options.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 020-trackers-viewport-options.zip <020-trackers-viewport-options.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_