Customer Portal

Energy analysis using scripting API

Scripting API is a great way to save time by automating repeatable tasks. Scripting gives access to Rocky DEM raw data and simulation results, so you can automate your case setup and post-processing steps, especially when you’re performing complex analysis for many similar kinds of cases.

Scripts are usually created and/or edited in code editors and then applied to simulations in Rocky. While knowing how to code in Python is not required use Rocky, you can use Python to customize and extend the features included within Rocky.

As an example, we will analyze and report energy data through automated steps created by Scripting API. Granular media are extremely dissipative systems, and the contact force model has to allow significant energy dissipation. Providing the distribution of dissipated energy altogether for all elements of the system helps engineers better understand and plan for improved design decisions.

Energy analysis in mining industries

In the mining industry, grinding processes are typically low energy-efficient equipment with more than 90% of the input energy dissipated as heat loss. In this example, we will execute the energy analysis report script on a semi-autogenous grinding (SAG) mill. The goal is to provide an energy balance and analyze the distribution of input energy.

The Scripting API allows us to create an additional interface layer and collect required input(s) for the analysis (Figure 1). This means the user can expand and create a new interface on top of Rocky for unique tasks like multiscale and multi-disciplinary modeling.

Figure 1. Energy report interface added to Rocky DEM through scripting API.

The script accesses the inputs in the previous step and collects the data needed from the simulation. Finally, data reporting and visualization can be tailored to suit your needs. Figure 2 plots a chart to highlight the distribution of dissipated energy and useful mechanical work for the mill.

Report of energy distribution in an industrial SAG mill design using Rocky Scripting API.
Figure 2. Report of energy distribution in an industrial SAG mill design using Rocky Scripting API.

Additionally, further post-processing was done to highlight energy losses for collision pairs (particle – particle/boundary), losses due to dissipation work per collision in normal or tangential directions. Such data is useful to understand process dynamics, identify issues with the current operation, set optimization targets, and then model the effect of changes before field testing. As a high-fidelity tool, Rocky DEM provides an accelerated decision-making environment for virtual optimization at a fraction of the cost of field testing.

Collision pair between the elements of the system, both in normal and tangential directions, reported for a SAG mill
Figure 3. Collision pair between the elements of the system, both in normal and tangential directions, reported for a SAG mill (only collision pairs above 0.01% are shown).

Rocky Scripting API is a powerful tool that offers an additional layer of customization and allows you to quickly perform repetitive tasks, customize calculations, and data export and visualization over and beyond what is offered in Rocky UI. If you’re doing similar analyses for multiple cases, you’re wasting valuable time. Increase efficiency with customized Scripting API capabilities tailored to your unique needs. Rocky offers many useful scripts in the customer portal library. Contact us today to find out more.


author Ahmad Haghnegahadar

Ahmad Haghnegahdar

Applications Engineer, Rocky DEM Business Unit at ESSS

Ahmad holds a Master of Science degree in Chemical Engineering from Oklahoma State University. He brings experience in analyzing multiphase and turbulent flows in the field of biomechanics. His prior roles included developing and optimizing chemical processes through data analysis tools. Given his diverse background from chemical to pharmaceuticals, Ahmad recognizes and understands the challenges engineers face in simulating multiphysics systems across many industries.


Related posts

Leave a comment


Get Fresh Updates on Email

Subscribe to our newsletter





    I agree to receive communications.

    By providing my data, I agree to the  Privacy and Processing of Personal Data Terms.