Difference between revisions of "ASCEND/C2/Solving-Cubic-EOS/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with ''''Tutorial 4: Cubic EOS: Peng Robinson''' {| style="border-spacing:0;" | style="border:0.75pt solid #000001;padding:0.0104in;"| <center>'''Visual Cue'''</center> | style="bord…')
 
Line 18: Line 18:
 
We will learn how to
 
We will learn how to
  
* create a reusable model
+
* Create a reusable model
* reuse the model for different components
+
* Reuse the '''model '''for different components
* import data from the Thermodynamics library
+
* Import data from the '''Thermodynamics library'''
  
* solve the model
+
* Solve the '''model'''
  
  
Line 45: Line 45:
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| To follow this tutorial, user must have basic knowledge of
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| To follow this tutorial, user must have basic knowledge of
  
Linux
+
'''Linux'''
  
ASCEND and
+
'''ASCEND''' and
  
Peng Robinson cubic EOS
+
'''Peng Robinson cubic EOS'''
  
 
|-
 
|-
Line 55: Line 55:
  
 
Pre-requisites
 
Pre-requisites
| 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;"| To know more about ASCEND please visit ascend4.org
+
| 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;"| To know more about ASCEND please visit '''ascend4.org'''
  
 
For relevant tutorials please visit our website
 
For relevant tutorials please visit our website
Line 65: Line 65:
  
 
Peng Robinson Cubic EOS
 
Peng Robinson Cubic EOS
| style="border:0.75pt solid #000001;padding:0.0104in;"| Let’s write a general model to solve Peng Robinson cubic equation of state. Peng Robinson equation of state is a cubic equation of state which contains volume terms to the third power. It is usually expressed to give pressure in terms of temperature and molar volume. These are the equation for PR EOS
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Let’s write a general model to solve '''Peng Robinson cubic equation of state'''.  
 +
 
 +
'''Peng Robinson equation''' '''of state''' is a '''cubic equation of state''' which contains volume terms to the third power.
 +
 
 +
It is usually expressed to give pressure in terms of temperature and molar volume. These are the equation for '''Peng Robinson equation of state '''
  
 
|-
 
|-
Line 71: Line 75:
  
 
Peng Robinson Cubic EOS
 
Peng Robinson Cubic EOS
| 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;"| It is sometime more convenient to express the polynomial in terms of the compressibility factor Z
+
| 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;"| It is sometime more convenient to express the polynomial in terms of the '''compressibility factor Z'''
  
These are the equations which we will be using in our model to compute the value of Z
+
These are the equations which we will be using in our model to compute the value of '''Z'''
  
 
|-
 
|-
| style="border:0.75pt solid #000001;padding:0.0104in;"| Open the code file in gedit
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Open the code file in '''gedit'''
| style="border:0.75pt solid #000001;padding:0.0104in;"| Let's now look at the code for Peng Robinson model.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Let's now look at the code for '''Peng Robinson model'''.
  
I already have the code for Peng Robinson model in a text file.
+
I already have the code for''' Peng Robinson model''' in a text file.
  
Open the file Peng Robinson.a4c in a text editor
+
Open the file '''Peng Robinson.a4c''' in a text editor
  
 
Let me explain the code.
 
Let me explain the code.
Line 87: Line 91:
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight REQUIRE "thermodynamics.a4l";
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight REQUIRE "thermodynamics.a4l";
| style="border:0.75pt solid #000001;padding:0.0104in;"| For solving this model, we require data from the thermodynamics library. So, add ‘REQUIRE “thermodynamics.a4l”.  
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| For solving this model, we require data from the '''thermodynamics library.'''
 +
 
 +
So, add '''REQUIRE “thermodynamics.a4l'''”.  
  
  
Line 94: Line 100:
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the lines sequentially
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the lines sequentially
| style="border:0.75pt solid #000001;padding:0.0104in;"| I have named this model as pengrobinson.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| I have named this '''model''' as '''pengrobinson'''.
  
After this define variables like P, T, V etc. using WILL_BE operator.
+
After this define variables like '''P, T, V''' etc. using '''WILL_BE '''operator.
  
WILL_BE operator is used to make our model reusable
+
'''WILL_BE''' operator is used to make our '''model''' reusable
  
