• No results found

Working with Specific Simulation Platforms

In document Aspen-Simulation Workbook User Guide (Page 113-127)

Specific Simulation Platforms

Using ASW with Esteco

ModeFrontier

Esteco Mode Frontier can be used with ASW to perform optimizations on your Aspen simulations. To set this up, you should prepare an ASW workbook that is linked to the simulation that you want to optimize with Mode Frontier, and then create table(s) containing the variables that you want exposed.

When you set up Mode Frontier you will be specifying the cells containing the input variable values that you want optimized and the cells containing the output values that will be judged in your optimization.

One important point to remember is that you need to call the ASW macro named ASWRunSynchActiveSimulation from Mode Frontier when you want the simulation to solve: this will perform a synchronous solve, meaning that Mode Frontier won’t read the simulation output values until the simulation has finished running and ASW has placed the new output values back in the workbook.

You should also set up your ASW workbook to automatically connect to the simulation when opening (set the simulation property

activateOnStartup=True). This way, when Mode Frontier opens the workbook, the simulation will be connected and ready to solve.

Using ASW with Oracle

CrystalBall

Oracle Crystal Ball can be used with ASW to perform Monte Carlo and other analysis on your Aspen simulations. In order for ASW to work properly with Crystal Ball, you need to add a small amount of VBA code to your workbook. This VBA code triggers ASW to run the Aspen simulation during each Crystal Ball trial run.

Using Oracle Crystal Ball to perform Monte

Carlo analysis with ASW Simulations

The following steps are needed to run ASW with Crystal Ball:

1 Install Both Add-ins

After ASW and Crystal Ball are installed, confirm that both are installed correctly and are loading when Excel starts. You should see both ASW and Crystal Ball custom menu options as part of Excel.

2 Setup ASW Workbook Inputs & Output table(s)

In Excel, enable ASW and link to the Aspen

Simulation that you are interesting in using. Copy the relevant input and output simulation variables into the ASW Variable Organizer. After that, create tables in the workbook containing those variables.

3 Setup Crystal Ball

“Assumptions” (inputs) In Crystal Ball, you “define assumptions” by selecting an input distribution type (e.g. Normal distribution with a mean 25 and a sigma of 3) and associating that distribution with a cell in Excel. For each of the input values that you want to vary in your Monte Carlo simulation, you should define a Crystal Ball Input distribution and associate that distribution with the corresponding ASW table cell that contains that value.

4 Setup Crystal Ball

“Forecasts” (outputs) In Crystal Ball, you “define forecasts” by a forecast name and selecting the cell in Excel which will hold its value. For each of the ASW simulation output values that you are interested in tracking, you should create a Crystal Ball Forecast and set the associate Excel cell to the ASW table cell which contains the output value.

5 Setup ASW Run Trigger When Crystal Ball performs a simulation, it does the following during each trial run:

• Selects input values for each input (“Assumption”) that you have setup

• Sets the newly selected input values into their corresponding cells in Excel

• Forces Excel to recalculate all cells

(unfortunately, this does not also automatically run the ASW simulation)

• Retrieves output values (“Forecasts”) from corresponding Excel cells

Crystal Ball allows you to run a custom VBA macro during each Monte Carlo simulation trial. This needs to be setup to force Aspen to do a simulation run during each trial.

In order to set this up, you need to add a VBA macro to the workbook that meets the following Crystal Ball requirements:

1 Name The macro must be named CBAfterRecalc

2 Arguments The macro must take exactly one argument and its type must be ‘long’. The macro returns no value (i.e. it is declared as a ‘sub’, not a ‘function’)

3 Location The macro must be in the same workbook as the simulation and must be in a VBA model associated with any of the worksheets or with the workbook. It can NOT be placed in an added VBA module in the workbook.

The macro only needs to contain one line of code. It needs to call the ASW function to force a synchronous solve of the current simulation. The line of code should be “ASW_SyncRun”.

4 Run Simulation

