Event Scheduler & Spreadsheet 1
Event Scheduler & Spreadsheet 1
1
2004 Aspen Technology. - All Rights Reserved.
Workshop
With the Event Scheduler, it is possible to have HYSYS perform given tasks while a simulation is running in dynamics. The tasks can be triggered by a pre-determined simulation time, a logical expression becoming true, or a variable stabilizing to within a given tolerance for a set amount of time. Examples of tasks that can be performed with the Event Scheduler would be emergency shutdown, start-up and some batch processes, among others. The Spreadsheet Operation in HYSYS allows users perform calculations that may otherwise not be done in HYSYS. Virtually any process variable can be transferred into the spreadsheet. Any user specifiable process variable can be calculated and exported. This functionality is particularly useful in Dynamics because it provides an easy way to customize the flow sheet. In this workshop, we will work with the Spreadsheet and the Event Scheduler Manager
Learning Objectives
Once you have completed this section, you will be able to: Use the Spreadsheet Use the Event Scheduler Manager Create Event Schedules Create Sequences Create Event Conditions
Process Overview
The Event Scheduler is accessed from the Simulation Menu Bar, or by using the hot key CTRL E. When you open the Event Scheduler, HYSYS displays the Event Scheduler Manager, which contains a list of the Schedules in the case.
Figure 2
The buttons in the Current Events Schedule group are used to manage the schedules for the current case: View. Allows you to view the selected schedule. This is only active when a schedule exists in the case. Add. Allows you to add new schedules to the case. Delete. Allows you to delete the selected schedule. This is only active when a schedule exists in the case. Copy. Allows you to make a copy of the selected schedule. this is only active when a schedule exists in the case. Import. Allows you to import a saved schedule from disk. Schedules have the extension.sch. Export. Allows you to export the selected schedule to disk. Once exported, a schedule can be retrieved using the Import button. This is only active when a schedule exists in the case. Sort. Allows you to arrange the schedules. This is only active when at least 2 schedules exist in the case.
The Specified field in the matrix indicates whether all the Events in the Schedule have been fully specified. If all the Events in all the Sequences which make up the Schedule have been fully specified, the Specified field will display True, otherwise it will be False. The No. Sequences field displays the number of Sequences in the Schedule.
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 bull's 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 Connections Page. On the Connections page, click 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.
The value of any spreadsheet cell can be exported, except if it is an imported value.
The 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: 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)
A cells numerical value can be copied to another cell by using a simple formula (e.g. =A1). Parenthesis are mandatory in many of the advanced spreadsheet functions and can also be used to designate calculation order.
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. Represented in HYSYS with the following forms: @ln, @log, and @exp. Pi. Simply enter +pi to represent the number 3.1416....
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 +A1<A2 were entered into cell A3. The cell would display a value of 0 because the logic statement is false. The following logical operators can be used in Boolean logic statements: Equal to. Uses ==, e.g +A1==A2 Not Equal to. Uses !=, e.g. +A1!=A2 Greater than. Uses >, e.g. +A1>A2 Less than. Uses <, e.g. +A1<A2 Greater than or Equal to. Uses >=, e.g. +A1>=A2 Less than or Equal to. Uses <=, e.g. +A1<=A2
IF/THEN/ELSE Statements
The HYSYS Spreadsheet also supports the basic IF/THEN/ELSE Statement. The form of this statement is: @if (condition) then (if true) else (if false)
The else portion of the statement is not optional. An if/then statement is not valid.
The condition is a logical expression, such as B1<= 10. The if true represents what the cell will show if the condition is true; it can be a number or a formula. The if false represents what the cell will show if the condition is false; it can also be a number or a formula.
An example of the completed statement follows. @if (B1<=10) then (B1*2) else (B1/10)
Suppose that the value in cell B1 is 8. What will the IF/ THEN/ELSE Statement shown above calculate? _____________________________________
10
6.
Click OK.
Figure 3
7.
Spreadsheet formulas can be prefixed with either + or =. Logicals are prefixed with @.
Cell B3 B4 B6
8.
Cell B5 B7 B8
D2
@if(b9=1)then(0)else(b8)
Energy
10
11
Figure 4
The heat input to the vessel is determined by equation A-2 from API Recommended Practice 521.
9.
10. Place the cursor in D9 and press the right mouse button. 11. Select Export Formula Result from the drop-down menu. 12. Select Q-Fire as the object and Heat Flow as the variable. 13. Click OK. 14. Note that the value shown in cell B9 will be changed by the Event Scheduler. If it is equal to anything other than 1, the energy calculated in cell B8 will be exported to Q Fire via the logical expression in cell D2. Otherwise cell D2 exports a value of zero to Q Fire.
11
12
Figure 5
16. In the bottom right hand corner of the Schedule view, rename the new Schedule to Fire Relief Scenario. In the Schedule Sequences group, seven buttons allow you to organize all the Sequences for the current Schedule: View. Allows you to view the selected sequence. This is only active when a sequence exists in the schedule. Add. Allows you to add new sequence to the schedule. Delete. Allows you to delete the selected sequence. This is only active when a sequence exists in the schedule. Copy. Allows you to make a copy of the selected sequence. This is only active when a sequence exists in the schedule. Import. Allows you to import a saved sequence from disk. Are saved in *.seq format. Export. Allows you to export the selected sequence to disk. Once exported, a sequence can be retrieved using the Import button. This is only active when a sequence exists in the schedule. Sort. Allows you to arrange the sequences. This is only active when at least 2 sequences exist in the schedule.
12
13
The Sequence field contains the name of the Sequence. The Run Mode field displays the sequence mode, which can be either One Shot or Continuous. A One Shot Sequence executes all its Events in order and then its Status will change to Complete. A Continuous Sequence returns to the first Event after the last Event has been executed, in a continuous loop. The Event, Waiting For, and Pending Actions fields display the current event number with its corresponding Condition name and Action List name. 17. On the Schedule view, click the Add button to create a new sequence. 18. Rename the Sequence to Fire Relief.
Figure 6
The Schedule of Events tab shows the list of events for the schedule. The fields on this view are defined as follows: Specified. True/False indicates whether the event has been fully defined Condition. Displays the condition name of the event Action List. Shows the name of the events action list
13
14
Jump When. Displays whether the Event will Jump over any Events and, if so, under what condition Jump To. Displays the event to jump to.
At the bottom of the view the sequence name, current event number and sequence status are shown. If the event is not fully specified, the Analyze button is enabled and provides additional feedback. On the Settings tab, the sequence Run Mode is selected, a unit set global to the sequence can be chosen and different Status Window Reporting options are available. Selecting the Synchronize All Time Sensitive Conditions check box will assure execution of a particular event at an exact simulation time. This applies only when one of the two time conditions has been selected for the Event. Default Time Out Behaviour is specified here and applies to all the events unless a specific event overrides the behaviour. The Fire Relief Sequence created in this module will hold three Events to be executed at three predetermined times. The first on this list of events is the shutting of the three control valves. 19. On the Fire Relief sequence view, click the Add button to create a new Event. 20. In the Condition Name field, rename the condition Pre Fire Shutdown. 21. In the Wait For box, select the An Elapsed Amount of Time radio button. 22. In the Wait For field, enter 2 minutes.
14
15
Figure 7
23. Proceed to the Action List tab. Rename the action list Fire Shutdown. 24. Click the Add button to add a new action. 25. Name the action Close Flow Valve and select Set Controller Mode as a Type. 26. Click the Select Target button and select FIC-100. 27. Select Man from the New Mode drop-down box. This will put the controller in manual mode and allow you to set the OP to 0%, which will close VLV-100. 28. Activate the New OP check box and enter a new OP of 0%. 29. Add two more Actions, Close Level Control Valve and Close Pressure Control. In both cases, the action types to be selected are Set Controller Mode and the controllers should be put in manual mode and their respective OPs set to 0%.
15
16
Figure 8
30. Two additional Events should be added to the Fire Relief Sequence: Event 2
Purpose To start a simulated fire under V-100. This Event will change the value of cell B9 such that the logic in the spreadsheet will evaluate to false and the heat flow to V100 will be determined using the equations in the spreadsheet. Start Fire Elapsed Time = 10 min Start Fire Add Heat to Vessel Specify Variable Fire Calculations, B9 2 Name Type Target Value
Event 3
Purpose Once the vessel pressure has stabilized, the fire will be extinguished and the flow, pressure, and level controllers will be switched back on. Post Fire Pressure of V-100 is stable within specified bandwidth (+10%) for 30 minutes
16
17
Action List Name Action Name Type Target Value Name Type Target New Mode New Setpoint Name Type Target New Mode New Setpoint Name Type Target New Mode New Setpoint
Post Fire Actions Fire Off Specified Variable Fire Calculations, B9 1 Level Controller On Set Controller Mode LIC-100 Auto 50% Pressure Controller On Set Controller Mode PIC-100 Auto 85 psia (586.1 kPa) Flow Controller On Set Controller Mode FIC-100 Auto 100 lbmol/h (45.36 kgmol/h)
31. Once all of the Events have been added, return to the Fire Relief Scenario Schedule view and press the Start button at the bottom of the view. This will activate the selected sequence. You should notice that the status of Fire Relief will change from Inactive to Waiting.
17
18
18