Getting started#
PyRocky is a Python client library for remotely controlling Ansys Rocky, which is the most powerful software in the market for performing DEM (discrete element method) simulations.
Install PyRocky#
PyRocky is currently a private GitHub library in the Ansys Internal account. To install PyRocky in user mode, run this command:
python -m pip install ansys-rocky-core
Launch PyRocky#
The best way to experiment with PyRocky is by using Jupyter Notebook
or Visual Studio Code. The following code launches a
headless Rocky session and returns a RockyClient
instance from which you can programmatically
interact with the software:
import ansys.rocky.rocky as pyrocky
rocky = pyrocky.launch_rocky()
You use the close()
method to close the Rocky session:
rocky.close()
If you want to launch the Rocky UI, set headless=False
:
rocky = pyrocky.launch_rocky(headless=False)
Connect to an existing session#
Assume that a Rocky session is started with the --pyrocky
option:
C:\Program Files\Ansys Inc\v241\Rocky> bin\Rocky.exe --pyrocky
When the Rocky session is started in this way, you can connect to it with PyRocky:
import ansys.rocky.rocky as pyrocky
rocky = pyrocky.connect_to_rocky()