Python script to run a serie of simulations on EDEM

Julia Bonaldo
Julia Bonaldo Altair Community Member
edited October 2023 in Community Q&A

Hello,

I would like to know if someone has a script to run a series of simulations on EDEM. I can only run one simulation at a time, but it would be very helpful if I could set up a couple of simulations, and once one simulation is finished the next one on the list would automatically start.

It could be a draft of a script, I just need something as a base.

Thanks a lot.

Julia

Tagged:

Answers

  • PrasadAvilala
    PrasadAvilala
    Altair Employee
    edited October 2023

    Hi Julia,

     

    There is a bat file and pdf document explaining the procedure to submit jobs in batch mode.

    hope this helps.

     

     

    Thanks,

    Prasad A

  • Julia Bonaldo
    Julia Bonaldo Altair Community Member
    edited October 2023

    Hello Prasad,

    For some reason, I am not succeding in downloading your zip file. Where can I find this tutorial?


    Thanks 

  • PrasadAvilala
    PrasadAvilala
    Altair Employee
    edited October 2023

    Hello Prasad,

    For some reason, I am not succeding in downloading your zip file. Where can I find this tutorial?


    Thanks 

    Hi Julia,

     

    Please find the below link. 

    In this below link 3 tutorials please follow the instructions in 10.1 pdf document

     

    Tutorials, How To, Troubleshooting - EDEM Tutorial 10: Material Calibration and Batch Mode Simulations using EDEM Cal and EDEMpy (altair.com)

     

    Thanks,

    Prasad A

  • Stefan Pantaleev_21979
    Stefan Pantaleev_21979
    Altair Employee
    edited October 2023

    Hi Julia,

    You can find the tutorial here:

    EDEM Tutorial 10

    The first part covers running EDEM from command line and you can find further details on command flags in the EDEM documentation:

    EDEM batch mode docs

    There is also an easy graphical way to run EDEM simulations with varying parameters using HyperStudy which you would have access to under your units:

    EDEM-HyperStudy connector

    I recommend using the HyperStudy workflow so check out the how-to videos in the above link.

    Best regards,

    Stefan

  • Julia Bonaldo
    Julia Bonaldo Altair Community Member
    edited October 2023

    Thank you Stefan and Prasad for the answers.
    I've created a simple script shell if you use a Linux machine on SSH mode to run EDEM simulations. I checked the EDEM documentation, but it uses a .bat file, so I believe it's more applied to a Windows machine if I am not mistaken.

    As an example here I run 2 simulations in SSH, and once the first one is finished, the second one will start automatically:

    #!/bin/bash

    dos2unix run_simulations.sh

    # Define the simulation paths
    simulation_path1="enter_your_simulation1_path"
    simulation_path2="enter_your_simulation2_path"

    echo "Debug: Current directory is $(pwd)"  # Print the current working directory

    #to check if the path you entered is correct:

    echo "Debug: simulation_path1 is $simulation_path1"
    echo "Debug: simulation_path2 is $simulation_path2"

    # Run simulation 1 in the background
    echo "Running simulation 1: $simulation_path1"
    nohup edem -c -i "$simulation_path1/name_file.dem" -r 5 > simulation1.log 2>&1 &
    echo "Simulation 1 started in the background."

    # Wait for simulation 1 to finish
    wait

    # Run simulation 2 in the background
    echo "Running simulation 2: $simulation_path2"
    nohup edem -c -i "$simulation_path2/name_file.dem" -r 5 > simulation2.log 2>&1 &
    echo "Simulation 2 started in the background."

     

    In this case, I've added the command nohup, so The simulation will happen in the background. It means that if I turn off MobaXterm for example my simulation will keep running in the Linux machine.

    But I believe that if someone uses this script needs to be careful when killing a job as I am not sure if the last data will be saved.

     

    Please let me know if you have more suggestions to improve this shell.

     

    Julia