ASCEND/C2/Iterative-calculations-and-Plotting-Graphs/English
Tutorial 6: Iteration & Graph Plotting
|
|
Slide number 1
Title slide |
Welcome to the tutorial on Iteration & Graph Plotting in ASCEND |
Show Slide 2 | In this tutorial,
We will learn
|
Slide number 3
System Requirement |
Here I am using
Ubuntu Linux OS version 12.04 ASCEND version 0.9.8 |
Slide number 4
Pre-requisites |
To follow this tutorial, user must have basic knowledge of Linux and ASCEND.
|
Slide number 5
Problem Statement |
This is the problem statement for this tutorial.
i.e. H to D ratio. The equation describing our system is the mass of the metal: metal mass = density of the metal into volume of the wall |
Source Code in Text Editor | Let's look at the source code for this problem. |
Zoom in on the MODEL vessel and paremeters part of the code. | We have two models in our file.
The first model defines parameters that will be passed into second model.
|
Zoom out and show the entire MODEL vessel | After defining the parameters, we define the required variables and equations.
|
Zoom in on the second MODEL vesselplot. | Now we write our second MODEL vesselplot. This model uses the previously defined parameters. |
Highlight the declaration of n_entries | We define the total number of data points that we want, by defining variable n_entries |
Highlight the declaration of H_to_D_ratio and metal_mass | Therafter, we declare two arrays H_to_D_ratio and metal_mass. |
Highlight the FOR loop | Now,we start a FOR loop, using which, we pass the parameters of previous model in a new array v. |
Highlight the FOR loop in METHOD values | Note that,we assign values to the previously defined array H_to_D_ratio under METHOD values. |
Open up ASCEND interface.Load the program and run it. | Before moving any further, let us load the ASCEND interface and then run our program. |
On the ASCEND interface. | Let me open our file which is of the name vesselplot.
Let me load the model. |
On the ASCEND interface. | Let me run the values METHOD and solve it. |
Point to the type 'array' displayed on interface | As you can see, ASCEND clearly indicates that H_to_D_ratio and metal_mass are of the type arrays. |
Click on 'H_to_D_ratio' arrow | To see the different values stored in the array, we just click on the drop down menu.
|
Click on 'v' arrow | Also, to see the values of the various parameters passed to array v, we first click on the arrow next to it.
|
Source code in Text editor | Now, let's see how to plot graphs using ASCEND.
Let me minimize this window and open the source code. |
Highlight REQUIRE "plot.a4l” | Firstly, we need to include a new library in our MODEL'.
The name of the library is plot.a4l |
Highlight massVSratio IS_A plt_plot_symbol | To plot a graph in ASCEND, we need to declare a variable of the type plt_plot_symbol.
Here we define mass v/s ratio as a variable of this type. |
Highlight (CurveSet, Curves) | This declaration requires two parameters namely, Curveset and Curves. |
Highlight the following lines:
CurveSet IS_A set OF symbol_constant; CurveSet :== ['test']; |
Curveset allows us to tag and identify each of the curves we plot. |
Highlight the following lines:
Curves['test'] IS_A plt_curve([1..n_entries], metal_mass,H_to_D_ratio) |
The second parameter Curves requires 3 parameters-
In our case, this set of integers is from 1 to 20.
|
Highlight the following lines:
massVSratio.title :='Metal mass of the walls vs H to D ratio for a thin-walled cylindrical vessel'; massVSratio.XLabel := 'H to D ratio'; massVSratio.YLabel := 'metal mass IN kg/m^3 |
We give title and label for our plot under the METHODS section. |
Open up ASCEND interface.Load the program and run it. | Let us now see how to get the required plot.
|
Right-click on massVSratio and choose the plot option | Let us go to the variable mass vs ratio.
|
Maximise the plot window | This gives us the required plot, with the title and the labels that we had mentioned in the code. |
Source code in Text editor | Let us now see what happens if we don't mention the plot title. |
Remove the massVSratio.tittle line from the source code and save it. | We remove the line that defines the title for our plot. |
Open up ASCEND interface.Load the program and run it. | Let me save the file and reload it in the ASCEND interface.
Let me again solve it and plot the graph again. |
Maximise the plot window | We can clearly see that ASCEND titles the plot as 'Undefined'. |
Slide number 6
Summary |
This brings us to the end of this tutorial. |
Click to bring up the bullets | In this tutorial, we have learnt
|
Slide Number 7
Assignment |
As an assignment to this tutorial, change the size of array to 40.
|
Slide Number 8
About slide |
Information on the Spoken Tutorial project is available on the Internet. |
Slide number 9
About slide |
Workshops based on Spoken Tutorials are also available. |
Slide number 10
Acknowledgment |
Spoken Tutorial Project is funded by the NMEICT, MHRD. |
Slide number 11
Thank you slide |
This is Tarun Gangwar from IIT Bombay signing off. Thank you. |