The variables defined using WILL_BE are used as parameters in our test model
+
The variables defined using '''WILL_BE''' are used as parameters in our '''test model'''
  
I will come back to the explanation of WILL_BE as we move ahead in our tutorial
+
I will come back to the explanation of '''WILL_BE''' as we move ahead in our tutorial
  
 
|-
 
|-
Line 118: Line 124:
  
 
PSI, OMEGA, sigma, eps IS_A real_constant;
 
PSI, OMEGA, sigma, eps IS_A real_constant;
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now we Define rest of the variables accordingly. Like, R IS_A molar gas constant, Pc IS_A pressure and so on
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now we Define rest of the variables accordingly. Like, '''R IS_A molar gas constant, Pc IS_A pressure''' and so on
  
Note that factor denotes a dimensionless variable, Thus alpha, beta, q etc. are defined as factors
+
Note that '''factor '''denotes a dimensionless variable, Thus '''alpha, beta, q '''etc. are defined as '''factor'''
  
 
|-
 
|-
Line 132: Line 138:
  
 
eps :== 0.414213562;
 
eps :== 0.414213562;
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now we mention the values of all the constants used in PR Cubic EOS.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now we mention the values of all the constants used in '''Peng Robinson equation''' '''of state''' .
  
 
Please note that the values of these constants will be reused in our test model.
 
Please note that the values of these constants will be reused in our test model.
Line 152: Line 158:
  
 
T_degC = T/1{K} - 273.15;
 
T_degC = T/1{K} - 273.15;
| style="border:0.75pt solid #000001;padding:0.0104in;"| We take the critical temperature, critical pressure and omega data from the thermodynamics library.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| We take the critical temperature, critical pressure and omega data from the '''thermodynamics library'''.
  
 
And so we write
 
And so we write
  
Pc=data.Pc and so on.
+
'''Pc=data.Pc''' and so on.
  
Now we define the reduced temperature and pressure in terms of Tc and Pc.
+
Now we define the reduced temperature and pressure in terms of '''Tc '''and '''Pc'''.
  
Now we mention the PR Equation as shown in the previous slide
+
Now we mention the '''Peng Robinson equation''' as shown in the previous slide
  
Note that labels like eq 4, eq 5 etc. are not compulsory to write but they help in debugging the problem
+
Note that labels like '''eq 4, eq 5''' etc. are not compulsory to write but they help in debugging the problem
  
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the METHODS syntax sequentially
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the METHODS syntax sequentially
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now let’s define methods to solve this model.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| Now let’s define '''methods''' to solve this '''model'''.
 +
 
 +
We use the '''method default''' to solve this '''model''' and run the '''METHODS specify '''and''' values''' under it.
  
We use the method default to solve this model and run the METHODS specify and values under it.
+
Under '''specify''' we fix the variables by writing , '''P.fixed := TRUE'''<nowiki>;and </nowiki>'''T.fixed := TRUE'''<nowiki>; </nowiki>
  
Under specify we fix the variables by writing , P.fixed := TRUE;and T.fixed := TRUE; Note that True implies fixed variable whereas all other variables that are not mentioned here are y default set to False, i.e. Free variables
+
Note that '''True''' implies '''fixed''' variable whereas all other variables that are not mentioned here are by default set to '''False''', i.e. '''Free''' variables
  
 
Now under values, we define values to the fixed variables
 
Now under values, we define values to the fixed variables
  
For Z, we set the upper and lower bound and also provide a nominal value to initiate the solution.
+
For '''Z''', we set the '''upper and lower bound''' and also provide a '''nominal '''value to initiate the solution.
  
 
The syntax used is
 
The syntax used is
  
Z.lower_bound := 0.0;
+
'''Z.lower_bound := 0.0'''<nowiki>;</nowiki>
  
Z.nominal := 0.1;
+
'''Z.nominal := 0.1'''<nowiki>;</nowiki>
  
Now we end Peng Robinson model
+
Now we end '''Peng Robinson model'''
  
Parameters defined in this model, can now be reused by any model to calculate Z for specific components
+
Parameters defined in this model, can now be reused by any model to calculate '''Z''' for specific components
  
