Difference between revisions of "ASCEND/C2/Solving-Cubic-EOS/English"
Nancyvarkey (Talk | contribs) |
|||
Line 10: | Line 10: | ||
Title slide | Title slide | ||
− | | style="border:0.75pt solid #000001;padding:0.0104in;"| Welcome to the tutorial on '''Solving Cubic | + | | style="border:0.75pt solid #000001;padding:0.0104in;"| Welcome to the spoken tutorial on '''Solving Cubic Equation Of State in ASCEND''' |
|- | |- | ||
| style="border:0.75pt solid #000001;padding:0.0104in;"| Show Slide 2 | | style="border:0.75pt solid #000001;padding:0.0104in;"| Show Slide 2 | ||
− | | 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 |
− | + | * 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 32: | Line 27: | ||
| 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 v. 12.04 |
− | + | *ASCEND v. 0.9.8 | |
− | ASCEND v. 0.9.8 | + | |
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
Line 45: | Line 36: | ||
| 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 Equation Of State''' |
− | + | ||
− | '''Peng Robinson cubic | + | |
|- | |- | ||
Line 55: | Line 44: | ||
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''' |
− | |||
− | http://spoken-tutorial.org | + | For relevant tutorials please visit our website http://spoken-tutorial.org |
|- | |- | ||
Line 65: | Line 53: | ||
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'''. | + | | style="border:0.75pt solid #000001;padding:0.0104in;"| Let’s write a general '''model''' to solve '''Peng Robinson cubic equation of state'''. |
− | |||
− | It is usually expressed to give pressure in terms of temperature and molar volume. These are the | + | '''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 '''equations''' for '''Peng Robinson equation of state ''' | ||
|- | |- | ||
Line 75: | Line 68: | ||
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 | + | | 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 sometimes 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;"| | + | | style="border:0.75pt solid #000001;padding:0.0104in;"| |
| 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 | + | |- |
+ | | 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 file '''Peng Robinson.a4c''' in a text editor. | ||
− | Let me explain the code. | + | |
+ | Let me explain the '''code'''. | ||
|- | |- | ||
Line 94: | Line 92: | ||
So, add '''REQUIRE “thermodynamics.a4l'''”. | So, add '''REQUIRE “thermodynamics.a4l'''”. | ||
− | |||
− | |||
− | |||
|- | |- | ||
Line 102: | Line 97: | ||
| 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'''. | ||
− | |||
− | '''WILL_BE''' operator is used to make our '''model''' reusable | + | After this, we define variables like '''P, T, V''' etc. using '''WILL underscore 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''' | 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 124: | Line 123: | ||
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 | + | | 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 '''factor''' | + | |
+ | Note that '''factor '''denotes a '''dimensionless variable''', Thus '''alpha, beta, q '''etc. are defined as a '''factor''' | ||
|- | |- | ||
Line 138: | 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 '''Peng Robinson equation | + | | 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'''. |
− | So we use a colon and is equal to sign twice to assign values to constants | + | |- |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| So we use a '''colon''' and '''is equal to''' sign twice, to assign values to constants | ||
|- | |- | ||
Line 158: | Line 160: | ||
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'''. |
− | |||
− | '''Pc=data.Pc''' and so on. | + | And so we define |
+ | *'''Pc=data.Pc''' | ||
+ | *'''Tc=data.Tc''' | ||
+ | *and so on. | ||
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the lines | ||
− | Now we | + | | style="border:0.75pt solid #000001;padding:0.0104in;"| Now we define the '''reduced temperature''' and '''reduced pressure" in terms of '''Tc '''and '''Pc'''. |
− | |||
|- | |- | ||
− | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the | + | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the lines |
− | + | ||
− | + | | style="border:0.75pt solid #000001;padding:0.0104in;"|Now we mention the '''Peng Robinson equation''' as shown in the previous slide | |
− | |||
− | Note that ''' | + | Note that labels like '''eq 4, eq 5''' etc. are not compulsory to write but they help in debugging the problem. |
− | Now | + | |- |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | 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;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| We use the '''method default''' to solve this '''model''' and run the '''METHOD specify '''and''' METHOD values''' under it. | ||
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Under '''specify''' we fix the '''variables''' by writing , '''P.fixed := TRUE'''<nowiki>;and </nowiki>'''T.fixed := TRUE'''<nowiki>; </nowiki> | ||
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Note that | ||
+ | *'''True''' implies '''fixed variables''' | ||
+ | *whereas all other '''variables''' which are not mentioned here | ||
+ | *are, by default, set to '''False''', i.e. '''free variables''' | ||
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| 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. | |
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| The syntax used is | ||
− | + | *'''Z.lower_bound := 0.0'''<nowiki>;</nowiki> | |
− | + | *'''Z.nominal := 0.1'''<nowiki>;</nowiki> | |
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Now we end '''Peng Robinson model'''. | ||
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Parameters defined in this '''model''', can now be reused by any '''model''' to calculate '''Z''' for specific components. | ||
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| 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'''. | |
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| 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'''. | |
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| We use a '''colon''' and '''equal to''' sign twice as this''' c1''' is passed as a parameter to another variable '''components underscore data,''' which is present in '''thermodynamics library'''. | ||
− | + | Here we define '''cd '''as '''components_data''' of '''ethylene'''. | |
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Note that | ||
+ | *in the '''parenthesis, c1''' in '''square bracket''' implies fetch 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. | |
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Note that we used '''WILL_BE''' to define '''P,V,Z''' etc | ||
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| 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 | |
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| We define '''tpeng IS_A pengrobinson'''. | ||
− | |||
− | ''' | + | Now '''tpeng''' includes all the '''equations''' and '''methods''' defined in the '''peng robinson model'''. |
− | We | + | |- |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| We have passed the required parameters to the '''pengrobinson model '''in '''parenthesis'''. | ||
+ | So we don't have to write the '''equations''' and '''variables''' again. | ||
|- | |- | ||
− | | style="border:0.75pt solid #000001;padding:0.0104in;"| | + | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line |
− | | style="border:0.75pt solid #000001;padding:0.0104in;"| | + | | style="border:0.75pt solid #000001;padding:0.0104in;"| 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 | + | |- |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| We define equations for '''Tr''' and '''Pr''' as | ||
− | + | *'''<nowiki>Tr = T/cd.data[c1].Tc</nowiki>'''<nowiki>; | |
+ | *and similarly for </nowiki>'''Pr'''<nowiki>;</nowiki> | ||
− | |||
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| | ||
+ | '''cd.date c1.Tc''' imports the value of '''Tc''' for '''ethylene''' from '''thermodynamics library.''' | ||
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| | ||
+ | In '''METHODS''', we define the '''standard methods''' again. | ||
− | + | But now | |
+ | *under '''method specify''', we run ''' tpeng.specify''' | ||
+ | *under '''method values''', we run ''' tpeng.values''' | ||
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| This is done to run the '''methods''' from '''pengrobinson model''' in our '''test model'''. | ||
− | |||
− | + | |- | |
− | + | | style="border:0.75pt solid #000001;padding:0.0104in;"| Highlight the line | |
− | + | | style="border:0.75pt solid #000001;padding:0.0104in;"|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 | + | |- |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Point as per narration | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"|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 | + | |- |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Point as per narration | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"|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''' | + | |- |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Point as per narration | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"|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'''. | |
− | + | |- | |
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Point as per narration | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"|Now double click on '''test'''. | ||
+ | The''' model''' opens under '''Simulation.''' | ||
+ | |- | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Point as per narration | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"|Now run the '''on_load method''' and click on '''Solve''' | ||
+ | |- | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"| Point as per narration | ||
+ | | style="border:0.75pt solid #000001;padding:0.0104in;"|You will see''' pressure''', '''temperature''' are the fixed variables. | ||
+ | |||
+ | |||
+ | And '''ASCEND''' has successfully calculated values for '''z''', '''volume, reduced Temperature '''and''' reduced Pressure''' | ||
|- | |- | ||
Line 323: | Line 372: | ||
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;"| Now, let us summarize. In this tutorial, we have learnt how 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;"| Now, let us summarize. In this tutorial, we have learnt how to: | ||
− | |||
* Create a reusable model | * Create a reusable model | ||
Line 329: | Line 377: | ||
* Import data from the '''Thermodynamics library''' | * Import data from the '''Thermodynamics library''' | ||
* Solve the '''model''' | * Solve the '''model''' | ||
− | |||
Line 336: | Line 383: | ||
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'''. |
|- | |- |
Latest revision as of 23:07, 6 July 2014
Tutorial 4: Cubic EOS: Peng Robinson
|
|
Show Slide number 1
Title slide |
Welcome to the spoken tutorial on Solving Cubic Equation Of State in ASCEND |
Show Slide 2 | In this tutorial, we will learn how to
|
Show Slide number 3
System Requirement |
Here I am using
|
Show Slide number 4
Pre-requisites |
To follow this tutorial, user must have basic knowledge of
|
Show Slide number 5
Pre-requisites |
To know more about ASCEND, please visit ascend4.org
|
Show Slide number 6
Peng Robinson Cubic EOS |
Let’s write a general model to solve Peng Robinson cubic equation of state.
|
Show Slide number 7
Peng Robinson Cubic EOS |
It is sometimes more convenient to express the polynomial in terms of the compressibility factor Z.
|
Let's now look at the code for Peng Robinson model.
| |
Open the code file in gedit | Open the file Peng Robinson.a4c in a text editor.
|
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.
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,
|
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.
|
Highlight the lines | Now we define the reduced temperature and reduced pressure" in terms of Tc and Pc.
|
Highlight the lines | Now we mention the Peng Robinson equation as shown in the previous slide
|
Highlight the line | Now let’s define methods to solve this model. |
Highlight the line | We use the method default to solve this model and run the METHOD specify and METHOD values under it. |
Highlight the line | Under specify we fix the variables by writing , P.fixed := TRUE;and T.fixed := TRUE; |
Highlight the line | Note that
|
Highlight the line | 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. |
Highlight the line | The syntax used is
|
Highlight the line | Now we end Peng Robinson model. |
Highlight the line | Parameters defined in this model, can now be reused by any model to calculate Z for specific components. |
Highlight the line | 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. |
Highlight the line | 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. |
Highlight the line | We use a colon and equal to sign twice as this c1 is passed as a parameter to another variable components underscore data, which is present in thermodynamics library.
Here we define cd as components_data of ethylene. |
Highlight the line | Note that
|
Highlight the line | Note that we used WILL_BE to define P,V,Z etc |
Highlight the line | To reuse these parameters from previous model, we need to define them here using IS_A operator
Thus we define
|
Highlight the line | We define tpeng IS_A pengrobinson.
|
Highlight the line | We have passed the required parameters to the pengrobinson model in parenthesis.
So we don't have to write the equations and variables again. |
Highlight the line | The values of constants and other variables will be called in the test model from peng robinson model.
|
Highlight the line | We define equations for Tr and Pr as
|
Highlight the line |
cd.date c1.Tc imports the value of Tc for ethylene from thermodynamics library. |
Highlight the line |
In METHODS, we define the standard methods again. But now
|
Highlight the line | This is done to run the methods from pengrobinson model in our test model.
|
Highlight the line | 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. |
Point as per narration | Under Modules section, you will see two names
peng robinsing and test model |
Point as per narration | In the panel below you will see the message
|
Point as per narration | As we have used WILL_BE in peng robinson, we can’t execute this model.
|
Point as per narration | Now double click on test.
The model opens under Simulation. |
Point as per narration | Now run the on_load method and click on Solve |
Point as per narration | You will see pressure, temperature are the fixed variables.
|
Open Slide number 8
Summary |
Now, let us summarize. In this tutorial, we have learnt how to:
|
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 |