Vous êtes sur la page 1sur 4

Calculator blocks let you insert Fortran statements or Excel spreadsheets into flowsheet computations to perform user-defined tasks.

Since Aspen Plus is a sequential modular simulator that executes one unit operation at a time, you must specify where in the sequence of unit operations each Calculator block is to be executed. You can do this by specifying one of these:

Which flowsheet variables are Imported from and Exported to Aspen Plus by the Calculator block The position of the Calculator block in the list of unit operation blocks

Define a Calculator block by: 1. 2. 3. 4. Creating the Calculator block. Identifying the flowsheet variables that the block samples or manipulates. Entering the Excel formulas or Fortran statements. Specifying when the Calculator block is executed.

Note: Variables changed by a Calculator will remain at their last values at the start of the next run if you do not reinitialize the problem. If you modify the problem so that these variables are no longer changed, the old changed variables will retain their last values from the Calculator (rather than values previously specified on other forms) until otherwise changed or reinitialized. You can use Fortran in Aspen Plus to perform any task that can be written as valid Fortran expressions. You can input Fortran expressions in a number of ways in Aspen Plus:

In Fortran Calculator blocks On the Fortran sheets of other blocks, such as design specifications, sensitivity or optimization problems In external Fortran subroutines

Fortran Calculator blocks:


Contain Fortran expressions used to perform user-defined tasks Can read and/or write flowsheet variables Are executed at a specific point in the simulation

Aspen Plus checks your Fortran code interactively as you enter it so most syntax errors are detected before a run. If the status indicator on a Fortran sheet is , use Next to find out what is incomplete. You can write external User Fortran subroutines when the models provided by Aspen Plus do not meet your needs. After you compile these subroutines, they are dynamically linked when the simulation is run. Aspen Plus allows extensive customization of the models through the use of these external user subroutines. For more information on external user subroutines, see Aspen Plus User Models. Aspen Plus can interpret most in-line Fortran. Fortran that cannot be interpreted is compiled and dynamically linked to the Aspen Plus module. Because dynamic linking is used, the overhead for in-line Fortran requiring compilation is small.

Note: If the Fortran cannot be interpreted, a Fortran compiler is needed. See chapter 1 of Aspen Plus User Models for information on supported compilers and on configuring Aspen Plus to use your compiler. Calculator blocks let you insert Fortran statements into flowsheet computations to perform userdefined tasks, such as:

Calculating and setting input variables before they are used (feedforward control) Writing information to the Control Panel Reading input from a file Writing results to the Aspen Plus report or to any external file Calling external subroutines Writing your own user models

Define a Fortran Calculator block by: 1. 2. 3. 4. Creating the Calculator block. Identifying the flowsheet variables that the block samples or manipulates. Entering the Fortran statements on the Calculate sheet. Specifying when the Calculator block is executed.

See Also To create a Fortran Calculator block: 1. 2. 3. 4. From the Data menu, point to Flowsheeting Options, then Calculator. In the Calculator Object Manager, click New. In the Create New ID dialog box, enter an ID or accept the default, and click OK. On the Calculate sheet, select Fortran (default).

Now identify the flowsheet variables. You must identify the flowsheet variables used in a Calculator block and assign them variable names. A variable name identifies a flowsheet variable on other Calculator block sheets. Use the Define sheet to identify a flowsheet variable and assign it a variable name. When completing a Define sheet, specify the variables on the Variable Definition dialog box. The Define sheet shows a concise summary of all the accessed variables, but you cannot modify the variables on the Define sheet. 1. To create a new variable, click the New button on the Define sheet. or To edit an existing variable, select a variable and click the Edit button on the Define sheet. or To create or edit the variable from Excel, on the Calculate sheet, click the Open Excel Spreadsheet button. In Excel, select the cell and click the Define button on the Aspen Plus toolbar. 2. Type the name of the variable in the Variable Name field. A Fortran variable name must:

Be eight characters or less Start with an alphabetic character (A Z) Have subsequent alphanumeric characters (A Z, 0 9)

Not begin with IZ or ZZ

In Excel Calculator blocks, variable names must:


Follow the above limitations on Fortran variable names Not be a cell reference, such as A1 or R1C1.