Let's now see how to use these parameters and calculate Z for ethylene in a test model.
+
Let's now see how to use these parameters and calculate '''Z '''for '''ethylene''' in a '''test model'''.
  
Let's now look at the code for test model
+
Let's now look at the code for '''test model'''
  
Note that the test model is written below the Peng Robinson model in the same document
+
Note that the '''test model''' is written below the '''Peng Robinson model '''in the same document
  
we name this model as test
+
We name this model as test
  
We define a symbol constant – c1.
+
We define a symbol constant – '''c1.'''
  
And assign c1 is equal to ethylene.
+
And assign '''c1 '''is equal to '''ethylene'''.
  
We use a colon and equal to sign twice as c1 is passed as a parameter to another variable components_data which is present in thermodynamics library
+
We use a colon and equal to sign twice as c1 is passed as a parameter to another variable '''components_data''' which is present in '''thermodynamics library'''
  
Here we define cd as components_data of ethylene
+
Here we define '''cd '''as '''components_data''' of '''ethylene'''
  
Note that in the parenthesis,c1 in square bracket implies such data for ethylene from thermodynamics library whereas c1 outside square bracket is set as reference component
+
Note that in the parenthesis,'''c1''' in square bracket implies such data for '''ethylene''' from '''thermodynamics library '''whereas '''c1''' outside square bracket is set as reference component
  
 
More on this will be explained in future tutorials
 
More on this will be explained in future tutorials
  
Note that we use WILL_BE to define P,V,Z etc
+
Note that we use '''WILL_BE''' to define '''P,V,Z''' etc
  
To reuse these parameters from previous model we need to define them here using IS_A operator
+
To reuse these parameters from previous model we need to define them here using '''IS_A''' operator
  
 
Thus we define
 
Thus we define
  
P IS_A pressure;
+
'''P IS_A pressure;'''
  
T IS_A temperature and so on;
+
'''T IS_A temperature''' and so on;
  
We define tpeng IS_A pengrobinson
+
We define '''tpeng IS_A pengrobinson'''
  
Now tpeng includes all the equations and methods
+
Now '''tpeng''' includes all the equations and methods
  
defined in the peng roinson model
+
defined in the '''peng robinson model'''
  
we have passed the required parameters to pengrobinson model in parenthesis,so we don't have to write the variables and the equations again
+
We have passed the required parameters to '''pengrobinson model '''in parenthesis,so we don't have to write the variables and the equations again
  
the values of constants and other variables will be called in the test model from peng robinson model
+
the values of constants and other variables will be called in the '''test model''' from '''peng robinson model'''
  
 
This is how we make our model reusable
 
This is how we make our model reusable
  
we define equations for Tr and Pr as
+
We define equations for Tr and Pr as
  
<nowiki>Tr = T/cd.data[c1].Tc; and similarly for Pr;</nowiki>
+
'''<nowiki>Tr = T/cd.data[c1].Tc</nowiki>'''<nowiki>; and similarly for </nowiki>'''Pr'''<nowiki>;</nowiki>
  
We reuse this model in the test model to find out Z for ethylene.
+
We reuse this model in the '''test model''' to find out '''Z for ethylene.'''
  
  
Line 239: Line 247:
 
|-
 
|-
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Scroll the text file to show the next model
 
| style="border:0.75pt solid #000001;padding:0.0104in;"| Scroll the text file to show the next model
| style="border:0.75pt solid #000001;padding:0.0104in;"| We will now look at the code for testpengrobinson model.
+
| style="border:0.75pt solid #000001;padding:0.0104in;"| We will now look at the code for '''testpengrobinson model'''.
  
I already have the code for testpengrobinson model in a text file.
+
I already have the code for''' testpengrobinson model''' in a text file.
  
 
Let me explain the code.
 
Let me explain the code.
  
We name this model as testpengrobinson.
+
We name this model as '''testpengrobinson'''.
  
We define a symbol constant – c1.
+
We define a symbol constant '''– c1'''.
  
And assign c1 is equal to ethylene.
+
And assign '''c1 is equal to ethylene'''.
  
This c1 is passed as a parameters to another model components_data which is present in one of our ‘REQUIRED’ libraries.
+
This '''c1''' is passed as a parameters to another model '''components_data''' which is present in one of our ‘'''REQUIRED’ libraries'''.
  
Here we define cd as the component data of ethylene.
+
Here we define '''cd''' as the component data of '''ethylene'''.
  
To reuse the parameters from previous model like P, V, Z etc we need to define them here using the IS_A operator
+
To reuse the parameters from previous model like '''P, V, Z''' etc we need to define them here using the '''IS_A '''operator
  
We define tpeng as a pengrobinson.
+
We define''' tpeng''' as a''' pengrobinson'''.
  
Now tpeng includes all the equations and methods defined in pengrobinson model.
+
Now '''tpeng '''includes all the equations and methods defined in '''pengrobinson model'''.
  
We have passed the required parameters to pengrobinson
+
We have passed the required parameters to '''pengrobinson'''
  
 
So we do not have to write the equations and variables again.
 
So we do not have to write the equations and variables again.
Line 267: Line 275:
 
This is how we make our model reusable.
 
This is how we make our model reusable.
  
We define equations for Tr and Pr as :
+
We define equations for '''Tr '''and '''Pr''' as :
  
<nowiki>Tr = T/cd.data[c1].Tc;</nowiki>
+
'''<nowiki>Tr = T/cd.data[c1].Tc;</nowiki>'''
  
<nowiki>Pr = P/cd.data[c1].Pc;</nowiki>
+
'''<nowiki>Pr = P/cd.data[c1].Pc;</nowiki>'''
  
<nowiki>cd.dada[c1].Tc imports the value of Tc for ethylene from thermodynamics library.</nowiki>
+
'''<nowiki>cd.dada[c1].Tc</nowiki>''' imports the value of '''Tc''' for '''ethylene''' from '''thermodynamics library'''.
  
In METHODS we define the standard methods again
+
In '''METHODS''' we define the standard methods again
  
But now under METHOD specify we RUN tpeng.specify
+
But now under '''METHOD specify''' we RUN '''tpeng.specify'''
  
Under METHOD values we RUN tpeng.values. This is done to run the METHODS from pengrobinson model in our test model.
+
Under '''METHOD values''' we RUN '''tpeng.value'''s. This is done to run the '''METHODS''' from '''pengrobinson model''' in our '''test model'''.
  
In the end we define the METHOD on_load in which we run specify and values;
+
In the end we define the '''METHOD on_load''' in which we run specify and values;
  
Now end the test model
+
Now end the '''test model'''
  
 
|-
 
|-
| 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 the model in Ascend and run the on_load method
+
| 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 the model in '''ASCEND''' and run the '''on_load method'''
| 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 this model in ASCEND
+
| 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 this '''model''' in '''ASCEND'''
  
Under Modules section, you will see two names
+
Under '''Modules''' section, you will see two names
  
peng robinsing and test model
+
'''peng robinsing''' and '''test model'''
  
 
In the panel below you will see the message
 
In the panel below you will see the message
  
won’t auto-initiate the model peng robinson
+
''''won’t auto-initiate the model peng robinson'''
  
