.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery_examples/5_get_layup_properties_example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_gallery_examples_5_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. .. GENERATED FROM PYTHON SOURCE LINES 15-21 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 21-28 .. code-block:: default 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 29-30 Start a DPF server and copy the example files into the current working directory. .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. code-block:: default server = connect_to_or_start_server() composite_files_on_server = get_continuous_fiber_example_files(server, "shell") .. GENERATED FROM PYTHON SOURCE LINES 34-37 Set up model ~~~~~~~~~~~~ Set up the composite model. .. GENERATED FROM PYTHON SOURCE LINES 37-39 .. code-block:: default composite_model = CompositeModel(composite_files_on_server, server) .. GENERATED FROM PYTHON SOURCE LINES 40-43 Get lay-up properties ~~~~~~~~~~~~~~~~~~~~~ Get lay-up properties for all elements and show the first one as an example. .. GENERATED FROM PYTHON SOURCE LINES 43-51 .. code-block:: default 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 52-55 Plot lay-up properties ~~~~~~~~~~~~~~~~~~~~~~ Plot basic layer properties (layer thicknesses, angles, and analysis ply names). .. GENERATED FROM PYTHON SOURCE LINES 55-73 .. code-block:: default 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_5_get_layup_properties_example_001.png :alt: 5 get layup properties example :srcset: /examples/gallery_examples/images/sphx_glr_5_get_layup_properties_example_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.543 seconds) .. _sphx_glr_download_examples_gallery_examples_5_get_layup_properties_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 5_get_layup_properties_example.py <5_get_layup_properties_example.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 5_get_layup_properties_example.ipynb <5_get_layup_properties_example.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_