Skip to main content

03. How to Get Started with PyRocky

andre.goncalve… | 08.20.2026

Before using PyRocky, users should have:

  • A compatible version of Ansys Rocky installed
  • Python 3.11 or newer installed
  • A Python IDE or coding environment: Visual Studio Code and Jupyter Notebooks are good alternatives

PyRocky can be installed with pip:

python -m pip install ansys-rocky-core

It can also be installed with Conda:

conda install conda-forge::ansys-rocky-core

A basic PyRocky workflow starts by importing the package and launching an Ansys Rocky session:

import ansys.rocky.core as pyrocky

rocky = pyrocky.launch_rocky()

Ansys Rocky software is launched in headless mode by default (without showing the Graphical User Interface, GUI), which is useful for automated workflows where the GUI is not required.

If the user wants to launch Ansys Rocky software with the GUI visible, the ‘headless’ argument can be set to ‘False’:

rocky = pyrocky.launch_rocky(headless=False)

A connection can also be established to an existing Ansys Rocky session that was started with ‘--pyrocky’ option:

C:\Program Files\Ansys Inc\v242\Rocky\bin\Rocky.exe --pyrocky

When the Ansys Rocky session is started in this way, you can connect it with PyRocky:

import ansys.rocky.core as pyrocky

rocky = pyrocky.connect_to_rocky()

From there, users can create projects, access studies, import geometries, define particle entities, configure solver settings, start simulations, and extract results.

A simplified workflow usually follows these steps:

  1. Launch or connect to an Ansys Rocky session.
  2. Create or open an Ansys Rocky project.
  3. Access the study.
  4. Configure geometry, particles, inlets, outlets, motions, and solver settings.
  5. Run the simulation.
  6. Extract curves, grid functions, and relevant engineering results.
  7. Export the processed data to CSV, Excel, databases, dashboards, or reports.
  8. Close the Ansys Rocky session.

For example:

import ansys.rocky.core as pyrocky

rocky = pyrocky.launch_rocky()
api = rocky.api
project = api.CreateProject()
study = project.GetStudy()
study.SetName("Automated DEM Study")
project.SaveProject("automated-dem-study.rocky")
api.close()

This simple structure is the foundation for more advanced DEM automation workflows.


Connect with Ansys