model requires parameters
+
'''model requires parameters''''
  
As we have used WILL_BE in peng robinson, we can’t execute this model but the parameters defined here will be executed in our test model
+
As we have used '''WILL_BE''' in '''peng robinson''', we can’t execute this '''model''' but the parameters defined here will be executed in our '''test model'''
  
Now double click on test, the model opens under simulation
+
Now double click on '''test''', the''' model''' opens under simulation
  
Now run the on_load method and click on solve
+
Now run the '''on_load method''' and click on solve
  
you will see pressure, temperature are the fixed variables and ascend has successfully calculated values for z, volume, reduced Temperature and reduced Pressure
+
You will see''' pressure''', '''temperature''' are the fixed variables and '''ASCEND''' has successfully calculated values for '''z''', '''volume, reduced Temperature '''and''' reduced Pressure'''
  
  
Line 317: Line 325:
  
  
* create a reusable model
+
* Create a reusable model
* reuse the model for different components
+
* Reuse the '''model '''for different components
* import data from the Thermodynamics library
+
* Import data from the '''Thermodynamics library'''
* solve the model
+
* Solve the '''model'''
  
  
Line 328: Line 336:
  
 
Assignment
 
Assignment
| 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;"| As an assignment, try to modify pengrobinson model to solve the value of V.
+
| 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;"| As an assignment, try to modify '''pengrobinson''' model to solve the value of V.
  
