.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/modeling_features/05-rosettes-ply-directions.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_modeling_features_05-rosettes-ply-directions.py: .. _rosette_example: Rosette example =============== This example illustrates how you can use rosettes to define the reference directions of a ply. It only shows the PyACP part of the setup. For a complete composite analysis, see :ref:`pymapdl_workflow_example`. .. GENERATED FROM PYTHON SOURCE LINES 35-39 Import modules -------------- Import the standard library and third-party dependencies. .. GENERATED FROM PYTHON SOURCE LINES 39-44 .. code-block:: Python import pathlib import tempfile import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 45-46 Import the PyACP dependencies. .. GENERATED FROM PYTHON SOURCE LINES 46-58 .. code-block:: Python from ansys.acp.core import ( ACPWorkflow, EdgeSetType, PlyType, RosetteSelectionMethod, RosetteType, get_directions_plotter, launch_acp, ) from ansys.acp.core.extras import ExampleKeys, get_example_file .. GENERATED FROM PYTHON SOURCE LINES 60-62 Start ACP and load the model ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 64-65 Get the example file from the server. .. GENERATED FROM PYTHON SOURCE LINES 65-69 .. code-block:: Python tempdir = tempfile.TemporaryDirectory() WORKING_DIR = pathlib.Path(tempdir.name) input_file = get_example_file(ExampleKeys.BASIC_FLAT_PLATE_DAT, WORKING_DIR) .. GENERATED FROM PYTHON SOURCE LINES 70-71 Launch the PyACP server and connect to it. .. GENERATED FROM PYTHON SOURCE LINES 71-73 .. code-block:: Python acp = launch_acp() .. GENERATED FROM PYTHON SOURCE LINES 74-78 Define the input file and instantiate an ``ACPWorkflow`` instance. The ``ACPWorkflow`` class provides convenience methods that simplify file handling. It automatically creates a model based on the input file. This example's input file contains a flat plate with a single ply. .. GENERATED FROM PYTHON SOURCE LINES 78-88 .. code-block:: Python workflow = ACPWorkflow.from_cdb_or_dat_file( acp=acp, cdb_or_dat_file_path=input_file, local_working_directory=WORKING_DIR, ) model = workflow.model print(workflow.working_directory.path) print(model.unit_system) .. rst-class:: sphx-glr-script-out .. code-block:: none /tmp/tmpttsvn6zy mks .. GENERATED FROM PYTHON SOURCE LINES 89-91 Define directions with a parallel rosette ----------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 93-94 Create a material and fabric. .. GENERATED FROM PYTHON SOURCE LINES 94-101 .. code-block:: Python ud_material = model.create_material( name="UD", ply_type=PlyType.REGULAR, ) fabric = model.create_fabric(name="UD", material=ud_material, thickness=0.1) .. GENERATED FROM PYTHON SOURCE LINES 102-103 Create a parallel rosette where the first direction is rotated by 45 degrees around the y axis. .. GENERATED FROM PYTHON SOURCE LINES 103-111 .. code-block:: Python parallel_rosette_45_deg = model.create_rosette( name="ParallelRosette", rosette_type=RosetteType.PARALLEL, origin=(0, 0, 0), dir1=(np.sqrt(2) / 2, 0, np.sqrt(2) / 2), dir2=(-np.sqrt(2) / 2, 0, np.sqrt(2) / 2), ) .. GENERATED FROM PYTHON SOURCE LINES 112-113 Create an oriented selection set (OSS) and assign the rosette. .. GENERATED FROM PYTHON SOURCE LINES 113-123 .. code-block:: Python oss = model.create_oriented_selection_set( name="oss", orientation_point=(0.0, 0.0, 0.0), orientation_direction=(0.0, 1.0, 0), element_sets=[model.element_sets["All_Elements"]], rosettes=[parallel_rosette_45_deg], ) model.update() .. GENERATED FROM PYTHON SOURCE LINES 124-125 Plot the orientation and reference directions of the OSS. .. GENERATED FROM PYTHON SOURCE LINES 125-130 .. code-block:: Python plotter = get_directions_plotter( model=model, components=[oss.elemental_data.orientation, oss.elemental_data.reference_direction] ) plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_001.png :alt: 05 rosettes ply directions :srcset: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_001.vtksz .. GENERATED FROM PYTHON SOURCE LINES 131-134 Create a ply that uses the reference directions defined by the rosette. The ply angle is set to 20 degrees, which means that the fiber direction is rotated by 20 degrees from the reference direction. .. GENERATED FROM PYTHON SOURCE LINES 134-142 .. code-block:: Python modeling_group = model.create_modeling_group(name="modeling_group") modeling_ply = modeling_group.create_modeling_ply( name="ply", ply_angle=20, ply_material=fabric, oriented_selection_sets=[oss], ) .. GENERATED FROM PYTHON SOURCE LINES 143-144 Plot the reference directions, fiber directions, and transverse directions of the ply. .. GENERATED FROM PYTHON SOURCE LINES 144-154 .. code-block:: Python plotter = get_directions_plotter( model=model, components=[ modeling_ply.elemental_data.reference_direction, modeling_ply.elemental_data.fiber_direction, modeling_ply.elemental_data.transverse_direction, ], ) plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_002.png :alt: 05 rosettes ply directions :srcset: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_002.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_002.vtksz .. GENERATED FROM PYTHON SOURCE LINES 155-163 Define directions with a radial rosette --------------------------------------- Create a radial rosette and plot the resulting reference directions. For a radial rosette, a line is constructed that goes through the origin. Its direction vector is normal to a plane spanned by ``dir1`` and ``dir2``. Therefore, the reference directions are parallel to the shortest connection from the line to each point for which it is computed. .. GENERATED FROM PYTHON SOURCE LINES 163-177 .. code-block:: Python radial_rosette = model.create_rosette( name="RadialRosette", rosette_type=RosetteType.RADIAL, origin=(0.005, 0, 0.005), dir1=(1, 0, 0), dir2=(0, 0, 1), ) oss.rosettes = [radial_rosette] model.update() plotter = get_directions_plotter(model=model, components=[oss.elemental_data.reference_direction]) plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_003.png :alt: 05 rosettes ply directions :srcset: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_003.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_003.vtksz .. GENERATED FROM PYTHON SOURCE LINES 178-184 Define directions with a cylindrical rosette -------------------------------------------- Create a cylindrical rosette and plot the resulting reference directions. For a cylindrical rosette, the reference directions are tangential to the circles around the origin that lie in a plane spanned by ``dir1`` and ``dir2``. .. GENERATED FROM PYTHON SOURCE LINES 184-198 .. code-block:: Python cylindrical_rosette = model.create_rosette( name="CylindricalRosette", rosette_type=RosetteType.CYLINDRICAL, origin=(0.005, 0, 0.005), dir1=(1, 0, 0), dir2=(0, 0, 1), ) oss.rosettes = [cylindrical_rosette] model.update() plotter = get_directions_plotter(model=model, components=[oss.elemental_data.reference_direction]) plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_004.png :alt: 05 rosettes ply directions :srcset: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_004.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_004.vtksz .. GENERATED FROM PYTHON SOURCE LINES 199-206 Define directions with a spherical rosette ------------------------------------------ Create a spherical rosette and plot the resulting reference directions. For a spherical rosette, the reference directions are tangential to a sphere around the origin. Note that for this example, the reference directions of the spherical rosette are the same as those of the cylindrical rosette. .. GENERATED FROM PYTHON SOURCE LINES 206-220 .. code-block:: Python spherical_rosette = model.create_rosette( name="SphericalRosette", rosette_type=RosetteType.SPHERICAL, origin=(0.005, 0, 0.005), dir1=(1, 0, 0), dir2=(0, 0, 1), ) oss.rosettes = [spherical_rosette] model.update() plotter = get_directions_plotter(model=model, components=[oss.elemental_data.reference_direction]) plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_005.png :alt: 05 rosettes ply directions :srcset: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_005.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_005.vtksz .. GENERATED FROM PYTHON SOURCE LINES 221-232 Define directions with an edge-wise rosette ------------------------------------------- Create an edge-wise rosette and plot the resulting reference directions. The reference directions are given by a projection of ``dir1`` and the path of the edge set. ``dir1`` of the rosette is projected onto the point on the edge that is closest to the rosette's origin. This determines the reference directions along the edge set. You can reverse the reference directions by inverting ``dir1``. An element within an OSS gets its reference directions from the direction of the point on the edge that is closest to the element centroid. .. GENERATED FROM PYTHON SOURCE LINES 234-236 Create the edge set from the "All_Elements" element set. Because you assigned 120 degrees to the limit angle, all the edges are selected. .. GENERATED FROM PYTHON SOURCE LINES 236-260 .. code-block:: Python edge_set = model.create_edge_set( name="edge_set", edge_set_type=EdgeSetType.BY_REFERENCE, limit_angle=120, element_set=model.element_sets["All_Elements"], origin=(0, 0, 0), ) edge_wise_rosette = model.create_rosette( name="EdgeWiseRosette", rosette_type=RosetteType.EDGE_WISE, edge_set=edge_set, origin=(0.005, 0, 0.005), dir1=(1, 0, 0), dir2=(0, 0, 1), ) oss.rosettes = [edge_wise_rosette] model.update() plotter = get_directions_plotter(model=model, components=[oss.elemental_data.reference_direction]) plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_006.png :alt: 05 rosettes ply directions :srcset: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_006.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_006.vtksz .. GENERATED FROM PYTHON SOURCE LINES 261-263 Combine rosettes ---------------- .. GENERATED FROM PYTHON SOURCE LINES 265-267 Create an additional parallel rosette that points along the x direction and has its origin at ``(0.01, 0, 0.01)``. .. GENERATED FROM PYTHON SOURCE LINES 267-275 .. code-block:: Python parallel_rosette_0_deg = model.create_rosette( name="ParallelRosette", rosette_type=RosetteType.PARALLEL, origin=(0.01, 0, 0.01), dir1=(1, 0, 0), dir2=(0, 0, 1), ) .. GENERATED FROM PYTHON SOURCE LINES 276-280 Assign both rosettes to the OSS and set the rosette selection method to ``RosetteSelectionMethod.MINIMUM_DISTANCE_SUPERPOSED``. This implies that the reference directions are weighted by the inverse distance to each rosette. Note that the origin of the rotated rosette is at ``(0,0,0)``. .. GENERATED FROM PYTHON SOURCE LINES 280-283 .. code-block:: Python oss.rosettes = [parallel_rosette_45_deg, parallel_rosette_0_deg] oss.rosette_selection_method = RosetteSelectionMethod.MINIMUM_DISTANCE_SUPERPOSED .. GENERATED FROM PYTHON SOURCE LINES 284-285 Plot the resulting reference directions. .. GENERATED FROM PYTHON SOURCE LINES 285-288 .. code-block:: Python model.update() plotter = get_directions_plotter(model=model, components=[oss.elemental_data.reference_direction]) plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_007.png :alt: 05 rosettes ply directions :srcset: /examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_007.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/modeling_features/images/sphx_glr_05-rosettes-ply-directions_007.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 4.396 seconds) .. _sphx_glr_download_examples_modeling_features_05-rosettes-ply-directions.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 05-rosettes-ply-directions.ipynb <05-rosettes-ply-directions.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 05-rosettes-ply-directions.py <05-rosettes-ply-directions.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 05-rosettes-ply-directions.zip <05-rosettes-ply-directions.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_