This action might not be possible to undo. Are you sure you want to continue?
Aspen Plus 2004.1
Getting Started Customizing Unit Operation Models
Who Should Read this Guide
This guide is suitable for advanced Aspen Plus users who want to customize the unit operation models available in Aspen Plus and create new models. Users should be familiar with the procedures covered in Aspen Plus Getting Started Building and Running a Process Model before starting these examples.
Who Should Read this Guide
INTRODUCING ASPEN PLUS ............................................................................ 6
Sessions in this Manual ............................................................................................. 6 Files Created in these Sessions .................................................................................. 7 Integration Features for Custom Unit Operation Models ................................................. 8 Aspen Plus Excel Unit Operations................................................................................ 8 Aspen Plus Fortran Models......................................................................................... 8 Creating GUI forms for Proprietary Models ................................................................... 8 Supporting Files....................................................................................................... 9
1 CREATING AN EXCEL UNIT OPERATION MODEL......................................... 10
Defining the Simulation........................................................................................... 11 Setting Up the Model in Aspen Plus........................................................................... 12 To Start Aspen Plus ........................................................................................... 12 To Specify the Application Type and Run Type for the New Run ............................... 12 Build the Process Flowsheet ................................................................................ 13 Enter Title, Components, Base Method, and Feed Specifications ............................... 13 Enter Excel Path and User Array Data .................................................................. 15 Setup a Product Stream Flash ............................................................................. 16 Setting Up the Excel Model ...................................................................................... 17 Copy and Examine the Excel Template ................................................................. 17 Edit the Excel Sheets ......................................................................................... 18 Enter Membrane Model Equations and Parameters ................................................. 21 Running the Excel Model ......................................................................................... 22 Examining Simulation Results .................................................................................. 22 To View the Results from the Excel Model ............................................................. 22 To View the Block Results................................................................................... 27
2 CUSTOMIZING THE EXCEL/ASPEN PLUS INTERFACE ................................. 28
Revising the Excel Model ......................................................................................... 29 Revising the User Subroutine ................................................................................... 31 Code Listing – Subroutine MEM2 .............................................................................. 32 Code Description – Subroutine MEM2 ........................................................................ 45 Compiling and Linking the Subroutine ....................................................................... 46
............................................................................................................. 92 Create OCR and OCX Files for Your Model .. 53 Creating a Model Library .................. 83 Create Three Named Controls ............................................................................................................................ 68 Code Description – Subroutine HFUM ................ 60 Create References to the Real and Integer Parameters .......................... 54 Create a Template for Your Custom Model ...................................................................................................................................................................................................................................................................................................................................................................... 47 Running the Simulation......................................................................... 79 5 CREATING AN ASPEN PLUS CUSTOM FORM ..........................................................................................................................................................................................................................................................Compile the Excel Interface Subroutine ....... 63 Check and Edit Setup Sheets ............................................................................................................................................................................................................................ 54 Create an Empty Custom Model Library .............................................................. 81 Creating the Visual Basic Form............................................. 63 Compile............................................................. Link.......... 68 Code Listing – Subroutine HFUM........................................................................................................................................... 95 Results from the Custom Form......................... 64 4 CREATING AN ASPEN PLUS FORTRAN MODEL............................................... 67 Putting the Model Equations in the User Subroutine ... 48 Results from the Custom Excel Model...................................................... 83 Build the Tab Control ...... 96 Contents 4 ........................................................................................................................... 56 Editing the Custom Model............................................................ 46 Create a Shared Library ................................................................................... 77 Running the Simulation....................................... 75 Compiling and Linking the Subroutine ........... 78 Results from the Custom Fortran Model ................ 62 Insert the New Model................................................................................................................................................................................................. 55 Create the Custom Model from the Template............................... 61 Inserting the New Model and Running the Simulation ................................................................................. and Run ....................... 86 Build the Results Control ................................................................... 84 Build the Input Control.. 59 Create a Custom Icon ............................................ 94 Testing the New Form...................................................... 80 Setting Up the Visual Basic Environment ........................ 90 Integrating Forms with Aspen Plus.. 92 Register the OCX File............................. 50 3 CUSTOMIZING THE ASPEN PLUS MODEL LIBRARY.................
..............6 CONNECTING TO THE ASPEN PLUS SIMULATION ENGINE ...............................100 Technical Support ............101 Online Technical Support Center........................................................................................................................................................101 Contents 5 .....................................................101 Phone and E-mail ........................................................................................................................................................................................................... 99 Copyright....................................................................................... 99 Related Documentation............ 98 GENERAL INFORMATION....
Perform model calculations in a Fortran subroutine instead of in an Excel spreadsheet. Sessions in this Manual Follow the steps in this chapter: 1 Creating an Excel Unit Operation Model 2 Customizing the Excel/Aspen Plus Interface 3 Customizing the Aspen Plus Model Library 4 Creating an Aspen Plus Fortran Model 5 Creating an Aspen Plus Custom Form To learn how to: Create a simulation that uses an Excel model to determine product stream properties. Alter the Fortran interface subroutine to accommodate an expanded Excel model. Introducing Aspen Plus 6 . and Excel.Introducing Aspen Plus Aspen Plus offers the option of using custom or proprietary models in Aspen Plus simulations. Create a model with pre-defined parameters for repeated use. Visual Basic. This guide assumes that you are have installed Aspen Plus. The tutorials in this guide illustrate key features of this capability by building a simulation based on an external membrane model and performing the model calculations using either an Excel file or a Fortran subroutine. Even though most users of the customizing options described in this guide are highly experienced with Aspen Plus. Create your own Aspen Plus GUI forms to handle input and results for your custom models. Fortran development software. and Microsoft Excel on your computer. Visual Basic development software. anyone who has completed the tutorials in Getting Started Building and Running a Process Model. This guide is designed for advanced users of Aspen Plus who have a working knowledge of Fortran. will be able to work through the tutorials here by following the step-by-step instructions.
Introducing Aspen Plus 7 .dll.apw ProjectFile.apw Chpt 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 Description USER2 model.obj. Code written by Aspen Plus for named references.ocx ModelName.opt Membrane2.Files Created in these Sessions Filename Membrane1.xls MemCalc. Visual Basic files to for custom Aspen Plus form. DLL file w/ Mem2 subroutine.opt HFUM. Excel calculations.ctl.ctl. USER2 model. TabControlFile.xls Mem2. InputControlFile.ocx ModelName.opt HFUM.dll Membrane2_Loc_dll. DLOPT w/ location of Membrane2.dll. DLOPT w/ location of Mem2. Code w/ model equations. Custom model + custom form. Fortran calculations. Excel file after the run. DLOPT w/ location of HFUM. Custom Model Library created by the user. Excel calculations.opt Membrane2. custom interface. Excel file w/ viscosity and cgs units for use with custom interface.f/obj HFUM_List_OBJs. Excel file after the run.obj.f/obj Membrane2_List_OBJs.obj and Mem2Vars.ctl ProjectFile.obj and Mem2Vars. Fortran calculations. of HFUM.dll Membrane2_CM. no interface. DLL w/ Mem2 and Mem2Vars Custom model.xls MemCalc_Custom. Excel calculations custom interface.apw HFUM.vbp. default interface.f /obj Membrane2_List_OBJs.apm Mem2Vars.opt Membrane2. ResultsControlFile. Code for custom interface. no interface.apw Ultrafiltration. DLOPT w/ loc. Renamed Visual Basic OCX file to be linked to a particular model.obj.ocr HFUM_CF. Excel file for use with default interface (before simulation run).apw MemCalc_PreRun. DLOPT file w/ location of Mem2.xls MemCalc_Custom_PreRun. DLL w/ HFUM and Mem2Vars. Text OCR file containing specifications for custom form.dll HFUM_Loc_dll. Custom model. 5 5 5 5 Visual Basic OCX file containing custom form.
Introducing Aspen Plus 8 . Once you identify the input variables and physical properties used by Excel. or can be dynamically dimensioned based on a user-defined integer variable. You can create: • • • • Custom Model Libraries. You can develop rich data structures for user-defined unit operation models involving integer. real and character data. Aspen Plus Fortran Models Aspen Plus provides utilities for convenient read and write access to named user-defined variables from within the Fortran user model routine.Integration Features for Custom Unit Operation Models Aspen Plus offers powerful features that make it easy to use Aspen Plus simulations containing proprietary models. and standard and default model input templates. Aspen Plus Excel Unit Operations You can use an Excel Workbook as an Aspen Plus user-defined unit operation model. You can utilize the full power of Excel including all of its built-in functions and specialized Visual Basic routines that are provided in the Aspen Plus Excel template. custom icons to better represent the equipment that your models describe. you can develop and test the model within Excel without performing iterative compile and link steps that are required when developing and testing a Fortran model. Vector data can be automatically dimensioned based on nine standard lengths such as Number of Components or Number of Inlet Streams. This simplifies user-defined parameter mapping into external user routines. user-defined variables that become part of the Aspen Plus data structure as an alternative to Real and Integer arrays. User-defined variables can be easily linked to these forms. The forms can have a free format layout to suit the needs of your model. The parameters can either be scalar or vector. Creating GUI forms for Proprietary Models You can create your own user interface forms for proprietary or custom models using the same environment employed to create built-in Aspen Plus forms.
For example. Supporting Files The Aspen Plus backup. Visual Basic template files are distributed with Aspen Plus to help reduce the development effort. combined with the templating capabilities outlined in this guide. it is possible to create forms for an existing plant unit that hides design parameters for users interested in performing rating only calculations. is a very powerful customization capability. Introducing Aspen Plus 9 . Excel. Fortran and Visual Basic files described in this book are delivered in the GUI\xmp directory of the Aspen Plus installation. These forms are easily inserted into Aspen Plus by registering the OCX file created by Visual Basic using the Aspen Plus ApFormSetup utility.The ability to create forms.
Run a simulation. specify feed and product streams. Then use Excel to create a spreadsheet to calculate product stream properties. template. Save a simulation. In particular. View the data in the results sheets. Aspen Plus will write data to and read data from the Excel spreadsheet. First use Aspen Plus to build a process flowsheet. Navigate from form to form using the Data Browser menu tree. or existing simulation). Enter data into the required fields in the input sheets.1 Creating an Excel Unit Operation Model Aspen Plus offers several interfaces for including custom or proprietary models in Aspen Plus simulations. Place blocks and streams. you must be able to: • • • • • • • Start Aspen Plus (using a blank simulation. and enter real and integer parameters corresponding to the membrane. Among these is the option to use a User2 unit operation block in your Aspen Plus simulation with an Excel spreadsheet to perform the calculations. In this session you will create a User2 Excel model for an ultrafiltration membrane. 1 Creating an Excel Unit Operation Model 10 . Allow about 60 minutes for this session. The tutorial sessions in this Getting Started Guide assume that you have completed all of the sessions in Getting Started Building and Running a Process Model.
Large solute species. Figure 1. The solvent and small solute species pass through the membrane and are termed the permeate. Aspen Plus will read the product stream data from Excel. 1 Creating an Excel Unit Operation Model 11 . Excel will calculate product stream data such as mole flow rates and solute concentrations using a user-specified set of equations. There is one feed stream (a water-protein feed).1 Ultrafiltration Membrane Model Aspen Plus will write feed stream data and real and integer membrane parameters (such as physical dimensions) to Excel. are retained by the membrane and are termed the retentate. Results will be displayed in the Excel file and on Aspen Plus results forms. such as proteins. one unit operation block (an ultrafiltration membrane).Defining the Simulation Construct an Ultrafiltration Membrane model. The simulation that you will construct is shown below in Figure 1.1. and two product streams (permeate and retentate). Ultrafiltration is a pressuredriven membrane process used to separate components based on molecular size and shape.
The Aspen Plus Startup dialog box appears. The New dialog box appears. Use this dialog box to specify the application type and the run type for the new run. use an Aspen Plus template. click Start and then select Programs. To Specify the Application Type and Run Type for the New Run 5 Select the General with Metric Units template. Flowsheet. Click OK to apply this option. Select AspenTech | Aspen Engineering Suite | Aspen Plus 2004. In this simulation. The default run type.Setting Up the Model in Aspen Plus To Start Aspen Plus 1 2 From your desktop. Aspen Plus displays a dialog box whenever you must enter information or make a selection before proceeding. Aspen Plus uses the application type to automatically set various defaults appropriate to your application. 3 4 Select Template. 1 Creating an Excel Unit Operation Model 12 . is appropriate for this simulation.1 | Aspen Plus User Interface.
Enter Title. Name the input stream FEED by selecting the stream or its label. Fortran) data to an Aspen Plus array that contains product stream data. Note: If the Connect to Engine dialog box appears. Locate the User 2 icon FILTER in the fourth row of icons. and selecting Rename Stream. The first stream declared also comes first in the data array. 10 Name the block MEMBRANE. It takes a few seconds for Aspen Plus to apply these options. Name the first product stream you created RETENTAT. select the User Models tab. Build the Process Flowsheet 1 From the Model Library. the property method. Go to the Setup | Specifications | Global sheet and enter a title. Drag the FILTER icon to the Process Flowsheet window. Aspen Plus will handle everything but the calculations that correspond to the ultrafiltration process itself. you might call it Membrane1.6 Click OK to apply these options. build the process flowsheet. For this customized simulation. The next step is to enter a title. in the next chapter. rightclicking.1. 1 Creating an Excel Unit Operation Model 13 . Your process flowsheet should look similar to Figure 1. Components. For example. next to the User 2 block icon to display all the User 2 model Move the mouse over the icons to see a name (or label) for each. and feed stream characteristics. see Chapter 6. First. Aspen Plus accepts eight letters and displays them as upper case. Note: It matters which stream was created first because you will be passing Excel (and. specify the components used in the simulation. 2 3 4 5 6 7 8 9 Click icons. and Feed Specifications 1 2 Press F8 to open the Data Browser. Name the second product stream you created PERMEATE. Create one input stream and two product streams. The Aspen Plus main window is now active. and select it. Base Method.
Lysine will stand in as a protein for the purposes of this illustration. so the Component name and Formula fields remain blank. solvent. pressure. 7 8 9 Go to the Properties | Specifications | Global sheet and select the IDEAL model in the Base method field. change the type of units displayed to MassConc. total flow. Go to the Streams | Feed | Input | Specifications sheet. The Component name and Formula are automatically filled in because Aspen Plus recognizes the ID “WATER. type PROTEIN and press Enter on the keyboard. The Solvent field is now available. type LYSINE in the Component name field. 12 Click the Flash Options tab to open the Streams | FEED | Input | Flash Options sheet. 1 Creating an Excel Unit Operation Model 14 . Protein is not in the Aspen Plus databank. type WATER and press Enter on the keyboard. and press Enter on the keyboard.” Another row opens up in the table. 6 In the Protein row. change the type of units displayed to Volume. 10 In the Composition area. 5 In the next Component ID field. In the Component ID field. 11 Enter the temperature.3 4 Go to the Components | Specifications | Selection sheet. In the Total flow section of the State variables area. and protein mass concentration as indicated below. Aspen Plus recognizes the amino acid lysine and fills in the Formula field.
13 In the Valid phases field, select Liquid-Only. Next, specify the location of the Excel file that performs membrane calculations and enter the integer and real parameters that define the physical and calculational characteristics of the particular membrane being used for this simulation. The integer and real parameter user array will also hold results that do not correspond to standard Aspen Plus stream properties.
Enter Excel Path and User Array Data
1 2 Go to the Blocks | MEMBRANE | Setup | Subroutines sheet. In the Excel file name area, enter the full path to the (future) Excel file. For example enter: d:\Program Files\AspenTech\Excel\MemCalc.xls. Important Note: Aspen Plus will accept a maximum of 64 characters for the Excel path. If the Aspen Plus Working Folders directory results in too long a path, choose another folder. No other fields on this sheet need to be specified for this example. In the next chapter, a customized Fortran subroutine is used to interface with the Excel spreadsheet and the name of the subroutine is entered in the Model field in the User 2 subroutines area. A customized Fortran subroutine allows you to control which data is passed between the Excel spreadsheet and Aspen Plus.
3 4 5
Click the User Arrays tab to open the Blocks | MEMBRANE | Setup | User Arrays sheet. In the Number of parameters area, enter 1 in the Integer field, 13 in the Real field, and 13 in the Character field. Enter the parameters as indicated below. The character entries are optional here; they are just for convenience in this example. The last two real parameters are Excel-calculated results and will appear (filled in) in the copy of the User Array table that is written to the Blocks | MEMBRANE | Results sheet after the simulation run.
1 Creating an Excel Unit Operation Model
Next, make a product flash specification to cause Aspen Plus to evaluate the enthalpy and other product stream properties based on the temperature and pressure calculated by Excel.
Setup a Product Stream Flash
1 2 3 4 5 6 Click the Stream Flash tab to open the Blocks | MEMBRANE | Setup | Stream Flash sheet. In the Stream field, select RETENTAT. In the Flash type field, select Temperature & pressure. In the Stream field, select PERMEATE. In the Flash type field, select Temperature & pressure. Save your Aspen Plus file as Membrane1.apw.
1 Creating an Excel Unit Operation Model
Setting Up the Excel Model
An Excel template is available to expedite the specification process. For Excel 97 and 2000, use this template:
. . .\Engine\User\userxlTemplate.xls
Another template named userxlTemplate95.xls is available for use with Excel 95.
Copy and Examine the Excel Template
1 2 Place one of the templates in the folder you specified on the Aspen Plus Blocks | MEMBRANE | Setup Subroutines sheet. Open the template and save a copy as MemCalc_PreRun.xls. Note: Later, save a copy of this file as MemCalc.xls. This second file will be changed by Aspen Plus and you may wish to compare the changed version to the original MemCalc_PreRun.xls. 3 Use the tabs on the bottom of the screen to view the four Excel sheets in the template that contain data. Model calculations will be performed on Sheet 1 (now empty).
The four data sheets and the data they will contain after the simulation is run are listed below: − Aspen_IntParams: One integer parameter read from the Integer User Array (entered on the Blocks MEMBRANE Setup User Arrays Aspen Plus sheet). Aspen_RealParams: Eleven real parameters read from the Real User Array and two results (protein concentration in each product stream) calculated by Excel on Sheet 1. Aspen_Input: The mole flow rates (in kmol/s) of each component of the feed stream and nine stream parameters. Aspen_Output: The mole flow rates (kmol/s) of each component of each product stream and the three product stream parameters that will be calculated by Excel. The other six product stream parameters are calculated by Aspen Plus.
1 Creating an Excel Unit Operation Model
2 3 Select NTUBES and click Insert | Name | Define. The entries in the first two columns are dummies. Aspen Plus will fill in these cells when you run the simulation.Note: The flow rates and nine stream parameters are stored in Aspen Plus in two arrays: MSIN (input streams) and SOUT (output streams). Next. All data read from or written to MSIN or SOUT must be in SI units. 1 Creating an Excel Unit Operation Model 18 . Edit the Refers to field so that NTUBES represents the value in cell B2. Use these variables in the model calculations performed on Sheet 1. Mole flow data must be in kmol/s. Cell B2 will contain the integer parameter from the Aspen Plus User Arrays sheet. Only the NTUBES entry in cell C2 is strictly necessary. Edit the Excel Sheets 1 Edit the Aspen_IntParams sheet as shown below. modify the four Excel sheets to reflect the number of input and output streams and input and output parameters in this example. Define variables to reference data-containing cells. Aspen Plus first transfers input data from MSIN to Excel and then transfers output results from Excel to SOUT.
Again. 5 Define the boldfaced variables (one at a time) in the third column to refer to the cells in the second column. The Fortran interface subroutine reads the actual values of the feed stream properties from the Aspen Plus MSIN array and writes to column B the Excel sheet. select DIAM and click Insert | Name | Define and change C2 to B2 in the Refers to field. Excel will not be able to determine values for cells B13 and B14. To display the equations (instead of an error message) click Tools | Options | View and select the Formulas checkbox.4 Edit the Aspen_RealParams sheet as shown below. Aspen Plus will fill in the first two columns but will not overwrite equations. For example. Edit the Excel Aspen_Input sheet as shown below. The units column is optional. Note: Since CP and CR haven’t been defined yet. 6 1 Creating an Excel Unit Operation Model 19 . the entries in the first and second column are dummies except for the equations in cells B13 and B14.
The four sheets you just built hold data that the Fortran interface subroutine reads from Aspen Plus as well as results that are passed to Aspen Plus. the template comes with a number of “aspen helper” functions built in. and change the last number in the definition. for example. Sheet1. 1 Creating an Excel Unit Operation Model 20 . The ahGetValue function. run the menu command Insert | Name | Define. The equations won’t produce numbers yet because variables such as FP must be determined on Sheet1. Click Tools | Options | View and select Formulas to display the equations. The remaining Excel sheet. Instead of using =DENS_FEED/1000 in cell B9 on Sheet1. change the definition from Aspen_Input!$B$2:$B$12 to Aspen_Input!$B$2:$B$13.Note: If you change the number of input variables. select Tools | Macro | Visual Basic Editor). The first argument of this function is the Aspen_Input variable mentioned previously and the second argument is a first-column string to search for within the specified range. They are implemented as Visual Basic routines (to look at the code. select the Aspen Input variable. Note: To facilitate construction of the Excel model. “DENSITY”) / 1000. you could use =ahGetValue(Aspen_Input. to add one variable in row 13. Create the model by entering equations and parameters on Sheet1. it calculates the product stream properties using input from the first four sheets. The units column is optional. contains the unit operation model equations. The helper functions are described in the Aspen Plus User Models manual. To do this. Edit the Aspen_Output sheet as shown below. For example. lets you refer to data using a label in the first column. 7 8 Define the variables in the fourth column to refer to the cells in the second column. you should redefine the variable Aspen_Input to refer to the new range.
Because there is no data yet. and Aspen_Input sheets.xls file. Save a copy as MemCalc. Notes in column C are optional. 2 3 4 5 6 7 Click Tools | Options | View and clear the Formulas checkbox.xls. Optional: Put sensible data in the Aspen_IntParams. save your MemCalc_PreRun. This file will be altered by Aspen Plus. Turn off formulas in the Aspen_Output and the Aspen_RealParams sheets as well and check that there is a number in each cell. Verify that your equations produce a number in each cell. Variables that are used in other sheets are shown in boldface. Turn on formulas. Once you are satisfied with the Excel ultrafiltration membrane model. Aspen_RealParams. Define each variable in column A to refer to the cell to its right in column B. these numbers are meaningless. 1 Creating an Excel Unit Operation Model 21 .Enter Membrane Model Equations and Parameters 1 Edit Sheet1 as shown below.
xls and then open Membrane1apw. Aspen_Output: Column A already has the correct labels – the interface routine overwrites with the same labels. open MemCalc. Column B contains the eleven real parameters from the Aspen Plus User Arrays sheet that describe the membrane. Column B now contains the input parameters for the feed stream. − − − − 1 Creating an Excel Unit Operation Model 22 . Turn off formulas in each sheet and reformat numbers as needed using the Excel Format | Cells command. Cell B2 contains the number of tubes in the membrane model as specified on the Aspen Plus User Arrays sheet. Note: Opening Excel before Aspen Plus saves startup time. Press F5 to run the simulation. The interface routine reads the data in columns B and C and writes to the Aspen Plus SOUT array. Aspen_Input: Column A already has the correct labels – the interface routine overwrites with the same labels. Column C is not changed.Running the Excel Model The Excel sheet can remain open when the simulation is run. Aspen_RealParams: Column A contains the row number because no labels are specified in the default interface routine. 2 3 Go to the Blocks | MEMBRANE | Setup | Subroutines sheet and verify that the path to the Excel file is correct. enthalpy data is available to Aspen Plus even though it is not calculated by Excel. Aspen_Output_MEMBRANE: This is a new sheet created via a call to EndIteration which copies the contents of Aspen_Output to this new sheet. Cells B12 and B13 contain equations and are therefore not directly changed by the interface routine. Columns B and C are initialized to zero except for the cells containing equations which are not changed. The sheets are changed as follows: − Aspen_IntParams: Column A contains the row number because no labels are specified in the default interface routine. Aspen Plus performs a product stream flash to replace the zeroes in SOUT with data so that. for example. These data are read from the Aspen Plus MSIN array. The subroutine CalculateData invokes the Excel calculations and product stream results appear in cells B2:B6 and C2:C6. 1 If necessary. Examining Simulation Results To View the Results from the Excel Model 1 Examine the altered Excel file.
the data-filled Excel sheets and Aspen Plus results sheets are reproduced here. the equations on Sheet1 determine concentrations and flow rates for the two output streams. Aspen_IntParams: Aspen_RealParams: 1 Creating an Excel Unit Operation Model 23 . The interface routine does not read or write directly to or from this sheet. For convenience.− Sheet 1: Using the feed stream data and real and integer parameters read from Aspen Plus arrays to the Excel sheets.
Aspen_Input: Aspen_Output (and Aspen_Output_MEMBRANE): 1 Creating an Excel Unit Operation Model 24 .
Sheet1: 1 Creating an Excel Unit Operation Model 25 .
Aspen Plus Blocks | MEMBRANE | Stream Results | Material sheet: Aspen Plus Blocks | MEMBRANE | Results | Summary sheet: 1 Creating an Excel Unit Operation Model 26 .
Go to the Blocks | MEMBRANE | Results | Summary sheet to view the real and integer parameter data read from Excel. MemCalc. Save the run.xls.apw will be used in the next chapter. The last two real parameters displayed on this Aspen Plus sheet contain values. Go to the Blocks | MEMBRANE | Stream Results | Material sheet and the Blocks | MEMBRANE | Results | Summary sheet to verify that Aspen Plus data and Excel data are the same. 1 Creating an Excel Unit Operation Model 27 . Aspen Plus read these values from the Excel Aspen_RealParams sheet without regard to units. Aspen Plus did read the correct output values from Excel but it assumed (correctly) that they were in SI units and converted the data to METCBAR units before displaying it on the Stream Results sheet. Save the changed version of your Excel file. This Aspen Plus file. Membrane1. Exit Aspen Plus. 7 8 9 10 Exit Excel. Go back to the Stream Results form and compare the flow rates now reported in kmol/s to those listed in the Excel sheets. the component mole flow rates are reported in kmol/hr instead of kmol/sec. For example.To View the Block Results 2 3 Go back to the Aspen Plus simulation environment. You find that the units are different. 4 5 6 Go to the Setup | Specifications | Global sheet and change the Output results field to SI and run the simulation again.
The new interface routine will create custom labels for the Aspen_RealParams Excel sheet. You need Compaq Visual Fortran 6. More importantly. 2 Customizing the Excel/Aspen Plus Interface 28 . calculated the product stream flow rates. In this session you will revise the interface routine to convert the input data to mass basis and the results data back to mole basis. it will obtain the viscosity of the feed stream by calling the appropriate Aspen Plus built-in subroutines.0 (or a later version) to compile your customized interface routine using the aspcomp command in Aspen Plus Simulation Engine Window. This was necessary because the Aspen Plus MSIN and SOUT arrays expect flow rate data in mole basis. The new interface routine will then pass the viscosity to the Excel model so that the user doesn’t have to enter this parameter by hand (on Sheet1) as in the previous chapter. and then converted back to mole basis in Aspen_Output so that the data could be transferred to Aspen Plus. The Excel model in the previous chapter used Aspen Plus feed stream data in mole basis from the Aspen_Input sheet.2 Customizing the Excel/Aspen Plus Interface Aspen Plus allows the user to customize the Fortran interface subroutine that communicates with the Excel model. By customizing the subroutine. Allow about 60 minutes for this session. converted to mass basis in Sheet1. the user can control which data is passed back and forth and can manipulate the data before or after it is processed in the Excel spreadsheet. The interface subroutine passes feed stream data from Aspen Plus to Excel and it passes product stream data from Excel to Aspen Plus.
B7. converted to the appropriate units. Two rows are no longer needed (PMF and TMF) and three cells (B4.xls. Alter Sheet1 to use the viscosity calculated by Aspen Plus. Change the units in rows 2. 1 2 Open MemCalc_PreRun. 3. and B8) require minor changes.Revising the Excel Model Alter the Excel file from the previous chapter so that when the revised interface routine writes the feed stream viscosity to the Excel Aspen_Input sheet. Add row 13 to the Aspen_Input sheet as shown below.xls and save a copy as MemCalc_Custom_PreRun. The three new equations are shown in boldface. change Aspen_Input. it is passed to Sheet1. Also. 3 4 Define MU_ASPEN to be the viscosity that will be written to cell B13 using the Insert | Name | Define command. 2 Customizing the Excel/Aspen Plus Interface 29 . Convert the viscosity (Aspen Plus always uses SI units) to cgs units and change two equations in the Excel model to use mass basis. Aspen_Output. and 4 to indicate mass basis. and used in the model calculations. and Sheet1 so that they use mass basis.
Change the units in rows 2. 6 7 Save your new Excel file.xls so that you retain the original version after the run. and 4 to indicate mass basis. The new equations are shown in boldface. Make sure this version is stored in the folder specified on the Aspen Plus Subroutines sheet.xls. MemCalc_Custom_PreRun. 3. 2 Customizing the Excel/Aspen Plus Interface 30 .5 Alter the Excel Aspen_Output sheet to calculate component flow rates in mass basis. Save a copy of the new Excel file as MemCalc_Custom.
For example. The complete revised subroutine is listed below with changes marked. 1 Put a copy of \Engine\User\usrxls.Revising the User Subroutine The code for the default subroutine provides a template that will make creating the customized subroutine easier.f. Numbers in parentheses following the boldface comments refer to the relevant part of the Code Description that follows the listing. 2 3 2 Customizing the Excel/Aspen Plus Interface 31 . copy this file to d:\Program Files\AspenTech\Working Folders\Aspen Plus\Membrane\Mem2. Some of the comments from the template (usrxls. Edit the file as indicated in the code listing that follows.f) have been shortened while others have been added.f and change the name of the subroutine to Mem2.f in a folder in your working directory. Open Mem2.
(NMATI. REALV. ITYPE(NSUBS).3). INTV(NINT). Declare variables used in dimensioning first. SINFO. -------------NMATI. NTOT. IDXSUB. INTV. SUBROUTINE MEM2 2 3 4 5 6 7 C IMPLICIT NONE C C C INTEGER + + INTEGER + + + REAL*8 + + C C-------------------. NIWORK. NIWORK. NWORK. NMATO.NMATI). NPO. NINFO. SINFO(NINFO). REALV(NREAL) WORK(NWORK). SINFI. NINFI. SINFI(NINFI). NSUBS. NPO. NREAL.NINFI). NSUBS. NREAL IDSMI(2. LD MSIN(NTOT. IDSIO(2. IDS(2.NMATO). IDSIO. ITYPE. ESIZE(NSIZE). INTSIZ(NSIZE). ESIZE. NINFO.NMATO). IWORK(NIWORK).Aspen Plus Common Definitions Start in Column 1. IDSMO. NWORK. NTOT. IDSII(2. NSIZE. IDSMI. IDXSUB(NSUBS). MSIN.Code Listing – Subroutine MEM2 C C C C C You can use any subroutine name up to six characters as long as you identify the name on the Blocks BLOCKNAME Setup Subroutines sheet in Aspen Plus. SOUT(NTOT. NSIZE. SOUT. IDSMO(2. The argument list must not be lengthened or shortened. NINT. IDS. NMATO. INTSIZ. WORK. NBOPST(6. NINFI. IDSII.NINFO). IWORK.NPO).NMATI). LD ) User2 Unit Operation Model Subroutine for Excel Models 2 Customizing the Excel/Aspen Plus Interface 32 . then other variables. NBOPST. NINT.
KINPUT(2). IDX(10).Declare Aspen Plus utility functions that will be used.NCOMP_NCC+10) REALROWS(2. SSID(2). ERRNUMBER. SOURCE(16). !Moved LABELS and ROWNAMES declarations. LEN. X(10) RealLabels(13) REAL*8 INSTREAM(NTOT*NMATI). (1) !Hollerith Realparam row ID's. 4HUT / 2 Customizing the Excel/Aspen Plus Interface 33 . KDIAG. DMS_IFCMNC C C--------------------.Data Section ----------------------------C DATA KINPUT DATA KOUTPUT /4HINPU. KOUTPUT(2). NUM_LINES. NUM_ROWS. 4HT / /4HOUTP.J. LID. DESCRIPTION(128) KINPSOL(3).OUTSTREAM(NTOT*NMATO) C C--------------------------.NTOT+1) LMW.KOUTSOL(3). EXCEL_NAME_LEN.cmn" #include "ppexec_user. -----C INTEGER DMS_IRRCHK.Local Variable Declarations -------------------C INTEGER + + + + + + + Integer Integer Integer Real*8 Character*8 OFFSET.C #include "dms_errout. IBLANK(2).cmn" #include "dms_plex. KREAL(3). (1) !Ten labels instead of nine.10). IPROG(2).IB(1)) C C-------. HOL_STRLEN. RETCODE. LDATA. C_OFF. NCD. (2) !Conversion and Viscosity. KINT(3). DESC_LENGTH. (4) !Realparam row ID's. SOR_LENGTH. XMW.cmn" #include "dms_ncomp.K. (3) !Calc component mass flow. ROWNAMES(2. EXCEL_NAME(16). NCP FLOW. I. LIDSC. NUM_COLS. (5) LABELS(2.cmn" REAL*8 B(1) EQUIVALENCE (B(1).
Establish Excel link and call StartIteration Workbook Hook Function C CALL USRUTL_GETEXCEL(EXCEL_NAME. 4HMS / /4HINTP. 4HENTH. + + + + + + + + + 4HTEMP. 'Pperm '. '. ' / C---------------------------------------------------------------------C. 4HLIQ . 4HMUMX. 4HPARA. (7) 'Dab '. '. 4HVAP . 'DeltaP '.DATA KREAL DATA KINT DATA KINPSOL DATA KOUTSOL DATA IPROG DATA IBLANK /4HREAL. 4HENTR. 4H / /4HOUT_. '. 4HALPY. '. (6) . 4HLOW . 4HARAM. '. 'Cp 'Cr '. 4H / /4HUSRX. '. 4HDENS. 4HS / DATA LABELS /4HTOTF. 4H . 4H WT . 4H . 4H 4HPRES. 4H . EXCEL_NAME_LEN) 2 Customizing the Excel/Aspen Plus Interface 34 . DATA RealLabels /' + + + + + + + + + + + + x 'L 'Cg 'R 'C1 'C2 'C3 'C4 '. '. 4H / !MUMX is viscosity label. 4HOPY . 4HLS / /4HIMIS. 4HITY . 4HS / /4HINP_. !Labels for Realparam table (each total eight chars). 4HMOLE. 4HFRAC. 4HFRAC.
K) END DO NUM_ROWS = NCOMP_NCC + 10 !9!10 (8) !9!10 (8) C C C C Now fill in column 2 (using the INSTREAM array) with Aspen Plus feed stream data ( from the MSIN array). 8) IF(RETCODE . OFFSET = DMS_IFCMNC('IDSCC') DO J=1.J) = IB(I) ROWNAMES(2.K) ROWNAMES(2. list the nine standard stream properties plus any extras (in this case.J) = IB(I+1) END DO C C After the component names.NE. Convert to mass basis using molecular weights. NCOMP_NCC I = OFFSET + 2*(J-1) + 1 ROWNAMES(1. there is one extra).Build Aspen_Input Data Table ------------------------C C C C C First get name of each of the NCOMP_NCC components for first NCOMP_NCC rows in column 1 of the table.J) = LABELS(1. DO K=1. 0) GOTO 1000 C--------------. IDS(1.64.J) = LABELS(2. 10 J = K + NCOMP_NCC ROWNAMES(1. Also have Aspen Plus calculate viscosity of feed stream. Make a column for each feed stream. Component names in column 1 label component flow rates in column 2. (9) LMW = DMS_IFCMNC('MW') NUM_COLS = NMATI 2 Customizing the Excel/Aspen Plus Interface 35 . !Will need molecular weights of individual !components to do flow rate conversions. Names are in two four letter blocks.1).CALL StartIteration(RETCODE. EXCEL_NAME.
8 !Convert total mole flow to total mass !flow using molec wgt of stream.DO J=1. NUM_COLS OFFSET = (J-1)*(NCOMP_NCC+10) DO I=1. ROWNAMES.J)*XMW END IF IF (I .NE. (12) !Convert and fill INSTREAM. KINPUT. IDX. 0) GO TO 1000 2 Customizing the Excel/Aspen Plus Interface 36 .J). NUM_ROWS IF (I . NBOPST. NCP. NUM_ROWS. IDSMI . RETCODE) !To do last row (10) !"pack" data !then get !viscosity. NUM_ROWS) THEN Call SHS_CPACK(MSIN(1. FLOW) KDIAG = 4 K = NCOMP_NCC Call PPMON_VISCL(MSIN(K+2. NCOMP_NCC+1) + INSTREAM(OFFSET+I) = INSTREAM(OFFSET+I)*MSIN(I+8.EQ. 8 + + 8 . (11) !9!10 (8) . LDATA ) IF (RETCODE . X. !If doing flow rates.J). !make XMW molecular wgt. IDX. .2 . ---------------------LDATA = 8*NUM_ROWS*NUM_COLS CALL WRITETABLE(RETCODE .J). NCP. (13) !Only convert flow rates. INSTREAM(OFFSET+I). INSTREAM.Send Aspen_Input table to Excel.LE. NUM_COLS. KDIAG. NCOMP_NCC) XMW = B(LMW + I) INSTREAM(OFFSET + I) = MSIN(I.EQ.J) END DO END DO C--------------. MSIN(K+3. + + ELSE XMW = 1 IF(I . X.
1 . NINT . Length to Excel. IDSMO . IBLANK. KOUTPUT. 0) GO TO 1000 C-------. (15) . NREAL . RealRows(1.NE.2 . 8 + + ROWNAMES.NE. REALV.LDATA ) IF (RETCODE . 1 .Send Aspen_IntParams table to Excel. 2 .LDATA ) !Send Labels. OUTSTREAM.NE. --------------------LDATA = 8*NINT CALL WRITETABLE(RETCODE. 12 .Initialize the Aspen_Output Excel table.I). !Make the 13 labels into Holleriths. KINT. 8 . 0) GO TO 1000 2 Customizing the Excel/Aspen Plus Interface 37 . LDATA ) IF (RETCODE . NUM_ROWS. IBLANK. + + RealRows. KREAL. 13 CALL USRUTL_CHARTOH(RealLabels(I). 1 .C-----------. 8 8 . 0 .D0 END DO END DO NUM_COLS = NMATO LDATA = 8*NUM_ROWS*NUM_COLS CALL WRITETABLE(RETCODE . + + IBLANK . (14) IF (RETCODE . INTV. NUM_COLS . --------------------NUM_ROWS = NCOMP_NCC + 9 DO J=1. . NUM_ROWS OUTSTREAM(OFFSET+I) = 0. 12 .Send Aspen_RealParams table to Excel. 0 . ------------------DO I = 1. !No viscosity for output streams. 0) GO TO 1000 C-------------. 8) END DO LDATA = 8*NREAL CALL WRITETABLE(RETCODE. NMATO OFFSET = (J-1)*(NCOMP_NCC+9) DO I=1. 0 .
1) Then C Build the input tale for each solid substream DO K=2.NSUBS IF (ITYPE(K) . The name of substream will be appended onto the sheet name. The component names and stream properties for this stream will be prepared similarly to Aspen_Input. IF (NSUBS . NSUBS will be greater than 1 if any solid substreams exist. another Excel sheet will be created as the interface with a separate sheet being created for each substream.J) = IB(LID+1) ROWNAMES(2. NCD LID = LIDSC + 2*(J-1) ROWNAMES(1.C C------------. a sheet called Aspen_INP_CISOLID will be created for the CISOLID substream.EQ. For example.Solid Substream Section -------------------------------C C C C C C C C C C When a simulation contains either conventional or nonconventional solids. A separate column will be used for each feed.J) = IB(LID+2) END DO C C Place stream property labels in column 1 DO J=1.GT. 3) THEN C Nonconventional solid LIDSC = DMS_IFCMNC('IDSNCC') NCD = NCOMP_NNCC ELSE C Conventional solid LIDSC = DMS_IFCMNC('IDSCC') NCD = NCOMP_NCC ENDIF DO J=1. 9 I=NCD+J 2 Customizing the Excel/Aspen Plus Interface 38 .
NUM_ROWS.J) ROWNAMES(2.I) = LABELS(2.ROWNAMES(1. K. . KINPSOL. 8 8 . INSTREAM. NUM_COLS OFFSET = (J-1)*(NCD+9) DO I=1. NUM_COLS.2 . NCD+9 INSTREAM(OFFSET+I) = MSIN(IDXSUB(K)+I-1. 12 + + C C Initialize the Excel output interface for the substream NUM_COLS = NMATO DO J=1. LDATA ) .J) END DO NUM_ROWS = NCD+9 C C C Append the substream name onto the end of the input and output Excel sheet name. IDSMI . CALL SHS_PID(LD. NCD+9 OUTSTREAM(OFFSET+I) = 0.D0 END DO END DO ROWNAMES. NUM_COLS OFFSET = (J-1)*(NCD+9) DO I=1.NE.J) END DO END DO C C Send interface table to Excel LDATA = 8*NUM_ROWS*NUM_COLS CALL WriteTable(RETCODE .I) = LABELS(1. 0) GO TO 1000 2 Customizing the Excel/Aspen Plus Interface 39 . IF (RETCODE . SSID) KINPSOL(2) = SSID(1) KINPSOL(3) = SSID(2) KOUTSOL(2) = SSID(1) KOUTSOL(3) = SSID(2) C C Register the stream data NUM_COLS = NMATI DO J=1.
temperature and pressure.2 . KINT. 12 + + ROWNAMES.Invoke Excel Workbook Calculations ---------------------CALL CalculateData(RETCODE) IF (RETCODE . NUM_ROWS.NE. 8 8 . Send interface table to Excel IF (RETCODE . + 1 IF (RETCODE .NE. 12 . LDATA = 8*NINT CALL READTABLE(RETCODE. NREAL. . 0) GOTO 1000 C C C Read product stream data from Excel Aspen_Output sheet to OUTSTREAM. LDATA = 8*NREAL CALL READTABLE(RETCODE. 0) GOTO 1000 C---------. OUTSTREAM. .2 . 0) GO TO 1000 END DO End If CC-----------. 0) GOTO 1000 C -. INTV. LDATA) 2 Customizing the Excel/Aspen Plus Interface 40 . KOUTSOL. 12 .Read back real parameter table in case it has results.NE. NINT . + 1 IF (RETCODE .NE. NUM_COLS . total flow rate. 1 . KREAL. LDATA) . Only have component flow rates.C C C NUM_ROWS = NCD+9 LDATA = 8*NUM_ROWS*NUM_COLS CALL WriteTable(RETCODE . REALV.Read Excel values into Aspen Plus Arrays ---------C----. IDSMO . LDATA ) .Read back integer parameter table in case it has results.
pres. NCOMP_NCC+1) THEN SOUT(I. OUTSTREAM.J) = OUTSTREAM(OFFSET + I) END IF END DO END DO C---------------------------------------------------------------------!Total flow to SOUT (3rd row). 8 + NUM_COLS. NUM_ROWS IF(I . NMATO FLOW = 0 OFFSET = (J-1)*NUM_ROWS DO I = 1.J) = FLOW ELSE SOUT(I. 2 Customizing the Excel/Aspen Plus Interface 41 . This time get total mole flow by just adding up component mole flows. 2 IF (RETCODE .J) ELSE IF(I . !Convert flow rates to mole !basis and fill Aspen Plus array.C C C First column of data (the retentate stream data) comes first in the 1 dimensional OUTSTREAM array. SOUT expects flow rate data in mole basis so convert back to mole basis using molecular weights. NUM_ROWS = NCOMP_NCC + 3 NUM_COLS = NMATO LDATA = 8*NUM_ROWS*NUM_COLS CALL READTABLE(RETCODE . J) = OUTSTREAM(OFFSET+I)/B(LMW+I) FLOW = FLOW + SOUT(I. (16) C C C C C C C C DO J = 1. NUM_ROWS. . (17) ! Holds the total mole flow. (17) !For other rows. Retentate stream was placed first and it must also be listed first in the Excel Aspen_Output sheet. Put results from two product streams (OUTSTREAM array) in Aspen Plus product stream array (2 dimensional SOUT). The first stream placed by the user on the Aspen Plus process flowsheet comes first in SOUT. NCOMP_NCC) THEN SOUT(I. temp. 0) GOTO 1000 .EQ.LE.NE. The second dimension of SOUT is the number of streams. (17) !Store total. LDATA ) ! 9!3. Two flow rates + tot flow. just fill array. KOUTPUT.
LDATA ) 2 Customizing the Excel/Aspen Plus Interface 42 . 3) THEN NCD = NCOMP_NNCC ELSE NCD = NCOMP_NCC ENDIF CALL SHS_PID(LD.GT.NE. KOUTSOL. NCD+9 SOUT(IDXSUB(K)+I-1.NSUBS IF (ITYPE(K) . NMATO OFFSET= (J-1)*(NCD+9) DO I=1.C For solid substreams. . 2 IF(RETCODE . J) = OUTSTREAM(OFFSET+I) END DO END DO END DO End If C--------------. OUTSTREAM. obtain product info from Excel interface sheets C IF (NSUBS . 1) Then C C Retrieve data for each substream DO K = 2.EQ.End of Current Iteration ----------------------------NUM_COLS. 0) GO TO 1000 . NUM_ROWS. K. 12 + C C Store data into outlet stream vector DO J=1. SSID) KOUTSOL(2) = SSID(1) KOUTSOL(3) = SSID(2) C C Read Excel interface product sheet for substream NUM_ROWS = NCD+9 NUM_COLS = NMATO LDATA = 8*NUM_ROWS*NUM_COLS CALL ReadTable(RETCODE .
4. I=1.(SOR_LENGTH+3)/4) ERRNUMBER.Error Handling Section ---------------------1000 CONTINUE C C ALL ERRORS COME HERE TO REPORT ERRORS C C Call GetLastTableDataErr() C C HOL_STRLEN SETS THE PADDING FOR ERROR HANDLING STRING RETURNED C FROM THE EXCEL INTERFACE. WILL BE PRINTED C TO HISTRY FILE BY ERRPRT(). 10) WRITE(ERROUT_IEROUT(2). USER_IUMISS. + 0. C REGISTER SEVERE SIMULATION ERROR FROM USER2 WITH ENGINE 2 Customizing the Excel/Aspen Plus Interface 43 . WRITE(ERROUT_IEROUT(1).NE. 0. DESC_LENGTH. 2) . 4. !No more changes. 8 ) NUM_LINES = 8 C MOVE STRINGS TO ERROUT_IEROUT ARRAY OF STRINGS. SOURCE.CALL EndIteration(RETCODE) RETURN C C--------------. 1. 11)(SOURCE(I). 0) THEN C DETERMINE NUMBER OF LINES OF LENGTH HOL_STRLEN TO PRINT C MAX IS 10 SO WE CAN USE 8 FOR DESCRIPTION OF ERROR NUM_LINES = ( (DESC_LENGTH+HOL_STRLEN-1) /HOL_STRLEN) IF (NUM_LINES . C HOL_STRLEN = 64 DESC_LENGTH= 512 SOR_LENGTH = 64 CALL GetLastTableDataErr(RETCODE.GT. FIRST WRITE "MS Excel" THEN SOURCE C STRING RETURNED BY API AS ERROR HEADING. HOL_STRLEN.End of Current Iteration ------------CALL EndIteration(RETCODE) RETURN C-----------------------. + + SOR_LENGTH) USER_ICONVG = -3 IF (DMS_IRRCHK(IPROG. DESCRIPTION.
16A4) 10 FORMAT(' 11 FORMAT(' END 2 Customizing the Excel/Aspen Plus Interface 44 . CALL DMS_ERRPRT(NUM_LINES+2) ENDIF C END ERROR REPORTING TO HISTORY FILE 2000 CONTINUE C Call EndIteration() C EndIteration IS CALLED EVEN WHEN A SEVERE ERROR OCCURS ABOVE. I=1.NUM_LINES C_OFF = (J-1) * HOL_STRLEN/4 WRITE(ERROUT_IEROUT(J+2). CALL EndIteration(RETCODE) 999 CONTINUE C FORMAT STATEMENTS MS EXCEL Interface Reports:') '.(HOL_STRLEN+3)/4 ) CONTINUE C PRINT ERROR MESSAGES TO HISTORY FILE USING THE FIRST NUMLINES+2 C LINES OF THE ERROUT_IEROUT ARRAY OF STRINGS. 11) + 111 ( DESCRIPTION(I+C_OFF).C WRITE ERROR MESSAGE RETURNED FROM EXCEL API TO THE HISTORY FILE DO 111 J=1.
XMW will hold the molecular weight data for a given component. There are now 10 rows in the Aspen_Input and Aspen_Output tables in addition to the NCOMP_NCC = 2 rows that correspond to the component flow rates so DO loops have to be lengthened. The PPMON_VISCL subroutine needs a packed stream array when it calculates stream viscosity. The user subroutine includes the following statements: #include "dms_plex. We want to add labels (stored in REALROWS) to the Aspen_RealParams table. FLOW will hold the total mole flow for the output streams.IB(1)) These statements allow the subroutine to access component data. The molecular weight of the first component will be found at B(LMW + 1) where LMW is the offset returned by the function.Code Description – Subroutine MEM2 1 The MUMX (viscosity) addition to the list of stream properties means that there will be 10 properties read from Aspen Plus instead of the usual 9 so LABELS and ROWNAMES must be redimensioned. 10 The subroutine SHS_CPACK “packs” the stream array by determining which components are actually present (have a non-zero flow rate) and putting their mole fractions in the X array. 2 3 4 5 6 7 8 9 2 Customizing the Excel/Aspen Plus Interface 45 . RealLabels is a character array for the labels of the Aspen_RealParams Excel sheet that will be converted to Hollerith format. LMW will hold the “offset” to the location of the molecular weight data for each component. MUMX is stored in Hollerith format and will be written to the Aspen_Input and Aspen_Output Excel sheets along with the standard nine stream property labels. Labels for the Aspen_RealParam table are entered explicitly as a character array. The character strings to feed to the DMS_IFCMN function are listed in the Universal Constant Names and Definitions table in Chapter 6 of the User Models manual. DMS_IFCMNC is an integer function that determines the location of the data such as molecular weight and critical temperature that corresponds to each component. X will contain the mole fraction of each component actually present in the stream and is sent to the Physical Property Monitor subroutine PPMON_VISCL which calculates the viscosity of the stream.cmn" REAL*8 B(1) EQUIVALENCE (B(1). NCP will hold the actual number of components present in the stream.
vapor fraction. enthalpy. and 8 other properties as MSIN (see item 13 above). the viscosity is placed in the INSTREAM array.OBJ files and another tells Aspen Plus where to find the DLL being used for a particular run. pressure. entropy. Compile the Excel Interface Subroutine 1 Save your customized Fortran file as Mem2. density. 14 The subroutine USRUTS_CHARTOH converts the explicitly entered character labels into Hollerith format so that they may be sent to the WRITETABLE subroutine. 12 The “B” array is used to get the molecular weight which is used to convert component flow rates. The first two (NCOMP_NCC) are the component mole flows.OBJ file and ensure consistent compiler options. The MSIN and SOUT arrays contain component and total flow rates in mole basis (kmol/s) and eight other properties in standard SI units. 16 Since the Excel model only calculates flow rates. there is no point sending it a bunch of zeroes for the other properties.f. These are listed in Appendix C of the User Models manual and these are the data that appear in the Aspen_Input and Aspen_Output Excel sheets. 13 The total mole flow is the third (NCOMP_NCC + 1) entry in the Aspen Plus stream input array called MSIN. liquid fraction. temperature.11 The subroutine PPMON_VISCL returns the viscosity of the stream. and molecular weight. When the SOUT array is filled with the OUTSTREAM values. Two “DLOPT” (dynamic linking option) files control the linking process: one creates a DLL from specified . The next eight stream properties are temperature. The properties that Excel does calculate are placed in OUTSTREAM when READTABLE is called. 15 Only the viscosity of the feed stream is calculated so the output table still has the usual (NCOMP_NCC + 9) rows. 17 The array SOUT contains the same NCOMP_NCC component mole flows. and pressure. Compiling and Linking the Subroutine The aspcomp command delivered in the Simulation Engine DOS prompt window will create the . 2 Customizing the Excel/Aspen Plus Interface 46 . these data will be available in Aspen Plus results sheets. The integer variable NCOMP_NCC is equal to the number of conventional components (in this case 2) declared in the Components Specifications Selection sheet and is passed through the common DMS_NCOMP also included in this subroutine. total flow. In the subroutine in this example.
2 Launch the Aspen Plus Simulation Engine Window.opt.1 | Aspen Plus Simulation Engine.f. 3 Use the DOS cd command to set the default directory to the location of Mem2. In the top line of this file type the full path to membrane2.opt] membrane2. (From the Start menu click Programs | AspenTech | Aspen Engineering Suite | Aspen Plus 2004.\membrane\Mem2. 5 6 Create another DLOPT text file called Membrane2_Loc_DLL.dll using all the object files in the default directory. 4 Create a Shared Library 1 2 Use a text editor such as Notepad to create a text file called Membrane2_List_OBJs. type cd membrane if your Fortran file is in a subfolder called membrane in your working directory. In the DOS window of the Aspen Plus Simulation Engine. 3 4 Save the file and exit the text editor. Type aspcomp Mem2 to compile the subroutine. it can be used with Aspen Plus even if you don’t have a Fortran compiler available. . 2 Customizing the Excel/Aspen Plus Interface 47 .) A DOS window appears with the working directory as the default directory. . A file called membrane2. For example.obj in the top line of the text file. Keep the DOS window available for the linking step and use a text editor to create a DLOPT file to control the creation of a shared library (also known as a dynamic linking library).opt. Once you have the shared library. An object file (Mem2. Type the full path to Mem2. type asplink [dlopt membrane2_list_objs.f.obj) is created in the same directory as Mem2.dll is created. Using a shared library avoids the need for a linking step when Aspen Plus runs. Note: If you simply type asplink membrane2 Aspen Plus will create membrane2. This is a Fortran shared library.dll.obj. For example: D:\Program Files\ .
Put a copy of the Membrane2_Loc_DLL.xls. change the name of the Excel file to MemCalc_Custom. and make sure SI units are selected for the output. Note: If you have both the GUI and the Simulation Engine Window open at the same time. you can run the simulation using membrane1.opt in your Aspen Plus Working Directory. On the Subroutines sheet. Go to the Blocks MEMBRANE Setup Subroutines sheet and type MEM2 in the Model field in the User2 subroutines area so that Aspen Plus knows what your new subroutine is called. Running the Simulation Now that you have your revised Excel file and have created a shared library containing your customized Fortran subroutine. change the title to membrane2.7 8 Save the text file and exit the text editor. select Run | Settings. 2 Customizing the Excel/Aspen Plus Interface 48 . At run time.apw from the previous chapter. you will tell Aspen Plus the name of this file so that the shared library will be available. Select Run | Reinitialize (or press Shift-F5) and click OK twice to clear data from the previous run. an asplink command will fail unless you reinitialize the open run. 1 2 Open membrane1apw. 3 4 Go to the Setup Specifications Global sheet. The Run Settings dialog box appears. 5 6 From the Aspen Plus menu.
11 Save the run as membrane2. 8 9 Click OK.opt so that Aspen Plus knows the name of the file containing the location of the library that contains your customized subroutine.apw and exit Aspen Plus. Note: You can change the default Aspen Plus working directory in the Tools | Options | Startup tab. The membrane2_loc_dll.opt file must be saved in the same directory as the simulation file. This DLOPT file must be in your Aspen Plus Working Folder. 10 Compare your Aspen Plus and Excel Results to those displayed below. 2 Customizing the Excel/Aspen Plus Interface 49 .7 In the Linker options field in the Miscellaneous files area type membrane2_loc_dll. Run the simulation.
It now contains labels in column A specified in the interface routine. The Excel Aspen_RealParams sheet appears below. It now contains viscosity data as calculated by Aspen Plus. The Excel Aspen_Input sheet appears below. The original label “Aspen Viscosity” was overwritten with the new label “MUMX” specified in the interface routine. The value of Cr in cell B14 is slightly different from that in the previous chapter because the viscosity used in this example is more accurate: 2 Customizing the Excel/Aspen Plus Interface 50 .Results from the Custom Excel Model For convenience Excel and Aspen Plus sheets are shown here.
The Aspen Plus Blocks | MEMBRANE |Stream | Results | Material sheet: 2 Customizing the Excel/Aspen Plus Interface 51 . It contains flow rates in mass basis.The Excel Aspen_Output sheet appears below.
The Aspen Plus Blocks MEMBRANE Results Summary sheet: 2 Customizing the Excel/Aspen Plus Interface 52 .
Create a custom icon for your model. In the previous chapter you entered a set of real and integer parameters for the physical characteristics and calculational coefficients of the model using the Aspen Plus User Arrays data sheet. Then replace the User 2 block in membrane2. Allow about 30 minutes for this session. create a new Aspen Plus Library. In addition.apm.apm extension) and displayed in the Model Library palette. Ultrafiltration.apw with your custom block and run the simulation again. 3 Customizing the Aspen Plus Model Library 53 . In this session. With a customized unit operation model. Use the same model parameters as in the previous chapter to specify the membrane characteristics. The icon itself can be custom drawn. the name of the user Fortran subroutine and Excel file can be associated with the customized model. you can enter these parameters once and they will be automatically included whenever the customized block is placed on the Process Flowsheet. thereby simplifying the code. This data can be accessed in the user Fortran subroutine by referring to the variable names.3 Customizing the Aspen Plus Model Library Your customized Excel model can have its own unit operation model stored in an Aspen Plus Library file (. Finally. a Configured Variables sheet is available in which the set of real and integer parameters are associated with character strings and identified as input or output. containing a customized model for the ultrafiltration membrane.
Create an Empty Custom Model Library 1 2 3 Create a sub-folder in your Aspen Plus Working Folder called. 4 5 In the Enter Display Name field. to contain library files. Select Library | New. for example. The present hollow fiber ultrafiltration membrane has 180 tubes but another might have only 90. type Ultrafiltration. 3 Customizing the Aspen Plus Model Library 54 . Each model is represented by an icon (multiple icons may be created and used for strictly aesthetic reasons) and has default parameters associated with it. They could be represented as separate models. Click (it’s a Browse button) and navigate to the directory where you wish to store library files. The Create Aspen Plus User Model Library dialog box appears. lib.Creating a Model Library A model library has three levels: the library itself consists of a set of categories each identified by a tab in the Model Library palette. Open an Aspen Plus blank simulation. Each category consists of a set of models. The New User Model Library dialog box appears.
6 7 Click Save. type the path the Excel file that contains the equations for the model.xls. Create a Template for Your Custom Model 1 2 3 4 From the Model Library. For example. It gets the default ID B1 Open the Data Browser and go to the Blocks B1 Setup Subroutines sheet. In the Model field. Click the User Arrays tab and enter the same real and integer parameters as in the previous chapter including two empty real parameters for results data. type Mem2. You have created an empty library. type the name of the Fortran subroutine that will be used with the customized block. place a User Models User 2 FILTER block on the process flowsheet. The previous dialog box reappears. In the Excel file name area. The next step is to create a template that contains default parameters for your customized model. 5 3 Customizing the Aspen Plus Model Library 55 . d:\Program Files\AspenTech\Excel\MemCalc_Custom. Click Create. It contains no categories and no models. For this example.
The Add Custom Model Type to User Model Library Wizard dialog box appears. . Select your template block. and select your library (Ultrafiltration). Note: If you start Aspen Plus in the future and find the Add to Model Library option unavailable. select Library | References . right click. Select Library | Save Default to make sure the selected library is available whenever you start Aspen Plus.Now your template is prepared and you are ready to create the customized model. Create the Custom Model from the Template 1 2 Go back to the Process Flowsheet. Then select Library | Ultrafiltration | Writable so that you can edit it or add a model to it. 3 Customizing the Aspen Plus Model Library 56 . and select Add to Model Library.
click Create New Category. Aspen Plus will automatically save the new model at the end of the creation process. The Choose Custom Model Category dialog box reappears. and click Next. 4 5 In the Choose Custom Model Category dialog box. Type Membranes and click OK. Note: If you leave the Save User Model Library after Addition box checked. 3 Customizing the Aspen Plus Model Library 57 .3 Select Add: Create a new ….
The Choose Single Block or Multi Record Custom Model Type dialog box appears.6 Select Membranes and click Next. Choose any icon option. 8 9 Replace B1 with HollowF. 7 Select Single Block Custom Model and click Next. The Choose Custom Model Type Creation Options dialog box appears with the block ID (B1) entered automatically. you will delete the icon and create a custom icon. 3 Customizing the Aspen Plus Model Library 58 . Later.
rename it. 17 Exit Aspen Plus.10 Make sure the Copy/create model template checkbox is selected. The defaults for the HollowF model remain intact. Aspen Plus will copy the data you entered on the Subroutines sheet and on the User Arrays sheet into the new model. Aspen Plus automatically saves the new library. The Add Custom Model Type to User Model Library Wizard appears automatically. The model you created is visible. delete the path to the Excel file and use a revised Fortran subroutine to perform the model calculations. you will have access to the HollowF unit operation model with default user subroutine name. 15 From the Model Library. Aspen Plus will make the Configured Variables sheet available to the new model so that you can associate variable names with your real and integer parameters. drag a HollowF unit operation model onto the Process Flowsheet. the Save option should be shaded. however. whenever you start Aspen Plus and select Library | References and click the Ultrafiltration checkbox. The HollowF model can be edited. in the next chapter. 13 In the Model Library click the Membranes tab. Excel file path. redraw the icon. you can overwrite the default entries to the Blocks | BLOCKNAME | Setup | Subroutines and User Array sheets.) A tab for the Membranes category of the Ultrafiltration library now appears alongside the tabs of the Built-in library. (Select Library | Ultrafiltration. 16 Open the Data Browser and go to the Blocks B1 Setup form and check that the default data appears correctly on the Subroutines sheet and on the User Arrays sheet. Note: Any Aspen Plus model from the Model Library can be moved into the new library by dragging the icon into the Model Library Editor (select Library | Ultrafiltration | Edit to open the Editor). This change only affects the block to which it is applied. you will place a HollowF block. 12 Click Finish. and real and integer parameters. and add named variables that refer to 3 Customizing the Aspen Plus Model Library 59 . Editing the Custom Model When you use a model from a custom library.apm. in the following ways: you can delete it. 11 Make sure the Copy/create user model configuration checkbox is selected. There is no need to save an apw file since the library is already saved as Ultrafiltration. 14 Delete the block on the Process Flowsheet that you used as a template. For example. Now.
The icon disappears except for two arrows that represent the universal input and output ports.0. Open the simulation from the previous chapter and edit the HollowF model. right click.the real and integer parameters on the User Arrays sheet.at(0. and select Edit Current Icon . From the tools menu. select Library | Ultrafiltration | Writable. From the tools menu. select the HollowF model. The small enclosed crosshair indicates the automatic position of the block ID and the call Label. . 3 Customizing the Aspen Plus Model Library 60 . Keep your custom drawing reasonably well centered. Select Library | References. These changes are stored in the library when you select Library | LIBNAME | Save. . In the Ultrafilteration – Model Library Editor. Click OK. then add named references to the real and integer parameters.1) statement in the lower pane indicates that it will be placed very close to the spot where the user clicks on the process flowsheet. Create a Custom Icon 1 2 3 4 5 6 Open Membrane2. . select Library | Ultrafiltration | Edit.apw. If the coordinates are far from zero. 7 Click and hold and drag across the entire icon to enclose it in a dashed box. . The Icon Editor appears. First customize the icon. and select the checkbox next to Ultrafiltration to make your library available. Click the right mouse button and select Delete. block placement could be unpreditcable.
Move the universal port arrows so they are attached to the icon.8 9 Use the graphics tools to create a custom icon for the hollow fiber ultrafiltration membrane. a main Icon menu becomes available on the menu bar for the main window. Note: Existing AutoCAD DXF files can also be imported into the Icon Editor. 11 Drag a P1(OUT) port from the left-hand pane and place it directly over the universal output arrow. For the simulation in this chapter. the two parameters designated as output data will appear in a new results sheet. When the Icon Editor is active. and select Edit User Configuration. 14 Click Yes when prompted to save the new icon. The User Model Configuration Editor appears. Create References to the Real and Integer Parameters 1 Select Library | Ultrafiltration | Edit. Otherwise this run will be identical to the run in the previous chapter. 16 Exit the Model Library Editor by closing the window. 13 Exit the Icon Editor by closing the window. 12 Select Icon | Update icon to update the code in the lower pane. right click the icon. 10 Drag an F1(IN) port from the left-hand pane and place it directly over the universal input arrow. Select Import DXF from the Icon menu. These names will be used in the Fortran code in the next chapter. 15 Select Library | Ultrafiltration | Save to save the changes to the library. Next. 3 Customizing the Aspen Plus Model Library 61 . add named references to the real and integer parameter arrays.
This will be discussed further in the next chapter. right click.2 Create names for the 1 integer and 13 real parameters in the order that they appear on the Blocks MEMBRANE Setup User Arrays sheet. and 3 Customizing the Aspen Plus Model Library 62 . This allows the user to access the parameters using the structure name and an index value and then place the real parameter in an array. Note: It is also possible to create a structure called coefficients by choosing structure in the type field and then making coef1. For NTUBES. Exit the Model Library Editor by closing the window. The completed table is shown below. Inserting the New Model and Running the Simulation Delete the old model and replace it with your new HollowF model. coef3. Select Library | Ultrafiltration | Save. Note: Aspen Plus will correctly identify the integer no matter where you put it. coef2. The named references on the Configured Variables sheet must be supported by a short Fortran subroutine that you must create. and respecifying the product stream Flash. select it. Note: To delete a row. click in the Type field and select Integer from the drop-down menu. For the last two real parameters. select Remove Row. click in the Input/Output field and select Output only. 3 4 Real is the default type. The new icon and the variable names will now appear whenever you use the HollowF model. 5 6 7 Exit the Configuration Editor by closing the window. and coef4 real parameters with a depth of 1. Parameters are designated as Input by default. compile. reconnecting the streams.
Once both streams are connected they can be separated for clarity. delete the MEMBRANE block. 4 5 6 7 8 On the Process Flowsheet. Reconnect the PERMEATE stream. Your Ultrafiltration library has one category called Membranes and its tab appears in the Model Library. right-click. Insert the HollowF model. 9 10 Rename the block.apw. Move the cursor over the Feed port and click once to reconnect the stream. Check and Edit Setup Sheets 1 2 3 Open the Data Browser and go to the Blocks | HFUM180 | Setup form. If you accidentally select the PERMEATE stream first. a Hollow Fiber Ultrafiltration Membrane with 180 tubes. The Model Library Editor will write this new subroutine for you. select Reconnect Destination. Place a HollowF block on the Process Flowsheet. Insert the New Model 1 2 3 Open Membrane2. then run the simulation and examine the results. Select the FEED stream. check the data sheets for the HFUM180 block. The order matters because the first stream connected comes first in the output stream data array (SOUT).f.link along with the user model subroutine Mem2. Make sure all the data included with the model by default is correct and add the product stream Flash specification. HFUM180. create a new dll file containing the new subroutine. Now that the Process Flowsheet is complete. Check the User Arrays and Configured Variables sheets. Press Shift-F5 and click OK twice to reinitialize the simulation. Check the Subroutines sheet and make sure the subroutine name and path to the Excel file are correct. Select Library | References… and select Ultrafiltration. The two results parameters that you defined for the HollowF model in the Configuration Editor do not appear on the Configured Variables sheet 3 Customizing the Aspen Plus Model Library 63 . press Esc on the keyboard to cancel. Reconnect the RETENTAT stream to the Product port using the Reconnect Source option.
f to the folder that contains Mem2.) 3 Customizing the Aspen Plus Model Library 64 . You can alter the numerical data if you wish and it will be changed for the particular block that you placed. right-click.because they were specified as output parameters. and Run 1 2 3 Select Library | Ultrafiltration | Writable and then Library | Ultrafiltration | Edit to open the Model Library Editor. Note: The data in the User Arrays sheet and Configured Variables sheet are the same. Select the HollowF model. and run the simulation. Now create the Fortran file to handle the new variable names. they will appear on a results sheet. No data is needed in the Flash specifications area. Compile. the same change will automatically appear on the other sheet. If you change any of the numbers on one sheet. For future block placements. Select Fortran | Export and save the Fortran file as Mem2Vars. the defaults will remain intact. create a shared library including your user subroutine and this new subroutine. 4 Go to the Stream Flash sheet and specify a Temperature & pressure Flash for each product stream. and select Edit User Configuration to open the User Model Configuration Editor. Link.f (\Working Folders\Aspen Plus\Membrane. compile it.
so the obj file should already exist.obj. A new version of Membrane2. Save the library (Library | Ultrafiltration | Save) and exit the Model Library Editor. From the Membrane sub-folder. open your DLOPT file. The Mem2 subroutine was compiled in the previous chapter. 11 Type asplink [DLOPT Membrane2_List_OBJs. Save your run as Membrane2_CM.opt] Membrane2 and press Enter to create a new shared library from the two obj files. Membrane2_List_OBJs. 8 9 Start the Aspen Plus Simulation Engine to get the DOS window.dll is placed in your Membrane subfolder.apw and then Aspen Plus so that you can run asplink in a moment. 10 Type aspcomp Mem2Vars and press Enter to compile the new Fortran subroutine.4 5 6 7 Exit the Configuration Editor by closing the window. Save the new DLOPT file and exit the text editor.opt and add a line indicating the path to Mem2Vars. 3 Customizing the Aspen Plus Model Library 65 . type cd Membrane and press Enter to set the directory to the location of your Fortran files.
12 Close the Aspen Plus Simulation Engine Window window.dll. 16 Click OK. Note: This simulation file uses the same Mem2 subroutine as Membrane2.dll. 13 Check that your other DLOPT file.apw and exit Aspen Plus. an updated version of Membrane2_List_OBJs. 18 Go to the Blocks | HFUM180 | Results | Summary sheet to see the entire real and integer parameter lists including the two real parameters that were specified as output only. 17 Run the simulation.apw.opt.opt is still in the Aspen Plus Working Folder and contains the location of Membrane2. If necessary. 14 Start Aspen Plus. 15 Select Run | Settings. 19 Go to the Configured Variables sheet to see just the two output parameters. It has been named Membrane2_CM. type Membrane2_Loc_dll. It uses an updated version of Membrane2. Membrane2_Loc_dll. 20 Save the simulation as Membrane2_CM. and the same Membrane2_Loc_dll.opt file as in the previous chapter and produces the same results.apw to emphasize this connection to the previous simulation.opt in the Linker Options field to tell Aspen Plus where to find the shared library.apw. and open Membrane2_CM. 3 Customizing the Aspen Plus Model Library 66 .
Use the named references (such as “DIAM”) you specified when you created the model. A complete listing is provided here. The absence of Excel interface functions and the presence of the Aspen Plus utility functions make for compact code in the new subroutine. However. you may wish to perform the model calculations in the user Fortran subroutine and transfer the results directly to Aspen Plus. In this chapter. 4 Creating an Aspen Plus Fortran Model 67 . once the model is developed. build a User2 Fortran model to replace the Excel model that you developed previously.4 Creating an Aspen Plus Fortran Model Excel is useful for testing and troubleshooting a new model because it is selfcontained – during the testing phase. Use Aspen Plus utility functions that read from and write to the real and integer array stored with the HollowF customized model. it is not necessary to run Aspen Plus simulations. Allow about 30 minutes for this session.
WORK. NSIZE. IWORK. 1 Put a copy of \Engine\User\Usrus2. Numbers in parentheses after the boldface comments refer to the relevant part of the Code Description that follows the listing. IDSMO. ITYPE. (2) Dms_ncomp. NBOPST. For example. IDSII. MSIN. INTSIZ.cmn" #include "dms_plex. 2 Code Listing – Subroutine HFUM SUBROUTINE HFUM 2 3 4 5 6 7 IMPLICIT NONE #include "ppexec_user. SINFO.f in the folder you are using for your Fortran subroutines. NPO. NSUBS. (1) Dms_plex. NREAL. copy this file to Aspen Plus working directory. SOUT.cmn" Real*8 B(1) Equivalence (B(1). NINFI. IDSMI. Edit Usrus2.cmn" C Include files pass additional variables via COMMONs. IDXSUB. NINT. (3) 4 Creating an Aspen Plus Fortran Model (NMATI.f extension is allowed and any subroutine name up to six characters is allowed. IDSIO. 3 Rewrite the subroutine following the complete Code Listing below.cmn passes USER_NHSTRY.cmn passes arrays containing component C data such as molecular weight. The complete subroutine is listed below. NINFO. C Ppexec_user. LD ) 68 . Note: Any filename with the . INT. NTOT.IB(1)) #include "dms_ncomp. IDS. NMATO.Putting the Model Equations in the User Subroutine A Fortran template is available that will make creating a subroutine to perform the calculations for the HollowF model easier. SINFI. NIWORK. SIZE.f and change the name of the subroutine to HFUM. REAL. NWORK.cmn passes NCOMP_NCC.
IRET. IDX(10). IPERM. MU. NCP. (4) !To write results data to Aspen Plus. (5) !Standard Fortran function. C4. NMATO. XMW.NMATO). NINFO. FIN. LMW. NIWORK. NBOPST(6. IDXSUB(NSUBS). SINFO(NINFO). KDIAG. IDS(2. LD MSIN(NTOT. CR. JM. WORK(NWORK).NMATI). NINFI. SINFI(NINFI). REAL(NREAL) C --------------. PIN. CP. UAVE. NWORK. LEN.Declare Local Variables --------------------------------------------INTEGER + REAL*8 + + OFFSET. INDEX. REJ_COEF. NSUBS. FP. CG. CIN.NINFI). INTSIZ(NSIZE). I.Begin Executable Code -------------------------------------------------C ------------------------------Get configured REAL variables from Aspen Plus. X(10). DELTA_P.NINFO). SC. IERR.IFAIL DIAM. NTUBES. IDSIO(2. IWORK(NIWORK). P_PERM. LDATA. ITYPE(NSUBS).NPO).C ------------------. NPO. C2.Declare arguments ----------------------------------------------------INTEGER + + INTEGER + + + + REAL*8 + + NMATI. SOUT(NTOT. NSIZE. NREAL IDSMI(2. NINT. USRUTL_GET_INT_PARAM. ------------------ 4 Creating an Aspen Plus Fortran Model 69 . NTOT. (4) !Determines offset to universal constant data. C3.NMATI). J. RE. KM. INT(NINT). C ----------------------------. FLOW C ----------------. IDSMO(2. IDSII(2. C1. SIZE(NSIZE). PRET.NMATO).3).Declare Functions -------------------------------------------------INTEGER + + INTEGER REAL*8 USRUTL_GET_REAL_PARAM. RHO. USRUTL_SET_REAL_PARAM DMS_IFCMNC DLOG !These functions allow access to real and !integer parameters using named references. DIFF.
NE. DIFF) IF (IERR .NE. CG) IF (IERR . INDEX. (8) WRITE(USER_NHSTRY. INDEX. INDEX.NE.NE. 0) THEN WRITE(USER_NHSTRY.*) ' ERROR FETCHING REJECTION COEFFICIENT' IFAIL = 1 END IF IERR = USRUTL_GET_REAL_PARAM('COEF1'. 0) THEN WRITE(USER_NHSTRY. !Write to History file if error.*) ' ERROR FETCHING HYDRAULIC DIAMETER' 4 Creating an Aspen Plus Fortran Model 70 . (7) IF (IERR . INDEX. 0) THEN IFAIL = 1 END IF IERR = USRUTL_GET_REAL_PARAM('LEN'. DIAM) !Used for passing a structure.IFAIL = 0 INDEX = 0 IERR = USRUTL_GET_REAL_PARAM('DIAM'.NE. (6) !Put Configured Variable called !”DIAM” in local variable DIAM. INDEX. 0) THEN !Local variable can have any name. C1) IF (IERR .NE. 0) THEN WRITE(USER_NHSTRY.*) ' ERROR FETCHING LENGTH' IFAIL = 1 END IF IERR = USRUTL_GET_REAL_PARAM('DIFF'. INDEX. REJ_COEF) IF (IERR .*) ' ERROR FETCHING DIFFUSIVITY' IFAIL = 1 END IF IERR = USRUTL_GET_REAL_PARAM('GEL_CONC'.*) ' ERROR FETCHING GEL CONCENTRATION' IFAIL = 1 END IF IERR = USRUTL_GET_REAL_PARAM('REJ_COEF'. LEN) IF (IERR . 0) THEN WRITE(USER_NHSTRY.
C3) IF (IERR . C4) IF (IERR . INDEX.*) ' ERROR FETCHING PERMEATE PRESSURE' IFAIL = 1 END IF IERR = USRUTL_GET_REAL_PARAM('DELTA_P'.*) ' ERROR FETCHING COEF2' IFAIL = 1 END IF IERR = USRUTL_GET_REAL_PARAM('COEF3'. 0) THEN WRITE(USER_NHSTRY. NTUBES) 4 Creating an Aspen Plus Fortran Model 71 .NE. C2) IF (IERR . 0) THEN WRITE(USER_NHSTRY. 0) THEN WRITE(USER_NHSTRY.*) ' ERROR FETCHING PRESSURE DROP' IFAIL = 1 END IF C ---------------------------------. INDEX.*) ' ERROR FETCHING COEF1' IFAIL = 1 END IF IERR = USRUTL_GET_REAL_PARAM('COEF2'. 0) THEN WRITE(USER_NHSTRY. DELTA_P) IF (IERR .Get configured INTEGER variables from Aspen Plus -------------------------------IERR = USRUTL_GET_INT_PARAM('NTUBES'.WRITE(USER_NHSTRY. 0) THEN WRITE(USER_NHSTRY.*) ' ERROR FETCHING COEF3' IFAIL = 1 END IF IERR = USRUTL_GET_REAL_PARAM('COEF4'. INDEX. P_PERM) IF (IERR .NE. INDEX.NE.*) ' ERROR FETCHING COEF4' IFAIL = 1 END IF IERR = USRUTL_GET_REAL_PARAM('PERM_PRES'. INDEX.NE.NE. INDEX.
1) / 1000. MSIN(NCOMP_NCC+3. NCP. 0) THEN WRITE(USER_NHSTRY. !Protein conc. (10) IDX.CP) / (CIN . !Feed flow in l/hr. !Feed stream pressure in atmospheres.) * 1000. 0) THEN WRITE(USER_NHSTRY.1). !Volumetric flux in m/s. / 3600. !Permeate stream protein conc. !Mass xfer coef in m/s. (11) MSIN(2. !Bulk average velocity in cm/s. in feed stream in g/l. KDIAG. !Schmidt number. (9) C ------------------------------------. C1 * RE**C2 * SC**C3 * (DIAM/LEN)**C4 * DIFF/DIAM/100. MSIN(NCOMP_NCC+1.14*NTUBES/4.NE. in g/l.Calculate viscosity ----------------------------------------------------------CALL SHS_CPACK(MSIN(1. 1) RETURN C ----------------------------.CP)) !Reynolds number.1) * B(LMW+2) / FIN * 3600000. = = = = = DIAM * UAVE * RHO / MU MU / (RHO * DIFF) CG * (1 – REJ_COEF) KM * DLOG((CG . NBOPST. NCP. X. *) ' ERROR EVALUATING VISCOSITY FOR FEED' IFAIL = 1 END IF IF (IFAIL . FLOW) KDIAG = 4 CALL PPMON_VISCL(MSIN(NCOMP_NCC+2. X. put result in MU. IDX. MU. 4 Creating an Aspen Plus Fortran Model 72 .Get location of molecular weight data. (11) !Viscosity of feed stream in g/cm/s. IERR) !Calculate viscosity. !Density of feed stream in g/cm^3 [=kg/l].1) / 101325. (9) !Pack stream data. (11) MSIN(NCOMP_NCC+3. + IF (IERR .1).IF (IERR .1).1) / RHO * 3600.EQ. (11) FIN / (DIAM**2*3.--------------------------------LMW = DMS_IFCMNC('MW') !Offset to the component molecular weight data. = = = = MU * 10.*) ' ERROR FETCHING NUMBER OF TUBES' IFAIL = 1 END IF C ---------------------------------------.NE.1) * MSIN(NCOMP_NCC+9.Model Equations --------------------------------------------------------------RHO MU FIN CIN PIN UAVE = RE SC CP KM JM = MSIN(NCOMP_NCC+8.
!Permeate stream flow rate in l/hr (CIN .IRET) = PRET * 101325. !It contains the outlet stream ID’s.IPERM) = FP * RHO / 3600. ------------------------------------------SOUT(1. unchanged from feed (deg K).IRET) = MSIN(1. !Water flow in kmol/s.SOUT(1. !Approximate water flow in kmol/s.1) .IPERM) + SOUT(2.NE. PIN – DELTA_P C ----------------------------.IRET) + SOUT(2. (13) !Protein flow in kmol/s. / B(LMW+1) SOUT(2. (13) !Pressure in N/m^2.14 * NTUBES*100*3600/1000.IRET) = MSIN(4.Assume (incorrectly) PERMEATE stream is first. switch if not. / 3600.IPERM) = SOUT(1. (13) C ----------------------------Now set values of the two variables designated as output parameters. unchanged from feed (deg K).1) SOUT(5. (13) !Total flow in kmol/s. (13) !Temp.1) .IPERM) = P_PERM * 101325. in g/l.IRET) = MSIN(2. 'RETE') THEN IPERM = 2 IRET = 1 END IF C --------------------------. ---------------------------IPERM = 1 IRET = 2 IF (IDSMO(1. -----------IERR = USRUTL_SET_REAL_PARAM('CP_PROT'. (13) !Protein flow in kmol/s.Fill SOUT array for PERMEATE stream.IRET) = SOUT(1.FP CR PRET = = = JM * DIAM * LEN * 3.1) SOUT(5.FP/FIN) !Retentate stream protein conc.*) ' ERROR STORING PERMEATE PROT CONC' IFAIL = 1 !The HollowF model was designed !to accept 2 output parameters. 0) THEN WRITE(USER_NHSTRY.IPERM) SOUT(4. (13) !Pressure in N/m^2.IPERM) = MSIN(4. INDEX. (13) !Temp.IPERM) SOUT(3. --------------SOUT(1. (13) !Total flow in kmol/s. !Retentate stream pressure in atm.1) .FP/FIN*CP) / (1 .IPERM) SOUT(2. (12) C -------------Fill SOUT array for RETENTAT stream using values from PERMEATE stream. CP) IF (IERR .EQ.SOUT(2.IRET) SOUT(4.IPERM) = FP * CP / 1000. / B(LMW+2) SOUT(3. (14) 4 Creating an Aspen Plus Fortran Model 73 . (13) !IDSMO is an argument passed to the subroutine.
INDEX. CR) IF (IERR .END IF IERR = USRUTL_SET_REAL_PARAM('CR_PROT'. 0) THEN WRITE(USER_NHSTRY.NE.*) ' ERROR STORING RETENTATE PROT CONC' IFAIL = 1 END IF RETURN END 4 Creating an Aspen Plus Fortran Model 74 .
The three USRUTL functions return an integer which will have the value zero if there were no errors.4 INDEX(1) = i Ierr = USRUTL_GET_REAL_PARAM(‘coefficients’. and str2c. The integer function DMS_IFCMCN takes a character string as input (for example. there are two.Code Description – Subroutine HFUM 1 USER_NHSTRY is the Fortran unit number for the History File. .coef2) may also be referenced directly by its 2 3 4 5 6 4 Creating an Aspen Plus Fortran Model 75 . For example. ID. A scalar element within a structure (for example. str2b. USRUTL_GET_REAL_PARAM. The data is accessed by using a function to find the offset to the location of the data in the B or IB array. DO i = 1. i REAL*8 C(4) . and physical property parameters such as molecular weight. see the User Models manual and step 10 in this list. For more discussion of the DMS_PLEX common and examples see the User Models manual and steps 5 and 10 in this list. These functions allow the user to pass values between the Fortran subroutine and Aspen Plus according to the names defined using the User Model Configuration Editor. suppose you have nested structures with str1 containing str2a. if you created a coefficients structure with four elements you could access them using the following code: INTEGER INDEX(1). water and protein. coefficients. In this example. set INDEX(1) = 2 and INDEX(2) = 3. From Aspen Plus. However. ‘MW’ for molecular weight) and returns the offset to an area of the “Plex” data array. you can access this file by selecting View | History. Its value is irrelevant in the present example since none of the data are structures. NCOMP_NCC is the number of conventional components in the simulation.C(i)) END DO The 1-based INDEX array contains only as many elements as there are levels of structure. Aspen Plus will also save a History File if you save the simulation as an apw file. Each element must be set once per loop. For more information and examples. Ierr.INDEX. The common DMS_PLEX contains data for all components including the formula. INDEX is an array of indices used in the USRUTL functions when handling a structure. If str2b has five scalar elements and you wish to access the third. This command will open the history file with a text editor and it can be saved using the text editor.
For example. the offset (LMW) to the molecular weight data is obtained using the string ‘MW. conversions must be performed. a reduced list of component mole fractions with the zeroes removed) produced by a packing utility such as SHS_CPACK. liquid fraction. C2). 13 The SOUT array has the same structure as the MSIN array.*) ‘diam = ‘. They are listed in Appendix C of the User Models manual and are in SI units. entropy.” The function USRUTL_GET_REAL_PARAM retrieves the value of this parameter and puts it into a local Fortran variable that. NMATO) where NMATO is the number of material outlet streams. and molecular weight of the stream. This History File. In this example there is only one feed stream so the second index is always 1. IDSMO is an array with dimension (2. enthalpy. temperature. The molecular weight of protein (really lysine) is stored in B(LMW + 2). pressure. In this example. 9 The user can call physical property monitors such as PPMON_VISCL to access the Aspen Plus Physical Property system.lowest level name (‘coef2’ in this example) as if it were not in a structure at all: USRUTL_GET_REAL_PARAM(‘coef2’. pressure. For more information about accessing physical properties see Chapters 3 and 4 of the User Models manual. The first two elements are the mole flows in kmol/s for water and protein. the programmer can instruct users to always connect the Retentate stream first. It contains the mole flow. in this example. Alternatively. 11 The input (feed) stream array MSIN contains NCOMP_NCC+9 elements for each feed stream. 0. The PPMON subroutines require the stream information in “packed” form (that is.’ The molecular weight of the first component listed by the user on the Aspen Plus Components Specifications Selection sheet (water) is stored in B(LMW + 1). is a useful place for error messages and troubleshooting output statements. 8 10 For a list of the names to feed to DMS_IFCMNC in order to retrieve component data from Aspen Plus. set the product stream temperatures equal to the feed stream temperature. The program calculates flow rates for each component. For each stream. Since the model equations in this example use other units. 7 On the Aspen Plus Blocks | HFUM180 | Setup | Configured Variables sheet. the total flow rates. These data are 4 Creating an Aspen Plus Fortran Model 76 . vapor fraction. 12 The argument list for User 2 models is documented in Chapter 5 of the User Models manual. there are 2 four-character labels. the streams are distinguished by the first four letters in the label of each (RETE and PERM). the user can see that one of the real parameters is called “DIAM. Of course any declared Real*8 variable is allowed to hold the value of this parameter. see Chapter 6 of the User Models manual. also discussed in Step 1 above. temperature. The first index may be 1 through 11 since there are two components. a statement like write(user_nhstry. The following nine elements are total mole flow. and calculates the pressure of each stream. diam might be useful if your calculations aren’t coming out properly and you want zero in on the problem. In this example. and other data for the two product streams. is named DIAM. density.
Open Membrane2_List_OBJs. 1 2 Save your Fortran code as HFUM.sent to Aspen Plus by filling the first five elements of the SOUT array for each stream.obj. From the Aspen Plus Working Folder. 14 Other data not included in SOUT will appear on the Blocks | HFUM180 | Results | Configured | Variables sheet because two variables were designated output only when the user set up the configured variables for the HollowF model. Then create a new DLOPT file that contains the name of the new subroutine. Since this is user-specified output data. 3 4 5 6 7 8 9 In the DOS window of the Aspen Plus Simulation Engine.obj. Save the file as HFUM_List_OBJs. Create the DLL file and place a DLOPT file in the Aspen Plus Working Folder that contains the path to this new DLL. 4 Creating an Aspen Plus Fortran Model 77 . Compiling and Linking the Subroutine Use the aspcomp command to compile the subroutine. Type aspcomp HFUM to compile the subroutine to create HFUM. (From the Start menu click Programs | AspenTech | Aspen Engineering Suite | Aspen Plus 2004.) In the DOS prompt window type cd membrane if your Fortran files are in a sub-folder of your Aspen Plus Working Directory called membrane. type asplink [dlopt HFUM_List_OBJs.opt] HFUM to create HFUM.opt and replace Membrane2.dll.dll. The protein concentration in g/l for both product streams appears on the results sheet. Start the Aspen Plus Simulation Engine.opt and exit the text editor.f and exit the development environment.opt and replace Mem2.opt and exit the text editor. Save the file as HFUM_Loc_DLL.obj with HFUM.dll with HFUM.1 | Aspen Plus Simulation Engine. open Membrane2_Loc_dll. Aspen Plus makes no assumptions about units.
and click OK. Go to the Setup Specifications Global sheet and change the title to HFUM. Select Run | Reinitialize (or press Shift-F5) and click OK twice. Run the simulation. Save the run as HFUM.apw and exit Aspen Plus. 5 6 7 8 Select Run | Settings.Running the Simulation Use the membrane2_cm. Since your model calculations will be performed by the Fortran subroutine. change the name of the Fortran subroutine to HFUM and delete the reference to the Excel file. 1 2 3 4 Open membrane2_cm. Compare your results to those obtained using the Excel model or to the results displayed below. type HFUM_Loc_DLL.apw simulation from the previous chapter. Go to the Blocks | HFUM180 | Setup | Subroutines sheet.apw.opt in the Linker Options field. remove the reference to the Excel file. Then enter the name of the DLOPT file containing the location of the dll file and run the simulation. 4 Creating an Aspen Plus Fortran Model 78 .
Results from the Custom Fortran Model Blocks HFUM180 Stream Results Material sheet: Blocks HFUM180 Results Configured Variables sheet: 4 Creating an Aspen Plus Fortran Model 79 .
Allow about 40 minutes for this session. Include the new form as an addition to the usual forms associated with the HollowF model and create a new model that contains the special form. Fields commonly used by the Aspen Plus GUI can be applied to a new sheet by dragging it from a Controls Toolbox. Visual Basic template files are provided with Aspen Plus to reduce the amount of time required to develop custom forms. These forms are easily inserted into Aspen Plus by registering the OCX file created by Visual Basic using the Aspen Plus ApFormSetup utility.5 Creating an Aspen Plus Custom Form Creating graphical forms using Microsoft Visual Basic is the last level of customization for supporting custom models in Aspen Plus. It is now possible to create forms for an existing plant unit that hides design parameters for users interested in performing rating only calculations for example. 5 Creating an Aspen Plus Custom Form 80 . In this example. create a special Blocks BLOCKNAME Input_And_Results form containing two sheets: an Input sheet that provides access to two important membrane parameters and a Results sheet that contains results of particular interest. The ability to create forms combined with the templating capabilities that you used in the previous chapter is a very powerful customization capability. Configured variables that were defined for these models can be linked into these forms.
To see clearly how the Aspen Plus/Visual Basic interface works.ctx formtemplate. select formtemplate. and ModelName.vbp. then create a text (OCR) file with specifications. Use these template files to set up an environment in which you can easily create custom forms that have the same look and functionality as the standard Aspen Plus forms. to support the control files) to define the development environment for creating Aspen Plus GUI forms. create d:\Program Files\AspenTech\Working Folders\Aspen Plus\VB Copy the following files from the GUI\xeq folder of the Aspen Plus 2004. 5 Creating an Aspen Plus Custom Form 81 . keep these three names separate for this example. create a model that will “own” the form.ctx 3 Copy the following file from the GUI\xeq folder of the APRSYSTEM 2004. project and control names. Select Project | MyModel Properties… and change the Project Name to ProjectName.1 folder to your VB folder: tabtemplate.ctl). Save the project as ProjectFile. and two graphics files (. 7 Select Project | Add User Control | Existing (tab). 1 2 Create a new folder to use as a Visual Basic Working Folder.vbp.ctx. ProjectName. This example uses literal naming such as ProjectFile.ctl and click open to add the control used for creating forms to your project. two Visual Basic control files (.1 folder to your VB folder: Template. you may wish to have ProjectFile = ProjectName = ModelName. and the model name so that the interface works. For example.vbp). Note: When creating forms after this exercise. Sheet2Name = Results. run a program that automatically sets up the Aspen Plus/Visual Basic interface.ctl tabtemplate. and test the new form.vbp 4 5 6 Open the Visual Basic project by double clicking Template.Setting Up the Visual Basic Environment Use Visual Basic to create your form (an OCX file). It is important to keep track of file names.ctl formtemplate. the example uses ordinary names for the form and its two sheets: FormName = Input_And_Results and Sheet1Name = Input. However. Aspen Plus provides a Visual Basic project file (.
Now you are ready to create an Aspen Plus form.8 Add tabtemplate.ctl to your project. Your VB window should look something like this: The cursor in the picture is hovering over the MMTabStrip tool that you will use to create your custom form. The Toolbox (displayed via View | Toolbox) contains a number of tools in addition to MMTabStrip designed expressly for creating Aspen Plus GUI forms.ctl and formtemplate. The MM prefix indicates an Aspen Plus tool. 5 Creating an Aspen Plus Custom Form 82 .
Change FormTemplate (formtemplate.ctl). Select TabTemplate (tabtemplate. For the Input and Results controls. The text file (.ctl.ctl). specify two labeled tabs. and specify the daughter control corresponding to each tab. Click in the Properties window. 5 6 7 Change FormTemplate (formtemplate. change the entry in the (Name) field to TabControlName and press Enter.ctl) to InputControlName (InputControlFile.Creating the Visual Basic Form Create three controls: one parent control (Tab).ctl). and save the file as TabControlFile. rename the two templates. create labeled fields and indicate the Aspen Plus Path to the variables corresponding to each field. A graphics window appears and the Properties window fills with data.ctl) by repeating steps 2 – 4 above. Select Project | Add User Control | Existing (tab) and import another instance of formtemplate.ctl). and two daughter controls (Input and Results).vbp) so that the two control templates appear. 5 Creating an Aspen Plus Custom Form 83 . right-click. For the Tab control. Create Three Named Controls 1 2 3 4 Go to the Project window and expand ProjectName (ProjectFile. Double click TabTemplate (TabControlFile. and import another instance of FormTemplate and rename it as well.ctl.ocr) that you will create provides Aspen Plus with the name of the tab control which has links to the two sheets which in turn have links to Aspen Plus variables. First.ctl) to ResultsControlName (ResultsControlFile. The Tab control is now listed in the Project window as TabControlName (TabControlFile.
Click and drag diagonally across the drawing area and release the mouse to create a box with three tabs. click . From the toolbox on the left-hand side of the VB window. 5 Creating an Aspen Plus Custom Form 84 . Build the Tab Control 1 2 3 4 From your VB project. your window will look something like this: Next. This “box with three tabs” is called a tab strip. build the Tab control.After cleaning up. Use the MMTabStrip tool and make two tabs (the default is three so you’ll have to delete one) linked to the Input and Results sheets. maximize the TabControlName window. Move the cursor onto the drawing area in the TabControlName window (it becomes a crosshair).
5 6 7
Select the tab strip, right-click, and select Properties. The Property Pages dialog box appears. In the Caption field, type Input. Create the link to the Input control by typing ProjectName.InputControlName in the FormName field. Property Pages dialog, close-up view:
Advance the Current Tab field from 0 to 1 by clicking the up arrow to the right of the field. In the Caption field, type Results.
10 Create the link to the Results control by typing ProjectName.ResultsControlName in the FormName field. 11 Advance the Current Tab field to 2. 12 Click Remove Tab as you need only two tabs, the 0th and 1st.
5 Creating an Aspen Plus Custom Form
13 Click OK. The tab strip, (most-recently-edited tab is bold):
Note: The MMTabStrip object selected above and the User Control object (selected if you click in the drawing area outside the tab strip) are separate objects with separate properties. 14 Reduce the TabControlName window so that you can access the other controls. 15 Select TabControlName (TabControlFile.ctl) in the project window, right-click, and select Save TabControlFile.ctl Next, build the Input control. Use the MMFrame tool to create a frame for two input fields. Then use the MMLBUText tool to create the two fields – one labeled Channel Hydraulic Diameter and the other labeled Channel Length. In the HollowF model, you created named variables for the membrane parameters and they appeared on the Configured Variables sheet. Now two of these variables will also appear on your new Input sheet. You will specify the Aspen Plus paths to these variables in the Input control you are about to build.
Build the Input Control
1 2 3 4 Maximize the InputControlName window. From the toolbox, click .
Click and drag in the drawing area of the Input control to create a Frame. Select View | Properties Window or press F4 to open the Properties window.
5 Creating an Aspen Plus Custom Form
Enter Membrane Parameters in the Caption field. The Properties window :
6 7 8 9
Close the Properties window. From the toolbox, click .
Click and drag in the upper half of the Frame to create a field area. It won’t look nice right away. Select the new field area, right-click, and select Properties. Another Property Pages dialog box appears. Use it to position and label the field and assign it a path to an Aspen Plus variable.
10 Select the MMLBTUText tab, and clear the checkboxes for the Basis and Units fields. 11 Set the Width for the Label to 2350. 12 Set the Left parameter for the Text to 2400.
5 Creating an Aspen Plus Custom Form
click Add to create a variable having a Node datatype. enter main. Input. 5 Creating an Aspen Plus Custom Form 88 .13 Select the MMLBTUTextLabel tab. 14 On the Variable tab. type Channel Hydraulic Diameter in the Label Caption field. Use a space between the words User and Table. DIAM respectively into the first four cells. User Table. 15 In the first Path column.
The variable main used above is automatically assigned to the path to the block containing your form: Application. This is important because any given block could have any user-chosen name at run time. 5 Creating an Aspen Plus Custom Form 89 .The full path to variable you defined as DIAM when you created the HollowF model is shown below in the Aspen Plus Variable Explorer window which is accessed by via the Tools | Variable Explorer… command.Blocks. 16 Click OK to close the Property Pages dialog box. 17 Select the Channel Hydraulic Diameter field area and resize it so that it doesn’t take up too much space in the Membrane Parameters frame.Tree.B1 in this example.Data. 19 Click and drag in the frame to create a small label. 18 Click in the tool box.
select Properties and enter cm in the Caption field. 22 Reduce the InputControlName window. CR_PROT. 23 Select InputControlName (InputControlFile.ctl) in the Project window. An abbreviated procedure is given below – refer to steps 7 – 21. CP_PROT and CR_PROT.User Table. 21 Resize the label and move it to the right of the Channel Hydraulic Diameter field. that you defined in the HollowF model. Specify paths to the two Output only variables. The eventual Blocks BLOCKNAME Input_And_Results Input sheet looks like this: Next. right-click. Output. User Tree. right-click. Make a field for Retentate Protein Concentration and map the variable to: main.20 Select the label. User Tree. build the Results control. Output. Build the Results Control 1 2 3 4 Make a frame called Membrane Performance. Make a field for Permeate Protein Concentration and map the variable to: main. Create two fields.Input. CP_PROT. Permeate Protein Concentration and Retentate Protein Concentration.. 24 Repeat steps 7-23 and create a Channel Length field mapped to the LEN variable with path: main. and select Save. 5 Creating an Aspen Plus Custom Form 90 .LEN. Add the concentration units (g/l) next to the field.
ctl file. 8 5 Creating an Aspen Plus Custom Form 91 . Exit the VB development environment.The eventual Blocks BLOCKNAME Input_And_Results Results sheet looks like this: 5 6 Save the ResultsControlFile.ocx… and click OK to create the ocx file that will be registered with the operating system and thereby integrated with Aspen Plus. The finished Project: 7 Select File | Make ProjectFile. Save the Visual Basic Project.
A form called Input_And_Results will appear in the Blocks folder on the Data Browser menu tree when a ModelName block is placed in the Process Flowsheet.ocx.exe in GUI\xeq to register your OCX file (the OCR file is processed automatically). Your new form applies only to a USER2-based custom model (called ModelName in this example) for a hollow fiber ultrafiltration membrane. The ModelName model should contain all the usual USER2 forms. the name of the form as it will appear on the Data Browser menu tree. Create a text file called ModelName.ocx to ModelName.ocx. The OCR file contains the name of the unit operation model that uses the form. Letters in the name of the unit operation model (in this case MODELNAME) must ALL be capitalized even if the actual Aspen Plus model is called ModelName.ocr with the first line as shown below. Put copies of your OCR and OCX file in GUI\forms. The OCX file created above contains the actual form. The new form should appear only with this particular model.ocr. A step-by-step procedure is provided below. The do this: Rename the OCX file to ModelName.Integrating Forms with Aspen Plus The connection between Aspen Plus and your custom form is accomplished by means of two files. A text file with the OCR extension will contain specifications for the form. The number “5” is for position in the form list and the number “1” indicates a tabbed form. Copy and paste specifications for the usual USER2 forms from the Aspen Plus OCR files in GUI\forms to your OCR file. Create OCR and OCX Files for Your Model 1 2 Rename ProjectFile. Aspen Plus will use the tab control object called ProjectName. the name of the tab control. Put the specification for the new form into your OCR file. 5 Creating an Aspen Plus Custom Form 92 . and information specifying the placement of the new form in the list of forms. Use ApFormSetup.TabControlName to create the form. Create an OCR file called ModelName.
The CC. Replace Blocks\USER2 with Blocks\MODELNAME. Your new form called Input_And_Results (position 5) will be placed after the Setup and Petro Characterization forms (positions 0 and 1 respectively). NodeName entries are for the Aspen Plus completion checking system.ocr and exit the text editor. 4 5 Open the files containing the Blocks\USER2 specifications and copy and paste these lines into ModelName. The Setup form will open by default when you click on the BLOCKNAME folder in the Data Browser.3 Use the Windows (Start | Search | For Files or Folders…) to find OCR files in the GUI\forms folder that contain Blocks\USER2 specifications. 6 Save ModelName.ocr. 5 Creating an Aspen Plus Custom Form 93 .
exe in the GUI\xeq folder of the Aspen Plus installation.ResultsControlName Register the OCX File 1 Run ApFormSetup. Click OK when ApFormSetup.ocr and ModelName. Select Update Data Browser Menu since you are only adding a form to a previously-built menu.TabControlName ProjectName. 5 Creating an Aspen Plus Custom Form 94 . The Register Forms dialog box appears listing all OCX files in the GUI\Forms folder. The Register PlotWizard dialog box appears. scroll down to ModelName. The Data Browser updates (new entries are made in the System Registry) so that Aspen Plus has access to the new form. 5 Click Next. register the ocx file with the operating system to give Aspen Plus access to the three controls you created: − − − ProjectName.7 Copy ModelName. In the Product specific forms list.ocx to the GUI\Forms folder of the Aspen Plus installation.exe announces success.ocx and click it so that only it is selected. Next. 2 3 4 Click Deselect All to clear all the selections. 6 7 Click Deselect All and then click Finish since you have no new plot wizard files to register.InputControlName ProjectName.
Press Shift-F5 to reinitialize the run. Single Block Custom Model. 6 When the Enter name to use for the model type field appears. 7 8 9 10 Go to the Blocks CFTEST Setup Subroutines sheet and type HFUM in the Model field and eliminate the reference to the Excel file. Then click Finish.exe (click Start | Run.apw and create a new model called ModelName in your ultrafiltration library. Membranes. Check the Results sheet. 1 2 3 4 5 Open HFUM. replace it with a ModelName model. and select Add to Model Library.. type ModelName. etc.8 Optional: Run Regedit. Then replace the HollowF model with the new model and run the simulation. called HFUM180. There is no data there yet.. Open the Data Browser and go to the Blocks CFTEST Input_And_Results Input sheet. A series of dialog boxes appears.. Name the new block CFTEST. Step 6 contains abbreviated instructions – refer to Chapter 3 for details. Select the HollowF block. 5 Creating an Aspen Plus Custom Form 95 . right-click. Select Library | References… and check Ultrafiltration. Note the data in the two fields. type Regedit in the Open field and click OK. Exit the Registry Editor without changing anything.) and examine the new entries under HKEY_CLASSES_ROOT. Delete the HollowF model on the Process Flowsheet. Testing the New Form Open HFUM. The three VB control object that you created are listed. Otherwise.apw. and Copy current icon only. and reconnect the streams. Select Library | Ultrafiltration | Writable. select the following options: Add: Create a New etc.
13 Run the simulation. 16 Save the simulation as HFUM_CF. change the input values of the two parameters. 12 Select Run | Settings and type HFUM_Loc_dll.opt in the Linker Options field. and click the results tab to see the changes. 14 Go to the Blocks CFTEST Input_And _Results Results sheet to check the results. 15 Go to the Blocks CFTEST Input_And_Results Input sheet.apw and exit Aspen Plus. Results from the Custom Form The customized Data Browser menu tree: 5 Creating an Aspen Plus Custom Form 96 .11 Go to the Blocks CFTEST Setup Stream Flash sheet and set Temperature & pressure flashes for both product streams. run the simulation again.
The Blocks CFTEST Input_And_Results Input sheet with new data: The Blocks CFTEST Input_And_Results Results sheet after the run with new data: 5 Creating an Aspen Plus Custom Form 97 .
In these cases. The simulation engine is installed on your PC. enter the node name of the computer on which the Aspen Plus simulation engine will execute. the message Connection Established appears in the message box. see your Aspen Plus system administrator for more information on network protocols and host computers for the Aspen Plus simulation engine. you will be prompted to specify the host computer for the Aspen Plus simulation engine after you start the Aspen Plus User Interface: • • The simulation engine is not installed on your PC. Click OK to continue. but the Activator security device is not connected to your PC. and select the type of host computer If you choose Local PC as the server for the simulation engine. 6 Connecting to the Aspen Plus Simulation Engine 98 . If the Connection Established message does not appear. If you choose Windows 2000 or XP server as the server for the simulation engine. 1 2 In the Server type field. Your password for the above user name. When the network connection is established. the Connect to Engine dialog box appears. enter the following information: User name Password Working directory Your user name for the specified host/server. you do not need to enter any more information into the dialog box. In the other fields. 5 Click OK. click for the simulation engine. The associated working directory.6 Connecting to the Aspen Plus Simulation Engine If either of the following conditions exist. enter the following additional information: 3 4 In the Node name field.
Aspen COMThermo®. Aspen MPIMS™. Aspen RefSYS Spiral™. Aspen Process Plant Construction Standards™. Aspen Cim-IO for Intellution Fix™. Aspen PIMS Distributed Processing™. Aspen Crude Manager™. Aspen Terminals Management™. Aspen Operations Manager . Aspen Properties®. Aspen HYSYS OLGAS 3-Phase™. Aspen Capable-to-Promise®. Aspen Demand Manager™. Aspen Dynamics®. Aspen FIHR™. Aspen Cim-IO for GSE D/3™. Aspen Multivariate Server™. Aspen Process Recipe®. Aspen PIMS Mixed Integer Programming™. Aspen APLE™. Aspen Supply Chain Connect™. Copyright Version Number: 2004. Aspen PIMS Simulator Interface™. Aspen HYSYS®. Aspen Compliance. Aspen Cim-IO for Yokogawa EW3™. Aspen Product Margin & Blending Evaluation™. Aspen Operations Manager . Aspen Tank Management™. Aspen Cim-IO for Yokogawa Centum XL™. Aspen ProFES® 2P Tran. Aspen Planning Accuracy™. Aspen Cim-IO for ACS™. Aspen Icarus Process Evaluator®. Aspen Cim-IO for G2™. Aspen Resource Scheduling Optimization™. Aspen OnLine®. Aspen CatRef®. Aspen Order Credit Management™. Aspen ProFES® 3P Tran. Aspen Decision Analyzer™. Aspen Plant Scheduler™. Aspen InfoPlus. Aspen TICP™. Aspen Watch General Information 99 . Aspen HYSYS OLGAS™. Aspen Aerotran®. Aspen RateSep™. Aspen Plant Planner & Scheduler™. Aspen Automated Stock Replenishment™. Aspen Crude Margin Evaluation™. Aspen IQ Desktop™. All rights reserved. Aspen Process Order™. Aspen Cim-IO for WonderWare InTouch™. Aspen Production Control Web Server™. Aspen Process Tools™. Aspen Supply Chain Analytics™. Aspen PIMS™. Aspen Hetran®. Aspen PIMS XNLP Optimizer™. Aspen ACOL™. Aspen Cim-IO Monitor™. Aspen Collaborative Demand Management™. Aspen ERP Connect™. Aspen Utilities™. Aspen LIMS Interface™. Aspen General Construction Standards™. Aspen Cim-IO for Yokogawa Centum CS™. Aspen DPO™. Aspen Process Data™. Aspen IQ Online™. Aspen Hydrocracker®. Aspen PIPESYS™. Aspen Apollo Desktop™. Inc. Aspen Cim-IO™. Aspen Inventory Balancing™.21™. Aspen Calc™. Aspen HX-Net®. Aspen eBRS™. Aspen Adsim®. Aspen Supply Planner™. Aspen Transition Manager™. Aspen Voice Fulfillment Management™. Aspen DISTIL™. Aspen ProFES® 2P Wax. Aspen Alarm & Event™. Aspen Cim-IO for Melsec™. Aspen Apollo Online™. Aspen PIMS Enterprise Edition™. Aspen Advisor™. Aspen Q Server™. Aspen SQLplus™. Aspen SmartStep Desktop™. Aspen DMCplus® Composite. Aspen LPIMS™. Aspen Plus®. Aspen Watch Desktop™. Aspen PIMS Blend Model Library™. Aspen Fuel Gas Optimizer Desktop™. Aspen Collaborative Forecasting™.21®. Aspen SmartStep Online™. Aspen MIMI®. Aspen RTO Watch Cim-IO Server™. Aspen Batch. Aspen Fuel Gas Optimizer Online™. Aspen Local Security™. Aspen Process Explorer™. Aspen IQmodel Powertools™. Aspen Hydrotreater™.1 April 2005 Copyright © 1981 – 2005 Aspen Technology. Aspen BatchCAD™. Aspen Operations Manager Integration Infrastructure™. Aspen Custom Modeler®. Aspen Cim-IO for Hitachi PLC (H04E)™. Aspen HYSYS Tacite™. Aspen RTO Watch Server™. Aspen Chromatography®. Aspen HYSYS Dynamics™. Aspen Orion Planning™. Aspen MBO™. Aspen HYSYS Crude™. Aspen Plus OLI Interface™. Aspen Fleet Operations Management™. Aspen Kbase®. Aspen Teams®. Aspen ATOMS™. Aspen Cim-IO for Hewlett-Packard RTAP™. Aspen COMThermo TRC Database™. Aspen AssetBuilder™.Event Management™. Aspen Process Manual™. Aspen FCC®. Aspen Batch Plus®. Aspen ProFES® Tranflo. Aspen CimIO for Csi VXL™. Aspen FLARENET™. Aspen NPIMS™.Peformance Scorecarding™. Aspen FRAN™. Aspen Operations Manager .General Information This section provides Copyright details and lists any other documentation related to this release. Aspen Enterprise Model™. Aspen HYSYS OLI Interface™. Aspen RefSYS CatCracker™. Aspen MUSE™. Aspen Scheduling & Inventory Management™. Aspen Framework™. Aspen Cim-IO for Dow MIF™. Aspen Data Source Architecture™. Aspen Cost Factor Manual™. Aspen DMCplus® Desktop. Aspen Orion™. Aspen PIMS Solution Ranging™. Aspen Plant Scheduler Lite™. Aspen BatchSep™. Aspen HYSYS Amines™. Aspen PPIMS™. Aspen Polymers Plus®. Aspen DMCplus® Online. Aspen TASC™. Aspen Cim-IO Interfaces™. Aspen HYSYS Upstream Dynamics™. Aspen PIPE™. Aspen Distribution Scheduler™.Role Based Visualization™. Aspen HYSYS Upstream™. Aspen RefSYS™. Aspen PIMS Submodel Calculator™. Aspen Pumper Log™. Aspen TASC-Mechanical™. Aspen Icarus Project Manager®. Aspen Turbo PIMS™.21™. Aspen Report Writer™. Aspen PEP Process Library™.
Aspen XPIMS™. MA. A prerequisite for the other Getting Started guides Tutorials covering the use of equationoriented models in Aspen Plus Tutorials covering the Aspen Plus features designed to handle solids Tutorials covering the Aspen Plus features designed to handle electrolytes Tutorials covering the Aspen Plus features designed to handle petroleum Instructions for installing Aspen Plus and other Aspen Engineering Suite products Procedures for using Aspen Plus Specifications for custom models Aspen Plus User Guide Aspen Plus User Models General Information 100 .aspentech. Aspen Water™. MA 02141-2201 USA Phone: (1) (617) 949-1000 Toll Free: (1) (888) 996-7001 Fax: (1) (617) 949-1030 URL: http://www. This document is intended as a guide to using AspenTech's software. All other brand and product names are trademarks or registered trademarks of their respective companies. This documentation contains AspenTech proprietary and confidential information and may not be disclosed. Ten Canal Park Cambridge. SLM Commute™. SLM™.. used. Aspen Web Fulfillment Management™. Cambridge. Inc. Aspen Zyqad™.com/ Related Documentation Title Aspen Plus Getting Started Building and Running a Process Model Aspen Plus Getting Started Using Equation Oriented Modeling Aspen Plus Getting Started Modeling Processes with Solids Aspen Plus Getting Started Modeling Processes with Electrolytes Aspen Plus Getting Started Modeling Petroleum Processes Aspen Engineering Suite Installation Manual Content Tutorials covering basic use of Aspen Plus. and Plantelligence are trademarks or registered trademarks of Aspen Technology. the aspen leaf logo. Inc. Aspen Zyqad Development Version™. Aspen WinRace Database™. SLM Config Wizard™. or copied without the prior consent of AspenTech or as set forth in the applicable license.Server™. Corporate Aspen Technology.
Registered users can also subscribe to our Technical Support e-Bulletins. Send suggestions. For the most up-to-date phone listings. Product release announcements. please see the Online Technical Support Center at: http://support. Search for and review known limitations. fax.aspentech.Technical Support Online Technical Support Center AspenTech customers with a valid license and software maintenance agreement can register to access the Online Technical Support Center at: http://support. Phone and E-mail Customer support is also available by phone. and e-mail for customers who have a current support contract for their product(s).com Support Centers North America South America Europe Asia and Pacific Region Operating Hours 8:00 – 20:00 Eastern time 9:00 – 17:00 Local time 8:30 – 18:00 Central European time 9:00 – 17:30 Local time General Information 101 .com You use the Online Technical Support Center to: • • • • • • • Access current product documentation. Submit and track technical issues.aspentech. and frequently asked questions (FAQs). Toll-free charges are listed where available. solutions. Search for and download service packs and product updates. Search for technical tips. These e-Bulletins proactively alert you to important technical support information such as: • • • • Technical advisories. otherwise local and international rates apply. Service Pack announcements. Search for and download application examples. Product updates.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.