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
53 changes: 11 additions & 42 deletions src/ansys/sherlock/core/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def run_analysis(
- elements: list
List of tuples (``type``, ``event``)

- analysis_type : RunAnalysisRequest.Analysis.AnalysisType
- analysis_type : RunAnalysisRequestAnalysisType
Type of analysis to run.

- event : list
Expand Down Expand Up @@ -116,7 +116,7 @@ def run_analysis(
"Test",
"Card",
[
(SherlockAnalysisService_pb2.RunAnalysisRequest.Analysis.AnalysisType.NaturalFreq,
(RunAnalysisRequestAnalysisType.NATURAL_FREQ,
[
("Phase 1", ["Harmonic Event"])
]
Expand Down Expand Up @@ -280,10 +280,6 @@ def update_harmonic_vibe_props(
)

"""
if self.FREQ_UNIT_LIST is None:
self._init_freq_units()
if self.TEMP_UNIT_LIST is None:
self._init_temp_units()
try:
if project == "":
raise SherlockUpdateHarmonicVibePropsError(message="Project name is invalid.")
Expand Down Expand Up @@ -355,15 +351,6 @@ def update_harmonic_vibe_props(

if "analysis_temp_units" in harmonic_vibe_props.keys():
analysis_temp_units = harmonic_vibe_props["analysis_temp_units"]
if (
(self.TEMP_UNIT_LIST is not None)
and (analysis_temp_units is not None)
and (analysis_temp_units not in self.TEMP_UNIT_LIST)
):
raise SherlockUpdateHarmonicVibePropsError(
message=f"Analysis temperature units are invalid for "
f"harmonic vibe properties {i}: " + analysis_temp_units
)
else:
analysis_temp_units = None

Expand All @@ -384,15 +371,6 @@ def update_harmonic_vibe_props(

if "natural_freq_min_units" in harmonic_vibe_props.keys():
natural_freq_min_units = harmonic_vibe_props["natural_freq_min_units"]
if (
(self.FREQ_UNIT_LIST is not None)
and (natural_freq_min_units is not None)
and (natural_freq_min_units not in self.FREQ_UNIT_LIST)
):
raise SherlockUpdateHarmonicVibePropsError(
message=f"Minimum natural frequency units are invalid for "
f"harmonic vibe properties {i}: " + natural_freq_min_units
)
else:
natural_freq_min_units = None

Expand All @@ -403,15 +381,6 @@ def update_harmonic_vibe_props(

if "natural_freq_max_units" in harmonic_vibe_props.keys():
natural_freq_max_units = harmonic_vibe_props["natural_freq_max_units"]
if (
(self.FREQ_UNIT_LIST is not None)
and (natural_freq_max_units is not None)
and (natural_freq_max_units not in self.FREQ_UNIT_LIST)
):
raise SherlockUpdateHarmonicVibePropsError(
message=f"Maximum natural frequency units are invalid for "
f"harmonic vibe properties {i}: " + natural_freq_max_units
)
else:
natural_freq_max_units = None

Expand Down Expand Up @@ -512,7 +481,7 @@ def get_random_vibe_input_fields(self, model_source=None):
cca_name="Card",
)
>>> sherlock.analysis.get_random_vibe_input_fields(
model_source=SherlockAnalysisService_pb2.ModelSource.STRAIN_MAP
model_source=ModelSource.STRAIN_MAP
)
"""
if not self._is_connection_up():
Expand Down Expand Up @@ -629,7 +598,7 @@ def update_random_vibe_props(
random_vibe_damping="0.01, 0.05",
analysis_temp=20,
analysis_temp_units="C",
model_source=SherlockAnalysisService_pb2.ModelSource.STRAIN_MAP,
model_source=ModelSource.STRAIN_MAP,
)

"""
Expand Down Expand Up @@ -1004,13 +973,13 @@ def update_pcb_modeling_props(self, project, cca_names, analyses):
analyses : list
List of elements consisting of the following properties:

- analysis_type : UpdatePcbModelingPropsRequest.Analysis.AnalysisType
- analysis_type : UpdatePcbModelingPropsRequestAnalysisType
Type of analysis applied.
- pcb_model_type : UpdatePcbModelingPropsRequest.Analysis.PcbModelType
- pcb_model_type : UpdatePcbModelingPropsRequestPcbModelType
The PCB modeling mesh type.
- modeling_region_enabled : bool
Indicates if modeling regions are enabled.
- pcb_material_model : UpdatePcbModelingPropsRequest.Analysis.PcbMaterialModel
- pcb_material_model : UpdatePcbModelingPropsRequestPcbMaterialModel
The PCB modeling PCB model type.
- pcb_max_materials : int
The number of PCB materials for Uniform Elements and Layered Elements PCB model
Expand Down Expand Up @@ -1044,11 +1013,11 @@ def update_pcb_modeling_props(self, project, cca_names, analyses):
["Main Board"],
[
(
update_request.Analysis.AnalysisType.NaturalFreq,
update_request.Analysis.PcbModelType.Bonded,
UpdatePcbModelingPropsRequestAnalysisType.HARMONIC_VIBE,
UpdatePcbModelingPropsRequestPcbModelType.BONDED,
True,
update_request.Analysis.PcbMaterialModel.Uniform,
SherlockAnalysisService_pb2.ElementOrder.SolidShell,
UpdatePcbModelingPropsRequestPcbMaterialModel.UNIFORM,
ElementOrder.SOLID_SHELL,
6,
"mm",
3,
Expand Down
105 changes: 7 additions & 98 deletions src/ansys/sherlock/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Common(GrpcStub):

def __init__(self, channel):
"""Initialize a gRPC stub for the Sherlock Common service."""
self.channel = channel
super().__init__(channel)
self.stub = SherlockCommonService_pb2_grpc.SherlockCommonServiceStub(channel)

def check(self):
Expand Down Expand Up @@ -73,99 +73,16 @@ def list_units(self, unitType):

Parameters
----------
unitType : string
Unit type. Options are:

- ``"ACCEL_DENSITY"``
- ``"ACCELERATION"``
- ``"AREA"``
- ``""BANDWIDTH"``
- ``"CAPACITANCE"``
- ``"CTE"``
- ``"CURRENT"``
- ``"DENSITY"``
- ``"DISP_DENSITY"``
- ``"FORCE"``
- ``"FREQUENCY"``
- ``"INDUCTANCE"``
- ``"LENGTH"``
- ``"POWER"``
- ``"RESISTANCE"``
- ``"SIZE"``
- ``"SPECIFIC_HEAT"``
- ``"STRAIN"``
- ``"STRESS"``
- ``"TEMPERATURE"``
- ``"THERMAL_CONDUCTIVITY"``
- ``"THERMAL_RESISTANCE"``
- ``"TIME"``
- ``"VELOCITY"``
- ``"VELOCITY_DENSITY"``
- ``"VOLTAGE"``
- ``"VOLUME"``
- ``"WEIGHT"``
unitType : ListUnitsRequestUnitType
Unit type.

Returns
-------
str
Units for the unit type.
"""
if unitType == "":
raise SherlockCommonServiceError(message="Unit type is missing.")
elif unitType == "ACCEL_DENSITY":
unitType = SherlockCommonService_pb2.ListUnitsRequest.ACCEL_DENSITY
elif unitType == "ACCELERATION":
unitType = SherlockCommonService_pb2.ListUnitsRequest.ACCELERATION
elif unitType == "AREA":
unitType = SherlockCommonService_pb2.ListUnitsRequest.AREA
elif unitType == "BANDWIDTH":
unitType = SherlockCommonService_pb2.ListUnitsRequest.BANDWIDTH
elif unitType == "CAPACITANCE":
unitType = SherlockCommonService_pb2.ListUnitsRequest.CAPACITANCE
elif unitType == "CTE":
unitType = SherlockCommonService_pb2.ListUnitsRequest.CTE
elif unitType == "CURRENT":
unitType = SherlockCommonService_pb2.ListUnitsRequest.CURRENT
elif unitType == "DENSITY":
unitType = SherlockCommonService_pb2.ListUnitsRequest.DENSITY
elif unitType == "DISP_DENSITY":
unitType = SherlockCommonService_pb2.ListUnitsRequest.DISP_DENSITY
elif unitType == "FORCE":
unitType = SherlockCommonService_pb2.ListUnitsRequest.FORCE
elif unitType == "FREQUENCY":
unitType = SherlockCommonService_pb2.ListUnitsRequest.FREQUENCY
elif unitType == "INDUCTANCE":
unitType = SherlockCommonService_pb2.ListUnitsRequest.INDUCTANCE
elif unitType == "LENGTH":
unitType = SherlockCommonService_pb2.ListUnitsRequest.LENGTH
elif unitType == "POWER":
unitType = SherlockCommonService_pb2.ListUnitsRequest.POWER
elif unitType == "RESISTANCE":
unitType = SherlockCommonService_pb2.ListUnitsRequest.RESISTANCE
elif unitType == "SIZE":
unitType = SherlockCommonService_pb2.ListUnitsRequest.SIZE
elif unitType == "SPECIFIC_HEAT":
unitType = SherlockCommonService_pb2.ListUnitsRequest.SPECIFIC_HEAT
elif unitType == "STRAIN":
unitType = SherlockCommonService_pb2.ListUnitsRequest.STRAIN
elif unitType == "STRESS":
unitType = SherlockCommonService_pb2.ListUnitsRequest.STRESS
elif unitType == "TEMPERATURE":
unitType = SherlockCommonService_pb2.ListUnitsRequest.TEMPERATURE
elif unitType == "THERMAL_CONDUCTIVITY":
unitType = SherlockCommonService_pb2.ListUnitsRequest.THERMAL_CONDUCTIVITY
elif unitType == "THERMAL_RESISTANCE":
unitType = SherlockCommonService_pb2.ListUnitsRequest.THERMAL_RESISTANCE
elif unitType == "TIME":
unitType = SherlockCommonService_pb2.ListUnitsRequest.TIME
elif unitType == "VELOCITY":
unitType = SherlockCommonService_pb2.ListUnitsRequest.VELOCITY
elif unitType == "VELOCITY_DENSITY":
unitType = SherlockCommonService_pb2.ListUnitsRequest.VELOCITY_DENSITY
elif unitType == "VOLTAGE":
unitType = SherlockCommonService_pb2.ListUnitsRequest.VOLTAGE
elif unitType == "VOLUME":
unitType = SherlockCommonService_pb2.ListUnitsRequest.VOLUME
elif unitType == "WEIGHT":
unitType = SherlockCommonService_pb2.ListUnitsRequest.WEIGHT
else:
raise SherlockCommonServiceError(message=f"Unit type '{unitType}' is invalid.")

if not self._is_connection_up():
LOG.error("Not connected to a gRPC service.")
Expand All @@ -175,18 +92,10 @@ def list_units(self, unitType):

try:
response = self.stub.listUnits(request)

return_code = response.returnCode

if return_code.value == -1:
if return_code.message == "":
raise SherlockCommonServiceError(error_array=response.errors)

raise SherlockCommonServiceError(message=return_code.message)

except SherlockCommonServiceError as e:
for error in e.str_itr():
LOG.error(error)
raise e

return response.units
59 changes: 0 additions & 59 deletions src/ansys/sherlock/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,62 +289,3 @@ def generate_trace_model(
except Exception as e:
LOG.error(str(e))
raise


# def set_trace_parameter(
# trace_param=None,
# trace_param_diameter_threshold_val=2,
# trace_param_diameter_threshold_unit="mm",
# trace_param_min_hole_diameter_val=0.25,
# trace_param_min_hole_diameter_unit="mm",
# ):
# """Set the Trace Properties for the Export Trace Reinforcement Model operation."""
# if trace_param is None:
# trace_param = SherlockModelService_pb2.ExportTraceReinforcementModelRequest().TraceParam()
# else:
# if not isinstance(
# trace_param, SherlockModelService_pb2.ExportTraceReinforcementModelRequest.TraceParam
# ):
# raise SherlockModelServiceError(
# "trace_param object is not of type "
# "SherlockModelService_pb2.ExportTraceReinforcementModelRequest.TraceParam."
# )

# trace_param.diameterThreshold.value = trace_param_diameter_threshold_val
# trace_param.diameterThreshold.unit = trace_param_diameter_threshold_unit
# trace_param.minHoleDiameterForShellOrBeam.value = trace_param_min_hole_diameter_val
# trace_param.minHoleDiameterForShellOrBeam.unit = trace_param_min_hole_diameter_unit

# return trace_param


# def set_trace_drill_hole_parameter(
# trace_drill_hole_param=None,
# trace_drill_hole_modeling="DISABLED",
# trace_drill_hole_min_diameter_val=2,
# trace_drill_hole_min_diameter_unit="mm",
# trace_drill_hole_max_edge_val=1,
# trace_drill_hole_max_edge_unit="mm",
# ):
# """Set the drill hole properties for exporting the trace reinforcement model."""
# if trace_drill_hole_param is None:
# trace_drill_hole_param = (
# SherlockModelService_pb2.ExportTraceReinforcementModelRequest().TraceDrillHoleParam()
# )
# else:
# if not isinstance(
# trace_drill_hole_param,
# SherlockModelService_pb2.ExportTraceReinforcementModelRequest.TraceDrillHoleParam,
# ):
# raise SherlockModelServiceError(
# "trace_drill_hole_param object is not of type "
# "SherlockModelService_pb2.ExportTraceReinforcementModelRequest.TraceDrillHoleParam."
# )

# trace_drill_hole_param.drillHoleModeling = trace_drill_hole_modeling
# trace_drill_hole_param.minHoleDiameter.value = trace_drill_hole_min_diameter_val
# trace_drill_hole_param.minHoleDiameter.unit = trace_drill_hole_min_diameter_unit
# trace_drill_hole_param.maxEdgeLength.value = trace_drill_hole_max_edge_val
# trace_drill_hole_param.maxEdgeLength.unit = trace_drill_hole_max_edge_unit

# return trace_drill_hole_param
20 changes: 6 additions & 14 deletions src/ansys/sherlock/core/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _init_location_units(self):
self.PART_LOCATION_UNITS = part_location_response.units

def _init_board_sides(self):
"""Initialize boad sides."""
"""Initialize board sides."""
if self._is_connection_up():
board_sides_request = SherlockPartsService_pb2.GetBoardSidesRequest()
board_sides_response = self.stub.getBoardSides(board_sides_request)
Expand All @@ -167,11 +167,10 @@ def update_parts_list(
Name of the CCA.
part_library : str
Name of the parts library.
matching : str
Matching mode for updates. Options are ``"Both"`` and ``"Part"``.
duplication : str
matching : UpdatesPartsListRequestMatchingMode
Matching mode for updates.
duplication : UpdatesPartsListRequestDuplicationMode
How to handle duplication during the update.
Options are ``"First"``, ``"Error"``, and ``"Ignore"``.

Examples
--------
Expand All @@ -190,8 +189,8 @@ def update_parts_list(
"Test",
"Card",
"Sherlock Part Library",
"Both",
"Error",
UpdatesPartsListRequestMatchingMode.BOTH,
UpdatesPartsListRequestDuplicationMode.ERROR,
)
"""
try:
Expand All @@ -201,10 +200,6 @@ def update_parts_list(
raise SherlockUpdatePartsListError(message="CCA name is invalid.")
if part_library == "":
raise SherlockUpdatePartsListError(message="Parts library is invalid.")
if matching not in self.MATCHING_ARGS:
raise SherlockUpdatePartsListError(message="Matching argument is invalid.")
if duplication not in self.DUPLICATION_ARGS:
raise SherlockUpdatePartsListError(message="Duplication argument is invalid.")
except SherlockUpdatePartsListError as e:
for error in e.str_itr():
LOG.error(error)
Expand All @@ -226,9 +221,6 @@ def update_parts_list(

try:
if return_code.value == -1:
if return_code.message == "":
raise SherlockUpdatePartsListError(error_array=response.updateError)

raise SherlockUpdatePartsListError(message=return_code.message)
else:
LOG.info(return_code.message)
Expand Down
3 changes: 3 additions & 0 deletions src/ansys/sherlock/core/types/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (c) 2023 ANSYS, Inc. and/or its affiliates.

"""PySherlock client library constants for enumerated types."""
Loading