Вы находитесь на странице: 1из 15

Transition Object

Extension

Developers Guide
Version Number: 7.0
Copyright (c) 2008 by Aspen Technology, Inc. All rights reserved.

Aspen HYSYS, Aspen RefSYS, Aspen HYSYS Petroleum Refining, and the aspen leaf logo are trademarks or
registered trademarks of Aspen Technology, Inc., Burlington, MA.

All other brand and product names are trademarks or registered trademarks of their respective companies.

This document is intended as a guide to using AspenTech's software. This documentation contains AspenTech
proprietary and confidential information and may not be disclosed, used, or copied without the prior consent of
AspenTech or as set forth in the applicable license agreement. Users are solely responsible for the proper use of
the software and the application of the results obtained.

Although AspenTech has tested the software and reviewed the documentation, the sole warranty for the software
may be found in the applicable license agreement between AspenTech and the user. ASPENTECH MAKES NO
WARRANTY OR REPRESENTATION, EITHER EXPRESSED OR IMPLIED, WITH RESPECT TO THIS DOCUMENTATION,
ITS QUALITY, PERFORMANCE, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.

Aspen Technology, Inc.


200 Wheeler Road
Burlington, MA 01803-5501
USA
Phone: (781) 221-6400
Toll free: (888) 996-7001
Website http://www.aspentech.com
Contents
1 Introduction .........................................................................................................3
About this document ...................................................................................... 3
Audience....................................................................................................... 3
Technical Support .......................................................................................... 3

2 Source Code .........................................................................................................5


Overview ...................................................................................................... 5
Global Variables ............................................................................................. 5
Initialize ....................................................................................................... 6
Execute ........................................................................................................ 6
Edf............................................................................................................... 9

3 Example .............................................................................................................11
Overview .....................................................................................................11
Installing the Extension..................................................................................11
Installing Aspen HYSYS Oil .............................................................................12
Installing REFSYS Oil .....................................................................................12
Building the Flowsheet ...................................................................................13

1
2 1 Introduction
1 Introduction

This chapter provides information about this document. It includes the


following topics:
About this document
Audience
Technical Support

About this document


This guide provides a detailed description of the source code necessary to
construct an Extension Transition object. An accompanying example is also
contained which illustrates the use of the extension.
The extension source code provided in this document is designed to update
the Molecular Weight and a Petroleum property of an Aspen HYSYS/RefSYS
process stream across a subflowsheet defined by the boiling point range of
components in the corresponding product streams. The accompanying
example converts a legacy Aspen HYSYS Oil to an Aspen HYSYS Refining
(RefSYS) Oil.

Audience
This guide is intended for developers.

Technical Support
AspenTech customers with a valid license and software maintenance
agreement can register to access the online AspenTech Support Center at:
http://support.aspentech.com
This Web support site allows you to:
Access current product documentation
Search for tech tips, solutions and frequently asked questions (FAQs)
Search for and download application examples

1 Introduction 3
Search for and download service packs and product updates
Submit and track technical issues
Send suggestions
Report product defects
Review lists of known deficiencies and defects
Registered users can also subscribe to our Technical Support e-Bulletins.
These e-Bulletins are used to alert users to important technical support
information such as:
Technical advisories
Product updates and releases
Customer support is also available by phone, fax, and email. The most up-to-
date contact information is available at the AspenTech Support Center at
http://support.aspentech.com.

4 1 Introduction
2 Source Code

This chapter provides information about the source code. It includes the
following topics:
Overview
Global Variables
Initialize
Execute
Edf

Overview
In this section a VB (Visual Basic) extension transition object will be created.
To begin construction start Microsoft Visual Basic 6.0 or a later version of
Visual Basic. In Visual basic select an ActiveX DLL project type and assign a
Project name myTransitionExtn and change the class name to
myCTransitionExtn. The VB project and class names will be entered in the
Aspen HYSYS edf (extension definition file). The name of the dll will be
myTransitionExtn.dll.
Two mandatory functions are required for a Transition extension to function
properly. These functions are the Initialize and Execute functions described in
following sections.

Global Variables
Global variables are declared for process streams and the unit operation
container. For a transition object additional global variables are needed for
petroleum properties. Declare property vectors for Molecular Weight and the
Flash Point for both the Feed and Product streams.

' RefSys objects


Public PropvectorMWFeed As PropertyVector ' Molecular Weight
Public PropvectorMWProd As PropertyVector ' Molecular Weight

2 Source Code 5
' petroleum properties
Public PropvectorFlashPointFeed As PropertyVector ' Flash Point
Property
Public PropvectorFlashPointProd As PropertyVector ' Flash Point
Property