Also re-use this model in a test model to compute value of V for ethylene.
+
Also re-use this model in a test model to compute value of '''V '''for '''ethylene'''.
  
 
|-
 
|-

Revision as of 12:32, 17 June 2014

Tutorial 4: Cubic EOS: Peng Robinson


Visual Cue
Narration
Show Slide number 1

Title slide

Welcome to the tutorial on Solving Cubic EOS in ASCEND
Show Slide 2 In this tutorial,

We will learn how to

  • Create a reusable model
  • Reuse the model for different components
  • Import data from the Thermodynamics library
  • Solve the model


Show Slide number 3

System Requirement

Here I am using

Ubuntu Linux OS v. 12.04

ASCEND v. 0.9.8



Show Slide number 4

Pre-requisites

To follow this tutorial, user must have basic knowledge of

Linux

ASCEND and

Peng Robinson cubic EOS

Show Slide number 5

Pre-requisites

To know more about ASCEND please visit ascend4.org

For relevant tutorials please visit our website

http://spoken-tutorial.org

Show Slide number 6

Peng Robinson Cubic EOS

Let’s write a general model to solve Peng Robinson cubic equation of state.

Peng Robinson equation of state is a cubic equation of state which contains volume terms to the third power.

It is usually expressed to give pressure in terms of temperature and molar volume. These are the equation for Peng Robinson equation of state

Show Slide number 7

Peng Robinson Cubic EOS

It is sometime more convenient to express the polynomial in terms of the compressibility factor Z

These are the equations which we will be using in our model to compute the value of Z

Open the code file in gedit Let's now look at the code for Peng Robinson model.

I already have the code for Peng Robinson model in a text file.

Open the file Peng Robinson.a4c in a text editor

Let me explain the code.

Highlight REQUIRE "thermodynamics.a4l"; For solving this model, we require data from the thermodynamics library.

So, add REQUIRE “thermodynamics.a4l”.



Highlight the lines sequentially I have named this model as pengrobinson.

After this define variables like P, T, V etc. using WILL_BE operator.

WILL_BE operator is used to make our model reusable

The variables defined using WILL_BE are used as parameters in our test model

I will come back to the explanation of WILL_BE as we move ahead in our tutorial

Highlight the following declaration statements

R IS_A molar_gas_constant;

Pc IS_A pressure;

Tc IS_A temperature;

T_degC IS_A factor;

alpha, beta, q,Tr, Pr, omega IS_A factor;

PSI, OMEGA, sigma, eps IS_A real_constant;

Now we Define rest of the variables accordingly. Like, R IS_A molar gas constant, Pc IS_A pressure and so on

Note that factor denotes a dimensionless variable, Thus alpha, beta, q etc. are defined as factor

Highlight the given constants used in the code

PSI :== 0.45724;

OMEGA :== 0.07780;

sigma :== 2.414213562;

eps :== 0.414213562;

Now we mention the values of all the constants used in Peng Robinson equation of state .

Please note that the values of these constants will be reused in our test model.

So we use a colon and is equal to sign twice to assign values to constants

Highlight the following syntax

Pc = data.Pc;

Tc = data.Tc;

omega = data.omega;

Tr = T/Tc;

Pr = P/Pc;

T_degC = T/1{K} - 273.15;

We take the critical temperature, critical pressure and omega data from the thermodynamics library.

And so we write

Pc=data.Pc and so on.

Now we define the reduced temperature and pressure in terms of Tc and Pc.

Now we mention the Peng Robinson equation as shown in the previous slide

Note that labels like eq 4, eq 5 etc. are not compulsory to write but they help in debugging the problem

Highlight the METHODS syntax sequentially Now let’s define methods to solve this model.

We use the method default to solve this model and run the METHODS specify and values under it.

Under specify we fix the variables by writing , P.fixed := TRUE;and T.fixed := TRUE;

Note that True implies fixed variable whereas all other variables that are not mentioned here are by default set to False, i.e. Free variables