Variable names are not case-sensitive in either Fortran or Excel. For instance, FLOW and Flow refer to the same variable. In Fortran, the first letter of the variable name does not affect its type (integer or real). The type is determined by the type of the value being referenced. 3. In the Category frame, use the option button to select the variable category. 4. In the Reference frame, select the variable type from the list in the Type field. Aspen Plus displays the other fields necessary to complete the variable definition. 5. In the Information Flow frame, select whether the variable is to be imported from Aspen Plus or exported to Aspen Plus from the Calculator block. For more information, see Import and Export Variables. Export variables in recycle loops may instead be marked as tear variables to indicate that they should be torn for solving the loops. For more information, see Converging Loops Introduced by Calculator Blocks. Note: Variables changed by a Calculator will remain at their last values at the start of the next run if you do not reinitialize the problem. If you modify the problem so that these variables are no longer changed, the old changed variables will retain their last values from the Calculator (rather than values previously specified on other forms) until otherwise changed or reinitialized. 6. In Calculator blocks, you can specify additional options used in EO calculations:

You can specify the EO variable which is connected to this calculator variable. If you do not specify this name, it will be filled in automatically, if possible, when you switch to the EO solution strategy. See EO Usage Notes for Calculator. You can specify the description of the EO variable in the calculator block. The EO variable names of calculator block variables will be blkid.BLK.description, where blkid is the name of the calculator block and description is the description provided. If you do not provide a description, Aspen Plus will assign a unique name to the variable based on its type. If you choose a variable in the parameter category, you can specify the physical type, units, and initial value of the variable.

7. Click Close to return to the Define sheet. For more information on accessing variables, see chapter 18. Tip: Use the Delete button to quickly delete a variable and all of the fields used to define it. Use the Edit button to modify the definition of a variable in the Variable Definition dialog box. Import Variables and Export Variables are used to establish which of the variables appearing on the Define sheet are only sampled variables, and which are changed by the Calculator block.

Import Variables establish information flow from the block or stream containing a sampled (read-only) variable to the Calculator block. Export Variables establish information flow from the Calculator block to Aspen Plus. If you specify a variable as a Tear Variable on the Variable Definition dialog box, that variable is also treated as an Export Variable.

If the automatic sequencing logic using Import Variables and Export Variables does not appear to work properly, use the Execute statement to specify explicitly when the block is executed. In Excel Calculator blocks, all variables must be specified as Import or Export Variables. In equation-oriented mode, Aspen Plus examines user Fortran statements to determine whether unspecified variables are assigned a value. Variables assigned a value are treated as export variables, and other variables are treated as import variables. Aspen Plus also performs this check in SM if you have specified only Import Variables or only Export Variables. You can specify Import Variables and Export Variables in addition to specifying the execute time on the Sequence sheet. The execute-time specification will take precedence for sequencing the block in SM. The Import and Export Variable specifications will apply when the block is run in EO. Only Calculator blocks with at least one variable specified as an Import Variable or Export Variable are run in EO. Note: The following variables are results variables, and cannot be specified as Export variables:

Mole-Frac, Mass-Frac, Stdvol-Frac, and Stream-Prop variables The following Stream-Var variables: MOLE-ENTHALPY, MASS-ENTHALPY, MOLEENTROPY, MASS-ENTROPY, MOLE-DENSITY, MASS-DENSITY, LFRAC

To achieve successful compilation of your Fortran statements, follow these rules:

By default, variables beginning with A through H, or O through Z, are double precision real. Variables beginning with I through N are integer. Use double precision functions (for example, DSQRT) and double precision constants (for example, 1D0). Do not use variable names beginning with IZ or ZZ. Because Fortran is column-sensitive, this table shows how to do certain things:

To do this Use Indicate comments Column one for C and leave column two blank Enter statement labels Only columns three, four, and five Begin executable Column seven or beyond statements You can call your own subroutines or functions. You can use labeled or blank (unlabeled) COMMON blocks. Fortran variables you define on the Specification sheet cannot be placed in a COMMON. Do not use IMPLICIT, SUBROUTINE, ENTRY, RETURN, END statements, nor arithmetic statement functions. READ and WRITE statements to numbered file units (as in WRITE (NTERM,*)) only work if the same compiler was used to compile the code containing these statements and the code which opened the files. Aspen Plus now uses the Intel Fortran compiler to open its built-in units for the report file, history file, and control panel. See Chapter 1 of Aspen Plus User Models for more information.