Initialize
Add an Initialize function. The initialize function is called each time a case
containing a transition extension object is loaded or when installing an
extension for the first time. When a transition object is installed for the first
time, the IsRecalling parameter is passed to the extension from RefSYS and is
used to initialize local parameters one time only. In the initialize function the
extension obtains the user interface variable usefeedstrmpetprop and is set to
0.
Public Function Initialize(ByVal Container As
ExtnUnitOperationContainer, _
ByVal IsRecalling As Boolean) As Long
Set hyContainer = Container
With hyContainer
Set usefeedstrmpetprop =
.FindVariable("usefeedstreampetprop").Variable
End With
Set hyFeed = hyContainer.FindVariable("Feed").Variable.object
Set hyProduct =
hyContainer.FindVariable("Product").Variable.object
If Not IsRecalling Then
usefeedstrmpetprop = 0 ' use petdata.dll
End If
Initialize = extnCurrentVersion
End Function

Execute
The Execute function contains the heart of the calculations or manipulations
for stream properties, and where the material and energy balances occur.
In this extension, the MW and a Petroleum Property the Flash point will be
calculated for a subflowsheet product stream composed of a different
component slate then the feed stream into the subflowsheet. The properties
will be ordered based on the product stream component boiling points.
Inside the Is Forgetting block of the Execute function, Property Vectors
must be added using PropertryVectors from a copy of the feed and product
streams, as fluid types.
Set PropvectorMWFeed =
StrmFeedFluid.PropertyVectors.Add("Molecular Weight")
Set PropvectorMWProd =
StrmProdFluid.PropertyVectors.Add("Molecular Weight")

vntMWFeedContent = PropvectorMWFeed.PointPropertyValue

6 2 Source Code
MyMWResults = PropvectorMWProd.PointPropertyValue
' petroleum properties
Set PropvectorFlashPointFeed =
StrmFeedFluid.PropertyVectors.Add("Flash Point")
Set PropvectorFlashPointProd =
StrmProdFluid.PropertyVectors.Add("Flash Point")

MyFlashPointResults = PropvectorFlashPointProd.PointPropertyValue
MyFlashPointResultsFeed =
PropvectorFlashPointFeed.PointPropertyValue
The idea is to map one set components to another based on the normal
boiling point ranges defined by the product stream components. For example
consider a component slate with a pseudo component of NBP 150F and a
product stream slate composed of two components NBP 111F and NBP 304F.
Since no NBP150F component exists in the product stream, the compositions
and properties of NBP150F will be stored in the component with NBP equal to
or higher than the NBP of 150F. In this case the properties of NBP150F will be
stored in NBP304F.
Add code to locate the heaviest component in the product stream component
slate and store the NBPs of each component.
For Each hyComponentProd In hyComponentsProd
normalbp(i) = hyComponentProd.NormalBoilingPoint
i = i + 1
Next hyComponentProd
Locate Library components in the feed and product streams and store the
corresponding properties and compositions.
Non-library components such as hypotheticals and oil components are
handled separately. Take note, hypothetical components are handled
differently than oil components and library components.
If hyComponentProd.IsHypothetical = True Then
Component mapping is achieved via an inner and outer loop corresponding to
the feed and product component slates. When a suitable product stream
component is located for mapping the next iteration of the feed stream
component loop is executed until all feed components have been mapped.
For Each hyComponentFeed In hyComponentsFeed
librarycompfound = False
oilcompfound = False
For Each hyComponentProd In hyComponentsProd

Next hyComponentProd

Next hyComponentFeed
When a product stream component is located, results for each property, MW
and Flash Point, are stored in corresponding property vectors.
If hyComponentFeed.NormalBoilingPoint > normalbp(0) Then
If hyComponentFeed.NormalBoilingPoint <= normalbp(i + 1)
Then

mymolefrac =
get_CompMoleFracFeed(hyComponentFeed.IDNumber, _

2 Source Code 7
hyCompMoleFrac_Feed, hyComponentsFeed)

molwi = get_CompMWFeed(hyComponentFeed.IDNumber,
hyComponentsFeed)

hyCompMoleFlow_Product(i) = hyCompMoleFlow_Product(i) _
+ mymolefrac * mymolarflow

' Molecular weight - add property vector data here


MyMWResults(i) = MyMWResults(i) + mymolefrac *
vntMWFeedContent(feedcompindex)
MyVolFlowResults(i) = MyVolFlowResults(i) + myvolfrac * myvolflow
MyMassFlowResults(i) = MyMassFlowResults(i) + _
hyCompMassFlow_Feed(feedcompindex)

' Petroleum properties


If usefeedstrmpetprop = NO Then

mypetroproperty = "Flash Point"


mypetropropresult =
GetPetroleumValueByID(hyComponentFeed.IDNumber, _
mypetroproperty)
MyFlashPointResults(i) = MyFlashPointResults(i) + mymolefrac * _
mypetropropresult
If mypetropropresult = EMPTY_ Then
FlashPointprod(i) = 100.01
Else
FlashPointprod(i) = mypetropropresult
End If

Else ' from feedstream

mypetroproperty = "Flash Point"


mypetropropresult =
MyFlashPointResultsFeed(feedcompindex)
MyFlashPointResults(i) = MyFlashPointResults(i) +
mymolefrac * _
mypetropropresult
If mypetropropresult = EMPTY_ Then
FlashPointprod(i) = 100.01
Else
FlashPointprod(i) = mypetropropresult
End If
End If
End If
End If
When the property vectors are populated and all component mapping is
complete, remaining properties are estimated and the flash invoked.
PropvectorMWProd.PointPropertyValue = MyMWResults
PropvectorFlashPointProd.PointPropertyValue = MyFlashPointResults

