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

Cloninig Settings and Running Coarse-graining for Multiple Scenarios

This is an example of a script that clones the coarse-graining settings of a base scenario to new scenarios where the input DEM data is modify based on a list of DEM simulations:

''' Given a Iota project, a Iota scenario (base scenario) where coarse-graining settings have been set, 
    a list of scenarios and the list of EDEM simulations that have been already run, for scenario and EDEM simulation, 
    clone the coarse-graining settings from the base scenario and run the coarse-graining analysis'''

import sys                              
import os
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

### 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 Beta','Design Gamma']    #Name for the new scenarios 
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 post-processed.

####################


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

pr = papi.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   
    sc = pr.add_scenario(sc_name)                                     #Creates a new scenario

    ### Clone base settings and update them
    for_new_scenario = base_cg.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

    ### Run coarse-graining with the updated settings
    print('Running scenario {}'.format(sc.name))
    sc.run_coarse_graining()
    print('Finished scenario {}'.format(sc.name))

print('All finished')
PreviousCreating Multiple Videos of a DatasetNextAutomating EDEM Simulations runs and Iota Analyses

Last updated 5 years ago

Was this helpful?