0% found this document useful (0 votes)
18 views

Lesson3.3 AdvancedScripting

Uploaded by

cma6301
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Lesson3.3 AdvancedScripting

Uploaded by

cma6301
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Lesson 3.

3 – Advanced scripting

This video is the third part of the lesson on creating EDEMpy scripts. We will look at using additional
Python modules and EDEMpy packages to enhance our postprocessing analysis. We will also explore
an alternative method of creating geometry bins and we will demonstrate how to compare results
from several EDEM decks.

Sometimes we want to run scripts which automatically access data from the EDEM decks within the
Python script directory. We begin by importing a new module, glob. The glob module finds all the
path names matching a specified pattern. In this case all the .dem files. By incorporating this into our
code we can create scripts that can be universally applied to all decks in the directory.

Running this code returns a list of the different .dem files in the directory.

Next, we look at an alternative method of creating geometry bins. Here we can import the Boxbin and
CylinderBin classes from the EDEMpy module. We can then define new variables to represent these
bins by calling the bin classes and specifying the center and dimensions of the bins like so.

In this example we will only use the Boxbin class.

We now move on to postprocessing our data. As usual we need to import the Deck class from the
EDEMpy module and define our variable deck to call data from our EDEM simulation. For now we are
only interested in the data from Rock Box 1 at the last timestep.

Begin by calling the timestep and timestep values. Next, we want to find all the particle inside the bin
using the function shown. The function takes the following arguments, therefore we first create two
lists of all the particles and their positions to search for inside the bin. Inputting these as the arguments
returns a list of the particle IDs inside the binned area when the script is run. Next, we find all the
triangle IDs for the box walls and list all the triangles and particles in contact with each other. Using
this information, we define an index to isolate all the contact IDs that that are inside the bin.

We then obtain all the normal forces between the particles and the geometry and append the index
to isolate only those force vectors within the bin. Using the NumPy package we find the magnitude of
the vectors. Using the function shown, with the option set to ‘total’, we find the total force within the
bin, which is effectively the equivalent of summing the normal force magnitudes. We can also find the
total tangential force on the geometry in the box by applying a similar method.

Now we edit the code to loop through all the timesteps and output the stress in the bin at each one.
This is done in the same way as was done in the previous video. We introduce a new variable
representing the area of the box walls inside the bin. We then divide the forces by this area and
append the results to an empty list. We also create an exception for timesteps where there are no
particles in the bin. Running the script outputs the following.

We also want the script to extract this information for all the EDEM decks in the directory. We
therefore create a new loop and move our deck variable inside of that loop. This code will now
evaluate the normal and tangential stress on both Rock Box 1 and Rock Box 2.

We are interested in visualizing this data graphically. We therefore need to import a new module to
create Python plots. The following code formats the axes for the normal and tangential subplots.
Moving to the end of the script we then define the timestep values as the X axis inputs and the stresses
as the Y axis data inputs. Running this script outputs the graphs shown. Here you can see the plots of
the stresses on both Rock Boxes over time.

You might also like