Iota Python API
1.0.0
1.0.0
  • Introduction
  • Getting started with Iota Python Library and Iota IPython Terminal
    • Starting a Session
    • Creating a New Project
    • Loading a Project
    • Creating a New Scenario
    • Loading a Scenario
    • Importing a Dataset
    • Running Coarse-graining
  • Writing Scripts
    • Generic Scripts
    • Run(scenario) Scripts
  • Running Scripts
    • Running Generic Scripts
    • Running run(scenario) Scripts
  • Iota Python Reference Library
    • Datasets
    • Graphs
    • Scene renderer
    • Meshing
    • Variable types
    • Session
    • Project
    • Scenario
    • Graph
    • Dataset
    • Mesh
    • Script
    • File
    • Auxiliar
    • Enums
  • Examples
    • Creating a New Project
    • Creating a New Scenario
    • Creating Multiple Scenarios
    • Loading a Project and a Scenario
    • Importing a Dataset into a Scenario
    • Importing Multiple Datasets into different Scenarios
    • Creating a Cut-Plane with Results in a Dataset
    • Creating a New Result in a Dataset
    • Calculating a KPI and Exporting into a Graph
    • Getting the Profile of Result along a Line
    • Creating Multiple Result Line Variations and Plotting them in a Single Graph
    • Integrating a Result over a Mesh
    • Getting the Evolution of the Statistics of a Result
    • Creating Multiple Screenshots of a Dataset
    • Creating Multiple Videos of a Dataset
    • Cloninig Settings and Running Coarse-graining for Multiple Scenarios
    • Automating EDEM Simulations runs and Iota Analyses
Powered by GitBook
On this page

Was this helpful?

  1. Examples

Automating EDEM Simulations runs and Iota Analyses

This is an example of a script that runs of a list of EDEM simulations and as soon as each simulation finishes, it launches the coarse-graining analysis based on a base coarse-graining settings. Note that the EDEM simulation and coarse-graining is also launched for the base scenario where the base coarse-graining settings are taken from.

''' Given a list of EDEM simulations that have been already set in EDEM, a Iota project, a Iota scenario (base scenario)
     where coarse-graining settings has been set and a list if scenarios names, for each EDEM simulation and scenario, 
     run the EDEM simulation and once the simulation is over, automatically clone the coarse-graining settings from 
     the base scenario and run the coarse-graining analysis'''

import sys                              
import os
import subprocess
import iota
sys.path.append(os.getenv('IOTA_PATH'))                                         # Add iota directory to Python paths

username = 'stephen'                                                            # Set Iota username
home_path = 'C:/Users/stephen/'                                                 # Set user's home directory


### Settings for EDEM executable
EDEM_path='C:/Program Files/DEM Solutions/EDEM 2018/bin/edem.exe'               #Path to EDEM executable on your machine

### Setttings for bacth cloning and setting coarse-graining
project_name = 'Backhoe optimization'                                 #Name of the project to work with
base_scenario = 'Design Alpha'                                        #Name of the scenario that contains the coarse-graning settings to be cloned
scenarios_names = ['Design_Alpha', 'Design Beta','Design Gamma']      #Name for scenarios to be post-processed
input_EDEM_Data = ['C:/Users/stephen/Backhoe_simulations/Design_Beta.dem',  
    'C:/Users/stephen/Backhoe_simulations/Design_Gamma.dem']          #Input DEM simulation files to be run and post-processed.
####################


my_session = iota.session(username,home_path + 'ParticleAnalytics/config.ini')  # Start new session

pr = my_session.get_project(project_name)                              #Get the selected project to work on

base_sc = pr.get_scenario(base_scenario)                         #Load the scenario that contains coarse-graining settings to be cloned
base_cg_settings = base_sc.get_coarse_graining_settings()        #Get the coarse-graining settings to be cloned for the other scenarios

## Batch loop starts here
for sc_name, simu_EDEM in zip(scenarios_names,input_EDEM_Data):       #For each scenario name and input EDEM data

    #Run EDEM simulation

    print('Running EDEM simulation for scenario {}'.format(sc_name))
    edem_command = ['edem.exe','--console', '-i', simu_EDEM]
    print('Running EDEM for scenario {}'.format(sc_name))
    p=subprocess.Popen(edem_command, executable=EDEM_path)                 #EDEM simulation is launched
    p.communicate()
    print('EDEM simulation for scenario {} finished'.format(sc_name))

    if sc_name != base_scenario:                                          # If the scenario is not the base scenario  
        sc = pr.add_scenario(sc_name)                                     #Create a new scenario

        ### Copy base settings and modify
        for_new_scenario = cg_base.as_dict().copy()                       #Copy coarse-graning settings from base scenario
        for_new_scenario['scenario'] = sc.id                              #Set the id of the new scenario
        for_new_scenario['output']['name'] = sc.name                      #Set the name of the output datasets to the new of the scenario
        for_new_scenario['output']['directory'] = sc.directory            #Set the output directory to the directory of the new scenario
        for_new_scenario['input']['data']['edem_filename'] = simu_EDEM    #Set the input DEM data to be processed in the new scenario

        ### Save the updated coarse-graining setting to the scenario
        cg_settings = sc.get_coarse_graining_settings()                   #Get the coarse-graining settings of the new scenario before updating
        cg_settings._dict = for_new_scenario                              #Update the coarse-graining settings of the new scenario
        cg_settings.set()                                                 #Save the updated coarse-grainings to the new scenario

    else:                                                                 #else the scenario to post-processed in the base scenario 
        sc = sc_base

    ### Run coarse-graining for the scenario
    print('Running coarse-graining fro scenario {}'.format(sc.name))
    sc.run_coarse_graining()
    print('Scenario {} finished'.format(sc.name))

print('All finished')
PreviousCloninig Settings and Running Coarse-graining for Multiple Scenarios

Last updated 5 years ago

Was this helpful?