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

Creating Multiple Result Line Variations and Plotting them in a Single Graph

This is an example of a run(scenario) script that loads coarse-graining (cg) dataset and gets the multiple profiles of a result along different lines. The data of the profiles is saved into the scenario as a single graph with multiple traces, one per line variation (raw data is also saved into a CSV file). Also, the graph is exported into a interactive HTML file.

'''This scripts loads the cg_dataset of a scenario. For a given timestep, mesh name,result and list of start and end point defined different line, it gets the profiles of the result along each line. The data of the profiles is saved into the scenario as single graph with a trace per line variation. Also, the CSV file with raw data of the profiles is created on disk and the graph is exported into a HTML file'''

import iota

def run(scenario):

    ## Settings for the line profile ##
    mesh_name = 'cg_volume_mesh'                           #Name of the volume mesh with the coarse-graining results

    res_name = 'Velocity'                                     #Name of the result for getting the line profiles
    res_component = 3                                         #Component of the result (X=0, Y=1, Z=2, Magnitude=3)
    res_analysis = 'none'                                     #Name of the analysis of the result


    ListOfStart_points = [[0,-1,0],[0,0,0],[0,1,0]]           #List of Start points [x,y,z] for the line profiles
    ListOfEnd_points = [[0,-1,1.3],[0,0,1.3],[0,1,1.3]]       #List of End points [x,y,z] for the line profiles
    Npoints = 50                                              #Number of points to get for the line profile
    t = '2.5'                                                 #Value of the timestep to get line from.   
    ########################################

    #### Settings for graph saving ######
    Name_graph = 'Profile {} at {}'.format(res_name,t)                  #Name for the graph
    Title_graph = 'Profile {} at {}'.format(res_name,t)                   #Title to shown in the graph
    xtitle = 'Distance (m)'                                               #Title for x-axis 
    ytitle = res_name + '[m/s]'                                           #Tile for y-axis based on result name + units
    graph_file = '{}/graphs/{}'.format(scenario.directory,Name_graph)     #Output name and path for exporting graph

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

    cg_dataset = scenario.get_cg_dataset()                            #Get the coarse-graining dataset of the scenario
    cg_data = cg_dataset.data()                                       #Load the data of the coarse-graining dataset
    ListOfTimesteps = cg_data.timesteps()                             #Get the list of time of the steps
    step = ListOfTimesteps.index(t)                                  #Get the step for time t.

    y_data_profiles = []                                             #To store the y-data of the different line profiles 
    legend = []                                                      #To store the names of the trces for the legened
    graph_tags = {"dataset": cg_data.name(), "mesh": mesh_name, "scenario": scenario.name, "result": res_name}

    for Start_point,End_point in zip(ListOfStart_points,ListOfEnd_points):

        x_data , y_data = cg_data.line_variation(step=step, mesh=mesh_name, 
            point_start=iota.Vector3d(Start_point), point_end=iota.Vector3d(End_point), num_points = Npoints, 
                result=res_name, analysis=res_analysis, component=res_component, x_type='dist')  #Get line profile data

        y_data_profiles.append(y_data[0])
        legend.append('{} to {}'.format(Start_point, End_point))          #Append name of the trace for the graph legend]

    graph = scenario.add_graph(name=Name_graph, title=Title_graph, xdata=x_data, ydata=y_data_profiles, 
        xtitle=xtitle, ytitle=ytitle, legend=legend,tags=graph_tags)       #Save the graph data to database (including raw data to csv file)

    graph.export_html(graph_file)                                        #Export the graph into html format
PreviousGetting the Profile of Result along a LineNextIntegrating a Result over a Mesh

Last updated 5 years ago

Was this helpful?