Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dd5059b
Linked python client code to grpc server. Added unit tests. Updated e…
khanson Aug 30, 2023
05a1cef
Update documentation
khanson Aug 30, 2023
2e95e65
Updated documentation of the return type from update_parts_from_AVL
khanson Aug 30, 2023
429a8fb
Updated documentation more and changed enums to be in all caps
khanson Aug 31, 2023
43d0f74
Fixing documentation for HTML
khanson Aug 31, 2023
8e7287e
fixed small + sign error in doc and spacing issues and Uncommented th…
khanson Aug 31, 2023
c0a7602
Updated tests to not require connection when doing client side verifi…
khanson Aug 31, 2023
c767050
Empty commit to test verification
khanson Sep 1, 2023
1854ea5
test1
khanson Sep 1, 2023
9d34bd1
test2
khanson Sep 1, 2023
d4520eb
test3
jmoody Sep 1, 2023
a0aa937
test5
anskhanson Sep 1, 2023
91a4bee
PR Feedback: Updated class names and exceptions
anskhanson Sep 5, 2023
6b8986a
PR Feedback: Updated type names in documentation
anskhanson Sep 5, 2023
e78092e
PR Feedback: Updated parameter names for update parts list to match u…
anskhanson Sep 14, 2023
4b3ee9d
MAINT: Bump ansys-sphinx-theme from 0.10.4 to 0.10.5 (#159)
dependabot[bot] Aug 29, 2023
0bc9558
MAINT: Bump ansys-api-sherlock from 0.1.20 to 0.1.21 (#161)
dependabot[bot] Aug 30, 2023
866c61e
User Guide: corrections in example code (#160)
ansjmoody Aug 31, 2023
cd5faea
MAINT: Bump pytest from 7.4.0 to 7.4.1 (#164)
dependabot[bot] Sep 5, 2023
ec1d802
MAINT: Bump ansys-sphinx-theme from 0.10.5 to 0.10.6 (#166)
dependabot[bot] Sep 5, 2023
658dec4
MAINT: Bump actions/checkout from 3 to 4 (#165)
dependabot[bot] Sep 5, 2023
20f0bcb
Added get_ict_analysis_input_fields and update_ict_analysis_props (#163)
ansys-pwalters Sep 6, 2023
ac4378c
MAINT: Bump grpcio from 1.57.0 to 1.58.0 (#167)
dependabot[bot] Sep 8, 2023
cd23657
MAINT: Bump pytest from 7.4.1 to 7.4.2 (#168)
dependabot[bot] Sep 8, 2023
4a6d8f4
MAINT: Bump ansys-sphinx-theme from 0.10.6 to 0.11.1 (#169)
dependabot[bot] Sep 11, 2023
fb53962
MAINT: Bump ansys-sphinx-theme from 0.11.1 to 0.11.2 (#170)
dependabot[bot] Sep 14, 2023
ec9756c
Empty commit to test verification
khanson Sep 1, 2023
9c61b5e
test1
khanson Sep 1, 2023
d05f15e
test2
khanson Sep 1, 2023
4de9550
test3
jmoody Sep 1, 2023
51541fc
test5
anskhanson Sep 1, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
python-version: [ '3.8', '3.9', '3.10', '3.11' ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Syncer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: micnncim/action-label-syncer@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 2 additions & 0 deletions doc/source/api/analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ The ``analysis`` module contains all analysis capabilities.
:toctree: _autosummary

ansys.sherlock.core.analysis.Analysis.get_harmonic_vibe_input_fields
ansys.sherlock.core.analysis.Analysis.get_ict_analysis_input_fields
ansys.sherlock.core.analysis.Analysis.get_mechanical_shock_input_fields
ansys.sherlock.core.analysis.Analysis.get_random_vibe_input_fields
ansys.sherlock.core.analysis.Analysis.get_solder_fatigue_input_fields
ansys.sherlock.core.analysis.Analysis.run_analysis
ansys.sherlock.core.analysis.Analysis.run_strain_map_analysis
ansys.sherlock.core.analysis.Analysis.update_harmonic_vibe_props
ansys.sherlock.core.analysis.Analysis.update_ict_analysis_props
ansys.sherlock.core.analysis.Analysis.update_mechanical_shock_props
ansys.sherlock.core.analysis.Analysis.update_natural_frequency_props
ansys.sherlock.core.analysis.Analysis.update_part_modeling_props
Expand Down
3 changes: 2 additions & 1 deletion doc/source/api/parts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ The ``parts`` module contains all parts management capabilities.
ansys.sherlock.core.parts.Parts.update_parts_list
ansys.sherlock.core.parts.Parts.update_parts_locations
ansys.sherlock.core.parts.Parts.update_parts_locations_by_file
ansys.sherlock.core.parts.Parts.get_part_location
ansys.sherlock.core.parts.Parts.get_part_location
ansys.sherlock.core.parts.Parts.update_parts_from_AVL
4 changes: 4 additions & 0 deletions doc/source/api/parts_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ Constants and classes used for the Parts API.
:toctree: _autosummary

PartLocation
PartsListSearchMatchingMode
PartsListSearchDuplicationMode
AVLPartNum
AVLDescription
3 changes: 1 addition & 2 deletions doc/source/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ The ``ansys-sherlock-core`` package supports Python 3.8 through Python 3.11 on W
To use PySherlock, you must download and install both the ``ansys-api-sherlock``
and ``ansys-sherlock-core`` packages. By using ``pip``, ``ansys-api-sherlock`` is
installed as part of ``ansys-sherlock-core``. Run the following to install

the publicly distributed version of the package.

.. code::

pip install ansys-sherlock-core

If you want to install the ``ansys-api-sherlock`` and ``ansys-sherlock-core`` packages
from its source code directly, follow the upcoming instructions:
from its source code directly, follow these instructions.

#. Download the latest ``ansys-api-sherlock`` package by running this
``git clone`` command:
Expand Down
18 changes: 10 additions & 8 deletions doc/source/user_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,16 @@ method to add a random vibe profile:

.. code::

sherlock.lifecycle.add_random_vibe_profile(
sherlock.lifecycle.add_random_vibe_profiles(
"Tutorial",
"Phase 1",
"RVEvent 1",
"Profile 1",
"HZ",
"G2/Hz",
[(30.4, 7.61e-5), (204, 0.1), (296, 0.06), (385, 0.06), (454, 0.03), (497, 0.06)]
[(
"Phase 1",
"RVEvent 1",
"Profile 1",
"HZ",
"G2/Hz",
[(30.4, 7.61e-5), (204, 0.1), (296, 0.06), (385, 0.06), (454, 0.03), (497, 0.06)],
)]
)

For information on the ``lifecycle`` module and its methods, see :ref:`ref_lifecycle_module`.
Expand All @@ -140,7 +142,7 @@ to run a random vibe analysis:
"Tutorial",
"Main Board",
[
("RANDOMVIBE",
(RunAnalysisRequestAnalysisType.RANDOM_VIBE,
[
("Phase 1", ["RVEvent 1"])
]
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ classifiers = [
]

dependencies = [
"ansys-api-sherlock==0.1.20",
"ansys-api-sherlock==0.1.21",
"grpcio>=1.17",
"importlib-metadata>=4.0,<5; python_version<='3.8'",
"protobuf~=3.20",
]

[project.optional-dependencies]
tests = [
"grpcio==1.57.0",
"grpcio==1.58.0",
"protobuf==3.20.3",
"pytest==7.4.0",
"pytest==7.4.2",
"pytest-cov==4.1.0",
]
doc = [
"ansys-sphinx-theme==0.10.4",
"ansys-sphinx-theme==0.11.2",
"numpydoc==1.5.0",
"Sphinx==6.2.1", # BLOCKED BY sphinx-design - Cannot upgrade to Sphinx 7 for now
"sphinx-copybutton==0.5.2",
Expand Down
184 changes: 183 additions & 1 deletion src/ansys/sherlock/core/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
SherlockRunAnalysisError,
SherlockRunStrainMapAnalysisError,
SherlockUpdateHarmonicVibePropsError,
SherlockUpdateICTAnalysisPropsError,
SherlockUpdateMechanicalShockPropsError,
SherlockUpdateNaturalFrequencyPropsError,
SherlockUpdatePartModelingPropsError,
Expand Down Expand Up @@ -42,6 +43,10 @@ def __init__(self, channel):
"forceModelRebuild": "force_model_rebuild",
"harmonicVibeDamping": "harmonic_vibe_damping",
"harmonicVibeCount": "harmonic_vibe_count",
"ictApplicationTime": "ict_application_time",
"ictApplicationTimeUnits": "ict_application_time_units",
"ictNumberOfEvents": "ict_number_of_events",
"ictResultCount": "ict_result_count",
"modelSource": "model_source",
"naturalFreqCount": "natural_freq_count",
"naturalFreqMin": "natural_freq_min",
Expand Down Expand Up @@ -333,7 +338,7 @@ def update_harmonic_vibe_props(

if "cca_name" not in harmonic_vibe_props.keys():
raise SherlockUpdateHarmonicVibePropsError(
message=f"CCA name is invalid for harmonic vibe properties {i}."
message=f"CCA name is missing for harmonic vibe properties {i}."
)

cca_name = harmonic_vibe_props["cca_name"]
Expand Down Expand Up @@ -483,6 +488,183 @@ def update_harmonic_vibe_props(
LOG.error(str(e))
raise e

def get_ict_analysis_input_fields(self):
"""Get ICT analysis property fields based on the user configuration.

Parameters
----------
None

Returns
-------
list
List of ICT analysis property fields based on the user configuration.

Examples
--------
>>> from ansys.sherlock.core.launcher import launch_sherlock
>>> sherlock = launch_sherlock()
>>> sherlock.analysis.get_ict_analysis_input_fields()
"""
if not self._is_connection_up():
LOG.error("There is no connection to a gRPC service.")
return

message = SherlockAnalysisService_pb2.GetICTAnalysisInputFieldsRequest()
response = self.stub.getICTAnalysisInputFields(message)

fields = self._translate_field_names(response.fieldName)
LOG.info(fields)

return fields

def update_ict_analysis_props(
self,
project,
ict_analysis_properties,
):
"""Update properties for an ICT analysis.

Parameters
----------
project : str
Name of the Sherlock project.
ict_analysis_properties : list
List of ICT analysis properties for a CCA consisting of these properties:

- cca_name : str
Name of the CCA.
- ict_application_time : double
Specifies the amount of time to complete one ICT event.
- ict_application_time_units : str
Application time units.
Options are ``"ms"``, ``"sec"``, ``"min"``, ``"hr"``, ``"day"``, ``"year"``.
- ict_number_of_events: int
Specifies the number of events to apply to the application time when computing
the time to failure for a component.
- part_validation_enabled: bool
Whether to enable part validation. The default is ``None``.
- require_material_assignment_enabled: bool
Whether to require material assignment. The default is ``None``.
- ict_result_count: int
The number of ICT result layers to generate. This parameter is for use with
thermal analysis.

Returns
-------
int
Status code of the response. 0 for success.

Examples
--------
>>> from ansys.sherlock.core.launcher import launch_sherlock
>>> sherlock = launch_sherlock()
>>> sherlock.project.import_odb_archive(
"ODB++ Tutorial.tgz",
True,
True,
True,
True,
project="Test",
cca_name="Card",
)
>>> sherlock.analysis.update_ict_analysis_props(
"Test",
[{
'cca_name': 'Card',
'ict_application_time': 2,
'ict_application_time_units': 'sec',
'ict_number_of_events': 10,
'part_validation_enabled': False,
'require_material_assignment_enabled': False,
},
]
)

"""
try:
if project == "":
raise SherlockUpdateICTAnalysisPropsError(message="Project name is invalid.")

if not isinstance(ict_analysis_properties, list):
raise SherlockUpdateICTAnalysisPropsError(
message="ICT analysis properties argument is invalid."
)

if len(ict_analysis_properties) == 0:
raise SherlockUpdateICTAnalysisPropsError(
message="One or more ICT analysis properties are required."
)

request = SherlockAnalysisService_pb2.UpdateICTAnalysisPropsRequest(project=project)

for i, ict_analysis_props in enumerate(ict_analysis_properties):
if not isinstance(ict_analysis_props, dict):
raise SherlockUpdateICTAnalysisPropsError(
f"ICT analysis props argument is invalid for ICT analysis properties {i}."
)

if "cca_name" not in ict_analysis_props.keys():
raise SherlockUpdateICTAnalysisPropsError(
message=f"CCA name is missing for ICT analysis properties {i}."
)

cca_name = ict_analysis_props["cca_name"]
if cca_name == "":
raise SherlockUpdateICTAnalysisPropsError(
message=f"CCA name is invalid for ICT analysis properties {i}."
)

props_request = request.ictAnalysisProperties.add()
props_request.ccaName = cca_name

if "ict_analysis_count" in ict_analysis_props.keys():
props_request.ictAnalysisCount = ict_analysis_props["ict_analysis_count"]

if "ict_application_time" in ict_analysis_props.keys():
props_request.applicationTime = ict_analysis_props["ict_application_time"]

if "ict_application_time_units" in ict_analysis_props.keys():
props_request.applicationTimeUnits = ict_analysis_props[
"ict_application_time_units"
]

if "ict_number_of_events" in ict_analysis_props.keys():
props_request.numberOfEvents = ict_analysis_props["ict_number_of_events"]

if "part_validation_enabled" in ict_analysis_props.keys():
props_request.partValidationEnabled = ict_analysis_props[
"part_validation_enabled"
]

if "require_material_assignment_enabled" in ict_analysis_props.keys():
props_request.requireMaterialAssignmentEnabled = ict_analysis_props[
"require_material_assignment_enabled"
]

if "force_model_rebuild" in ict_analysis_props.keys():
props_request.forceModelRebuild = ict_analysis_props["force_model_rebuild"]

except SherlockUpdateICTAnalysisPropsError as e:
LOG.error(str(e))
raise e

if not self._is_connection_up():
LOG.error("There is no connection to a gRPC service.")
return

response = self.stub.updateICTAnalysisProps(request)

try:
if response.value == -1:
raise SherlockUpdateICTAnalysisPropsError(response.message)
else:
LOG.info(response.message)
return response.value
except SherlockUpdateICTAnalysisPropsError as e:
LOG.error(str(e))
raise e

def get_mechanical_shock_input_fields(self, model_source=None):
"""Get mechanical shock property fields based on the user configuration.

Expand Down
29 changes: 29 additions & 0 deletions src/ansys/sherlock/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,18 @@ def __str__(self):
return f"Update harmonic vibe properties error: {self.message}"


class SherlockUpdateICTAnalysisPropsError(Exception):
"""Contains the error raised when properties for ICT analysis cannot be updated."""

def __init__(self, message):
"""Initialize error message."""
self.message = message

def __str__(self):
"""Format error message."""
return f"Update ICT analysis properties error: {self.message}"


class SherlockUpdateMechanicalShockPropsError(Exception):
"""Contains the error raised when properties for mechanical shock analysis cannot be updated."""

Expand Down Expand Up @@ -880,3 +892,20 @@ def __init__(self, message):
def __str__(self):
"""Format error message."""
return f"Update part modeling props error: {self.message}"


class SherlockUpdatePartsFromAVLError(Exception):
"""Contains the error raised when parts list cannot be updated by AVL."""

def __init__(self, message=None, error_array=None):
"""Initialize error message."""
self.message = message
self.error_array = error_array

def str_itr(self):
"""Create list of error messages."""
if self.message is None:
return [f"Update part from AVL error: {error}" for error in self.error_array]

assert self.error_array is None
return [f"Update part from AVL error: {self.message}"]
Loading