Note
Go to the end to download the full example code.
Get Random Vibration Analysis inputs#
This example demonstrates how to connect to the Sherlock gRPC service, import a project, and retrieve the analysis input fields.
Description#
Sherlock provides the ability to run a random vibration analysis using its gRPC interface. This script demonstrates how to: - Connect to the Sherlock service. - Retrieve the input fields required for random vibration analysis.
This example assumes you have already set up Sherlock and the necessary environment.
For more details on vibration analysis in Sherlock, refer to the official documentation.
from examples.examples_globals import SHERLOCK_CONNECT_TIMEOUT
from ansys.sherlock.core import launcher
Connect to Sherlock#
Connect to the Sherlock service and ensure proper initialization.
sherlock = launcher.connect(port=9092, timeout=SHERLOCK_CONNECT_TIMEOUT, transport_mode="wnua")
Traceback (most recent call last):
File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\examples\04-analyses\get_random_vibe_inputs_fields.py", line 59, in <module>
sherlock = launcher.connect(port=9092, timeout=SHERLOCK_CONNECT_TIMEOUT, transport_mode="wnua")
File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\.venv\Lib\site-packages\ansys\sherlock\core\launcher.py", line 326, in connect
raise e
File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\.venv\Lib\site-packages\ansys\sherlock\core\launcher.py", line 308, in connect
_wait_for_sherlock_grpc_ready(channel, timeout)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "C:\Users\ansys\actions-runner\_work\pysherlock\pysherlock\.venv\Lib\site-packages\ansys\sherlock\core\launcher.py", line 397, in _wait_for_sherlock_grpc_ready
raise SherlockConnectionError(message="Error starting gRPC service")
ansys.sherlock.core.errors.SherlockConnectionError: gRPC connection error: Error starting gRPC service
Get Random Vibration Input Fields#
Retrieve the list of input fields for the random vibration analysis.
try:
random_vibe_input_fields = sherlock.analysis.get_random_vibe_input_fields()
print("Random vibration analysis input fields:")
print(random_vibe_input_fields)
except Exception as e:
print("Error retrieving random vibration input fields.")
Total running time of the script: (0 minutes 2.020 seconds)