Skip to content

Commit

Permalink
DOC: update development documentation 799a674
Browse files Browse the repository at this point in the history
  • Loading branch information
roosre committed Nov 28, 2024
1 parent f056ca0 commit 4d7246a
Show file tree
Hide file tree
Showing 393 changed files with 28,059 additions and 20,201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Direction definition example {#direction_definition_example}\n============================\n\nThis example shows how to define directions from lookup tables. They can\nbe either reference directions for oriented selection sets or draping\nangles for modeling plies. The example only shows the PyACP part of the\nsetup. For a complete composite analysis, see\n`pymapdl_workflow_example`{.interpreted-text role=\"ref\"}.\n"
"Direction definition {#direction_definition_example}\n====================\n\nThis example shows how to define directions from lookup tables. They can\nbe either reference directions for oriented selection sets or draping\nangles for modeling plies. The example only shows the PyACP part of the\nsetup. For a complete composite analysis, see\n`pymapdl_workflow_example`{.interpreted-text role=\"ref\"}.\n"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"""
.. _imported_solid_model_example:
Imported Solid model
Imported solid model
====================
This example guides you through the definition of an :class:`.ImportedSolidModel`
Expand Down Expand Up @@ -58,7 +58,7 @@
from ansys.acp.core import ElementTechnology, LayupMappingRosetteSelectionMethod, launch_acp
from ansys.acp.core.extras import ExampleKeys, get_example_file

# sphinx_gallery_thumbnail_number = 3
# sphinx_gallery_thumbnail_number = 4


# %%
Expand Down Expand Up @@ -262,6 +262,9 @@
# as well. See example :ref:`solid_model_example` for more details.
# More plotting capabilities are shown in the example :ref:`solid_model_example` as well.
#
# An example of an :class:`.ImportedSolidModel` in combination with :class:`.ImportedModelingPly`
# is shown in :ref:`imported_plies_example`.
#
# The solid mesh can be exported as CDB for MAPDL or to PyMechanical for further analysis.
# These workflows are shown in :ref:`pymapdl_workflow_example` and
# :ref:`pymechanical_solid_example`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
# Copyright (C) 2022 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""
.. _composite_cae_h5_example:
HDF5 Composite CAE
==================
The HDF5 Composite CAE interface of PyACP is demonstrated in
this example. It shows how to write (export) and read (import)
layup data to and from a HDF5 Composite CAE file, respectively.
The HDF5 Composite CAE format is a vendor independent format
to exchange composite layup information between CAE tools.
This examples demonstrates how to:
- Load and manipulate a model
- Export data to a HDF5 Composite CAE file
- Import and map layup from HDF5 Composite CAE onto a different model (mesh)
- Export data with ply offsets (3D plies)
- Import a layup as :class:`.ImportedModelingPly`
- Import HDF5 Composite CAE with 3D plies and map the layup onto an :class:`.ImportedSolidModel`
"""

# %%
# Import the standard library and third-party dependencies.
import pathlib
import tempfile

import pyvista

# %%
# Import the PyACP dependencies.
from ansys.acp.core import (
HDF5CompositeCAEProjectionMode,
LinkedSelectionRule,
OffsetType,
launch_acp,
)
from ansys.acp.core.extras import (
FLAT_PLATE_SHELL_CAMERA,
FLAT_PLATE_SOLID_CAMERA,
ExampleKeys,
get_example_file,
)

# sphinx_gallery_thumbnail_number = 2


# %%
# Start ACP and load the model
# ----------------------------
# %%
# Get the example file from the server.
tempdir = tempfile.TemporaryDirectory()
WORKING_DIR = pathlib.Path(tempdir.name)
acph5_input_file = get_example_file(ExampleKeys.BASIC_FLAT_PLATE_ACPH5, WORKING_DIR)

# %%
# Launch the PyACP server and connect to it.
acp = launch_acp()

# %%
# Load the model from an acph5 file
model = acp.import_model(acph5_input_file)

# %%
# Crop some plies in order to generate a variable laminate
pr_x = model.create_parallel_selection_rule(
name="x axis",
direction=(1, 0, 0),
lower_limit=0.0025,
upper_limit=0.0075,
)
pr_z = model.create_parallel_selection_rule(
name="z axis",
direction=(0, 0, 1),
lower_limit=0.0015,
upper_limit=0.0085,
)
boolean_rule = model.create_boolean_selection_rule(
name="boolean rule",
selection_rules=[LinkedSelectionRule(pr_x), LinkedSelectionRule(pr_z)],
)

for ply_name in ["ply_1_45_UD", "ply_2_-45_UD", "ply_3_45_UD", "ply_4_-45_UD"]:
ply = model.modeling_groups["modeling_group"].modeling_plies[ply_name]
ply.selection_rules = [LinkedSelectionRule(boolean_rule)]

model.update()

# %%
# Plot the thickness distribution
thickness = model.elemental_data.thickness
assert thickness is not None
thickness.get_pyvista_mesh(mesh=model.mesh).plot(show_edges=True)

# %%
# Write HDF5 Composite CAE file
# -----------------------------
#
# Export the entire layup to a HDF5 Composite CAE file.
h5_output_file = WORKING_DIR / "hdf5_composite_cae.h5"
model.export_hdf5_composite_cae(
path=h5_output_file,
)

# %%
# Load HDF5 Composite CAE file into a different model
# ---------------------------------------------------
#
# A new acp model is created by importing a refined mesh of the same geometry.
# Both meshes (initial mesh in blue, refined one in red) are shown below.
dat_input_file_refined = get_example_file(ExampleKeys.BASIC_FLAT_PLATE_REFINED_DAT, WORKING_DIR)
refined_model = acp.import_model(path=dat_input_file_refined, format="ansys:dat")

plotter = pyvista.Plotter()
plotter.add_mesh(
model.shell_mesh.to_pyvista(),
color="blue",
edge_color="blue",
show_edges=True,
style="wireframe",
line_width=4,
)
plotter.add_mesh(
refined_model.shell_mesh.to_pyvista(),
color="red",
edge_color="red",
show_edges=True,
style="wireframe",
line_width=2,
)
plotter.camera_position = FLAT_PLATE_SHELL_CAMERA
plotter.show()

# %%
# Import the HDF5 Composite CAE file which is then automatically mapped
# onto the refined mesh. In this example, the default settings
# (tolerances, etc.) are used.
refined_model.import_hdf5_composite_cae(
path=h5_output_file,
)
refined_model.update()

# %%
# Plot the thickness distribution on the refined model
thickness = refined_model.elemental_data.thickness
assert thickness is not None
thickness.get_pyvista_mesh(mesh=refined_model.mesh).plot(show_edges=True)

# %%
# 3D plies with ply-offsets
# -------------------------
#
# The HDF5 Composite CAE interface also allows to export the 3D plies
# (plies with offsets) which can then be used to create
# imported modeling plies. The initial model is used to
# write a new HDF5 with ``layup_representation_3d`` enabled.
h5_output_file_3D = WORKING_DIR / "hdf5_composite_cae_3D.h5"
model.export_hdf5_composite_cae(
path=h5_output_file_3D,
layup_representation_3d=True,
offset_type=OffsetType.BOTTOM_OFFSET,
)

# %%
# A new acp model is created to properly separate the different workflows.
refined_model_3D = acp.import_model(path=dat_input_file_refined, format="ansys:dat")
refined_model_3D.import_hdf5_composite_cae(
path=h5_output_file_3D, projection_mode=HDF5CompositeCAEProjectionMode.SOLID
)

# %%
# An imported solid model is required for the 3D workflow (with imported modeling plies).
# Details about :class:`.ImportedSolidModel` and :class:`.ImportedModelingPly` can be found
# in the examples :ref:`imported_solid_model_example` and :ref:`imported_plies_example`.
local_solid_mesh_file = get_example_file(ExampleKeys.BASIC_FLAT_PLATE_SOLID_MESH_CDB, WORKING_DIR)
remote_solid_mesh_file = acp.upload_file(local_solid_mesh_file)
imported_solid_model = refined_model_3D.create_imported_solid_model(
name="Imported Solid Model",
external_path=remote_solid_mesh_file,
format="ansys:cdb",
)

# %%
# The :class:`.LayupMappingObject` is used to configure the mapping of the imported plies
# onto the imported solid model.
imported_solid_model.create_layup_mapping_object(
name="Map imported plies",
use_imported_plies=True, # enable imported plies
select_all_plies=True, # select all plies
scale_ply_thicknesses=True,
entire_solid_mesh=True,
delete_lost_elements=True, # elements without plies are deleted
)
refined_model_3D.update()

# %%
# The mapped top layer of the imported laminate is shown below.
# Note that the solid elements which do not intersect with the
# layup are deleted in this example.
imported_analysis_ply = (
refined_model_3D.imported_modeling_groups["modeling_group"]
.imported_modeling_plies["ply_5_0_UD"]
.imported_production_plies["ImportedProductionPly.6"]
.imported_analysis_plies["P1L1__ply_5_0_UD"]
)
plotter = pyvista.Plotter()
plotter.add_mesh(imported_analysis_ply.solid_mesh.to_pyvista(), show_edges=True)
plotter.add_mesh(refined_model_3D.solid_mesh.to_pyvista(), opacity=0.2, show_edges=False)
plotter.camera_position = FLAT_PLATE_SOLID_CAMERA
plotter.show()

# %%
# Note that the visualization of imported plies and imported solid model
# is limited. As an alternative, you can save the model and review it
# in ACP standalone.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"""
.. _thickness_definition_example:
Thickness definition example
============================
Thickness definition
====================
This example shows how the thickness of a ply can be defined by a geometry or a lookup table.
The example only shows the PyACP part of the setup. For a complete composite analysis,
Expand All @@ -46,7 +46,7 @@
# %%
# Import the PyACP dependencies.
from ansys.acp.core import DimensionType, ThicknessType, launch_acp
from ansys.acp.core.extras import ExampleKeys, get_example_file
from ansys.acp.core.extras import FLAT_PLATE_SOLID_CAMERA, ExampleKeys, get_example_file

# sphinx_gallery_thumbnail_number = 2

Expand Down Expand Up @@ -117,7 +117,7 @@
plotter.add_mesh(edges, color="black", line_width=2)
# Plot the ply thickness
plotter.add_mesh(model.elemental_data.thickness.get_pyvista_mesh(mesh=model.mesh), show_edges=True)

plotter.camera_position = FLAT_PLATE_SOLID_CAMERA
plotter.show()

# %%
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Thickness definition example {#thickness_definition_example}\n============================\n\nThis example shows how the thickness of a ply can be defined by a\ngeometry or a lookup table. The example only shows the PyACP part of the\nsetup. For a complete composite analysis, see\n`pymapdl_workflow_example`{.interpreted-text role=\"ref\"}.\n"
"Thickness definition {#thickness_definition_example}\n====================\n\nThis example shows how the thickness of a ply can be defined by a\ngeometry or a lookup table. The example only shows the PyACP part of the\nsetup. For a complete composite analysis, see\n`pymapdl_workflow_example`{.interpreted-text role=\"ref\"}.\n"
]
},
{
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"outputs": [],
"source": [
"from ansys.acp.core import DimensionType, ThicknessType, launch_acp\nfrom ansys.acp.core.extras import ExampleKeys, get_example_file"
"from ansys.acp.core import DimensionType, ThicknessType, launch_acp\nfrom ansys.acp.core.extras import FLAT_PLATE_SOLID_CAMERA, ExampleKeys, get_example_file"
]
},
{
Expand Down Expand Up @@ -180,7 +180,7 @@
},
"outputs": [],
"source": [
"model.update()\nassert model.elemental_data.thickness is not None\nplotter = pyvista.Plotter()\n# Plot the surface of the geometry\ngeometry_polydata = thickness_geometry.visualization_mesh.to_pyvista()\nplotter.add_mesh(geometry_polydata, color=\"grey\", opacity=0.05)\n# Plot the edges of the geometry\nedges = geometry_polydata.extract_feature_edges()\nplotter.add_mesh(edges, color=\"white\", line_width=4)\nplotter.add_mesh(edges, color=\"black\", line_width=2)\n# Plot the ply thickness\nplotter.add_mesh(model.elemental_data.thickness.get_pyvista_mesh(mesh=model.mesh), show_edges=True)\n\nplotter.show()"
"model.update()\nassert model.elemental_data.thickness is not None\nplotter = pyvista.Plotter()\n# Plot the surface of the geometry\ngeometry_polydata = thickness_geometry.visualization_mesh.to_pyvista()\nplotter.add_mesh(geometry_polydata, color=\"grey\", opacity=0.05)\n# Plot the edges of the geometry\nedges = geometry_polydata.extract_feature_edges()\nplotter.add_mesh(edges, color=\"white\", line_width=4)\nplotter.add_mesh(edges, color=\"black\", line_width=2)\n# Plot the ply thickness\nplotter.add_mesh(model.elemental_data.thickness.get_pyvista_mesh(mesh=model.mesh), show_edges=True)\nplotter.camera_position = FLAT_PLATE_SOLID_CAMERA\nplotter.show()"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Imported Solid model {#imported_solid_model_example}\n====================\n\nThis example guides you through the definition of an\n`.ImportedSolidModel`{.interpreted-text role=\"class\"} which allows to\nmap the layup onto an external solid mesh. In contrast to the\n`.SolidModel`{.interpreted-text role=\"class\"}, the raw solid mesh of\n`.ImportedSolidModel`{.interpreted-text role=\"class\"} is loaded from an\nexternal source, such as a CDB file. In this example, the layup is\napplied onto a t-joint which consists of different parts such as shell,\nstringer, and bonding skins. The example only shows the PyACP part of\nthe setup. For a complete composite analysis, see\n`pymapdl_workflow_example`{.interpreted-text role=\"ref\"}.\n\nThis example starts from an ACP model with layup. It shows how to:\n\n- Create an `.ImportedSolidModel`{.interpreted-text role=\"class\"} from\n an external mesh.\n- Define the `.LayupMappingObject`{.interpreted-text role=\"class\"} to\n apply the layup onto the solid mesh.\n- Scope plies to specific parts of the solid mesh.\n- Visualize the mapped layup.\n\nIt is recommended to look at the Ansys help for all the details. This\nexample shows the basic setup only.\n"
"Imported solid model {#imported_solid_model_example}\n====================\n\nThis example guides you through the definition of an\n`.ImportedSolidModel`{.interpreted-text role=\"class\"} which allows to\nmap the layup onto an external solid mesh. In contrast to the\n`.SolidModel`{.interpreted-text role=\"class\"}, the raw solid mesh of\n`.ImportedSolidModel`{.interpreted-text role=\"class\"} is loaded from an\nexternal source, such as a CDB file. In this example, the layup is\napplied onto a t-joint which consists of different parts such as shell,\nstringer, and bonding skins. The example only shows the PyACP part of\nthe setup. For a complete composite analysis, see\n`pymapdl_workflow_example`{.interpreted-text role=\"ref\"}.\n\nThis example starts from an ACP model with layup. It shows how to:\n\n- Create an `.ImportedSolidModel`{.interpreted-text role=\"class\"} from\n an external mesh.\n- Define the `.LayupMappingObject`{.interpreted-text role=\"class\"} to\n apply the layup onto the solid mesh.\n- Scope plies to specific parts of the solid mesh.\n- Visualize the mapped layup.\n\nIt is recommended to look at the Ansys help for all the details. This\nexample shows the basic setup only.\n"
]
},
{
Expand Down Expand Up @@ -263,7 +263,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Other features\n==============\n\nThe `.CutOffGeometry`{.interpreted-text role=\"class\"} can be used in\ncombination witt the `.ImportedSolidModel`{.interpreted-text\nrole=\"class\"} as well. See example\n`solid_model_example`{.interpreted-text role=\"ref\"} for more details.\nMore plotting capabilities are shown in the example\n`solid_model_example`{.interpreted-text role=\"ref\"} as well.\n\nThe solid mesh can be exported as CDB for MAPDL or to PyMechanical for\nfurther analysis. These workflows are shown in\n`pymapdl_workflow_example`{.interpreted-text role=\"ref\"} and\n`pymechanical_solid_example`{.interpreted-text role=\"ref\"}.\n"
"Other features\n==============\n\nThe `.CutOffGeometry`{.interpreted-text role=\"class\"} can be used in\ncombination witt the `.ImportedSolidModel`{.interpreted-text\nrole=\"class\"} as well. See example\n`solid_model_example`{.interpreted-text role=\"ref\"} for more details.\nMore plotting capabilities are shown in the example\n`solid_model_example`{.interpreted-text role=\"ref\"} as well.\n\nAn example of an `.ImportedSolidModel`{.interpreted-text role=\"class\"}\nin combination with `.ImportedModelingPly`{.interpreted-text\nrole=\"class\"} is shown in `imported_plies_example`{.interpreted-text\nrole=\"ref\"}.\n\nThe solid mesh can be exported as CDB for MAPDL or to PyMechanical for\nfurther analysis. These workflows are shown in\n`pymapdl_workflow_example`{.interpreted-text role=\"ref\"} and\n`pymechanical_solid_example`{.interpreted-text role=\"ref\"}.\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"""
.. _sandwich_panel:
Sandwich panel example
======================
Sandwich panel
==============
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,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"""
.. _direction_definition_example:
Direction definition example
============================
Direction definition
====================
This example shows how to define directions from lookup tables. They can be either
reference directions for oriented selection sets or draping angles for modeling plies.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Advanced selection rules example {#advanced_selection_rules_example}\n================================\n\nThis example shows how to use advanced rules, including the geometrical,\ncut-off, and variable offset rules. It also demonstrates how rules can\nbe templated and reused with different parameters. For more basic rules,\nsee `basic_selection_rules_example`{.interpreted-text role=\"ref\"}.\n\nThis example only shows the PyACP part of the setup. For a complete\ncomposite analysis, see `pymapdl_workflow_example`{.interpreted-text\nrole=\"ref\"}.\n"
"Advanced selection rules {#advanced_selection_rules_example}\n========================\n\nThis example shows how to use advanced rules, including the geometrical,\ncut-off, and variable offset rules. It also demonstrates how rules can\nbe templated and reused with different parameters. For more basic rules,\nsee `basic_selection_rules_example`{.interpreted-text role=\"ref\"}.\n\nThis example only shows the PyACP part of the setup. For a complete\ncomposite analysis, see `pymapdl_workflow_example`{.interpreted-text\nrole=\"ref\"}.\n"
]
},
{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 4d7246a

Please sign in to comment.