.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/modeling_features/01-sandwich-panel-layup.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_01-sandwich-panel-layup.py: .. _sandwich_panel: Sandwich panel example ====================== This example defines a composite lay-up for a sandwich panel using PyACP. 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-38 ------------------ Import the standard library and third-party dependencies. .. GENERATED FROM PYTHON SOURCE LINES 38-41 .. code-block:: Python import pathlib import tempfile .. GENERATED FROM PYTHON SOURCE LINES 42-43 Import the PyACP dependencies. .. GENERATED FROM PYTHON SOURCE LINES 43-57 .. code-block:: Python from ansys.acp.core import ( ACPWorkflow, FabricWithAngle, Lamina, PlyType, get_directions_plotter, launch_acp, print_model, ) from ansys.acp.core.extras import ExampleKeys, get_example_file from ansys.acp.core.material_property_sets import ConstantEngineeringConstants, ConstantStrainLimits .. GENERATED FROM PYTHON SOURCE LINES 59-61 Start ACP and load the model ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 63-64 Get the example file from the server. .. GENERATED FROM PYTHON SOURCE LINES 64-68 .. 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 69-70 Launch the PyACP server and connect to it. .. GENERATED FROM PYTHON SOURCE LINES 70-72 .. code-block:: Python acp = launch_acp() .. GENERATED FROM PYTHON SOURCE LINES 73-76 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. .. GENERATED FROM PYTHON SOURCE LINES 76-87 .. 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/tmparx8me1l mks .. GENERATED FROM PYTHON SOURCE LINES 88-89 Visualize the loaded mesh. .. GENERATED FROM PYTHON SOURCE LINES 89-92 .. code-block:: Python mesh = model.mesh.to_pyvista() mesh.plot(show_edges=True) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/modeling_features/images/sphx_glr_01-sandwich-panel-layup_001.png :alt: 01 sandwich panel layup :srcset: /examples/modeling_features/images/sphx_glr_01-sandwich-panel-layup_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_01-sandwich-panel-layup_001.vtksz .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/.cache/pypoetry/virtualenvs/ansys-acp-core-O77fA6pn-py3.12/lib/python3.12/site-packages/trame_vuetify/widgets/vuetify.py:495: SyntaxWarning: invalid escape sequence '\|' """ .. GENERATED FROM PYTHON SOURCE LINES 93-95 Create the sandwich materials ----------------------------- .. GENERATED FROM PYTHON SOURCE LINES 97-98 Create the UD material and its corresponding fabric. .. GENERATED FROM PYTHON SOURCE LINES 98-125 .. code-block:: Python engineering_constants_ud = ConstantEngineeringConstants.from_orthotropic_constants( E1=5e10, E2=1e10, E3=1e10, nu12=0.28, nu13=0.28, nu23=0.3, G12=5e9, G23=4e9, G31=4e9 ) strain_limit = 0.01 strain_limits = ConstantStrainLimits.from_orthotropic_constants( eXc=-strain_limit, eYc=-strain_limit, eZc=-strain_limit, eXt=strain_limit, eYt=strain_limit, eZt=strain_limit, eSxy=strain_limit, eSyz=strain_limit, eSxz=strain_limit, ) ud_material = model.create_material( name="UD", ply_type=PlyType.REGULAR, engineering_constants=engineering_constants_ud, strain_limits=strain_limits, ) ud_fabric = model.create_fabric(name="UD", material=ud_material, thickness=0.002) .. GENERATED FROM PYTHON SOURCE LINES 126-128 Create a multi-axial stackup and a sublaminate. Stackups and sublaminates help quickly build repeating laminates. .. GENERATED FROM PYTHON SOURCE LINES 128-148 .. code-block:: Python biax_carbon_ud = model.create_stackup( name="Biax_Carbon_UD", fabrics=( FabricWithAngle(ud_fabric, -45), FabricWithAngle(ud_fabric, 45), ), ) sublaminate = model.create_sublaminate( name="Sublaminate", materials=( Lamina(biax_carbon_ud, 0), Lamina(ud_fabric, 90), Lamina(biax_carbon_ud, 0), ), ) .. GENERATED FROM PYTHON SOURCE LINES 149-150 Create the core material and its corresponding fabric. .. GENERATED FROM PYTHON SOURCE LINES 150-161 .. code-block:: Python engineering_constants_core = ConstantEngineeringConstants.from_isotropic_constants(E=8.5e7, nu=0.3) core = model.create_material( name="Core", ply_type=PlyType.ISOTROPIC_HOMOGENEOUS_CORE, engineering_constants=engineering_constants_core, strain_limits=strain_limits, ) core_fabric = model.create_fabric(name="core", material=ud_material, thickness=0.015) .. GENERATED FROM PYTHON SOURCE LINES 162-164 Create the Lay-up ----------------- .. GENERATED FROM PYTHON SOURCE LINES 166-167 Define a rosette and oriented selection set. Plot the orientations. .. GENERATED FROM PYTHON SOURCE LINES 167-181 .. code-block:: Python rosette = model.create_rosette(origin=(0.0, 0.0, 0.0), dir1=(1.0, 0.0, 0.0), dir2=(0.0, 1.0, 0.0)) 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=[rosette], ) model.update() plotter = get_directions_plotter(model=model, components=[oss.elemental_data.orientation]) plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/modeling_features/images/sphx_glr_01-sandwich-panel-layup_002.png :alt: 01 sandwich panel layup :srcset: /examples/modeling_features/images/sphx_glr_01-sandwich-panel-layup_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_01-sandwich-panel-layup_002.vtksz .. GENERATED FROM PYTHON SOURCE LINES 182-183 Create the modeling plies which define the lay-up of the sandwich panel. .. GENERATED FROM PYTHON SOURCE LINES 183-208 .. code-block:: Python modeling_group = model.create_modeling_group(name="modeling_group") bottom_ply = modeling_group.create_modeling_ply( name="bottom_ply", ply_angle=0, ply_material=sublaminate, oriented_selection_sets=[oss], ) core_ply = modeling_group.create_modeling_ply( name="core_ply", ply_angle=0, ply_material=core_fabric, oriented_selection_sets=[oss], ) top_ply = modeling_group.create_modeling_ply( name="top_ply", ply_angle=90, ply_material=ud_fabric, oriented_selection_sets=[oss], number_of_layers=3, ) .. GENERATED FROM PYTHON SOURCE LINES 209-210 Update and print the model. .. GENERATED FROM PYTHON SOURCE LINES 210-212 .. code-block:: Python model.update() print_model(workflow.model) .. rst-class:: sphx-glr-script-out .. code-block:: none Model Material Data Materials 1 UD Core Fabrics UD core Stackups Biax_Carbon_UD Sublaminates Sublaminate Element Sets All_Elements Edge Sets _FIXEDSU Geometry Rosettes 12 Rosette Lookup Tables Selection Rules Oriented Selection Sets oss Modeling Groups modeling_group bottom_ply ProductionPly P1L1__bottom_ply P1L2__bottom_ply ProductionPly.2 P2L1__bottom_ply ProductionPly.3 P3L1__bottom_ply P3L2__bottom_ply core_ply ProductionPly.4 P1L1__core_ply top_ply ProductionPly.5 P1L1__top_ply ProductionPly.6 P2L1__top_ply ProductionPly.7 P3L1__top_ply /home/runner/.cache/pypoetry/virtualenvs/ansys-acp-core-O77fA6pn-py3.12/lib/python3.12/site-packages/ansys/mapdl/core/launcher.py:822: UserWarning: The environment variable 'PYMAPDL_START_INSTANCE' is set, hence the argument 'start_instance' is overwritten. warnings.warn( /home/runner/.cache/pypoetry/virtualenvs/ansys-acp-core-O77fA6pn-py3.12/lib/python3.12/site-packages/ansys/mapdl/core/component.py:174: SyntaxWarning: invalid escape sequence '\>' """Collection of MAPDL components. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 7.598 seconds) .. _sphx_glr_download_examples_modeling_features_01-sandwich-panel-layup.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 01-sandwich-panel-layup.ipynb <01-sandwich-panel-layup.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01-sandwich-panel-layup.py <01-sandwich-panel-layup.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 01-sandwich-panel-layup.zip <01-sandwich-panel-layup.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_