StrmProdFluid.EstimatePhysicalPropertyVectors

hyProduct.CalculateAsFluid StrmProdFluid, ftTPFlash

8 2 Source Code
Edf
Like other Aspen HYSYS/RefSYS extensions a corresponding edf is required
for a Transition extension. Feed and Product streams are attachments. An
internal switch is provided for available feed stream properties. This is set to
the off position.

2 Source Code 9
10 2 Source Code
3 Example

This chapter provides examples of the source code. It includes the following
topics:
Overview
Installing the Extension
Installing Aspen HYSYS Oil
Installing REFSYS Oil
Building the Flowsheet

Overview
In this example a Aspen HYSYS Oil will be installed and updated with
petroleum properties from Spiral Crude Oil manager. The updated oil will then
be converted to an existing RefSYS Oil that is imported as a csv file. The oil
conversion will take place via the extension transition object. This example
represents a typical scenario in which an Aspen HYSYS Oil is present in an
existing case, however is missing Petroleum Properties such as individual
component and bulk property RON, MON, PONA, Flash Points, Freezing Points
etc. and is then converted to a similar oil represented by a larger component
slate.
The following example will illustrate how to update a legacy Aspen HYSYS Oil
to a RefSYS Oil.

Installing the Extension


Begin the simulation by adding the Transition extension constructed in the
previous section. From the Main menu select Tools, Preferences and click
the Extensions Tab, then Register an Extension and select
myTransitionExtn.

3 Example 11
Installing Aspen HYSYS Oil
In this section an Aspen HYSYS Oil with Bulk Properties will be installed.
Begin a New Case and click the Fluid Pkgs tab in the Simulation Basis
Manager and Add a Fluid Package. Select the Peng Robinson equation and
add the following components:
Component Name

Methane
Ethane
Propane
i-Butane
n-Butane
i-Pentane
n-Pentane
Hexane

Enter the Aspen HYSYS Oil Environment and Add and an Assay. In this
case, only Bulk Properties are available. From the drop down list for Bulk
Properties select Used and enter a Molecular weight of 300MW for the oil and
a Standard Density of 890 kg/m3. Click the Calculate button to build the
Assay curves. Close the view and click the Cut/Blend tab in the Oil
Characterization View.
Add a Blend and Add Assay-1 with the Cut Point Selection set to Auto Cut.
Close the view and Install Oil with the name myOil. myOilwill correspond to
a flowsheet stream with Aspen HYSYS Oil Components.
Leave the Oil Environment and click the Simulation Basis Manager. Next,
update the Aspen HYSYS Oil with Petroleum Properties. This will be done by
selecting a similar oil in Spiral with the same standard density. Click the
Extend Simulation Basis Manager button, Add a Petroleum Assay and
Add Basis-1 to Associated Fluid Pkg. Click the Crude Manager button
and select Arab Heavy (Safaniya) with a density of 0.89 and click the
Transfer to RefSYS button. The Transfer to RefSYS button will gray out
when this step is complete. Close the CrudeManager view.

The Aspen HYSYS Oil is now fully defined and ready for use in RefSYS.

Installing REFSYS Oil


In this step, a RefSYS Oil with Petroleum properties is stored as a csv file and
will be imported into RefSYS. In the RefSYS Petroleum Assay Manager click
the Import button, click the Comma Separated Value File radio button and
the Continue button and select Assay-1.csv file from the examples directory.
Since the csv contains petroleum properties no further work is necessary.

12 3 Example
Note: the petroleum properties of Assay-1.csv can be viewed directly in Excel.
Enter Simulation Environment and keep Ethanol in the component slate.

Building the Flowsheet


Click the stream myOil and enter the following conditions:
FCC Gas Oil

Temperature [C] 25
Pressure [atm] 1.0
Molar Flow 100.0
[kgmole/hr]

Click the Flowsheet icon from the operations Palette F4 and Start with a
Blank Flowsheet. Double click the flowsheet icon in the PFD and enter
myOil as the External Stream in the connections tab. Click on the Transition
tab and select myTransitionExtn from the drop down list. Set T-P
(Temperature-Pressure) as the Transfer Basis. Enter the Sub-Flowsheet
Environment and add a Mixer operation with a single inlet and outlet stream
myRefSsysOil. All properties and conditions will be transferred exactly from
the feed to the product stream of the mixer. Return to the main flowsheet
environment. Set the Outlet Transition type as myTransitionExtn and the
Transfer Basis to T-P. Add an External stream myRefSsysOil in the
Connections Tab and set its Basis to Basis-2. Compare myOil and
MyRefSYSOil. Click the Composition tab of myRefSYSOil and click the Edit
Properties tab and select the Flash Point property. Examine the Flash Points of
the Library and Oil components.

3 Example 13

Вам также может понравиться