Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions src/ansys/acp/core/_tree_objects/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any, Iterable, cast
from typing import Iterable, cast

from grpc import Channel

Expand Down Expand Up @@ -48,22 +48,42 @@ class Model(TreeObject):

Parameters
----------
resource_path :
The Resource Path identifying the Model.
server :
The ACP server on which the model resides.
name :
The name of the model.
use_nodal_thicknesses :
Defines whether to use nodal thicknesses or element thicknesses.
draping_offset_correction :
Defines whether to consider lay-up thickness in draping analysis.
angle_tolerance :
Section computation angle tolerance (in degree).
relative_thickness_tolerance :
Section computation relative thickness tolerance.
minimum_analysis_ply_thickness :
Section computation minimum analysis ply thickness (in length
unit of model).
"""

__slots__: Iterable[str] = tuple()

COLLECTION_LABEL = "models"
OBJECT_INFO_TYPE = model_pb2.ObjectInfo

def __init__(self, name: str = "ACP Model", **kwargs: Any) -> None:
def __init__(
self,
name: str = "ACP Model",
use_nodal_thicknesses: bool = False,
draping_offset_correction: bool = False,
angle_tolerance: float = 1.0,
relative_thickness_tolerance: float = 0.01,
minimum_analysis_ply_thickness: float = 1e-6,
) -> None:
super().__init__(name=name)

for key, value in kwargs.items():
setattr(self, key, value)
self.use_nodal_thicknesses = use_nodal_thicknesses
self.draping_offset_correction = draping_offset_correction
self.angle_tolerance = angle_tolerance
self.relative_thickness_tolerance = relative_thickness_tolerance
self.minimum_analysis_ply_thickness = minimum_analysis_ply_thickness

def _get_stub(self) -> model_pb2_grpc.ObjectServiceStub:
return cast(model_pb2_grpc.ObjectServiceStub, super()._get_stub())
Expand All @@ -78,7 +98,6 @@ def _create_stub(self) -> model_pb2_grpc.ObjectServiceStub:
angle_tolerance = grpc_data_property("properties.angle_tolerance")
relative_thickness_tolerance = grpc_data_property("properties.relative_thickness_tolerance")
minimum_analysis_ply_thickness = grpc_data_property("properties.minimum_analysis_ply_thickness")
use_default_section_tolerances = grpc_data_property("properties.use_default_section_tolerances")

@classmethod
def from_file(cls, *, path: _PATH, channel: Channel) -> Model:
Expand Down
2 changes: 0 additions & 2 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test_unittest(grpc_server, model_data_dir_server, convert_temp_path):
check_property(model, name="path", value=input_file_path),
check_property(model, name="use_nodal_thicknesses", value=False, set_value=True),
check_property(model, name="draping_offset_correction", value=False, set_value=True),
check_property(model, name="use_default_section_tolerances", value=True, set_value=False),
check_property(model, name="angle_tolerance", value=1.0, set_value=2.0),
check_property(model, name="relative_thickness_tolerance", value=0.01, set_value=0.03)

Expand Down Expand Up @@ -68,7 +67,6 @@ def test_unittest(grpc_server, model_data_dir_server, convert_temp_path):
check_property(model, name="path", value=input_file_path)
check_property(model, name="use_nodal_thicknesses", value=True)
check_property(model, name="draping_offset_correction", value=True)
check_property(model, name="use_default_section_tolerances", value=False)
check_property(model, name="angle_tolerance", value=2.0)
check_property(model, name="relative_thickness_tolerance", value=0.03)
with suppress_for_pyacp():
Expand Down