The last step before running the Crystal Ball simulation is to make sure that the ASW simulation is setup and activated. It should be setup such that if you click the ASW run button then the ASW simulation will solver.

Now run the Crystal Ball simulation. You should notice that the Aspen Simulation runs once during each Crystal Ball trial. New values should be transferred to the ASW output values table each time.

In order to test your setup, you can run a short Crystal Ball simulation (e.g. 4 or 5 trials) and confirm ASW is calculating and retrieving new results values for each new set of input values.

Troubleshooting Tips

1 If the Crystal Ball Add-in doesn’t startup with Excel, then you should open the Crystal Ball Application Manager and check ON the option to startup Crystal Ball with Excel. If that still doesn’t work then you should try only opening Excel indirectly via the Crystal Ball shortcut in the Crystal Ball Program group (from the Windows Start button).

2 Sometimes opening an existing Excel / Crystal Ball / ASW workbook by double clicking on it causes the Crystal Ball Add-in to not load in Excel. If this happens, then try opening Excel via the Crystal Ball application shortcut (e.g. Start->Programs->Crystal Ball->Crystal Ball). Once Excel is open and you have confirmed that the Crystal Ball Add-in has loaded, you can then open the workbook via the standard File->open Excel menu option.

3 If the ASW Simulation isn’t solving then look at the following:

o Is the macro named correctly? The correct name must be “sub CBAfterRecalc(aTrial as long)…”

o Is the macro in the same workbook as your simulation? o Is the macro in a worksheet or the workbook VBA module? If

you added a new VBA code module to the VBA project of your workbook and then added the code to that module then it won’t work. You must add the macro code only to one of the existing worksheet modules or the workbook module.

Using ASW within Aspen Plus

This section covers details pertaining to Aspen Plus, in particular it deals with the development of Aspen Simulation Workbook interfaces for equation- oriented (EO) simulation cases.

EO and SM Variables and Synchronization

Most Aspen Plus cases can be solved using a sequential-modular (SM) strategy or an equation-oriented (EO) strategy. The sequential-modular method has the advantage of being robust; the SM models use several techniques to initialize and solve models even when good initial values are unavailable. Equation-oriented models tend to solve much faster than SM models, but they require reasonable initial guesses to converge reliably. The design of Aspen Plus leverages the strengths of both methods; EO models can be automatically initialized from a complete or partial SM solution.

The SM and EO representations of the problem are stored in two separate sets of variables solved by two separate computational processes. Most sequential-modular variables are exposed through the forms in the Aspen User Interface forms (some intermediate and/or results variables are stored internally and are only available by using the Aspen Variable Browser). These variables are used to initialize corresponding EO variables the first time an EO simulation is run, or after an EO simulation is reinitialized. This process is called synchronization.

The initial values of the EO variables may also be specified using the EO

Configuration, EO Input forms. The EO Input forms are located at three levels

in the Data Browser menu tree:

• Within the individual block folders EO Configuration folder • Within the hierarchy-level EO Configuration folder

• Within the top-level EO Configuration folder

• These forms provide a mechanism that allows Aspen Simulation Workbook access to specified EO variables.

• After the simulation is solved using the EO strategy, a second

synchronization step occurs to copy EO results to SM results in order to update the results variables shown in the Aspen Plus User Interface forms.

Developing Interfaces to EO Models

The dual SM/EO nature of Aspen Plus puts some constraints into the model interface development process. When developing an Aspen Simulation Workbook interface to an EO model, the Model Author must first identify which variables are to be treated as input specifications. These specifications variables must be copied from the EO Variable forms to the EO Input forms in Aspen Plus. The variables can be copied from the EO Input forms to the Organizer using the standard copy/paste mechanism described previously in this guide. This technique can also be used to allow the model user to enter initial values for other types of EO variables (Calculated, Measured,

Parameterized, Reconciled, or Independent variables).

To provide access to EO specifications (constant or independent variables) or to allow the user to provide initial values for other types of EO variables: Use the top-level, hierarchy-level, or block-level EO Inputs form to list these variables. Variables can be added to EO Inputs using the browse button ( ) on the EO Inputs form Variable or Alias field or by using copy/paste from the

