Difference between revisions of "ASCEND/C2/Iterative-calculations-and-Plotting-Graphs/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with ''''Tutorial 6: Iteration & Graph Plotting''' {| style="border-spacing:0;" | style="border:0.75pt solid #000001;padding:0.0104in;"| <center>'''Visual Cue'''</center> | style="bo…')
 
 
(2 intermediate revisions by the same user not shown)
Line 16: Line 16:
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| In this tutorial,
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| In this tutorial,
  
We will learn how to
+
We will learn  
  
* Use '''FOR''' loop in '''ASCEND'''
+
* how to use '''FOR''' loop in '''ASCEND'''
* Use '''Arrays''' in '''MODEL'''
+
* how to use '''Arrays''' in our '''MODEL'''
* Plot Graphs
+
* and how to plot Graphs using '''ASCEND'''
  
  
Line 30: Line 30:
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Here I am using
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Here I am using
  
'''Ubuntu Linux OS v. 12.04'''
+
'''Ubuntu Linux OS version 12.04'''
  
'''ASCEND v. 0.9.8'''
+
'''ASCEND version 0.9.8'''
  
 
|-
 
|-
Line 43: Line 43:
 
To know more about '''ASCEND,''' please visit '''ascend4.org'''
 
To know more about '''ASCEND,''' please visit '''ascend4.org'''
  
 
For relevant tutorials, please visit our website
 
 
[http://spoken-tutorial.org/ http://spoken-tutorial.org]
 
  
 
|-
 
|-
Line 52: Line 48:
  
 
Problem Statement
 
Problem Statement
| style="border:0.75pt solid #000001;padding:0.0104in;"| Suppose we want to study the variation in '''mass''' of a '''thin walled cylindrical vessel''' with respect to its '''H to D ratio.'''
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| This is the problem statement for this tutorial.
 +
 
 +
 
 +
Suppose we want to study the variation in '''mass''' of a '''thin walled cylindrical vessel''' with respect to its '''Height to Diameter ratio'''
 +
 
 +
i.e. '''H''' to '''D''' ratio.
  
The equations describing our system is:
+
The equation describing our system is the mass of the metal:
  
'''metal mass = metal density * wall vol'''
+
'''metal mass = density of the metal into volume of the wall'''
  
 
|-
 
|-
Line 66: Line 67:
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| We have two '''models''' in our file.
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| We have two '''models''' in our file.
  
The first model defines '''parameters''' that will be passed in the second model.
+
The first '''model''' defines  parameters that will be passed into second model.
  
  
To know more on writing reusable '''models''' refer to previous lectures in this series.
+
To know more on writing reusable '''models''' refer to other lectures in this series.
  
 
|-
 
|-
Line 80: Line 81:
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Zoom in on the second MODEL vesselplot.
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Zoom in on the second MODEL vesselplot.
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now we write our second '''MODEL''' '''vesselplot''' to use previously defined '''parameters'''.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now we write our second '''MODEL vesselplot'''.  This '''model''' uses the previously defined '''parameters'''.
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the declaration of n_entries
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the declaration of n_entries
| style="border:0.75pt solid #000001;padding:0.0104in;"| We define the total number of '''data points''' that we want, by defining '''variable''' '''n_entries'''
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| We define the total number of '''data points''' that we want, by defining '''variable n_entries'''
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the declaration of H_to_D_ratio and metal_mass
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the declaration of H_to_D_ratio and metal_mass
| style="border:0.75pt solid #000001;padding:0.0104in;"| Therafter, we declare two '''arrays H_to_D_ratio''' and '''metal_mass''' to store the required values.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Therafter, we declare two '''arrays H_to_D_ratio''' and '''metal_mass'''.
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the FOR loop
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the FOR loop
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now,we start a '''FOR''' loop, using which we pass the '''parameters''' of previous model in a new''' array v'''.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now,we start a '''FOR''' loop, using which, we pass the '''parameters''' of previous '''model''' in a new''' array v'''.
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the FOR loop in METHOD values
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the FOR loop in METHOD values
| style="border:0.75pt solid #000001;padding:0.0104in;"| Note that,we assign values to the previously defined '''array H_to_D_ratio '''under '''METHOD''' values and not in our '''MODEL'''.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Note that,we assign values to the previously defined '''array H_to_D_ratio '''under '''METHOD values'''.
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Open up ASCEND interface.Load the program and run it.
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Open up ASCEND interface.Load the program and run it.
| style="border:0.75pt solid #000001;padding:0.0104in;"| Before moving any further, let's run our program and see how it stores the values in '''arrays'''.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Before moving any further, let us load the '''ASCEND''' interface and then run our program.
 +
 
 +
|-
 +
| style="border:0.75pt solid #000001;padding:0.0104in;"| On the ASCEND interface.
 +
| style="border:0.75pt solid #000001;padding:0.0104in;"| Let me open our file which is of the name '''vesselplot'''
 +
 
 +
Let me load the '''model.'''
 +
 
 +
|-
 +
| style="border:0.75pt solid #000001;padding:0.0104in;"| On the ASCEND interface.
 +
| style="border:0.75pt solid #000001;padding:0.0104in;"| Let me run the '''values METHOD''' and solve it.  
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Point to the type 'array' displayed on interface
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Point to the type 'array' displayed on interface
| style="border:0.75pt solid #000001;padding:0.0104in;"| As you can see, '''ASCEND''' clearly indicates that '''H_to_D_ratio, metal_mass '''and '''v''' are '''arrays'''.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| As you can see, '''ASCEND''' clearly indicates that '''H_to_D_ratio''' and '''metal_mass ''' are of the type '''arrays'''.
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Click on 'H_to_D_ratio' arrow
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Click on 'H_to_D_ratio' arrow
| style="border:0.75pt solid #000001;padding:0.0104in;"| To see different values stored in the '''array''', we just click on the drop down menu.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| To see the different values stored in the '''array''', we just click on the drop down menu.
 +
 
 +
 
 +
This shows all the values stored in the array '''H to D ratio'''.
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Click on 'v' arrow
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Click on 'v' arrow
| style="border:0.75pt solid #000001;padding:0.0104in;"| Also, to see the values of the parameters passed to '''array v''', we click on the arrow next to it.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Also, to see the values of the various parameters passed to '''array v''', we first click on the arrow next to it.
 +
 
 +
 
 +
Then we can click on the arrow next to any of these numbers to see the required values.
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Source code in Text editor
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Source code in Text editor
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now, let's learn how to plot a graph between the values stored in the two '''arrays.'''
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now, let's see how to plot graphs using '''ASCEND'''.
 +
 
 +
 
 +
 
 +
Let me minimize this window and open the source code.
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight REQUIRE "plot.a4l”
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight REQUIRE "plot.a4l”
| style="border:0.75pt solid #000001;padding:0.0104in;"| Firstly, we need to include '''plot.a4l''' '''library''' in our '''model''' to use the '''plot function.'''
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Firstly, we need to include a new library in our '''MODEL''''. 
 +
 
 +
The name of the library is '''plot.a4l'''
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight massVSratio IS_A plt_plot_symbol
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight massVSratio IS_A plt_plot_symbol
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| To plot a graph in '''ASCEND''', we need to declare a '''variable''' of the type''' plt_plot_symbol'''.
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| 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.
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight (CurveSet, Curves)
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight (CurveSet, Curves)
| style="border:0.75pt solid #000001;padding:0.0104in;"| This declaration requires two '''parameters''' namely '''Curveset''' and '''Curves'''.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| This declaration requires two '''parameters''' namely, '''Curveset''' and '''Curves'''.
  
 
|-
 
|-
Line 144: Line 169:
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| The second parameter '''Curves''' requires 3 '''parameters-'''
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| The second parameter '''Curves''' requires 3 '''parameters-'''
  
# a set of '''integers''' and
+
# a set of '''integers'''  
# two lists of data giving the '''y-values''' and the '''x-values''' for the curve.
+
# two lists of data giving the '''y-values''' and  
 +
# the '''x-values''' for the curve.
  
In our case, this set of '''integers''' is from 1to 20.
+
In our case, this set of '''integers''' is from 1 to 20.
  
  
And the '''two arrays''' – '''metal_mass '''& '''H_to_D_ratio''' gives the '''y''' and '''x values''' respectiveley.
+
And the two '''arrays''' – '''metal_mass '''& '''H_to_D_ratio''' gives the '''y values''' and '''x values''' respectiveley.
  
 
|-
 
|-
Line 167: Line 193:
  
  
 
+
Let us go back to the '''ASCEND''' interface.
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Right-click on massVSratio and choose the plot option
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Right-click on massVSratio and choose the plot option
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| We simply need to click on the '''mass vs ratio''' and choose the '''plot''' option.
+
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Let us go to the variable '''mass vs ratio'''
 +
 
 +
 
 +
Right-click on it and select the option '''plot'''.
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Maximise the plot window
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Maximise the plot window
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| This gives us the required plot, with the title and the labels that we mentioned in the code.
+
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| This gives us the required plot, with the title and the labels that we had mentioned in the code.
  
 
|-
 
|-
Line 183: Line 212:
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Remove the massVSratio.tittle line from the source code and save it.
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Remove the massVSratio.tittle line from the source code and save it.
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| We remove the '''title line''' from our source code.
+
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| We remove the line that defines the '''title '''for our plot.
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Open up ASCEND interface.Load the program and run it.
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Open up ASCEND interface.Load the program and run it.
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| We will re-compile the program.
+
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Let me save the file and reload it in the '''ASCEND''' interface.
 +
 
 +
Let me again solve it and plot the graph again.
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Maximise the plot window
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Maximise the plot window
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| We can clearly see that '''ASCEND''' titles the plot as ''''undefined''''.
+
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| We can clearly see that '''ASCEND''' titles the plot as ''''Undefined''''.
  
 
|-
 
|-
Line 197: Line 228:
  
 
Summary
 
Summary
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| This brings us to the end of this tutorial. Let’s summarize.
+
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| This brings us to the end of this tutorial.  
  
 
|-
 
|-
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Click to bring up the bullets
 
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| Click to bring up the bullets
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| In this tutorial, we have learnt to
+
| style="border-top:none;border-bottom:0.75pt solid #000001;border-left:0.75pt solid #000001;border-right:0.75pt solid #000001;padding:0.0104in;"| In this tutorial, we have learnt  
 
+
* Use '''FOR''' loop in '''ASCEND'''
+
* Use '''Arrays''' in '''MODEL'''
+
* Plot Graphs
+
* using a sample program
+
 
+
  
 +
* How to use '''FOR''' loop in '''ASCEND'''
 +
* How to use '''Arrays''' in our '''MODEL'''
 +
* How to plot Graphs in '''ASCEND'''
  
 
|-
 
|-
Line 214: Line 242:
  
 
Assignment
 
Assignment
| style="border:0.75pt solid #000001;padding:0.0104in;"| As an assignment, change the size of array to 40 and re-attempt this problem.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| As an assignment to this tutorial, change the size of array to 40.
 +
 
 +
 
 +
And re-attempt this problem covered in this tutorial.
  
 
|-
 
|-
Line 220: Line 251:
  
 
About slide
 
About slide
| style="border:0.75pt solid #000001;padding:0.0104in;"| Watch the video available at
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Information on the Spoken Tutorial project is available on the Internet.
 
+
[http://spoken-tutorial.org/What_is_a_Spoken_Tutorial http][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial ://][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial spoken][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial -][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial tutorial][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial .][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial org][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial /][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial What][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial is][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial a][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial Spoken][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial _][http://spoken-tutorial.org/What_is_a_Spoken_Tutorial Tutorial]
+
 
+
It summarises the Spoken Tutorial project
+
 
+
If you do not have good bandwidth, you can download and watch it
+
  
 
|-
 
|-
Line 232: Line 257:
  
 
About slide
 
About slide
| style="border:0.75pt solid #000001;padding:0.0104in;"| The Spoken Tutorial Project Team:
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Workshops based on Spoken Tutorials are also available.
 
+
Conducts workshops using spoken tutorials
+
 
+
Gives certificates to those who pass an online test
+
 
+
For more details, please write to
+
 
+
contact@spoken-tutorial.org
+
 
+
 
+
 
+
  
 
|-
 
|-
Line 249: Line 263:
  
 
Acknowledgment
 
Acknowledgment
| style="border:0.75pt solid #000001;padding:0.0104in;"| Spoken Tutorial Project is a part of the Talk to a Teacher project
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Spoken Tutorial Project is funded by the NMEICT, MHRD.
 
+
It is supported by the National Mission on Education through ICT, MHRD, Government of India
+
 
+
More information on this Mission is available at[http://spoken-tutorial.org/NMEICT-Intro  ][http://spoken-tutorial.org/NMEICT-Intro http][http://spoken-tutorial.org/NMEICT-Intro ://][http://spoken-tutorial.org/NMEICT-Intro spoken][http://spoken-tutorial.org/NMEICT-Intro -][http://spoken-tutorial.org/NMEICT-Intro tutorial][http://spoken-tutorial.org/NMEICT-Intro .][http://spoken-tutorial.org/NMEICT-Intro org][http://spoken-tutorial.org/NMEICT-Intro /][http://spoken-tutorial.org/NMEICT-Intro NMEICT][http://spoken-tutorial.org/NMEICT-Intro -][http://spoken-tutorial.org/NMEICT-Intro Intro]
+
 
+
 
+
 
+
  
 
|-
 
|-
Line 262: Line 269:
  
 
Thank you slide
 
Thank you slide
| style="border:0.75pt solid #000001;padding:0.0104in;"| This is Tarun Gangwar from IIT Bombay signing off. Thank you for joining.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| This is Tarun Gangwar from IIT Bombay signing off. Thank you.
  
 
|}
 
|}

Latest revision as of 11:51, 19 August 2014

Tutorial 6: Iteration & Graph Plotting


Visual Cue
Narration
Slide number 1

Title slide

Welcome to the tutorial on Iteration & Graph Plotting in ASCEND
Show Slide 2 In this tutorial,

We will learn

  • how to use FOR loop in ASCEND
  • how to use Arrays in our MODEL
  • and how to plot Graphs using ASCEND


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.


To know more about ASCEND, please visit ascend4.org


Slide number 5

Problem Statement

This is the problem statement for this tutorial.


Suppose we want to study the variation in mass of a thin walled cylindrical vessel with respect to its Height to Diameter ratio

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.


To know more on writing reusable models refer to other lectures in this series.

Zoom out and show the entire MODEL vessel After defining the parameters, we define the required variables and equations.


Then we write METHODs to solve them.

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.


This shows all the values stored in the array H to D ratio.

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.


Then we can click on the arrow next to any of these numbers to see the required values.

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-
  1. a set of integers
  2. two lists of data giving the y-values and
  3. the x-values for the curve.

In our case, this set of integers is from 1 to 20.


And the two arraysmetal_mass & H_to_D_ratio gives the y values and x values respectiveley.

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.


Let us go back to the ASCEND interface.

Right-click on massVSratio and choose the plot option Let us go to the variable mass vs ratio.


Right-click on it and select the option plot.

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
  • How to use FOR loop in ASCEND
  • How to use Arrays in our MODEL
  • How to plot Graphs in ASCEND
Slide Number 7

Assignment

As an assignment to this tutorial, change the size of array to 40.


And re-attempt this problem covered in this tutorial.

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.

Contributors and Content Editors

Nancyvarkey, Tarung