The HYSYS Spreadsheet

download The HYSYS Spreadsheet

of 16

description

The HYSYS Spreadsheet

Transcript of The HYSYS Spreadsheet

  • The HYSYS Spreadsheet 1

    1

    The HYSYS Spreadsheet

    1999 AEA Technology plc - All Rights Reserved

    ADV 4_1.pdf

  • 2 The HYSYS Spreadsheet

    2

    WorkshopThe HYSYS Spreadsheet is a powerful tool that allows the user to apply the functionality of Shreadsheet programs to flowsheet modelling. The Spreadsheet has complete access to all process variables; this allows the Spreadsheet to be virtually unlimited in its applicability and function.

    In this module, the Spreadsheet will be used to calculate the required orifice area of a Pressure Safety Valve. Unlike the Depressurizing utility, where the area is an input, the flow will be inputted here and the Spreadsheet will calculate the required area.

    Learning ObjectivesAfter completion of this module, you will be able to:

    Import and export variables to and from the Spreadsheet Add complex formulas to the Spreadsheet Use the HYSYS Spreadsheet in a wide variety of applications Open and run Macro Language Editor programs

    PrerequisitesBefore beginning this module, you should be able to:

    Add Streams and Unit Operations to the PFD Manoeuvre within the HYSYS interface

  • Process Overview

  • 4 The HYSYS Spreadsheet

    4

    The HYSYS SpreadsheetWith complete access to all process variables, the Spreadsheet is a very powerful tool in the HYSYS environment. The power of the Spreadsheet can be fully realized by the addition of formulas, functions, logical operators, and basic programming statements.

    The Spreadsheets ability to import and export variables means that seamless transfer of data between the Simulation Environment and the Spreadsheet is a simple matter. Any changes in the Simulation Environment are immediately reflected in the Spreadsheet, and vice-versa.

    The Spreadsheet has several common applications. For example, the Spreadsheet can be used to:

    Transfer variables between flowsheet objects. Relate the pressure drop in a Heat Exchanger to the flow. Perform mathematical operations using variables from the

    simulation.

  • The HYSYS Spreadsheet 5

    5

    Importing and Exporting VariablesThe contents of any cell in the Simulation Environment can be added to the Spreadsheet. The contents of any Spreadsheet cell can be exported to any specifiable (blue) cell in the Simulation Environment. Note that the contents of any Spreadsheet cell cannot be simulationsly imported and exported.

    There are three ways of importing values into the Spreadsheet.

    Drag and Drop - Position the cursor over the desired item; then press and hold the right mouse button. Move the cursor over to the Spreadsheet. Once over the Spreadsheet, the cursors appearance will change to a "bulls eye" type. Release the right mouse button when the "bulls eye" cursor is over the desired cell. The specific information about the imported variable will appear in the Current Cell group.

    Variable Browsing - A variable may also be imported into the Spreadsheet by placing the cursor on an empty cell in the Spreadsheet and pressing (and releasing) the right mouse button. Choose Import Variable from the list that appears, and select the variable using the Variable Navigator.

    Connections Page - On the Connections page, press the Add Import button and select the desired variable using the Variable Navigator. After selecting the variable, choose the desired cell from the Drop Down list.

    Exporting variables from the Spreadsheet into the Simulation environment is also a simple procedure. The methods for doing this are very similar.

    Drag and Drop - Position the cursor over the Spreadsheet cell that is to be exported. Press and hold the right mouse button; the cursor should now change to the "bulls eye" type. Move the "bulls eye" cursor over to the desired cell. Release the right mouse button, the transfer should be completed.

    Variable Browsing - A variable may be exported from the Spreadsheet into the Simulation environment by placing the cursor on the exportable cell in the Spreadsheet and pressing (and releasing) the right mouse button. Choose Export Formula Result from the list that appears, and select the desired location for the variable using the Variable Navigator.

    Connections Page - On the Connections page, press the Add Export button and select the desired variable using the Variable Navigator. After selecting the variable, choose the desired cell from the Drop Down list.

    In order for a variable to be dragged out of a particular view, that view must be "un-pinned" or non-modal. Click on the pin to convert the view.

    The value in any Spreadsheet cell can be exported, except if it is an imported value.

  • 6 The HYSYS Spreadsheet

    6

    Adding Spreadsheet FunctionsThe HYSYS Spreadsheet has extensive mathematical and logical function capabilities. Users familiar with common Spreadsheet programs will immediately recognize the form of the HYSYS functions as similar to the form used by these other programs.

    All functions in the HYSYS Spreadsheet must be proceeded by either a "+" or an "@" depending on the type of function. Plus signs (+) are used for straight mathematical functions: addition, subtraction, multiplication, and division. The ampersand (@) is used before special functions such as logarithmic, trigonometric, and logical functions.

    Some examples of the HYSYS functions and their form follow here:

    Addition - uses the "+" sign, e.g. +A1+A2 Subtraction - uses the "-" sign, e.g. +A1-A2 Multiplication - uses the "*" sign, e.g +A1*A2 Division - uses the "/" sign (not the "\") e.g. +A1/A2 Power - uses the "^" sign, e.g. +A2^4 Factorial - uses the "!" sign, e.g +A2! Square Root - uses the "@SQRT" function, e.g @SQRT(A2) Sine, Cosine, and Tangent - use the @sin, @cos, and @tan

    functions, e.g @sin(A2). Inverse trigonometric functions are also available, @asin, @acos, and @atan. Hyperbolic functions can also be represented in HYSYS, they use the form @sinh, @cosh, and @tanh.

    Logarithmic Functions - are represented in HYSYS with the following forms: @ln, @log, and @exp.

    Pi - simply enter "+pi" to represent the number 3.1416....

    To view the available HYSYS functions any time, press the Function Help button. This view has two pages, Functions and Expressions.

    A cells numerical value can be copied to another cell using the simple formula, +A1, for example.

    Parenthesis are mandatory in many of the advanced HYSYS functions.

    They can also be used to designate the calculation order.

  • The HYSYS Spreadsheet 7

    7

    Logical Operators

    The HYSYS Spreadsheet supports Boolean logic, essentially a true/false logic. A true statement has a value of 1, and a false statement has a value of 0. For example, suppose that the cell A1 has a value of 10, and the cell A2 has a value of 5. If the logical statement +A1A2 Less than - uses "=", e.g. +A1>=A2 Less than or Equal to - uses "

  • 8 The HYSYS Spreadsheet

    8

    Building the SimulationIn this module, the required orifice area for a Pressure Relief Valve will be calculated in a manner quite different from the method used in the Depressurization module. However, the same streams will be used.

    Therefore, continue with, or open, the Depressurization case. In this module the two streams will be combined with a mixer, a flow rate will be specified and the Spreadsheet will be used to calculate the required orifice area.

    1. Add a Mixer to the PFD. Attach both streams as feed streams and create a product stream named Comb. Feed.

    2. Ensure that the pressure assignment on the mixer is set to "Set Outlet to Lowest Inlet"

    3. Set the Molar flowrates of both feed streams to 460 kgmole/hr (1000 lbmole/hr).

    4. Add a V/L Separator to the system, with the feed stream as Comb. Feed, the vapour product stream as PSV Vapour and the liquid product stream as PSV Liquid.

    The formulas that will be used to calculate the orifice area are based on API-520. The formula for orifice area for the vapour stream is:

    And the equation for the orifice area required for the liquid flow is:

    The addition of a V/L Separator allows the user to calculate orifice areas for both vapour and liquid streams separately.

    AVM T Z

    C Kd Kb Kv P MW-------------------------------------------------------------------------=

    ALG SG

    22.8 Kd Kw Ku P--------------------------------------------------------------------=

  • The HYSYS Spreadsheet 9

    9

    The terms in the above equations are defined here:

    AV and AL = the orifice area required for vapour and liquid flows, respectively, in square inches.

    M = the mass flow of the vapour stream in lb/hr. T = the stream temperature in Rankin. Z = the compressibility factor of the vapour stream. C = the Vapour Flow constant = 315, for this example. Kd = the Coefficient of Discharge of the orifice = 0.953, for this

    example. Kb = the Vapour Flow Correction Factor = 1.0, for this example. Kv = the Vapour Flow Factor for variable back pressures, used

    with bellows values only = 1.0, in this example. MW = the average Molecular Weight of the stream. P = the pressure of the stream, in psia. G = the actual Volume Flow, in GPM. SG = the specific gravity of the liquid stream. Delta P = Pressure Drop across the valve, in PSI. Kw = the Liquid Flow Factor of variable back pressures, used

    with bellows valves only = 1.0, in this example. Ku = the Liquid Viscosity Correction Factor = 1.0, in this

    example.

    Before entering the Spreadsheet, change the unit set to match the units above. The easiest way to do this is to clone the Field unit set and name the new set PSV Units. Change the required variables as shown below:

    Note that all of the constants given here are defined in Field units. Using SI units without changing the constants will give wrong results.

    The units are accessed through Tools/Preferences on the main menu bar.

    Variable Type Unit

    Area in2

    Temperature Rankin (R)

    Actual Liquid Volume Flow USGPM

  • 10 The HYSYS Spreadsheet

    10

    Adding and Defining the SpreadsheetTo install the Spreadsheet, choose Add Operation from the Flowsheet menu and select Spreadsheet. Alternatively, select the Spreadsheet button from the Object Pallet.

    1. Change the size of the Spreadsheet to 4 columns and 15 rows. The size of a Spreadsheet is set on the Parameters tab. The default unit set for the Spreadsheet can also be changed on the Parameters page. For this exercise, select the default unit set to be the newly created PSV Units unit set.

    2. Labels and constants can be added to the Spreadsheet, so that it looks like this:

    Spreadsheet Button

    Of course, labels are not necessary, but as the Spread-sheet grows, it can become difficult to remember what each number represents.

  • The HYSYS Spreadsheet 11

    11

    The following variables have to be imported into the Spreadsheet:

    The following formulas can now be to be added to the Spreadsheet:

    In this Cell... Import...

    B2 PSV Vapour - Mass Flow

    B3 PSV Vapour - Temperature

    B4 PSV Vapour - Phase Z Factor

    B7 PSV Vapour - Pressure

    B8 PSV Vapour - Molecular Weight

    D2 PSV Liquid - Act Liquid Vol. Flow

    D3 PSV Liquid - Mass Density

    D5 PSV Liquid - Pressure

    The methods of importing variables was discussed previously in this module.

    In this Cell... Enter...

    B12 +(b2*@sqrt(b3)*@sqrt(b4))/(b5*b6*b7*b9*b10*@sqrt(b8))

    D4 +d3/62.4

    D7 +d5-d6

    D12 +(d2*@sqrt(d4))/(22.8*d8*d9*d10*@sqrt(d7))

    C14 +b12+d12

    The formulas must be entered exactly as they are given here. A missing parenthesis or * will cause an error.

    Cell labels are not case sensitive.

  • 12 The HYSYS Spreadsheet

    12

    The final Spreadsheet should look like this:

    What is the total required area of the orifice? __________

    Save your case!

  • The HYSYS Spreadsheet 13

    13

    Exercise 1

    Compare with the Depressurizing UtilityIn this module, and the previous one, depressurizing of a system was examined. It may not be obvious, but the numbers used in this module were derived from the previous module. The flow rate used here was found by averaging the flow rate through the PSV found in the Depressurizing module. The streams in both modules share the same composition, the same flow and the same pressures.

    Because of the similar nature of these two streams, one would expect that inputting the orifice area that was found in this module into the depressurizing utility would yield similar results to those found in the Depressurization module. Well, lets try it.

  • 14 The HYSYS Spreadsheet

    14

    Create a depressurizing utility in the simulation with the following data. If you need help in finding the locations for these variables return to the previous module:

    In this Cell... Enter... (Field) Enter... (SI)

    Stream Comb. Feed Comb. Feed

    Vessel Volume 3200 ft3 90 m3

    Liquid Volume 1800 ft3 51 m3

    Wetted Area 62,000 in2 40 m2

    Mode Adiabatic Adiabatic

    Relief Pressure 435 psia 3000 kPa

    Depress. Time 900 seconds 900 seconds

    Final Pressure 14.7 psia 102 kPa

    Press. Steps 100 100

    Isentropic Efficiency 25 % 25 %

    Vessel Spec Heat 25 BTU/lb-F 100 kJ/kg-C

    Vessel Mass 13230 lb 6000 kg

    Valve Equation General General

    C1 0.953 2.5

    C2 0.5 0.5

    Gc 32.17 1

    Av 0.00886 ft2 0.00082 m2

    Valve Rate Units lb/hr kg/hr

    Upstream Pressure Units lbf/ft2 kPa

    Use only one unit set through-out this exercise. If using Field units, enter everything in Field units. If using SI, enter everything in SI.

    C1 is equal to the Orifice constant when working with Field units, and 2.62 * the Orifice constant when working in SI. This applies to General Valves only.

    Remember that Gc is always 32.17 when working with Field units, and 1 when working with SI.

  • The HYSYS Spreadsheet 15

    15

    Calculate the utility and move to the Plots page, select the Pressure radio button.

    Exercise 2

    Constant Rate DepressurizationAs an additional exercise, model the value in the Depressurizing utility as a subsonic valve with the following information:

    These settings set the valve as a constant rate type valve. If C2 = 0 then pressure has no impact on the valves flow rate.

    What final pressure and depressurizing time does the utility calculate? __________

    Is a valve of this size sufficient to meet the requirements of complete depressurization, i.e. the final pressure is atmospheric, in 15 minutes? __________

    In this Cell... Enter... (Field) Enter... (SI)

    C1 72,000 32,400

    C2 0 0

    Valve Rate Units lb/hr kg/hr

    What is the depressurization time in this case? __________

    Save your case!

  • 16 The HYSYS Spreadsheet

    16

    Challenge

    The Macro Language EditorHYSYS contains a Macro Language Editor, that lets the user write programs that can access information from the HYSYS Simulation, and calculate a value or a series of values.

    This language editor uses the WinWrap Basic script, a language very similar to Microsoft Visual Basic. The Macro Language Editor allows users to develop, test, and execute programs. Programs can also be saved and reopened in any number of HYSYS cases.

    There are several programs already prepared for many different applications. These programs can found on Hyprotechs website at www.hyprotech.com\OLE\default.htm.

    In this module, a prewritten program will be used to calculate the orifice area needed to vent the Comb. Feed stream.

    1. Access the Macro Language Editor under Tools in the Main Menu Bar.

    2. With the provided disk in the A: drive, open the file A:\PSV.wwb.

    3. Run the Program by selecting Run under Macro on the Menu Bar.

    4. Enter a Relief Pressure of 15.5 bar (225 psig), and select Two Phase Relief. Otherwise, accept all of the default values.

    What orifice area does the program calculate? __________

    How does this value compare with the value calculated previously? __________