EO Variables form. This is described in detail in the Aspen Plus Getting

Started Using Equation Oriented Modeling documentation.

(1) Select variables of interest on the EO

Configuration / EO Variables form

(2) Use CTRL+C to copy to buffer

Tip – sort by Specification to find variables quickly

Select the variables of interest by highlighting their values in the Value column of the EO Inputs form. Use CTRL+C to copy the variables to the clipboard. The lower and upper bounds for Optimized, Reconciled,

Independent, and Parameterized variables can be copied to Aspen Simulation Workbook by selecting the appropriate fields in the EO Inputs form and using CTRL+C to copy to the clipboard.

(3) Open EO Input form, go to Variable or alias field (4) Use CTRL+V to paste

(5) Select cells in Value and/or LB, UB fields and use CTRL+C to copy to clipboard

(6) Go to OSE Organizer and paste ( )

(3) Open EO Input form, go to Variable or alias field (4) Use CTRL+V to paste

(5) Select cells in Value and/or LB, UB fields and use CTRL+C to copy to clipboard

(6) Go to OSE Organizer and paste ( )

Return to Excel, open the Organizer to the Model Variables view, and click the Paste Variables button, , to bring the variables into the Organizer. From this point, you can make tables using the standard features described in Chapter 2.

Tip: Variables copied from the top-level EO Configuration form are grouped under the “EO Configuration” object in the Organizer. Use the block-level EO

Input form to force Aspen Simulation Workbook to group EO Variables in the

block object. The variable values show up as variable IVVALUE in the Organizer.

Objective Function Variables

All of the variables in the EO Configuration Objective Setup forms are

accessible through Aspen Simulation Workbook. The Enabled checkbox shows up as a YES/NO variable in the Organizer. The Cost variables show up as specified variables. Use the normal copy/paste mechanism to copy these fields from the Objective Setup form to the clipboard. These variables can be exposed in an ASW Table to allow the model end user to change or specify raw material costs and other parameters which influence the optimization objective function, or to specify plant data for reconciliation runs.

Accessing Spec-Groups

Aspen EO Models allow the user to define any number of variable specification groups (or Spec-Groups). The model end-user can activate or deactivate Spec-Groups to change the nature of the problem being solved. For example, the user could switch the operating mode of a distillation column to allow fixed reflux ratio or fixed overhead composition.

In Aspen Plus, the Spec-Groups are activated and deactivated from the EO

Configuration Spec-Groups forms located at the top-, hierarchy-, and block-

levels in the Aspen Plus Data Browser tree, as shown below).

To enable this workflow in Aspen Simulation Workbook, select all the rows in the Spec-Groups form, use CTRL+C to copy to the clipboard, and paste into the Organizer (Model Variables view). The variables show up as YES/NO variables in the Organizer (the Object Name is “Spec-Groups”, Object ID1 will be set to the Spec-Group ID, the variable name is “Enabled”).

Accessing Connections

The enabled property of EO variable connections can also be copied into Aspen Simulation Workbook. Open the EO Configuration Connection form, select the rows of interest, and use CTRL+C to copy to the clipboard, and paste into the Organizer (Model Variables view). This will copy the ENABLED variable along with several others (BIAS, SCALE, etc). Alternately, navigate through the ASW Variable Browser to the Connection node as shown below.

Troubleshooting EO Model Interfaces

The workflow for using Aspen Plus EO models is fairly complex and is

generally well understood only by fairly experienced modeling experts. If the Model User enters inputs far from the initial conditions, or if the model moves away from the SM conditions originally used to build the EO model, the model may fail to converge. Once this occurs, it may be necessary to reinitialize the model.

Apply these techniques to avoid convergence problems with EO models: • Do not expose more variables than the end-user really needs

• Set upper and lower bounds on input variables in Aspen Simulation Workbook

• Test all optimization and reconciliation functions exposed to the model user