Now under values, we define values to the fixed variables

For Z, we set the upper and lower bound and also provide a nominal value to initiate the solution.

The syntax used is

Z.lower_bound := 0.0;

Z.nominal := 0.1;

Now we end Peng Robinson model

Parameters defined in this model, can now be reused by any model to calculate Z for specific components

Let's now see how to use these parameters and calculate Z for ethylene in a test model.

Let's now look at the code for test model

Note that the test model is written below the Peng Robinson model in the same document

We name this model as test

We define a symbol constant – c1.

And assign c1 is equal to ethylene.

We use a colon and equal to sign twice as c1 is passed as a parameter to another variable components_data which is present in thermodynamics library

Here we define cd as components_data of ethylene

Note that in the parenthesis,c1 in square bracket implies such data for ethylene from thermodynamics library whereas c1 outside square bracket is set as reference component

More on this will be explained in future tutorials

Note that we use WILL_BE to define P,V,Z etc

To reuse these parameters from previous model we need to define them here using IS_A operator

Thus we define

P IS_A pressure;

T IS_A temperature and so on;

We define tpeng IS_A pengrobinson

Now tpeng includes all the equations and methods

defined in the peng robinson model

We have passed the required parameters to pengrobinson model in parenthesis,so we don't have to write the variables and the equations again

the values of constants and other variables will be called in the test model from peng robinson model

This is how we make our model reusable

We define equations for Tr and Pr as

Tr = T/cd.data[c1].Tc; and similarly for Pr;

We reuse this model in the test model to find out Z for ethylene.



Scroll the text file to show the next model We will now look at the code for testpengrobinson model.

I already have the code for testpengrobinson model in a text file.

Let me explain the code.

We name this model as testpengrobinson.

We define a symbol constant – c1.

And assign c1 is equal to ethylene.

This c1 is passed as a parameters to another model components_data which is present in one of our ‘REQUIRED’ libraries.

Here we define cd as the component data of ethylene.

To reuse the parameters from previous model like P, V, Z etc we need to define them here using the IS_A operator

We define tpeng as a pengrobinson.

Now tpeng includes all the equations and methods defined in pengrobinson model.

We have passed the required parameters to pengrobinson

So we do not have to write the equations and variables again.

This is how we make our model reusable.

We define equations for Tr and Pr as :

Tr = T/cd.data[c1].Tc;

Pr = P/cd.data[c1].Pc;

cd.dada[c1].Tc imports the value of Tc for ethylene from thermodynamics library.

In METHODS we define the standard methods again

But now under METHOD specify we RUN tpeng.specify

Under METHOD values we RUN tpeng.values. This is done to run the METHODS from pengrobinson model in our test model.

In the end we define the METHOD on_load in which we run specify and values;

Now end the test model

Open the model in ASCEND and run the on_load method Open this model in ASCEND

Under Modules section, you will see two names

peng robinsing and test model

In the panel below you will see the message

'won’t auto-initiate the model peng robinson

model requires parameters'

As we have used WILL_BE in peng robinson, we can’t execute this model but the parameters defined here will be executed in our test model

Now double click on test, the model opens under simulation

Now run the on_load method and click on solve

You will see pressure, temperature are the fixed variables and ASCEND has successfully calculated values for z, volume, reduced Temperature and reduced Pressure



Open Slide number 8

Summary

Now, let us summarize. In this tutorial, we have learnt how to:


  • Create a reusable model
  • Reuse the model for different components
  • Import data from the Thermodynamics library
  • Solve the model


Open Slide number 9

Assignment

As an assignment, try to modify pengrobinson model to solve the value of V.

Also re-use this model in a test model to compute value of V for ethylene.

Open Slide number 10

About the Spoken Tutorial Project

Information on the spoken tutorial project is available on our website

spoken-tutorial.org

Open Slide number 11

Spoken Tutorial Workshops

Details on Workshops based on spoken tutorials is also available on the website
Open Slide number 12

Acknowledgements

Spoken tutorial project is funded by NMEICT,MHRD



Open Slide number 13

Thank You

This is Priya Bagde from IIT Bombay signing off

Thank You for joining

Contributors and Content Editors

Gaurav, Nancyvarkey, Tarung