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

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 102: Line 102:
 
| 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 we 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

Revision as of 15:56, 30 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 we 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