• Ensure all Specified variables in Aspen Simulation Workbook are linked through the EO Input forms – SM input variables should not be linked directly to Excel since these can cause the EO model to re-synchronize EO variables to SM variables

• Echo all model inputs with calculated variables in the interface to allow the end-user to confirm that the model is using the expected inputs.

• Note that design specification expressions such as Spec., Target, and

Tolerance within the data browser's SPEC folder, as well as the upper and

lower limits on the Vary folder, are special fields. These fields should not be copied directly from the Aspen Plus User Interface as they contain values or FORTRAN expressions: units for these fields are not supported.

Accessing Calculator Blocks and Design

Specifications

When you access a cell in a calculator block you are making a link to a cell location - not the variable within the cell.

For example, if you make a format change in which the location of variables in the calculator change, then the ASW reference may now link to a different variable.

Using ASW within Aspen

Modeler Products

This section covers details pertaining to Aspen Custom Modeler and related products, including Aspen Chromatography, Aspen Adsorption, and Aspen Plus Dynamics. In this section, we use the term Aspen Modeler product to refer to this family of products generically.

Selecting and Copying Variables from Grids

Variables may be copied from any grid-style form in any Aspen Modeler product. To select variables from these forms, click the variable names in the left-hand column of the table. You can use the shift key to select a range of names or use the CTRL key to select multiple variables in different ranges. When the variables are selected properly, the entire row of the table will be highlighted, as shown below.

Next, right-click the mouse and select Copy from the pop-up menu (alternately, use CTRL+C to copy the variables).

Return to Excel, Open the ASW Organizer, select the Model Variables view, and click the paste button, , to add these variables to Aspen Simulation Workbook

Warning: If you select cells from any of the columns on the right, such as Spec, Value, etc, the paste buffer will contain only the data in the cells; it will not contain the variable links required by Aspen Simulation Workbook. Thus, you will not be able to paste the variables into the ASW Organizer.

Warning: You cannot copy variables directly from User-Defined Visual Basic forms in ACM or from any of the graphical forms in Aspen Plus Dynamics or in the other Aspen Modeler products. To copy variables from these applications, open one of the grid forms (all models include the All Variables grid) or use the Aspen Modeler Variable Finder form to select and copy the variables (see next section). Alternately, find the variables using the Variable Browser or the

Variable Query forms in Aspen Simulation Workbook.

Selecting and Copying Variables Using the

Aspen Modeler Variable Finder

Variables may be copied directly from the Aspen Modeler Variable Finder form. Open the variable finder from the simulation package using the Variable

Find button, , in the simulator toolbar.

Use the standard options on the Variable Find form to perform a search to identify a list of variables, as shown below. Select one or more of the results from the bottom pane of this form by clicking on the items. You can use the CTRL and Shift keys to select multiple items or ranges of values from this form.

After selecting the variables, select Edit, Copy from the simulator drop-down menus. This adds the variables to the paste buffer.

Return to Excel, Open the ASW Organizer, select the Model Variables view, and click the paste button, , to add these variables to Aspen Simulation Workbook

Accessing Solver Options and Run Options

Solver Options and Run Options are stored in special nodes in the simulation data tree under the Simulation Options node. You can add these variables to your ASW interface and use them in model variable tables much like any other type of variable.

To select and copy these variables into ASW, open the Organizer to the Model

Variables view and use the Browse for Variables button, , to open the variable browser. Select the simulation case, and open the nodes as shown below. Select the variables of interest, such as SimulationTime and click on the Add Selected button to add these variables to the ASW Organizer.

Tip: When using simulation options such as RunMode in your ASW interface it is good practice to link these model variables to an Excel Combo Box to show the model user a list of valid options and to prevent invalid input. See Getting

the Most From MS Excel later in this chapter for further details.

Activating and Deactivating Tasks in ASW

Dynamic models usually include one or more Tasks which control the

In document Aspen-Simulation Workbook User Guide (Page 113-127)

Related documents