.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery_examples/008_assembly_example.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_gallery_examples_008_assembly_example.py: .. _assembly_example: Postprocess an assembly ----------------------- This example shows how to postprocess an assembly with multiple composite parts. The assembly consists of a shell and solid composite model. The :class:`Composite Model <.CompositeModel>` class is used to access the data of the different parts. .. note:: When using a Workbench project, use the :func:`.composite_files_from_workbench_harmonic_analysis` method to obtain the input files. .. GENERATED FROM PYTHON SOURCE LINES 42-48 Set up analysis ~~~~~~~~~~~~~~~ Setting up the analysis consists of loading Ansys libraries, connecting to the DPF server, and retrieving the example files. Load Ansys libraries. .. GENERATED FROM PYTHON SOURCE LINES 48-59 .. code-block:: Python from ansys.dpf.composites.composite_model import CompositeModel from ansys.dpf.composites.constants import FailureOutput from ansys.dpf.composites.example_helper import get_continuous_fiber_example_files from ansys.dpf.composites.failure_criteria import CombinedFailureCriterion, MaxStressCriterion from ansys.dpf.composites.server_helpers import ( connect_to_or_start_server, version_equal_or_later, version_older_than, ) .. GENERATED FROM PYTHON SOURCE LINES 60-61 Start a DPF server and copy the example files into the current working directory. .. GENERATED FROM PYTHON SOURCE LINES 61-64 .. code-block:: Python server = connect_to_or_start_server() composite_files_on_server = get_continuous_fiber_example_files(server, "assembly") .. GENERATED FROM PYTHON SOURCE LINES 65-68 Configure combined failure criterion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Configure the combined failure crition. .. GENERATED FROM PYTHON SOURCE LINES 68-73 .. code-block:: Python combined_fc = CombinedFailureCriterion( name="failure of all materials", failure_criteria=[MaxStressCriterion()], ) .. GENERATED FROM PYTHON SOURCE LINES 74-77 Set up model ~~~~~~~~~~~~ Set up the composite model. .. GENERATED FROM PYTHON SOURCE LINES 77-79 .. code-block:: Python composite_model = CompositeModel(composite_files_on_server, server) .. GENERATED FROM PYTHON SOURCE LINES 80-83 Plot IRF ~~~~~~~~ Plot the maximum IRF per (solid) element. .. GENERATED FROM PYTHON SOURCE LINES 83-87 .. code-block:: Python output_all_elements = composite_model.evaluate_failure_criteria(combined_criterion=combined_fc) irf_field = output_all_elements.get_field({"failure_label": FailureOutput.FAILURE_VALUE}) irf_field.plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/gallery_examples/images/sphx_glr_008_assembly_example_001.png :alt: 008 assembly example :srcset: /examples/gallery_examples/images/sphx_glr_008_assembly_example_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pydpf-composites/pydpf-composites/doc/source/examples/gallery_examples/images/sphx_glr_008_assembly_example_001.vtksz .. GENERATED FROM PYTHON SOURCE LINES 88-91 Plot IRF on the reference surface ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Plot the maximum IRF on the reference surface .. GENERATED FROM PYTHON SOURCE LINES 91-98 .. code-block:: Python if version_equal_or_later(server, "8.0"): irf_field = output_all_elements.get_field( {"failure_label": FailureOutput.FAILURE_VALUE_REF_SURFACE} ) irf_field.plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/gallery_examples/images/sphx_glr_008_assembly_example_002.png :alt: 008 assembly example :srcset: /examples/gallery_examples/images/sphx_glr_008_assembly_example_002.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pydpf-composites/pydpf-composites/doc/source/examples/gallery_examples/images/sphx_glr_008_assembly_example_002.vtksz .. GENERATED FROM PYTHON SOURCE LINES 99-106 Get element information ~~~~~~~~~~~~~~~~~~~~~~~ In the assembly, two composite definitions exist: one with a "shell" label and one with a "solid" label. For DPF Server versions earlier than 7.0, the lay-up properties must be queried with the correct composite definition label. The code following gets element information for all layered elements. For DPF Server versions 7.0 and later, element information can be retrieved directly. .. GENERATED FROM PYTHON SOURCE LINES 106-121 .. code-block:: Python if version_older_than(server, "7.0"): element_infos = [] for composite_label in composite_model.composite_definition_labels: for ( element_id ) in composite_model.get_all_layered_element_ids_for_composite_definition_label( composite_label ): element_infos.append(composite_model.get_element_info(element_id, composite_label)) else: element_infos = [] for element_id in composite_model.get_all_layered_element_ids(): element_infos.append(composite_model.get_element_info(element_id)) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 10.114 seconds) .. _sphx_glr_download_examples_gallery_examples_008_assembly_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 008_assembly_example.ipynb <008_assembly_example.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 008_assembly_example.py <008_assembly_example.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 008_assembly_example.zip <008_assembly_example.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_