How to use EDEM Batch Commands


Hi Altair EDEM community

 

Running EDEM via command prompt is a very powerful way of running and exporting data efficiently.  For automated analysis of multiple cases, not just data export, you can look at EDEMpy and we have examples of these in the EDEM calibration kits. For optimisation of multiple runs we can look at the integration with EDEM and Hyperstudy, this blog focusses on highlighting the capabilities EDEM batch commands only.

When running simulations by batch you first need to have setup your simulation via the User Interface, once you have the EDEM files you can automate the running and post-processing of the results.

The EDEM commands listed below are the same for Windows and Linux however I’m using Windows for the example so any paths and additional operating system commands like ‘copy’ and ‘rename’ are operating system specific, however there are the equivalent options on Linux.

 

Firstly running the command:

 

edem --help

 

Gives an output of all the available commands.  I have attached a copy of all these flag outputs to the post in EDEMFlags.txt

 

To note running ‘edem’ as a standalone command will pickup the version of EDEM specified in the PATH environment variable:

Graphical user interface, text, applicationDescription automatically generated

If running on remote machines it’s often best to specify the full path for specific versions when running the commands, for example:

 

"C:\Program Files\Altair\2022\EDEM\bin\edem.exe" --help

 

I’m using a simple example of counting the amount of material in a box.  I have setup the simulation already and to run in via command prompt I need the command:

 

edem -c -i C:\processing\Pipe\example.dem -r 3 -E 2 -t 0.00016244 –rewind

 

Or if I create a batch file I can run multiple simulations consecutively:

 

Graphical user interface, text, applicationDescription automatically generated

If I run the command from the same location as the .dem file we don’t need the full path, just -i simulation_name.dem


In this case I’m specifying the file location and input deck via the -i flag. Setting it to run for 3 s with the -r flag, using the CUDA GPU engine (-E 2) and running a timestep of 00016244 s.  I also use the –rewind flag to restart the simulation from t=0 s, without this the simulation will start from last save point.

 

This can be submitted directly as 1 command or written into a batch (.bat for windows) file.

 

A picture containing chartDescription automatically generated

 

When I setup the simulation at t=0 s I also created a bin group to count the number of particles in the bin.

A picture containing bunch, arranged, several, saleDescription automatically generated

 

And in the EDEM Analyst I setup an export query to write this to a .csv file:

 

Graphical user interface, applicationDescription automatically generated

 

The query where we export data to the .csv is actually saved in the simulation .dfg file:

Graphical user interface, text, applicationDescription automatically generated

You can make a copy of the dfg file and use the same file in different simulations just for purposes of automated export:

Graphical user interface, text, application, chat or text messageDescription automatically generated

 

If I want to automatically export this query to the .csv I need to run the simulation with the -e (export) flag and point towards the .dfg file which has my query saved, for example:

 

edem -c -i C:\processing\Pipe\example.dem -r 3 -E 2 -t 0.00016244 --rewind -e C:\processing\Pipe\export.dfg

 Graphical user interface, text, application, chat or text messageDescription automatically generated


If I want to re-run the simulation with a different CAD geometry I can place this in the same folder and replace the existing geometry (called shell_1 in EDEM) with the geometry in cad.stp.  In which case I’ll use the --replace-geometry command. This references an additional .txt file with the required information in.

 

 

 edem -c -i C:\processing\Pipe\example.dem -r 3 -E 2 -t 0.00016244 --rewind -e C:\processing\Pipe\export.dfg --replace-geometry c:\processing\Pipe\CADReplace.txt

This then replaces the geometry “shell_1” with the contents of cad.stp and runs the simulation.

 

This allows us to then make use of windows (or linux) batch commands.  For example if we create a for loop:

 

for /L %%i in (1,1,20) DO (

 

This will create a loop with integer i increasing from 1 to 20 in steps of 1. 

 

copy pipe%%i.stp cad.stp

 

This will first copy pipe1.stp to cad.stp and continue for different values of i. We then run EDEM and rename MassOutput.csv to reference the i value:

 

ren MassOutput.csv MassOutput%%i.csv

 

And delete the cad.stp file to allow a new one to be replaced.  This then loops to i+1.  The full contents of the batch file is then:

 

for /L %%i in (1,2,39) DO (

 

copy pipe%%i.stp cad.stp

edem -c -i C:\processing\Pipe\example.dem -r 3 -E 2 -t 0.00016244 --rewind -e C:\processing\Pipe\export.dfg --replace-geometry c:\processing\Pipe\CADReplace.txt

ren MassOutput.csv MassOutput%%i.csv

del cad.stp

)

   

The CAD import is a specific case however the same loop approach is useful if you have multiple simulations to run and post-process.  Renaming the output.csv so it doesn’t get overwritten is often recommended, it also means you can always use the same .dfg file for multiple simulations without having to setup the same analysis time after time.