ASCEND/C2/Writing-basic-model/English
Tutorial 3: Developing a Basic model in ASCEND
|
|
Open Slide number 1
Title slide |
Welcome to the spoken tutorial on Developing a Basic Model in ASCEND |
Open Slide 2
Learning Objectives |
In this tutorial,
We will learn how to
|
Open Slide number 3
System Requirement |
Here I am using
|
Open Slide number 4
Pre-requisites |
To know more about ASCEND
Please visit ascend4.org For relevant tutorials please visit our website |
Open Slide number 5
Example |
Let us begin the tutorial with a simple example.
In this example, let us solve 3 simultaneous equations with 3 unknowns. We will use a text editor like gedit to write our model |
I already have the code for the example in a text file
Let me explain the code | |
Open mymodel.a4c in gedit | Open the file mymodel.a4c in a text editor |
Highlight the “system.a4l” line | Initially we mention the library (that is a collection of pre-defined models that we need in our model).
|
Highlight the “system.a4l” line | .a4l extension denotes the ascend4 library
|
Highlight the semi colon | Note that semi colon is a statement terminator in ASCEND.
ASCEND considers
|
Highlight MODEL my_model | MODEL my_model begins a model with name my_model
You can give any name to the model |
Highlight (*variables declaration*) | In ASCEND comments are written in parenthesis enclosed with in a pair of asterik mark.
|
Highlight solver_var | Any variable whose value is expected to be computed by ASCEND, must be of type solver underscore var |
Highlight all the defined variables | Thus we define variable x,y,z,d and a as a solver_var
The definition of the type solver_var is predefined in the system.a4l library IS underscore A is an operator in ASCEND which is used to define variable types. |
Highlight all the equation sequentially | The equations to be solved are
x+y+z = a*d x+y+2*z = 5 and 5*x+2*y-3*z = 0 |
Highlight continues | Note that we have not mentioned how to solve this given set of equations.
We have also not mentioned which variables are to be specified and which are to be calculated. |
Highlight END my_model | Now end this model with END my_model |
Show the loaded model on ASCEND interface | Now open this model in ASCEND. |
Highlight the successful execution line in the message panel | Note that ASCEND has executed the on_load method by default.
|
Highlight the values of the variables on ASCEND interface | Observe that ASCEND has given default values of 0.5 to each of the variables. |
Click the solve button | Now click on the Solve icon.
ASCEND displays the result. |
Highlight the converged message in the panel below | This can be confirmed in the panel below.
|
Highlight the values of the variables y and d | Note that ASCEND
|
Right click on d and assign it a value 1.
Fix d by selecting the fixed option. Repeat the same for x. |
Now suppose we want to
Then, right-click on d and select Properties from the drop down menu. Under Values, assign a value to d Here I am giving the value 1. Now in Solving section, select Fixed. Click on Apply and OK. Now similarly repeat the same procedure for fixing the value of x |
Highlight the corresponding results | Observe that ASCEND has solved the model and you will have a new set of results.
|
Open my_model in gedit | We will now explain different methods to solve our model.
|
Delete END my_model and remove asterik from METHODS and end of the code | Now remove the line END my_model.
|
Highlight the corresponding lines in the code sequentially | Under METHOD specify, we fixed variables a and d.
|
Note that to assign the values to a particular variable, we use a colon and = sign together.
| |
Highlight the corresponding lines in the code sequentially | Under METHOD on_load, we run the METHOD specify.
This is the method that describes ASCEND the action to be taken when a model is loaded. |
Click on the save button | Now end the METHOD on_load and my_model and save this file. |
Show the ascend interface | Now open this with ASCEND. |
Select the on_load method and run the code | Now under Methods select on_load
Click on Run. |
Click on the solve button and highlight the asnwers | And then click on Solve icon.
|
Open the code file again in gedit | Now open the code for my_model.a4c again. |
Carry out the required editing in the code file | Now remove the values assigned under specify. |
Type as per narration | Now we will add a new METHOD called values.
|
Type as per narration | Now under on_load type RUN values after RUN specify. |
Open the file with ascend | Now save the file and open it with ASCEND. |
Run the code using on_load method and press solve | Again run the Method on_load and click on Solve.
|
Open the required code file in gedit | Now let’s look at an interesting feature of dimensional consistency in ASCEND with the help of another model.
|
Type as per narration | I already have the code for this model.
Let me explain the code. Open cylinder.a4c with a text editor. |
Highlight the corresponding line in a sequential order | Note that, *here we require atoms.a4l library
|
Highlight continues |
|
Highlight the corresponding line in a sequential order | For example, we write
Volume, mass etc. are different variable types defined in atoms.a4l This helps in ensuring that the equations written in ASCEND models are dimensionally consistent. |
Scroll down the code | After this we write equations and methods as explained earlier.
|
Highlight the corresponding line in a sequential order | Note that, while specifying values for these variable types, we need to mention the corresponding physical units in curly brackets..
|
Open the file in ASCEND and run and solve it using the on_load method | Now open this file in ASCEND.
Now once again run the on_load Method and solve the problem. |
Highlight the answers | Observe that ASCEND has converted the values of volume into SI units and then calculated the mass in SI units
|
Open Slide number 5:
Summary |
Now let us summarize.
In this tutorial, We have learnt how to
|
Open Slide number 6:
Assignment |
Do the following assignment
|
Open Slide number 7
About the Spoken Tutorial Project |
Information on the spoken tutorial project is available on our website
spoken-tutorial.org |
Open Slide number 8
Spoken Tutorial Workshops |
Details on Workshops based on spoken tutorials is also available on the website |
Open Slide number 9
Acknowledgements |
Spoken tutorial project is funded by NMEICT,MHRD
|
Open Slide number 10
Thank You |
This is Priya Bagde from IIT Bombay signing off
Thank You for joining |