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…')
 
Line 20: Line 20:
 
* Use '''FOR''' loop in '''ASCEND'''
 
* Use '''FOR''' loop in '''ASCEND'''
 
* Use '''Arrays''' in '''MODEL'''
 
* Use '''Arrays''' in '''MODEL'''
* Plot Graphs
+
* Plot Graphs using '''ASCEND'''
  
  
Line 44: Line 44:
  
  
For relevant tutorials, please visit our website
+
For relevant tutorials, please visit our website http://spoken-tutorial.org
 
+
[http://spoken-tutorial.org/ http://spoken-tutorial.org]
+
  
 
|-
 
|-
Line 52: Line 50:
  
 
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;"| Let's look at the problem statement.
 +
 
 +
 
 +
Suppose we want to study the variation in '''mass''' of a '''thin walled cylindrical vessel''' with respect to its '''H to D ratio'''
 +
 
 +
where '''H''' denotes the height and '''D''' denotes the diameter of the '''vessel'''.
  
 
The equations describing our system is:
 
The equations describing our system is:

Revision as of 16:00, 11 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
  • Use Arrays in MODEL
  • Plot Graphs using ASCEND


Slide number 3

System Requirement

Here I am using

Ubuntu Linux OS v. 12.04

ASCEND v. 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


For relevant tutorials, please visit our website http://spoken-tutorial.org

Slide number 5

Problem Statement

Let's look at the problem statement.


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

where H denotes the height and D denotes the diameter of the vessel.

The equations describing our system is:

metal mass = metal density * wall vol

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 in the second model.


To know more on writing reusable models refer to previous 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 to use 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 to store the required values.
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 and not in our MODEL.
Open up ASCEND interface.Load the program and run it. Before moving any further, let's run our program and see how it stores the values in arrays.
Point to the type 'array' displayed on interface As you can see, ASCEND clearly indicates that H_to_D_ratio, metal_mass and v are arrays.
Click on 'H_to_D_ratio' arrow To see 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 parameters passed to array v, we click on the arrow next to it.
Source code in Text editor Now, let's learn how to plot a graph between the values stored in the two arrays.
Highlight REQUIRE "plot.a4l” Firstly, we need to include plot.a4l library in our model to use the plot function.
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.
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 and
  2. 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.


And the two arraysmetal_mass & H_to_D_ratio gives the y 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.



Right-click on massVSratio and choose the plot option We simply need to click on the mass vs ratio and choose the plot option.
Maximise the plot window This gives us the required plot, with the title and the labels that we 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 title line from our source code.
Open up ASCEND interface.Load the program and run it. We will re-compile the program.
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. Let’s summarize.
Click to bring up the bullets In this tutorial, we have learnt to
  • Use FOR loop in ASCEND
  • Use Arrays in MODEL
  • Plot Graphs
  • using a sample program


Slide Number 7

Assignment

As an assignment, change the size of array to 40 and re-attempt this problem.
Slide Number 8

About slide

Watch the video available at

http://spoken-tutorial.org/What_is_a_Spoken_Tutorial

It summarises the Spoken Tutorial project

If you do not have good bandwidth, you can download and watch it

Slide number 9

About slide

The Spoken Tutorial Project Team:

Conducts workshops using spoken tutorials

Gives certificates to those who pass an online test

For more details, please write to

contact@spoken-tutorial.org



Slide number 10

Acknowledgment

Spoken Tutorial Project is a part of the Talk to a Teacher project

It is supported by the National Mission on Education through ICT, MHRD, Government of India

More information on this Mission is available at[1]http://spoken-tutorial.org/NMEICT-Intro



Slide number 11

Thank you slide

This is Tarun Gangwar from IIT Bombay signing off. Thank you for joining.

Contributors and Content Editors

Nancyvarkey, Tarung