Scenario
iota.session.Scenario()
Description Iota scenario object.
Methods
Variables
name(str) scenario namedescription(str) scenario descriptionid(int) scenario Idproject(iota.session.Project) the project containing this scenario
Methods
Return a dataset record specified by name
Arguments
name: (str) dataset namedata_format: (str) data format of the dataset to be loaded. The scenario can have more than one dataset with the same name if data_format is different. (default: None)
Example
dataset = my_scenario.get_dataset(
name = 'mixing_rpm_30',
data_format = 'PADEM'
)Return the list of dataset records in the scenario
Example
print('List of datasets in the scenario')
for dataset in my_scenario.get_datasets():
print('dataset: {} (format: {})'.format(dataset.name,dataset.data_format))Add a Iota Dataset file to a scenario data_format must be one of PADEM or PACG
Arguments
name: (str) dataset namedata_format: (str) format of the datasetfile: (str) dataset filepathdescription: (str) dataset description (default: None)
Example
my_scenario.add_dataset(
name = 'mixing_rpm_32',
data_format = 'PADEM',
file = '/path/to/my/dataset/mixing_rpm_32.meta',
description = 'mixing analysis with drum speed of 32 RPM'
)Import external Dataset to a scenario data_format must be one of the accepted formats: [EDEM 2017]
Arguments
file: (str) dataset filepathname: (str) dataset name. If not defined, used the basename of the filepath (Default: None)data_format: (str) format of the datasetinclude_graphs: (bool) import any graph available in the dataset to the scenariodescription: (str) dataset description (Default: None)
Example
my_scenario.import_dataset(
file = '/path/to/my/edem/dataset/simulation.dem',
name = 'mixing_rpm_34',
data_format = 'EDEM 2017',
include_graphs = True,
description = 'mixing analysis with drum speed of 34 RPM'
)Check if exists a DEM dataset in the scenario
Example
if my_scenario.exists_dem_dataset():
print('Scenario have a DEM dataset')Return the scenario DEM Dataset if one exists in the scenario
Example
dataset = my_scenario.get_dem_dataset()
print('Dataset format: {}'.format(dataset.data_format))Return the scenario CG Dataset if one exists in the scenario
Example
dataset = my_scenario.get_cg_dataset()
print('Dataset format: {}'.format(dataset.data_format))Return True if graph exists, specified by name (and tags)
Arguments
name: (str) graph nametags: (dict) tags dictionary
Example
exists_graph = my_scenario.exists_graph(
name = 'Reaction Force',
tags = {
'dataset': 'mixing_rpm_34'
}
)
if exists_graph:
print('graph exist!')Return a graph, specified by name (and tags)
Arguments
name: (str) graph nametags: (dict) tags dictionary
Example
graph = my_scenario.get_graph(
name = 'Reaction Force',
tags = {
'dataset': 'mixing_rpm_34'
}
)Return the list of graphs in the scenario
Example
print('List of graphs:')
for graph in my_scenario.get_graphs():
print('Graph: {}'.format(graph.name))Add a new graph to a scenario. The graph can be defined in a csv file or by defining all the components (data, titles, etc)
Arguments
name: (str) graph nametitle: (str) graph titlefilepath: (str) optional file path for new graph file (Default: None)xdata: (iota.ArrayFloat) array of data representing the values of axis Xydata: (list[iota.ArrayFloat]) list of arrays representing the data serieslegend: (list[str]) list of names for the data seriesxtitle: (str) title of the axis Xytitle: (str) title of the axis Ycsvfile: (str) csv file containing the graph data. If this is defined, none of the previous variables are considereddescription: (str) graph descriptiontags: (dict) tags dictionaryoverwrite: (bool) overwrite graph file if already exists
Example
x_values = iota.ArrayFloat([0,1,2,3,4,5,6])
average_force = iota.ArrayFloat(len(x_values),10.0)
graph = my_scenario.add_graph(
name = 'Average Force',
title = 'Average Force',
xtitle = 'Step',
xdata = x_values,
ytitle = 'Force',
legend = ['Force'],
ydata = [average_force],
tags = {
'dataset': 'mixing_rpm_34'
},
overwrite = True
)
graph2 = my_scenario.add_graph(
name = 'Average Torque',
csvfile = '/path/to/my/graph/torque.csv',
tags = {
'dataset': 'mixing_rpm_34'
}
)Return a mesh specified by a name
Arguments
name: (str) mesh name
Example
mesh_record = my_scenario.get_mesh(
name = 'mixing_drum_v02'
)Return th elist of meshes in a scenario
Example
print('List of meshes:')
for mesh in my_scenario.get_meshes():
print(' mesh: {}'.format(mesh.name))Add a mesh by filepath to a scenario
Arguments
file: (str) mesh filepathdescription: (str) mesh description
Example
my_scenario.add_mesh(
file = '/path/to/my/mesh/mixing_drum_v2.stl',
description = 'Mixing drum with inclinantion of 30 degrees'
)Return a file, specified by name
Arguments
name: (str) file name
Example
file = my_scenario.get_file(
name = 'list of values test 2'
)Return the list of files in a scenario
Example
print('List of files:')
for file in my_scenario.get_files():
print(' file: {}'.format(file.name))Create and return a file, describe by name, filepath and optional description
Arguments
name: (str) scenario namefilepath: (str) file pathdescription: (str) file description (Default: None)
Example
my_scenario.add_file(
name = 'my text file',
filepath= '/path/to/my/file/text.txt',
description='this file contains the summary of parameters used for the simulations'
)Return a script spcified by a name
Arguments
name: (str) script name
Example
script_file = my_scenario.get_script(
name = 'calculate mixing index'
)Return the list of scripts in a scenario
Example
print('List of scripts:')
for script in my_scenario.get_scripts():
print(' script: {}'.format(script.name))Add a script (python file) to a scenario
Arguments
name: (str) script namefilepath: (str) script file pathdescription: (str) script description (Default: None)
Example
my_scenario.add_script(
name = 'calculate mixing index',
filepath = '/path/to/my/scripts/calculate_mixing_index.py',
description = 'This script calculate the Lacey mixing index using binning'
)Add a video file to a scenario
Arguments
file: (str) video file pathname: (str) video namedescription: (str) video description (Default: None)tags: (dict) tags dictionary (Default: None)thumbnail: (str) image file to be used as a thumbnail (Default: None)
Example
my_scenario.add_video(
file = '/path/to/my/videos/mixer_rpm_32_velocity_X.mp4',
name = 'Mixer at 32 RPM',
description = 'This video shows the velocity profile in X direction for the case with drum speed at 32 RPM',
tags = {
'dataset': 'mixer_rpm_32',
'result': 'Velocity (X)'
}
)Add image file to a scenario
Arguments
file: (str) screenshot file pathname: (str) screenshot namedescription: (str) screenshot description (Default: None)tags: (dict) tags dictionary (Default: None)
Example
my_scenario.add_video(
file = '/path/to/my/images/mixer_rpm_32_velocity-Y_time3.42.png',
name = 'Mixer at 32 RPM',
description = 'Velocity profile in Y direction for the case with drum speed at 32 RPM. Time = 3.42s',
tags = {
'dataset': 'mixer_rpm_32',
'result': 'Velocity (Y)',
'timestep': '3.42'
}
)Delete scenario from the database (and disk if applicable)
Example
name = my_scenario.name
my_scenario.delete()
if not my_project.exist_scenario(name):
print('scenario removed')Retun the a CG Settings object of defined in the current scenario (see CG_Settings for more info)
Example
config = my_scenario.get_coarse_graining_settings()
print('CG Output name: {}'.format(config['output']['name']))Run coarse graining on a scenario with optional custom settings. If custom settings are provided, a copy of the provided settings with with modified output directory and scenario fields will be used.
Arguments
with_settings: (iota.session.CG_Settings) Alternative settings to replace local one used for the analysis (Default: None)print_messages: (bool) activate/deactivate full verbosity during execution (Default: False)
Example
cg_settings = my_scenario.get_coarse_graining_settings()
cg_settings['output']['name'] = 'My dataset name'
cg_settings['output']['padem'] = True
cg_settings.set()
results = my_scenario.run_coarse_graining(
print_messages = True)
print(results.datasets)Last updated
Was this helpful?