.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery_examples/005_get_layup_properties_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_005_get_layup_properties_example.py: .. _layup_properties_plot: Lay-up properties ----------------- This example shows how to efficiently extract elemental lay-up properties such as thickness, angles, and analysis ply names. These are typically used for layer-wise postprocessing and data filtering. To get the full layer information of an element, including results, consider using the :class:`SamplingPoint <.SamplingPoint>` class. .. 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 44-50 Set up analysis ~~~~~~~~~~~~~~~ Setting up the analysis consists of importing dependencies, connecting to the DPF server, and retrieving the example files. Import dependencies. .. GENERATED FROM PYTHON SOURCE LINES 50-57 .. code-block:: Python from matplotlib import pyplot as plt import numpy as np from ansys.dpf.composites.composite_model import CompositeModel, LayerProperty from ansys.dpf.composites.example_helper import get_continuous_fiber_example_files from ansys.dpf.composites.server_helpers import connect_to_or_start_server .. GENERATED FROM PYTHON SOURCE LINES 58-59 Start a DPF server and copy the example files into the current working directory. .. GENERATED FROM PYTHON SOURCE LINES 59-62 .. code-block:: Python server = connect_to_or_start_server() composite_files_on_server = get_continuous_fiber_example_files(server, "shell") .. GENERATED FROM PYTHON SOURCE LINES 63-66 Set up model ~~~~~~~~~~~~ Set up the composite model. .. GENERATED FROM PYTHON SOURCE LINES 66-68 .. code-block:: Python composite_model = CompositeModel(composite_files_on_server, server) .. GENERATED FROM PYTHON SOURCE LINES 69-72 Get lay-up properties ~~~~~~~~~~~~~~~~~~~~~ Get lay-up properties for all elements and show the first one as an example. .. GENERATED FROM PYTHON SOURCE LINES 72-80 .. code-block:: Python element_id = 1 thicknesses = composite_model.get_property_for_all_layers(LayerProperty.THICKNESSES, element_id) angles = composite_model.get_property_for_all_layers(LayerProperty.ANGLES, element_id) shear_angles = composite_model.get_property_for_all_layers(LayerProperty.SHEAR_ANGLES, element_id) offset = composite_model.get_element_laminate_offset(element_id) analysis_plies = composite_model.get_analysis_plies(element_id) .. GENERATED FROM PYTHON SOURCE LINES 81-84 Plot lay-up properties ~~~~~~~~~~~~~~~~~~~~~~ Plot basic layer properties (layer thicknesses, angles, and analysis ply names). .. GENERATED FROM PYTHON SOURCE LINES 84-102 .. code-block:: Python y_coordinates = offset + np.cumsum(thicknesses) y_centers = y_coordinates - thicknesses / 2 fig, ax1 = f, ax = plt.subplots(figsize=(6, 10)) for y_coordinate in y_coordinates: ax1.axhline(y=y_coordinate, color="k") for angle, shear_angle, y_coordinate, analysis_ply in zip( angles, shear_angles, y_centers, analysis_plies ): ax1.annotate( f"Angle={angle}°, Shear Angle={shear_angle}°, {analysis_ply}", xy=(0.1, y_coordinate), xytext=(0.1, y_coordinate), ) fig.show() .. image-sg:: /examples/gallery_examples/images/sphx_glr_005_get_layup_properties_example_001.png :alt: 005 get layup properties example :srcset: /examples/gallery_examples/images/sphx_glr_005_get_layup_properties_example_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.758 seconds) .. _sphx_glr_download_examples_gallery_examples_005_get_layup_properties_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 005_get_layup_properties_example.ipynb <005_get_layup_properties_example.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 005_get_layup_properties_example.py <005_get_layup_properties_example.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 005_get_layup_properties_example.zip <005_get_layup_properties_example.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_