Post-processing EDEM data in Python using ‘EDEMpy’

Corinne Bossy_21127
Corinne Bossy_21127
Altair Employee
edited December 2021 in Altair HyperWorks

Originally posted on January 14, 2019

In this article we are introducing a unique tool available to EDEM users: EDEMpy.

EDEMpy is a Python library for post-processing and analyzing EDEM simulation data and takes advantage of the opensource hdf5 file format which has been used to store EDEM data since EDEM 2017. Adopting this standard allowed users to see their data directly using tools like HDFView and while exposing this data is useful, being able to manipulate it and process it in a scripting environment opens up many possibilities and this is what EDEMpy provides.

The motivation to develop EDEMpy has been driven by the requirement to do more complex analysis of EDEM data on ever larger simulation decks and to make simple tasks like comparing two or more EDEM simulations easier for users – you no longer need to open multiple decks and do data exports on them individually as all that data is now accessible from a Python script or prompt.

Using the library, it is easy to extract specific data from a simulation deck and process that data in a customizable and reusable way. Using EDEMpy you can, for example, extract force acting on a specific geometry over time and compare results back to back between multiple simulation decks (Fig 1.), track particles residence time over the course of a simulation, visualize networks of contacts and bonds in a new flexible way, visualize DEM data as a continuum (Fig 2.) or use EDEM data to calculate post processing properties for simulations such as segregation index.

image

Fig 1. Comparing Plough X Force results for two EDEM simulation decks

image

Fig 2. Particle velocity magnitude visualized as a continuum using EDEMpy

EDEMpy offers a new way of interacting with EDEM data – where it really shines is when you need to process data in a way that requires the flexibility and customization that scripting offers. With EDEM simulations now regularly being run with 10s of millions of particles the volume and complexity of the data generated lends itself particularly well to scripted post processing where you often need to dig into the data to extract meaningful results.

Python has widespread use in the scientific, engineering and data-analysis communities, this means we can put advanced scripted post processing capabilities in the hands of as many EDEM users as possible and these users benefit from the rich ecosystem of pre-existing Python libraries. Libraries like pandas, numpy, pyevtk, matplotlib and mayavi (to name just a few) are widely used and supported across the Python user community and make manipulating, plotting and exporting EDEM data using EDEMpy easy.

EDEMpy 0.1.0 supports a wide range of “get” functions so that users can “get” EDEM data from the hdf5 file format into numpy arrays in their Python environment. For example, to get a numpy array “pos” which contains the x, y, z positions of particle type 0 in the 10th save time step you would write:

from edempy import Deck

deck = Deck(‘MyEDEMSimulation.dem’)

pos = deck.timestep[10].particle[0].getPositions()

This structure is followed throughout EDEMpy for getting data from, for example, geometries, contacts, bonds and collisions.


EXAMPLE: SEGREGATION INDEX IN MIXING APPLICATION

Here we show how EDEMpy can be used to calculate a custom simulation variable – the segregation index for a simulation of a mixer containing 10 million particles. Segregation index is defined in Marigo et al. (2012) as:

image

where CAA, CBB and CAB are the total number of contacts between particles of different species, type A and type B.

Figure 3 below shows a representation of the definition of segregation index based on contacts. Segregation index ranges from 0 to 2. S = 2 corresponds to zero mixing, S > 1 corresponds to random mixing and S = 0 corresponds to ordered mixing.

image

Fig 3. Schematic representation of segregation index based on contacts (Marigo et al., 2012)

In order to calculate the segregation index  you therefore must have access to contact data and evaluate which particle species are in contact. EDEMpy provides this data in a format which means making this calculation is straight forward.

image

Fig 4. EDEMpy script running in Spyder IDE

The video below shows the mixer simulation in EDEM together with a graph showing how the segregation index changes over time.



HOW TO GET STARTED

To get started with EDEMpy, users can download the library and a ‘Getting Started’ guide which details installation and the syntax used throughout the library from the Knowledge Base. There are also several example scripts available.


References:
[1] Marigo, M. Cairns, D. L. Davies, M. Ingram, A. & Stitt, E. H. (2012) A numerical comparison of mixing efficiencies of solids in a cylindrical vessel subject to a range of motions. Powder Technology.

Tagged: