Lesson3.2 IntermediateScripting
Lesson3.2 IntermediateScripting
2 – Intermediate Scripting
This is the second part of the lesson on script writing with EDEMpy. This lesson will demonstrate one
method of creating geometry bins and will highlight how to create loops to output data from each bin at
every timestep.
We will look at determining the stress on the geometry of a Rock Box, but we will step through a more
complex script to determine more information. We begin this script by importing the classes we wish to
use from the EDEMpy package. We use the deck class to pull data from a specified EDEM simulation. Using
attributes from the Deck class we assign variables to represent the number of timesteps and the timestep
values.
Here we define the number of bins in the X, Y and Z direction, and the total number of bins is found by
multiplying these together.
Next, we want to determine the IDs of the triangle which make up the Rock Box walls. Here we use this
function from the geometry class, and we print the triangle IDs. Refer to the documentation if you wish
to find out more about the functions used in this lesson.
We will demonstrate the first method of binning. Here we use a new function from the bin class which
outputs a specified property related to the binned particles, geometry, or interactions. For the arguments,
the number of bins and the bin dimensions are specified. Setting the option to ‘default’, outputs the
contact IDs. Notice that we have also specified that we are interested in the particle-geometry
interactions. A zero is appended to the end of this function to specify that we only want the IDs of the
contacts in the lower bin. Note the NumPy package is also used to store the binned contacts as an array.
An index is then created using the triangle IDs that we obtained in the previous line. We are only interested
in the contacts between the particles and the Rock Box walls, therefore we extract the indices of all the
contacts with the same triangle IDs as those printed above.
We use the get Binned Property function. This time we input the option ‘normal force’ to obtain all the
normal force vectors between the particles and the walls in the bottom geometry bin. By appending the
index, we can isolate specifically the forces that we are interested in.
Using NumPy we then find the sum of the magnitude of the normal force vectors at the last time step.
The same process is repeated for finding the tangential forces.
Now we look at looping through all the bins and extracting the stress on the geometry in each. First, we
calculate the total wall surface area in the bin. Next, we create a ‘for’ loop with variable n representing
the bin numbers. In this case since there are only two bins, n takes the values 0 and 1. The script is then
updated to include n. Stress is calculated using the force values and wall area, and the results are
appended to the empty lists. An exception is also created in case there are no particles in the bin at the
specified timestep. Printing the result gives the following.
Next, we edit the script to also loop through and extract the stresses at all the timesteps. We define a new
variable ‘t’ representing the timestep numbers. Updating the script, we replace the last timestep with ‘t’.
We then append the normal and tangential stress values at each time step to an empty list. Running this
script outputs the following. Running this script will provide the stress results.