Vous êtes sur la page 1sur 63

UniSim Excel

Interface Tool

User Guide
Copyright
Release 450

The information in this help file is subject to change over time. Honeywell may make
changes to the requirements described. Future revisions will incorporate changes,
including corrections of typographical errors and technical inaccuracies.

For further information please contact

Honeywell
130 Dufferin Ave., Suite 1001
London, Ontario
N6A 5R2
Telephone: (519) 679-6570
Facsimile: (519) 679-3977

Copyright Honeywell 2016. All rights reserved.

Prepared in Canada.
Table of Contents
1 Introduction ......................................................... 1-1
1.1 Overview ........................................................ 1-2
1.2 Components of the UniSim Excel Interface........... 1-3

2 Getting Started ..................................................... 2-1


2.1 Installing the UniSim Excel Interface................... 2-2
2.2 Starting the UniSim Excel Interface .................... 2-2

3 The Excel Interface Template Workbook .............. 3-1


3.1 Overview ........................................................ 3-2
3.2 Configuring the workbook.................................. 3-2
3.3 Layout of the workbook..................................... 3-3

4 The UniSim Link Menu .......................................... 4-1


4.1 Overview ........................................................ 4-2
4.2 Configuring variables using the object browser ..... 4-2
4.3 The 'Run Simulation' window ............................. 4-9
4.4 Configuration options...................................... 4-10

5 Typical Usage ....................................................... 5-1


5.1 UniSim Excel Interface Tool mode ...................... 5-2
5.2 Browser Mode.................................................. 5-3

6 The UniSim Design Browser Excel Functions ........ 6-1


6.1 Overview ........................................................ 6-2
6.2 GetUniSimDesign ............................................. 6-2
6.3 GetUniSimDesignArray...................................... 6-3
6.4 SetUniSimDesign ............................................. 6-4
6.5 SetAutoUpdate................................................. 6-4
6.6 GetSpreadSheet............................................... 6-5
6.7 SetSpreadSheet ............................................... 6-5
6.8 GetSpreadSheetValue ...................................... 6-6
6.9 SetSpreadSheetValue ....................................... 6-6

7 Advanced Functions for Excel In-cell Formulae .... 7-1


7.1 Using the Auto Update option............................. 7-2
7.2 Preventing Excel from auto-calculating ................ 7-3

1
7.3 Using Stream Phases ........................................ 7-3
7.4 Setting Solver Mode ......................................... 7-4
7.5 Setting the environment.................................... 7-4
7.6 Suppressing the pop-up messages...................... 7-5
7.7 Accessing the UniSim Design spreadsheets .......... 7-5
7.8 Setting column specifications ............................. 7-6
7.9 Returning arrays of values................................. 7-7
7.10 Using the UniSim Design Browser ....................... 7-7
7.11 Determining connected streams and operations.... 7-9
7.12 Using the Backdoor variable monikers ............... 7-10
7.13 Reporting extension unit operation variables ...... 7-11
7.14 Reporting property correlations, user variables, and
user properties7-11
7.15 Reporting particle size distribution variables....... 7-12

8 Managing the Excel Add-ins.................................. 8-1

9 Frequently Asked Questions (FAQs) ..................... 9-1


9.1 SUPPORT FOR Microsoft Excel 64-bit Version ....... 9-2

A Appendix ..............................................................A-1
A.1 UniSim Design Browser Functions Description ...... A-2

2
Introduction 1-1

1 Introduction

1.1 Overview ....................................................................................... 2

1.2 Components of the UniSim Excel Interface .................................... 3

1-1
1-2 Overview

1.1 Overview
UniSim Excel Interface Tool is an Excel based tool that works with
UniSim Design. It has two modes of operation:
Excel based case study
A series of in cell custom formulae that can be used to set up
OLE Automation links between UniSim Design and Excel without
the user needing to write any Automation code (these functions
have been incorporated from the legacy UniSim Design Browser
tool)

The tool provides a graphical front end to simplify the set up of the case
study and the writing of these functions.

History
Prior to version R440 the UniSim Design Suite included two functionally
similar Excel Interface tools namely UniSim Excel Interface Tool (USE-
IT) and UniSim Design Browser that helped users to accomplish data
exchange between UniSim Design and Microsoft Excel. In R440 the
functionality of the UniSim Design Browser has been integrated into the
UniSim Excel Interface Tool.

The integrated tool uses the intuitive object browser from the UniSim
Design Browser and provides for the same case study and in cell
custom formulae functions as the earlier versions.

Files saved using earlier versions of either of these tools can be


seamlessly migrated to the new integrated tool.

Usage
UniSim Excel Interface R440 has many possible uses, for example:
Material and Energy Balance Tables
Equipment Data Sheets
Case Studies
Optimisation using Excel tools
Communication with other applications through Excel
Simplified model interfaces
What-if Scenarios

1-2
Introduction 1-3

1.2 Components of the


UniSim Excel Interface
UniSim Excel Interface is broadly split into three components:
Template Workbook (UniSim Excel Interface_Template.xlt).
The user can save their own copies of the template workbook
but should take care when overwriting the master template
(stored in C:\Program Files\Honeywell\UniSim Excel Interface)
Excel Add-In (UniSimExcelInterface10.xla). Contains macros
that 'drive' UniSim Excel Interface
Supporting dlls (stored in C:\Program Files\Honeywell\UniSim
Excel Interface)

1-3
Getting Started 2-1

2 Getting Started

2.1 Installing the UniSim Excel Interface ............................................ 2

2.2 Starting the UniSim Excel Interface ............................................... 2

2-1
2-2 Installing the UniSim Excel

2.1 Installing the UniSim


Excel Interface
To install UniSim Excel Interface , run the UniSim Design Suite installer,
navigate to Install Products > UniSim Design > Optional UniSim
Components, and select UniSim Excel Interface R440.

Refer to the UniSim Design Installation Guide for more information.

NOTE : In order to use the UniSim Excel Interface Tool, you


must enable macros in Excel.
The following table outlines how to enable macros in
different version of Excel.

Excel version Option to enable macros in Excel


Excel 2003 Excel Standard Menu > Tools > Macro > Security > Check
Security Level 'Medium'
Excel 2007 Office Button > Excel options > Trust Center > Settings >
Macro settings > Enable all macros
Excel 2010 File Menu > options > Trust Center > Trust Center >
Settings > Macro settings > Enable all macros

2.2 Starting the UniSim Excel


Interface
From the Windows Start menu choose Programs > Honeywell > UniSim
Excel Interface RXXX > UniSim Excel Interface Template Workbook.

Note: UniSim Excel Interface features are dependent upon


Microsoft Excel and its dependent components. If you face
issues while starting UniSim Excel Interface tool , before
seeking support, please ensure Windows Operating System's
related updates of Microsoft Excel and its components are
installed.

2-2
The Excel Interface Template Workbook 3-1

3 The Excel Interface


Template Workbook
3.1 Overview ....................................................................................... 2

3.2 Configuring the workbook ............................................................. 2

3.3 Layout of the workbook ................................................................. 3

3-1
3-2 Overview

3.1 Overview
The UniSim Excel Interface Template Workbook is used to configure the
tool and supports both modes of operation: Case Study (legacy UniSim
Excel Interface Tool) and in cell formulae (legacy UniSim Design
Browser)

UniSim Excel Interface tool is configured using the Template Worksheet.


A master template is supplied with the UniSim Excel Interface install.
The user is free to 'Save As' as many copies of this as they like for later
reuse, but should take care when-overwriting the master template
(stored in C:\Program Files\Honeywell\UniSim Excel Interface RXXX).

When a spreadsheet based on the UniSim Excel Interface Template


Worksheet is opened it will automatically open the tool's Excel Add In
and will create a UniSim Link menu entry in the Excel menus or ribbons.

NOTE: If the UniSim Excel Interface tool's Add In is not


automatically loaded, (in this case the Add-In tab will not
then show on the toolbar) follow the instructions in Chapter
8 - Managing the Excel Add-ins.

3.2 Configuring the workbook


UniSim Excel Interface tools are configured by making changes in the
Template Worksheet and operated using the UniSim link menu.

Setting up a case study


To set up a Case Study the user works with the coloured case study
template cells on the Unit Simulation tab of the UniSim Excel Interface
Template Workbook. The user defines Input Variables and Output
variables and configures a number of cases. UniSim Excel Interface tool
will step through the cases in turn, set the values of all the Input
Variables into UniSim Design, Solve UniSim Design and then report the
values of the Output Variables.

Setting up the in-cell formulae


To set up in-cell formulae the user works with any other cells (on any
worksheet) within the Template Workbook.

3-2
The Excel Interface Template Workbook 3-3

3.3 Layout of the workbook


The UniSim Excel Interface Template Worksheet is split into several
sections as follows:

Figure 3.1

Enter the UniSim Design case file path and name into cell C3
(either manually or via the UniSim link menu 'Load Simulation'
option)
Set Input Variables (in the Yellow cells) and Output Variables (in
the Blue cells). Variables are configured using the Object
Browser
Define the values of the Input Variables for each case (either by
hand or by getting the current values from UniSim Design)
Run the required cases

3-3
The UniSim Link Menu 4-1

4 The UniSim Link Menu

4.1 Overview ....................................................................................... 2

4.2 Configuring variables using the object browser............................. 2


4.2.1 New object browser.................................................................. 3
4.2.2 Configuring the file path settings................................................ 5
4.2.3 File Name, XML Path, and Variable Value fields............................. 5
4.2.4 List sort order settings.............................................................. 6
4.2.5 Import and export settings........................................................ 6
4.2.6 Insert Value or Insert Formula selection ...................................... 6
4.2.7 Adding the function and After Add settings ................................ 7
4.2.8 Target Cell setting .................................................................... 7
4.2.9 Legacy object browser .............................................................. 7

4.3 The 'Run Simulation' window......................................................... 9

4.4 Configuration options ...................................................................10

4-1
4-2 Overview

4.1 Overview
Use the UniSim link menu to:
Set the file name & path of the UniSim Design case to work with
in Case Study mode into cell C3 ('Load Simulation')
Run a case study (or read current values into the input or output
cells)('Run Simulation')
Configure case study Input\Output Variables ('Object Browser'
Set 'Options')
Re-Calculate the new- manually- configurable in cell functions
('Re-Calculate')

If this option is selected then Excel will recalculate all the formulae in
the workbook. Depending on the size of the workbook this could take a
considerable time; however this option is recommended when using the
SetAutoUpdate function (see Section 7.1 - Using the Auto Update
option) to ensure that SetAutoUpdate works correctly after the
Workbook is reloaded.

Figure 4.1

4.2 Configuring variables


using the object browser
Starting with UniSim Excel Interface R440 the Object Browser is
enhanced with a new look and feel along with more intuitive and user
friendly features.

The Legacy Object Browser is retained but it can only be accessed when
explicitly turned on via UniSim link menu' Options.

4-2
The UniSim Link Menu 4-3

The section following details both legacy and new Object Browser
features.

4.2.1 New object browser


The new Object Browser has two modes of operations:
1. Case Study (UniSim Excel Interface Tool) Mode
2. In cell Formulae (Browser) Mode

While the overall appearance and primary features are the same in both
the modes, there is a slight structural change in the features that are
provided to the user.

Case study (UniSim Excel Interface Tool) mode


The Object Browser opens up in UniSim Excel Interface Tool mode when
a user is trying to configure Input/Outputs on the Excel Template's
coloured cells (UniSim Excel Interface Tool cells).

The figure below shows the Object Browser opened in 'UniSim Excel
Interface Tool' mode:

Figure 4.2

The data rows in the "Unit Simulation" worksheet are grouped into four

4-3
4-4 Configuring variables using the

regions:

Rows in the
Region Description
worksheet
1 1 to 10 Case configuration cells
2 12 to 24 Input cells
3 26 to 38 Output cells
4 40 onwards The blank cells from which the Browser mode of the
Object Browser starts

Rows 11, 25, and 39 are blank rows that separate the above
regions from one another. The Object Browser, when
launched from these blank cells, opens up in USE-IT mode.

Browser mode
The Object Browser opens up in Browser Mode, when the user tries to
configure OLE automation links in non UniSim Excel Interface Tool (non-
coloured) cells.

The figure below shows the Object Browser opened in 'Browser' mode:

Figure 4.3

Firstly choose between Simulation or Oil Manager in the Environment


combobox. If Oil Manager is selected the Assays and Blends in the
current case are presented for the user to make a selection, otherwise
if Simulation is chosen the user may select a flowsheet, stream or unit
operation and then a variable. The way these selections are made is
similar to the UniSim Design variable navigator.

4-4
The UniSim Link Menu 4-5

Some variables contain an array of values (e.g. Component Fractions),


in this case it is necessary to provide specific information (e.g. the
particular component) in the Variable Specifics list, alternatively all
such variables also present two options: [All - Array V] and [All - Array
H] which return the whole set of variables into a vertical/horizontal
Excel array, see Section 7.9 - Returning arrays of values for more
information.

If one of the Particle Size Distribution (PSD) properties is selected an


extra listbox (labelled Solid Cpt) appears to enable the solid to be
selected.

4.2.2 Configuring the file path


settings
There are four options for how the UniSim Design Browser deals with
the UniSim Design file and path name in the spreadsheet function that
is created.

Option Description
Full Path This is the default; it puts the whole case path in the
function in the Excel cell. This makes each cell independent,
but involves a lot of work if the case name or path changes.
Relative Path This option adds a "\" then the file name only in the
function. Internally UniSim Design Browser will look for that
file in the same location as the Excel spreadsheet is saved.
This makes exchanging cases and sheets with colleagues
easier as all the functions will continue to work as long as
the two files are kept in the same location.
Same Name as This option replaces the file name in the function with the
Excel Sheet word "MyName". Internally UniSim Design browser will look
for a UniSim Design case with the same name as the Excel
sheet but with the extension ".usc". This is very useful if
you keep updating the versions of the Excel and UniSim
Design files.
Cell reference This option adds a cell reference in place of the file name.
This is the recommended option as it allows the
functionality of all the above options, whilst allowing the file
names to be kept in one central location.

The Update Cell with Current File Name button can be used to
update the selected cell reference with the current file name.

4.2.3 File Name, XML Path, and


Variable Value fields
The File Name indicates which UniSim Design case is being accessed.

4-5
4-6 Configuring variables using the

The XML Path contains the XML text about the selected variable, whose
value is being fetched.

The value of the currently selected variable is reported into Variable


Value. The colour of the text indicates whether the value is specified
(blue) or calculated (black). The units selected here are used when the
formula is inserted. The unit currently in use in UniSim Design is
selected by default.

4.2.4 List sort order settings


The List Sort Order combobox presents several options for sorting the
Assay/Blend/Streams/Unit Operations/Variables list boxes: Ascending,
Descending and USD Order. These options sort the list boxes
alphabetically A to Z or Z to A or in the order presented by UniSim
Design, with the most commonly used variables at the top.

4.2.5 Import and export settings


This sets whether the value is Imported from UniSim Design into the
Excel sheet or Exported from the sheet to UniSim Design. Only values
that are specifications (blue values) in UniSim Design can be exported.

When the Export option is chosen, the user can then type a value in
the Variable Value field. This value will instantaneously be exported to
UniSim Design, which will recalculate based on the value.

When an export (SetUniSimDesign) function is created in a cell the


value to be exported is hard-coded into the formula, (e.g. 35C in this
case):
=SetUniSimDesign(Sheet1!$H$3,"Main","Inlet
Gas","Stream","Temperature","C","",35)

When this value is changed the new value is written to UniSim Design
immediately. In most cases it makes sense to manually replace the
hard-coded value with a cell reference.

4.2.6 Insert Value or Insert


Formula selection
If insert Value is used then the current value of the selected variable is
written to the cell as a number.

4-6
The UniSim Link Menu 4-7

4.2.7 Adding the function and


After Add settings
There are two ways to add the function created by the UniSim Design
Browser to the spreadsheet: pressing the OK button or pressing the
Add button.

The OK button will also close the Browser window. The Add button will
keep the browser window open for other functions to be pasted. If Add
is pressed the setting in the After Add group controls how the next
function is placed relative to the first. If the next selected cell contains
a USD Browser function (GetUniSimDesign, GetUniSimDesignArray or
SetUniSimDesign) the browser will read this and populate the UniSim
Design Browser window automatically.

4.2.8 Target Cell setting


By changing the Target Cell field it is possible to explicitly set which cell
will receive the function from within the Browser window. Press the
Update button to read the formula in this cell and populate the UniSim
Design Browser window accordingly.

Hide Inapp. Prop (meaning "Hide Black Oil and Electrolyte variables for
streams not using an appropriate fluid package")

If this option is checked then Black Oil and Electrolyte variables will
only be displayed in the Browser for streams using an appropriate fluid
package.

These options are stored in the template workbook (on the hidden
USDBrowserTemplateID_XXX_X sheet) so must be set for each
template to be used.

4.2.9 Legacy object browser


The Legacy object browser may be activated by ticking the "Use Old
'Object Browser'" option on the Browser Options window accessible
from the UniSim Link menu.

Select any cell in the row in the case study input (yellow) or output
(blue) cells in which it is desired to add a variable and then choose
'Object Browser' from the UniSim link menu. The Object Browser shows
all the objects in the selected case, organised into a tree structure by
flowsheet and object type. For each object a list of available properties

4-7
4-8 Configuring variables using the

is displayed.

Figure 4.4

Note: Legacy Object Browser is not support from UniSim


Excel Interface 450 forward.

UniSim Excel Interface tool uses XML to record the variables it will read
and write. This XML is stored in column A. By ticking the 'Use
Description' checkbox a more descriptive variable name will be written
in column B. Units are written in column C and may be modified by the
user.

The UniSim Design Spreadsheet controls become activated when a


spreadsheet object is selected in the "Objects" tree; they are used to
select the spreadsheet cell to use as an input or output.

The Matrix By Row option becomes activated when a matrix type


variable (a 2D array of values) is selected in the "Properties" list; it sets
whether the matrix entries are grouped first by column, or by row in the
"Properties" list.

NOTE: Flowsheet object names starting with numerals are


prepended with a '_' in the UniSim Excel Interface tool to
make it a valid string name and the same will be displayed in
the tool.

Input configuration is permissible in the input section only for overall


phase variables. It is not permitted for phase specific variables like
liquid phase temperature, vapour phase pressure etc.

Also while configuring phase variables, the user has to follow certain

4-8
The UniSim Link Menu 4-9

steps in invoking the object browser. If the user is in UniSim Excel


Interface Tool Input section, object browser will not show phase specific
variables other than overall phase. Without closing object browser, if
user moves to configure output variables, the user can only configure
with overall phase variables. If the user wishes to add phase specific
variables in the output section, then the user needs to close the object
browser, ensure an active cell in the UniSim Excel Interface Tool output
section is chosen and invoke the object browser again.

The user cannot set component related information for a single


component. If required, the user has to provide related information to
the entire components in the list. For example, if the component list
has Methane, Ethane and propane and if user wishes to change the
molar flow of Methane, the user has to set molar flow for all the
components in the list.

4.3 The 'Run Simulation'


window
Here the user can start a case study for any previously configured
cases, or retrieve the current values of the Input or Output variables.

Figure 4.5

Select the cases to run in the list box (Use 'Shift' or 'Ctrl' to select
multiple cases if required).

The action taken on the selected cases when 'Run UniSim Design' is

4-9
4-10 Configuration options

pressed depends on the Mode radio button setting:

Option Description
Run Run the case study for each of the selected cases (i.e. Set
Inputs, Solve UniSim Design, Get Outputs)
Set Inputs Set the Inputs for the selected case(s), but don't solve
UniSim Design
Debug While running the UniSim Excel Interface calculation
period, if user wants to interrupt UniSim Simulation case
solving, in case of more than one specifiable property, user
can choose 'Debug' mode.
A message box "Do you want to proceed with debugging?"
will be prompted with Yes and No buttons. Pressing 'Yes'
will specify the appropriate input to the simulation case and
start the solver. Pressing 'No' will simply specify the
appropriate input and will not start the solver.
Get Inputs Get the current value for each of the Inputs.
Get Outputs Get the current value for each of the Outputs.

4.4 Configuration options


A number of options can be set from the UniSim link Options menu
button.

Hover the mouse over each option to see a description of that option.

The settings for the options are saved in a hidden sheet in the Template
Workbook, so different Template Workbooks can have different values
for the settings.

4-10
The UniSim Link Menu 4-11

Run options
Figure 4.6

Option Description
Run UniSim in UniSim Design flowsheet simulation case will be visible
Visible Mode while the case is running. This option depends on the
'UniSim Design Leave Open' option setting. Only when
'UniSim Design Leave Open' is checked on does 'Run
UniSim Visible Mode' take effect.
UniSim Design If checked UniSim Design application window will be left
Leave Open open once executions are done.
Run Oil Manager If checked UniSim Design will Enter and Leave the Oil
Environment before each case is run. Should be used when
Oil Environment settings are changed in the UniSim Excel
Interface Tool case study.
Force Download Force re-load of UniSim Design file before each case is run.
Each time the case is loaded a new instance of UniSim
Design is started.
Disable PreCalc
Macro
Disable PostCalc
Macro

The UniSim Excel Interface Template spreadsheet includes two


predefined macro functions eSim_UserPreCalc and eSim_UserPostCalc.
If the relevant Disable macro checkbox is unchecked then the macro
will be called either before or after the run of each case. These macros

4-11
4-12 Configuration options

can be used to enable custom functionality.

Macro Description
Case Iterations Allows the user to run each case multiple times in
succession, before moving on to the next.
Can be used with the Pre/PostCalc Macro to enable custom
functionality.
Dynamics Mode Allows the user to run dynamics models without stopping
the solver during specification changes.
Minimize USD Allows the user to instruct UniSim Design to send pop-up
PopUps messages during model execution to its trace window
preventing the need for user interaction with the pop-ups.

4-12
The UniSim Link Menu 4-13

Browser options
Figure 4.7

Option Description
Auto Description Automatically use UniSim Object /
Property name in description
(Column B)
Excel Auto Move Down Cannot be disabled. Move the Excel
selection down to the next row after
a variable has been added. If less
than three rows are left blank in the
Inputs / Outputs section below the
cell where the variable is added,
UniSim Excel Interface will add
additional rows.
UniSim SS Auto Move Down After a UniSim spreadsheet cell
property is added as a variable
automatically increment the row
selection in the Browser to select the
row underneath.
Allow UniSim SS Overrun Allow Linking to cells beyond UniSim
Spreadsheet limits.
Check Input Specifiable When an input variable is added to
the spreadsheet using the Browser
check whether it is currently
specifiable and if it is not display a
warning message to the user. If this
option is disabled then the user will
not be warned when adding a
calculated variable as an input. At
run time UniSim Excel Interface tool
will always give an error when
attempting to specify a variable
which is calculated in UniSim Design.

4-13
4-14 Configuration options

Option Description
Hide XML Path Hide XML object path display in
Object Browser and expand UniSim
object tree view to fill the whole
window.
Object/Property Sorted If ticked Object and Property items
are sorted alphabetically (A to Z)
when displayed in the Object
Browser. If unticked Objects are
displayed in the order they were
added to the case and properties
with most commonly used first.
Hide Calculated in Input When active cell is in input range,
calculated variables are hidden in the
property selection box in the Object
Browser.
Analyze Specifiable Check which properties are
calculated or specifiable and colour
code the Object Browser property
selection box accordingly (black =
calculated, blue = specifiable).

Other options
Figure 4.8

Option Description
Use Only Browser Mode The effect of ticking this is that the USE-IT's
'Unit Simulation' sheet is hidden so the user
may then only work in 'Browser Mode'
Show XML Data Link in Column A Show or Hide the XML string in the Column A
of the UniSim Excel Interface 'Unit
Simulation' worksheet.
Show Error in Dialog Show any error messages within a dialog box

4-14
The UniSim Link Menu 4-15

Option Description
Write Error In Log File Write any error messages to a log file
(eSimErrorLog.txt) in the same folder where
the UniSim Excel Interface template file is_
stored.
If the UniSim Excel Interface template has
not yet been saved as a specific xls file then
the error log file will be written in the root
directory (e.g. C:\ or D:\)
If UniSim Excel Interface tool cannot write the
error log file for any reason an error message
is displayed.
Pause between Calculation Require user confirmation to proceed between
Period calculation periods if multiple calculation
periods are chosen.
A message box "Do you want to proceed
running calculation trial 2?", will be prompted
for user input.
Use Old 'Object Browser' This check box, when checked, enables the
user to work with Object Browser interface
from the R430 version of USE-IT. See
Section 4.2.9 - Legacy object browser for
more details.
Enable Double Click To Open This Check box when checked enables user to
Object Browser open Object Browser upon double- click on
any of the active cells. Based on the active
cell type (colored/non-colored) the Object
Browser either opens in UniSim Excel
Interface Tool Mode (if the active cell is a
colored cell) or in Browser Mode (if the active
cell is non-colored cell).

4-15
Typical Usage 5-1

5 Typical Usage

5.1 UniSim Excel Interface Tool mode ................................................. 2

5.2 Browser Mode................................................................................ 3

5-1
5-2 UniSim Excel Interface Tool mode

New UniSim Excel Interface, starting from version R440 supports two
modes of operation, namely
UniSim Excel Interface Tool Mode
Browser Mode

In both the modes, the objective is to set up OLE links between UniSim
Design and Excel.

5.1 UniSim Excel Interface


Tool mode
Typical workflow would be as follows:
1. Open UniSim Design and load any Steady State case.
2. Open UniSim Excel Interface tool (From the Start menu choose
Programs\Honeywell\ UniSimExcel Interface RXXX\UniSim Excel
Interface Template Workbook.)
3. Set the UniSim Design case in cell C3, either manually or via the
UniSim link menu 'Load Simulation' option. (If C3 is empty and
UniSim Excel Interface Tool finds that a UniSim Design case is
currently open it offers to enter it into C3 when the user picks 'Load
Simulation').
4. Enter Run time/description for each required case.
5. Define Inputs - Select one of the Yellow coloured cells then choose
UniSim Excel Interface Tool\Object Browser and pick some input
variables.
6. Define Outputs - Select one of the Blue coloured cells, then choose
UniSim Excel Interface Tool\Object Browser and pick some output
variables.
7. Manually populate the 'Calculation period number' columns with
input variables, or populate them automatically based on the
current case.
(UniSim link\Run Simulation, select the runs to populate in the list
box and choose Get Inputs then press Run UniSim.)
8. Run the case study - Click UniSim link\Run Simulation, select the
periods to run then choose Run and press Run UniSim Design.
9. One Version Backward Compatibility - UniSim Excel Interface Tool
2.0 corresponding to UniSim Design R430 supports cases up to one
prior version of UniSim Design only.

5-2
Typical Usage 5-3

5.2 Browser Mode


User when invokes 'Object Browser' by selecting Excel's active cell
other than UniSim Excel Interface Tool cells (coloured cells), then he/
she can configure functions with Browser Mode of operation.

Typical Work flow would be as follows:


1. Open UniSim Design and load any case
2. From UniSim link Menu bar select 'Load Case' option
3. User is prompted with a message box "No case specified, use
currently open case?"
4. Select "Yes" to attach to the currently opened case, select "No", to
load a saved case
5. Once USD case is attached, the Flowsheet Name field gets furnished
with USD case's complete path name.
6. Select any non-colored cell, open Object Browser from UniSim link
menu bar
7. On the Object Browser window that appears, click in the boxes to
select an object (either a stream or unit operation) and a variable in
the currently active UniSim Design case.
8. If the variable is calculated (black) in UniSim Design only the
Import radio button is enabled; if it is a specified (blue) value either
Import or Export can be selected.
9. Press the OK button to set up the formula to import or export the
function and close the window
10. Press Add to add the function and keep the window open to create
another function.

The other options on this window are already explained in Section


4.2.1 - New object browser:

5-3
5-4 Browser Mode

Example:

Figure 5.1

Examine the formula that has been created on the spreadsheet. In the
example above this looks like:
=GetUniSimDesign("C:\Program Files\Honeywell\UniSim Design
R440\Samples\dyntut1.usc","Main","Feed
1","Stream","MolarFlow","kgmole/s","")

Here the case file name, flowsheet, object name, object type, variable
and unit for the selected variable are being passed as parameters to the
GetUniSimDesign custom function. This formula can be manipulated
just like a normal Excel formula. For example by inserting references to
other cells instead of directly specifying values, or by copy/pasting the
formula between cells.

If a value is being imported from UniSim Design and the value within
UniSim Design changes then the UniSim Design Browser functions do
not (by default) update automatically. Select the cells to update and
press the Re-Calculate Selected USD Browser Cells from the toolbar
menu to force an update.

Values being exported from Excel to UniSim Design are always updated
as soon as they are changed.

5-4
The UniSim Design Browser Excel Functions 6-1

6 The UniSim Design


Browser Excel Functions
6.1 Overview ....................................................................................... 2

6.2 GetUniSimDesign ........................................................................... 2

6.3 GetUniSimDesignArray .................................................................. 3

6.4 SetUniSimDesign ........................................................................... 4

6.5 SetAutoUpdate............................................................................... 4

6.6 GetSpreadSheet............................................................................. 5

6.7 SetSpreadSheet ............................................................................. 5

6.8 GetSpreadSheetValue .................................................................... 6

6.9 SetSpreadSheetValue .................................................................... 6

6-1
6-2 Overview

6.1 Overview
The UniSim Design Browser templates provide a set of custom Excel
spreadsheet functions to allow data to be extracted from and set into
UniSim Design. Some of these are accessible from the UniSim Design
Browser window discussed above; others must be directly entered into
the spreadsheet. All can be manually edited, if required, just like any
other Excel spreadsheet function. The functions are described briefly in
this section and in more detail in Section 7 - Advanced Functions for
Excel In-cell Formulae.

6.2 GetUniSimDesign
(Available directly from the Browser) The GetUniSimDesign function is
used to import a value for a certain variable from a UniSim Design case
into an Excel spreadsheet (or VBA application). The syntax for this
function is:
GetUniSimDesign (CaseFileName, EnvOrFSName, ObjectName,
ObjectType, VariableName, Units, ItemIndex, Update [Optional],
SolverMode [Optional], Environment [Optional], SuppressPopUps
[Optional], ExtraIndex [Optional])

where:

CaseFileName - The path for the UniSim Design case should go


here. There are several forms of parameter that can be used.
For more details see Section A.1.1 - CaseFileName.

EnvOrFSName - The tag of a specific flowsheet in the case should go


here, or "Oil Manager" if an object from the Oil Characterisation
environment is being reported. For more details see Section
A.1.3 - EnvOrFSName.

ObjectName - The name of the object of interest (i.e. name of the


assay, blend, stream or unit operation from which a specific
variable is required).

ObjectType - Since UniSim Design allows both a stream and a unit


operation with the same name on the same flowsheet, the
function cannot decide on its own whether the supplied object
name is a stream or a unit operation, so the words "Stream" or
"Operation" should be supplied here to specify the type of
object. Additionally stream phases can be specified here. For Oil
Manager objects supply either "Assay" or "Blend" here. See
Section A.1.9 - ObjectType for more information.

VariableName - The name of the variable of interest (e.g.


"Temperature", "Pressure", "MolarFlow", etc.).

Units - The units for the variable of interest

6-2
The UniSim Design Browser Excel Functions 6-

ItemIndex - This is used to specify the index of an item within an


array, (e.g. component position within a composition array, or
component name). For non array variables a zero length string
("") should be passed.

Update [Optional] - This is used to trigger an automatic update of


the formula to ensure the most up to date data is reported. See
Section A.1.16 - Update for more information.

SolverMode [Optional] - Used to change the steady state solver


mode (Active or Holding). See Section A.1.10 - SolverMode
for more information.

Environment [Optional] - Used to change the environment


(Simulation, Basis or Oil Manager). See Section A.1.11 -
Environment for more information.

SuppressPopUps [Optional] - Used to suppress any pop up


messages that might normally appear. See Section A.1.12 -
SuppressPopUps for more information.

ExtraIndex [Optional] - Used to pass additional information.


Currently this is used only to pass the solid component name or
index for Particle Size Distribution (PSD) variables. See
Section A.1.13 - ExtraIndex for more information.

6.3 GetUniSimDesignArray
(Available directly from the UniSim Design Browser, when an array
variable is chosen (e.g. ComponentNames or any Component fraction)
and the [All - Array V] or [All - Array H] options are chosen ).

The GetUniSimDesignArray function is used to import an array of values


for a certain variable from a UniSim Design case into an Excel
spreadsheet (or VBA application). The function definition is:
Function GetUniSimDesignArray(CaseFileName, EnvOrFSName,
ObjectName ObjectType, VariableName, Units, StartItemIndex,
EndItemIndex, VorH [Optional] Update [Optional], SolverMode
[Optional], Environment [Optional], SuppressPopUps [Optional],
ExtraIndex [Optional])

where:

StartItemIndex and EndItemIndex - The limits of the array to be


retrieved (supply either the component name or the index - the
first element is at position 0, pass "" to use first/last
component)

VorH - Specifies whether the array returned is vertical (default) or


horizontal.

Since GetUniSimDesignArray returns an array of values it can be

6-3
6-4 SetUniSimDesign

entered as an Excel array formula. This is done by selecting an array of


cells to hold the function result and then pressing Ctrl+Shift+Enter
when entering the formula. Excel represents array formulae by adding
curly brackets {} to the function. If the array of cells selected in Excel is
larger than the array returned by the function then the extra cells show
"#N/A". If the array of cells selected in Excel is smaller than the array
returned then the last values are truncated.

6.4 SetUniSimDesign
(Available directly from the Browser):

The SetUniSimDesign function is used to export a value to a certain


variable in a UniSim Design case from an Excel spreadsheet (or VBA
application). The syntax for this function is:
SetUniSimDesign (CaseFileName, EnvOrFSName, ObjectName,
ObjectType, VariableName, Units, ItemIndex, NewValue, Update
[Optional], SolverMode [Optional], Environment [Optional],
SuppressPopUps [Optional], ExtraIndex [Optional])

All the parameters of this function are the same as the


GetUniSimDesign function, with the exception of the NewValue
parameter which is the value to be set back into the UniSim Design
case.

Whenever this function is executed, NewValue is directly exported to


UniSim Design and the case will start running till it converges, then the
Browser spreadsheet becomes active again. If multiple changes are
being made at one time it makes sense to disable the UniSim Design
solver and then re-enable it once all the changes are made.

6.5 SetAutoUpdate
(Not available from the Browser Interface, can be used by manually
typing the function name in a cell)

This function sets a specific cell to be changed every time the UniSim
Design case re-solves. This change is then used to trigger any cell
referencing the UpdateCell to re-calculate. The syntax for this function
is:
SetAutoUpdate(CaseFileName, UpdateCell)

6-4
The UniSim Design Browser Excel Functions 6-

where:

UpdateCell - An Excel cell reference (e.g. A1) to the cell to be


changed. This cell can then be referenced in the AutoUpdate
parameter of any of the other UniSim Design Browser functions
to trigger them to be automatically updated when UniSim
Design resolves. See Section 7.1 - Using the Auto Update
option for more details.

It is recommended to check the 'Recalculate all Excel


formulae on workbook open' preferences setting when using
SetAutoUpdate to ensure that when the workbook is
reloaded, SetAutoUpdate works correctly.

Additionally there are several other functions included for backwards


compatibility reasons. These can be used to access UniSim Design
spreadsheets, although the GetUniSimDesign and SetUniSimDesign
functions now also provide access to UniSim Design spreadsheets.
These functions are:

6.6 GetSpreadSheet
(Not available from the Browser Interface, can be used by manually
typing the function name in a cell)

The GetSpreadSheet function is used to import a variable from the


UniSim Design spreadsheet. This function accesses the variable in a
specific cell rather than just the value. Hence a unit is required to get
the value. The syntax for this function is:
GetSpreadSheet (CaseFileName, EnvOrFSName, SpreadSheetName,
CellAddress, Units, Update [Optional], SolverMode [Optional],
Environment [Optional], SuppressPopUps [Optional], ExtraIndex
[Optional])

where:

SpreadSheetName - This is the name of the spreadsheet of


interest. The function checks if the object is a spreadsheet or
not.

CellAddress - This is the address of the cell in the UniSim Design


spreadsheet. The format is "A1". Note: ensure that the cell
address is enclosed in quotes ("") otherwise Excel assumes it is
a reference to another Excel cell.

6.7 SetSpreadSheet
(Not available from the Browser Interface, can be used by manually

6-5
6-6 GetSpreadSheetValue

typing the function name in a cell):

The SetSpreadSheet function is used to export to a variable in the


UniSim Design spreadsheet. This function accesses the variable in a
specific cell rather than just the value. Hence a unit is required to get
the value. The syntax for this function is:
SetSpreadSheet (CaseFileName, EnvOrFSName, SpreadSheetName,
CellAddress, Units, NewValue, Update [Optional], SolverMode
[Optional], Environment [Optional], SuppressPopUps [Optional],
ExtraIndex [Optional])

The parameters are the same as described previously.

6.8 GetSpreadSheetValue
(Not available from the Browser Interface, can be used by manually
typing the function name in a cell):

The GetSpreadSheetValue function is used to import the currently


displayed value from a UniSim Design spreadsheet. A unit is not needed
for such a function. The syntax for this function is:
GetSpreadSheetValue (CaseFileName, EnvOrFSName, SpreadSheetName,
CellAddress, Update [Optional], SolverMode [Optional],
Environment [Optional], SuppressPopUps [Optional], ExtraIndex
[Optional])

The parameters are the same as described previously.

6.9 SetSpreadSheetValue
(Not available from the Browser Interface, can be used by manually
typing the function name in a cell):

The SetSpreadSheetValue function is used to export just a value to a


UniSim Design spreadsheet. A unit is not needed for such a function.
The syntax for this function is:

SetSpreadSheetValue (CaseFileName, EnvOrFSName,


SpreadSheetName, CellAddress, NewValue, Update [Optional],
SolverMode [Optional], Environment [Optional], SuppressPopUps
[Optional], ExtraIndex [Optional])

The parameters are the same as described previously.

6-6
Advanced Functions for Excel In-cell Formulae 7-1

7 Advanced Functions for


Excel In-cell Formulae
7.1 Using the Auto Update option ........................................................ 2

7.2 Preventing Excel from auto-calculating ......................................... 3

7.3 Using Stream Phases ..................................................................... 3

7.4 Setting Solver Mode....................................................................... 4

7.5 Setting the environment ................................................................ 4

7.6 Suppressing the pop-up messages................................................. 5

7.7 Accessing the UniSim Design spreadsheets ................................... 5

7.8 Setting column specifications ........................................................ 6

7.9 Returning arrays of values............................................................. 7

7.10 Using the UniSim Design Browser................................................ 7


7.10.1 Exporting the stream compositions ........................................... 7
7.10.2 Setting tee splits .................................................................... 8

7.11 Determining connected streams and operations .......................... 9

7.12 Using the Backdoor variable monikers........................................10

7.13 Reporting extension unit operation variables .............................11

7.14 Reporting property correlations, user variables, and user properties11


7.14.1 Property correlations .............................................................11
7.14.2 User variables.......................................................................12
7.14.3 User properties .....................................................................12

7.15 Reporting particle size distribution variables..............................12

7-1
7-2 Using the Auto Update option

7.1 Using the Auto Update


option
The Auto Update option is currently not supported in the interface; it
can be used by manually adding the function to a spreadsheet cell.

The Auto Update functionality allows UniSim Design Browser functions


to be updated every time the UniSim Design case re-calculates.
Currently this functionality is limited to steady state cases and to Excel
2000 and later.

Auto Update gives a significant advantage to UniSim Design Browser


over the standard Copy/Paste Link feature, and facilitates the creation
of more diversified UniSim Design-Excel solutions.

To use Auto Update, do the following:


1. In a new cell in Excel insert the following function:
=SetAutoUpdate([Case Name], [Cell Reference])
Replacing [Case Name] with the name of the case you want to use
for triggering updates, and [Cell Reference] with the address of any
Excel cell, e.g. A1, b7, etc
2. The referenced cell will become your Auto Update cell, its contents
will be changed every time the UniSim Design case solves. A
random number generator is used to update the numbers in the
Auto Update Cell.
3. In the Get/Set function set the Update parameter to reference the
cell address of the Auto Update cell.
The changes in the Auto Update cell contents will trigger a change in
the Get/Set functions causing them to re-calculate.

The SetAutoUpdate function should only be used once per Excel file,

It is recommended to check the 'Recalculate all Excel formulae on


workbook open' preferences setting when using SetAutoUpdate to
ensure that when the workbook is reloaded, SetAutoUpdate works
correctly.

A current limitation of the SetAutoUpdate function is that it only


supports one UniSim Design Case and one Update cell per Excel file. So
it is recommended that you add this function to your spreadsheet only
once per file. Adding it multiple times will result in unexpected
behaviour as to which one will update.

Users should exercise caution when using this option, since it will force
more traffic between Excel and UniSim Design, and might cause one of

7-2
Advanced Functions for Excel In-cell Formulae

them to stop responding if the traffic becomes excessive. Ensure that


only the functions where Auto Update is really needed use it.

7.2 Preventing Excel from


auto-calculating
If you don't want all your cells to try to update their functions every
time a change is made in the spreadsheet (i.e. if you want to make all
changes then let it update once), you should do the following:

Set the Update parameter of the function to reference an empty Excel


cell.

Go to that empty cell and enter "False".

Example
Cell A1 =False
Cell B1 =1 (stream name)
Cell A2 =GetUniSimDesign("Z:\G-3.usc", "Main", B1, "Stream",
"Temperature", "C", "", A1)
Cell A2 will not update even if the value of cell B1 (stream name)
was changed.

7.3 Using Stream Phases


The option to use Stream Phases is currently not included in the
interface; it can be used by manipulating the GetUniSimDesign
function's parameters after it has been added to a spreadsheet cell.

After importing a value for a stream, go to the cell where the function
was inserted and replace the word Stream in the function's ObjectType
parameter with any of the following:
Vapour to get the vapour phase
Liquid to get the light liquid phase
HeavyLiquid to get the heavy liquid phase
CombinedLiquid to get the combined liquid phase

Fluid to get fluid properties

Example:
=GetUniSimDesign("Z:\G-3.usc", "Main", "1", "Vapour",
"Temperature", "C", "")

7-3
7-4 Setting Solver Mode

7.4 Setting Solver Mode


This feature can also only be accessed by manipulating the function
after it has been inserted in a cell. The optional SolverMode parameter
of each of the functions can be used to control the UniSim Design solver
mode. The options for the parameter are:
1. Active which activates the solver.
2. Hold which puts the solver on hold.

Toggle which toggles the current solver state.

If no entry is provided or anything other than these three options is


entered, the solver will stay in its current state.

Example:
=GetUniSimDesign ("Z:\G-3.usc", "Main", "1", "Stream",
"Temperature", "C", "", , "Hold")

This option is useful when a significant number of exports are made


from Excel to UniSim Design. You might not want UniSim Design to re-
converge after every export, as it would consume too much time and
processing power. It will be more efficient if you put the solver on hold
before the first export is made, and put it back to Active when the final
export is made.

7.5 Setting the environment


Similarly this feature can also only be used by manipulating the
function after it has been inserted in a cell. The optional Environment
parameter of each of the functions can be used to control the UniSim
Design environment setting. The options for the parameter are:
Simulation
Basis
OilManager

If no entry is provided or anything other than these three options is


entered, the solver will stay in its current state.

Example:
=GetUniSimDesign("Z:\G-
3.usc","Main","1","Stream","Temperature","C","", , ,"Basis")

7-4
Advanced Functions for Excel In-cell Formulae

7.6 Suppressing the pop-up


messages
Again this feature can also only be used by manipulating the function
after it has been inserted in a cell. The optional SuppressPopUps
parameter of each of the functions has three possible values.
SuppressAll
NoSuppress
If no entry is provided or anything other than these three
options is entered then NoSuppress is assumed and pop up
messages are not suppressed. If SuppressAll is passed then ALL
pop up messages are suppressed. This feature works by calling
the ChangePreferencesToMinimizePopupWindows method of the
UniSim Design application object.

Example:
=GetUniSimDesign("Z:\G-
3.usc","Main","1","Stream","Temperature","C","", , ,"Basis")
=GetUniSimDesign("Z:\G-3.usc","Main","1","Stream"," Temperature
","C","", , , ,"SuppressAll")

7.7 Accessing the UniSim


Design spreadsheets
Although the UniSim Design Browser includes several functions for
explicitly accessing spreadsheets it is also possible to use
GetUniSimDesign and SetUniSimDesign to do this. These settings must
be made directly in the cell; they cannot be made in the UniSim Design
Browser interface.

To access the variable in a particular cell (i.e. to get/set it in particular


units) simply supply "Variable" as the VariableName parameter and the
cell address (e.g. "B1") as the ItemIndex. To access the value in the
cell (in the units currently used to display it), use "CellValue" as the
VariableName parameter.

For example this call sets the value of the temperature variable
imported from a stream into cell B1, of the named spreadsheet on the
main flowsheet of the current case.
=SetUniSimDesign ("","Main","SPRDSHT-
1","Operation","Variable","F","B1",5)

This call returns the currently displayed value in cell A2 of the same
spreadsheet:

7-5
7-6 Setting column specifications

=GetUniSimDesign("","Main","SPRDSHT-
1","Operation","CellValue","","A2")

7.8 Setting column


specifications
Column specifications are not accessible directly from the UniSim
Design Browser interface; these settings must be made directly in the
cell. The form of the function is as follows:
=GetUniSimDesign(CaseFileName, EnvOrFSName, ColumnName,
"Operation", VariableName, Units, SpecName)
=SetUniSimDesign(CaseFileName, EnvOrFSName, ColumnName,
"Operation", VariableName, Units, SpecName, NewValue)

There are several options for the VariableName field:

Option Description
Goal To get or set the desired value for the specification
Current To get the current calculated value for the spec
IsActive To check if the spec is activated (with GetUniSimDesign) or
activate/deactivate it (with SetUniSimDesign)
IsUsedAsEstimat Corresponds to the Estimate checkbox for the spec
e
AbsoluteToleran To get or set the absolute tolerance
ce
WeightedToleran To get or set the weighted tolerance
ce
Error To get the weighted error

All the properties returning numeric values (all except IsActive and
IsUsedAsEstimate) should be supplied with a unit, these properties also
have companion properties named the same except with Value
appended (e.g. GoalValue) which accesses the variable in UniSim
Design internal units.

For example the function below retrieves the current value of the
"Kero_SS Prod Flow" spec from the column in the R-1.usc sample case:
=GetUniSimDesign("C:\Program Files\Honeywell\UniSim Design
R400\Samples\R-1.usc","Main","T-100","Operation","Current","m3/
h","Kero_SS Prod Flow")

This function sets a new goal value in another spec on the column:
=SetUniSimDesign("C:\Program Files\Honeywell\UniSim Design
R400\Samples\R-1.usc","Main","T-100","Operation","Goal","kJ/
h","Kero Reb Duty", 7950000)

7-6
Advanced Functions for Excel In-cell Formulae

7.9 Returning arrays of


values
The GetUniSimDesignArray() function uses Excel's array formula
compatibility and can return an array of values. To make use of this
feature enter the function as an Excel array formula. This is done by
selecting an array of cells to hold the function result and then pressing
Ctrl+Shift+Enter when entering the formula. Excel represents array
formulae by adding curly brackets {} to the function. If the array of

cells selected in Excel is larger than the array returned by the function
then the extra cells show "#N/A". If the array of cells selected in Excel
is smaller than the array returned then the last values are truncated.

The VorH parameter sets whether the array returned is vertical (by
rows) or horizontal (by columns).

For example the function below retrieves the component names from
stream "1" on the main flowsheet of the G-3.usc sample case.
=GetUniSimDesignArray("C:\Program Files\Honeywell\UniSim Design
R400\Samples\G-
3.usc","Main","1","Stream","ComponentNames","","Nitrogen","n-
Decane","v")

When specifying the limits for the values that are returned (via
StartItemIndex and EndItemIndex) it is possible to pass either the
component name, the position (0 is the first in the list, 1 the second
etc) or an empty string "". For StartItemIndex an empty string is
taken as the first entry and for EndItemIndex the last entry.

7.10 Using the UniSim Design


Browser
7.10.1 Exporting the stream
compositions
When using the SetUniSimDesign function for an array variable (e.g.
composition) it is possible to supply an array of values to the NewValue
parameter. There are two ways an array can be supplied:

As a text string, by using curly brackets {} for example

7-7
7-8 Using the UniSim Design Browser

{0.5,0.2,0.1,0.1}

As an Excel range, by using the standard Excel range notation (e.g.


A1:A10).

If an array of data is supplied the ItemIndex parameter is used to


determine the first entry in the USD array to be changed (note the
behaviour here is different for USD Browser version 1.1 onwards,
previously this parameter was ignored).

As an example, the function below sets the molar composition of


stream 1 in the main flowsheet of the current case equal to the values
in the Excel range A1:A4.
=SetUniSimDesign ("","Main","1","Stream",
"ComponentMolarFraction","","", A1:A4)

Mass and liquid volume fractions can also be set by using


"ComponentMassFraction" and "ComponentVolumeFraction"
respectively.

If the array passed is not normalised then this is done automatically by


UniSim Design.

7.10.2 Setting tee splits


Following on from the example in 10.10 above it is also possible to set
either a single value within an array of tee splits or multiple values
within the same array.

Consider a case with a tee on the main flowsheet with three product
stream connections. The first two split fractions are specified and the
tee calculates the other (1- sum of first two fractions). The following
functions could be used to set the first two split fractions
=SetUniSimDesign("E:\anycase.usc","Main","TEE-
100","Operation","Splits","","0",0.2)
=SetUniSimDesign("E:\anycase.usc","Main","TEE-
100","Operation","Splits","","1",0.3)

UniSim Design would then calculate the third split as 1 - 0.2 - 0.3 = 0.5

Typically the split fraction specifications would be entered in another


cell and this would be cross-referenced:
=SetUniSimDesign("E:\anycase.usc","Main","TEE-
100","Operation","Splits","","0",A10)

Alternatively both split fractions could be set at the same time using a
function like:
=SetUniSimDesign("E:\anycase.usc","Main","TEE-

7-8
Advanced Functions for Excel In-cell Formulae

100","Operation","Splits","","0",{0.2,0.3})

Or with a cross-reference to a range of cells carrying the splits, instead


of a text string:
=SetUniSimDesign("E:\anycase.usc","Main","TEE-
100","Operation","Splits","","0",A10:A11)

When setting the values the Browser checks to see if any of the entries
in the array were read only. Depending on the situation the result of the
formula (that is displayed in the cell) could be one of the following
values:

Result displayed Description


Array - None of the entries in the All the required new values were set
array were read only
Can't Modify Array Variable All of the entries in the array were
read only so none could be set
Array - some elements read only Some of the entries in the array were
read only but not those that were
being set
Array - some elements were not Some of the entries in the array that
set since read only were to be set were read only so
could not be set

7.11 Determining connected


streams and operations
If a variable name that returns an object is used, the name of the
object will be returned. For example to return the name of the product
stream of a unit operation (with a single product stream - e.g. a valve)
use the function:
=GetUniSimDesign("","Main","VLV-
100","Operation","ProductStream","","")

Similarly FeedStream gives the feed stream name and AttachedFeeds


and AttachedProducts can be used for operations with multiple
connected streams by supplying a value to the ItemIndex parameter to
set which connection is required. (The first connection is at index 0.)

For streams, the name(s) of the operation(s) connected immediately


downstream can be found by using a function like:
=GetUniSimDesign("", "Main", "Feed", "Stream",
"DownstreamOpers", "", "0")

For streams with multiple connected unit operations supply higher


numbers to the ItemIndex parameter. The variable UpstreamOpers
allows access to the unit operation(s) immediately upstream.

7-9
7-10 Using the Backdoor variable

This feature can be used to build sophisticated equipment datasheets


where the equipment name is the only required input and all the other
information is imported from UniSim Design using the attached
streams.

7.12 Using the Backdoor


variable monikers
All UniSim Design Browser functions (except the spreadsheet specific
functions) support the entry of Backdoor variable monikers. This
feature allows variables not exposed in the UniSim Design type library
to be reported. Monikers are the means used to identify UniSim Design
variables internally and can often be obtained by recording a script
(Tools menu Script Manger option) whilst editing the variable, or
importing it to a UniSim Design spreadsheet and viewing the script file
in a text editor. To enter a Backdoor moniker: edit the browser function
VariableName parameter to use the form:
Backdoor[Moniker]

where:

Moniker - The Backdoor variable moniker required.

For example to retrieve the stream property 'Phase Fraction [Mass


Basis]' enter:
=GetUniSimDesign("Z:\R-1.usc","Main","Atm
Feed","Stream","Backdoor[:PhaseMassFrac.502.0]","","")

Backdoor variables derived from the parent objects of the specified


stream or unit operation may also be reported using syntax like:
Backdoor[<flowsheet>Moniker]
Backdoor[<case>Moniker]
Backdoor[<application>Moniker]

Examples
To return the tag of the flowsheet containing a stream (in this situation
the result would be same whatever the object specified within the
flowsheet):
=GetUniSimDesign("","Main","1","Stream","Backdoor[<flowsheet>:N
ame]","","")

To return the file name of the case (in this situation the result would be
same whatever the object specified):
=GetUniSimDesign("","Main","1","Stream","Backdoor[<case>:FullFi

7-10
Advanced Functions for Excel In-cell Formulae

leName.100]","","")

To return the full version of UniSim Design (in this situation the result
would be same whatever the object specified):
=GetUniSimDesign("","Main","1","Stream","Backdoor[<application>
/:VersionString.200]","","")

7.13 Reporting extension unit


operation variables
Extension unit operation variables can be obtained in a similar way by
editing the browser function VariableName parameter to use the form:
ExtensionVar[Extension Variable 'Tag']

where:

Extension Variable 'Tag' - can be determined by examining the edf


file for the extension.

For example to retrieve the wet bulb temperature from the Saturate
example extension enter:
=GetUniSimDesign("Z:\G-2.usc","Main","Saturate
Stream","Operation","ExtensionVar[WetBulb]","C","")

7.14 Reporting property


correlations, user
variables, and user
properties
These types of variables can be reported by directly editing the formula
in the cell. The syntax is similar for backdoor variables, and the form is
same as that used in the UniSim Design Stream Reporter tool. Possible
values for the VariableName parameter are described below:

7.14.1 Property correlations


Correlation[Property Correlation Type\Property Name]

7-11
7-12 Reporting particle size distribution

where:

Property Correlation Type - The value displayed in the Correlation


Picker or Correlation Manager windows as the heading of the
branch containing the correlation.

For example:
=GetUniSimDesign(A1,"Main","1","Stream","Correlation[Standard\M
olecular Weight]","","")

7.14.2 User variables


UserVar[User Variable Tag]

where:

User Variable Tag - (note this is not necessarily the same as the
name) can be found on the user variable code editing window.

For example for a user variable with tag mymasscalc that has units of
mass.
=GetUniSimDesign(A1,"Main","1","Stream","UserVar[mymasscalc]","
lb","")

7.14.3 User properties


UserProp[User Property Name]

For example:
=GetUniSimDesign(A1,"Main","IN","Stream","UserProp[UserProp-
1]","","")

7.15 Reporting particle size


distribution variables
Particle Size Distribution (PSD) variables may be reported using the
UniSim Design Browser user interface or by directly editing the formula
in the cell. A typical formula looks like:
=GetUniSimDesign("D:\MyCase.usc","Main","Air With
Sand","Stream","PSD_SolidCptName","","",,,,,"2")

Which in this case reports the solid component name at position 2. (For
example "Sand*")

Whenever a PSD variable is reported the ExtraIndex parameter must be


used ("2") in this example. This indicates for which solid component

7-12
Advanced Functions for Excel In-cell Formulae

values are to be reported. Permissible values here are the position of


the solid component within the (zero-based) array of solid components,
or the solid component name, as in the following example:
=GetUniSimDesign("D:\MyCase.usc","Main","Air With
Sand","Stream","PSD_MassInRangeValues","","10",,,,,"Sand)

In this case the value "10" for the parameter ItemIndex indicates the
10th position within the (zero-based) array of PSD values.

7-13
Managing the Excel Add-ins 8-1

8 Managing the Excel


Add-ins
In Excel if the Add-ins are not visible on the ribbon or toolbar use the
following instructions.
1. Access the Add-In manager using the method described below for
your Excel version
2. From the Add-Ins screen click Browse and navigate to 'C:\Program
Files [(x86)]\Honeywell\UniSim Excel Interface RXXX'.
3. Click OK.

To display the Add-In manager in the following excel versions:

Excel 2003 Menu bar Tools Choose Add-Ins


Excel 2007 ExcelStartbuttonExceloptionsAddIns
ChooseExcelAddInsinManage:dropdown
Gobutton
Excel 2010, 2013 FileMenuOptionspageinlefthandlistAdd
InsChooseExcelAddInsinManage:drop
downGobutton

The following screen shows the Add-In menu Excel 2007.

Figure 8.1

8-1
Frequently Asked Questions (FAQs) 9-1

9 Frequently Asked
Questions (FAQs)
1. What do I do to use old UniSim Design- Browser Spread
Sheets with this new UniSim Excel Interface R440?
Copy the whole spreadsheet (say "Sheet 1") on to the new UniSim
Excel Interface tool's work book.
Select all Spreadsheet cells.
Press the Re-Calculate button from the UniSim link menu bar.
2. Does this new UniSim Excel Interface R440 affects while
working with old UniSim Excel Interface Tool cases
(spreadsheets)?
No, it doesn't affect.
Since manual functions are associated with USE-IT10_Template.xlt
file, those will not be available when user migrates from old UniSim
Excel Interface Tool cases.
3. Working with higher versions of Excel -2010 sometime
produces error like as shown in below screen?

This could be because the MSCOMCTL.ocx file is located at


C:\Windows\System32\...
Ensure that the Operating System is updated and that the latest
MSCOMCTL.ocx file is available.
If this error message appears even if you have the latest
MSCOMCTL.ocx file, un-register and re-register the MSCOMCTL.ocx
file.
4. Why does UniSim Excel Interface R440 not work if installed
in the non-default directory?
This is a limitation. In such case, please add the
UniSimExcelInterface10.xla add-in manually. The tool starts
working as usual.

9-1
Frequently Asked Questions (FAQs) 9-2

9.1 SUPPORT FOR Microsoft


Excel 64-bit Version
UniSim Excel Interface R450 is an Excel based tool as mentioned
earlier. This tool has been developed by writing VBA code that
references version dependent components like Add-Ins and DLLs. The
tool has been developed with x86 (32-bit) version of these
components.

From version R450 the UniSim Excel Interface tool also supports the 64
bit version of Microsoft Excel but the correct version must be installed.

Rational for support of the 64 bit MS Excel version

Below are the reasons that drive this development;


Microsoft has now introduced 32-bit and 64-bit versions of MS
Office installs from MS Office-2010 onwards. This means MS
Office installs like MS Office-2010, 2013 and 2016 come with
x86 and x64 versions
X64 versions of MS Office include a new upgraded version of
Visual Basic For Applications from VBA6 to VBA7
DLLs built for 32-bit applications (32-bit Excel) do not work in
64-bit applications (64-bit Excel such as Excel-2010, 2013 and
2016)
The syntax changes between VBA6 and VBA7 are very basic

New x64-bit Installer

Starting from UniSim Design R450, UniSim Excel Interface R450 is


provided with two installs;
1. x86 (32-bit) version of Install
2. x64 (64-bit) version of Install

x86 (32-bit) version of Install

This install is a regular UniSim Excel Interface Tools installer that takes
care of installing x86 (32-bit) version of UniSim Excel Interface on 32
and /or 64-bit operating system with strictly x86 (32-bit) version of
Microsoft Excel (for instance Excel-2007 and 32-bit version of Excel-
2010, 2013 and 2016).

Note: This installer should not be used in conjunction with x64 (64-bit)
version of Microsoft Excel (for instance 64-bit version of Excel-2010,
2013 and 2016).

9-2
Frequently Asked Questions (FAQs) 9-3

x64 (64-bit) Version of Install

This install is a new UniSim Excel Interface Tools installer that takes
care of installing x64 (64-bit) version of UniSim Excel Interface on only
64-bit Operating Systems (OSs) with strictly x64 (64-bit) version of
Microsoft Excel (for instance 64-bit version of Excel-2010, 2013 and
2016).

Note: This installer should not be used in conjunction with x86 (32-bit)
version of Microsoft Excel (for instance Excel-2007 and 32-bit version of
Excel-2010, 2013 and 2016).

To be clear: on a 64 bit Windows operating system the user/


administrator installing the UniSim Excel Interface should use
the installer version that matches the Excel version (32 or 64-
bit).

9-3
Appendix A-1

A Appendix

A.1 UniSim Design Browser Functions Description .............................. 2


A.1.1 CaseFileName.......................................................................... 2
A.1.2 CellAddress............................................................................. 2
A.1.3 EnvOrFSName ......................................................................... 3
A.1.4 ItemIndex .............................................................................. 3
A.1.5 StartItemIndex........................................................................ 4
A.1.6 EndItemIndex ......................................................................... 4
A.1.7 NewValue ............................................................................... 5
A.1.8 ObjectName ............................................................................ 5
A.1.9 ObjectType.............................................................................. 5
A.1.10 SolverMode ........................................................................... 6
A.1.11 Environment.......................................................................... 6
A.1.12 SuppressPopUps .................................................................... 6
A.1.13 ExtraIndex ............................................................................ 7
A.1.14 SpreadsheetName.................................................................. 7
A.1.15 Units .................................................................................... 7
A.1.16 Update ................................................................................. 7
A.1.17 UpdateCell ............................................................................ 8
A.1.18 VariableName ........................................................................ 8
A.1.19 VorH .................................................................................... 9

A-1
A-2 UniSim Design Browser Functions

A.1 UniSim Design Browser


Functions Description
The following sections detail each of the argument parameters used in
UniSim Design Browser functions.

A.1.1 CaseFileName
The CaseFileName parameter is used to pass the name of the case to
be accessed. There are five options for setting this parameter:
1. Full Name (including path)
for example "C:\Program Files\Honeywell\UniSim Design
R400\Samples\G-2.usc"
2. Relative Path
for example "\G-2.usc" or "\Samples\G-2.usc"
The preceding "\" indicates that the specified path is relative to the
owner Excel sheet. Note that this file location is dependant on the
file location of the Excel file, it has to be saved before relative path
is used.
3. The same name as the owner Excel file
This is particularly useful if you keep renaming your case and don't
want to keep changing the references in the Excel. This is set by
entering the word "MyName" in the CaseFileName parameter.
4. Empty quotes (use Active case)

Entering empty quotations indicates using the active UniSim Design


case.
5. Cell reference
This option can only be used if the function was entered in a cell in
Excel rather than in VBA code. The referenced cell can contain any
of the above four options and will be treated as described above.
Using cell reference is recommended since it facilitates the use of all
the other options while eliminating the need for updating every cell
in case of a file name change.

A.1.2 CellAddress
The CellAddress parameter is used by the Spreadsheet access functions
(GetSpreadsheet, Set Spreadsheet, etc...). It is used to pass the
address of the cell to be accessed, for example "A1", "B6", etc...

A-2
Appendix A-3

Note that forgetting to put quotation marks around the CellAddress,


e.g. entering A1 instead of A1 will result in Excel passing the contents
of cell A1 in the Excel sheet to find as the name of the UniSim Design
Spreadsheet cell.

A.1.3 EnvOrFSName
If accessing objects within the Oil Characterisation environment Oil
Manager is passed for the EnvOrFSName parameter, otherwise this is
used to pass the Tag of the flowsheet to be accessed. In UniSim Design
each flowsheet within a case must have a unique flowsheet Tag. It is
this Tag that must be passed to this parameter. The flowsheet Tag can
be found by looking on the Connections tab of the Sub-Flowsheet
window or by looking in the title bar of the PFD for the flowsheet.

Figure A.1

For example to access the main flowsheet of a UniSim Design case


enter "Main". In the case above the Tag is TPL1.

UniSim Design Browser also supports a full path approach for


backwards compatibility reasons.

For example "TPL2@TPL1@Main" would indicate sub-flowsheet tagged


TPL2, which is within sub-flowsheet TPL1 which is within Main.

A.1.4 ItemIndex
The ItemIndex parameter is used to identify a specific item within an

A-3
A-4 UniSim Design Browser Functions

array. For example if the variable being accessed is composition,


ItemIndex would represent the component position within the
composition array.

ItemIndex expects a string entry, yet it allows that entry to either be


the name of a component or its number (index) within the array. For
example "Methane" or "2" are both acceptable. UniSim Design arrays
number from 0.

ItemIndex parameter is a required parameter for both the


GetUniSimDesign and SetUniSimDesign functions, even though it is
only used with Array variables. If you are not using an Array Variable,
just enter an empty string ().

Array variables cover many variables in UniSim Design other than


composition (Tray Pressures, Tray temperatures in a column, etc...);
however UniSim Design Browser functions only recognise either
component names or index numbers. So, for example, you can't access
a tray temperature by tray name.

When dealing with component names, the functions internally translate


them to index numbers first then use them, so theoretically if you try to
access Tray temperature and pass "Methane" as your ItemIndex, the
function will find the index of "Methane" in the current component list,
then use the tray with the same index to return the temperature. This
approach is not recommended!

The GetUniSimDesignArray function has two itemindex parameters that


must be specified.

A.1.5 StartItemIndex
The StartItemIndex parameter is used to identify the first item in the
array that will be returned. As for the ItemIndex parameter either a
number or a name can be supplied. If an empty string is supplied the
first item is assumed.

A.1.6 EndItemIndex
The EndItemIndex parameter is used to identify the last item in the
array that will be returned. As for the ItemIndex parameter either a
number or a name can be supplied. If an empty string is supplied the
last item is assumed.

If EndItemIndex is specified so that it is lower than StartItemIndex


then they are swapped inside UniSim Design Browser.

A-4
Appendix A-5

A.1.7 NewValue
The NewValue parameter is used to pass the new value to be exported
to UniSim Design. The type of value you pass is a function of the
variable specified, for example "Temperature" would require a
numerical value, while "Name" would require a string.

Arrays are supported when passing new values, so if you are passing
composition through an Excel spreadsheet the following formats can be
used in your function for the NewValue parameter:
...,B1:B16,...
...,{0.05,0.04,0.84,0.36},...
[Note these are curly brackets {} not round brackets
()]
When passing arrays, the ItemIndex parameter is used to specify
the first entry in the UniSim Design array that will be modified. For
example if an array containing two values is passed to a UniSim
Design composition with an ItemIndex of 3 then the compositions
at positions 3 and 4 in UniSim Design will be updated. Remember
UniSim Design arrays number from 0.

[This behaviour is new for UniSim Design Browser from version


1.1 onwards; in previous versions the ItemIndex parameter
was totally ignored.]

Additionally if one of the items of the array is not modifiable, it will be


replaced by -32767 (the UniSim Design <empty> value). This is
particularly useful in the split ratio of a tee, where one of the ratios is
always calculated to be the balance of the rest.

A.1.8 ObjectName
The ObjectName parameter is used to pass the name of the object to
be accessed. Currently only Streams and Unit Operations are
supported.

A.1.9 ObjectType
The ObjectType parameter is used to pass the object type to be
accessed. In a UniSim Design flowsheet the names of all the streams
must be unique and similarly the names of all the unit operations must
be unique, but it is possible to have a stream named the same as a unit
operation; hence the need to differentiate. Also it is possible to make
UniSim Design Browser access stream phase properties by supplying a

A-5
A-6 UniSim Design Browser Functions

particular object type.

These are the supported Object Types:


Operation
Stream
Vapour
Liquid
HeavyLiquid
CombinedLiquid
Fluid

A.1.10 SolverMode
This is an optional parameter. All the functions are set up to default to
NoAction if no value is supplied.

The SolverMode parameter sets the solver mode of the case. The
options for this entry are:
Active - Activates the solver
Hold - Puts the solver on hold
Toggle - Switch it from its current state to the other
NoAction - Just leave it as it is (default)

Setting the solver mode to hold while you make a number of changes
can save time, since UniSim Design will not re-converge after every
change.

A.1.11 Environment
This is also an optional parameter. All the functions are set up to
default to NoChange if no value is supplied.

The Environment parameter sets the current environment mode of the


case. The options for this entry are:
Simulation
Basis
OilManager
NoChange - (default)

A.1.12 SuppressPopUps
This is also an optional parameter. All the functions are set up to
default to NoSuppress if no value is supplied.

A-6
Appendix A-7

The SuppressPopUps parameter can be used to suppress any pop up


messages produced in UniSim Design. The options for this entry are:
StillShowMaxIts
SuppressAll
NoSuppress - (default)

If no entry is provided or anything other than these three options is


entered then NoSuppress is assumed and pop up messages are not
suppressed. If StillShowMaxIts is used then all pop up messages are
suppressed except those generated by Adjusts or Recycles when they
reach maximum iterations. If SuppressAll is passed then ALL pop up
messages are suppressed. This feature works by calling the
ChangePreferencesToMinimizePopupWindows method of the UniSim
Design application object. It should be noted that once either
StillShowMaxIts or SuppressAll is used in any function then this setting
is remembered by UniSim Design until the application is closed
regardless of any subsequent NoSuppress calls from UniSim Design
Browser functions.

A.1.13 ExtraIndex
This parameter is currently used only to set the Name (or index) of the
solid component for PSD properties, and is required only when
reporting Particle Size Distribution (PSD) Properties.

A.1.14 SpreadsheetName
This parameter passes the name of the Spreadsheet to be accessed.

A.1.15 Units
This parameter passes the units for the value to be set or returned. If
no units are specified (empty quotes), UniSim Design internal units will
be used.

A.1.16 Update
The Update parameter is mainly used as a trigger for re-evaluating the
function. It can also be used to prevent uncontrolled updates by
setting its value to "False".

The best way to use the Update parameter is by making a reference to


another cell. This creates a control cell that can be set to false if the

A-7
A-8 UniSim Design Browser Functions

calculations are to be stopped, or set to anything else for default


behaviour. When using a cell reference, the referenced cell can also be
an "AutoUpdate" cell (see SetAutoUpdate function for details). This
will then cause the function to re-evaluate every time the UniSim
Design case re-converges.

Using AutoUpdate makes sense only with the Get functions


(GetUniSimDesign, GetSpreadsheet and GetSpreadsheetValue), since
the Set functions will be evaluated automatically every time their value
changes. Also using AutoUpdate with Set functions has the potential to
trigger an infinite loop between UniSim Design and Excel.

A.1.17 UpdateCell
The UpdateCell parameter accepts only a cell reference as a value and
is used by the SetAutoUpdate function to set a cell (other than the one
holding the function) to be an AutoUpdate cell. The referenced cell
value will be controlled by the UniSim Design Browser and will be
updated with a randomly generated number every time the UniSim
Design case re-calculates.

That cell can then be used as an Update cell in other UniSim Design
Browser functions to create a live link between UniSim Design and
Excel.

A current limitation of the SetAutoUpdate function is that it only


supports one UniSim Design Case and one Update cell per Excel file. So
it is recommended that you add this function to your spreadsheet only
once per file. Adding it multiple times will result in unexpected
behaviour as to which one will update.

A.1.18 VariableName
This is used to supply the name of the variable to be accessed. The
best way to get the value for this parameter is to create a function
using the UniSim Design Browser graphical interface which
automatically sets the value.

The UniSim Design Browser uses the variable names as defined in the
UniSim Design object library. This can be accessed in the Excel VBA
editor (Tools - Macro - Visual Basic Editor menu option) by using
the view Object Browser menu option.

Additionally Backdoor variables may be reported by supplying the


following for the VariableName parameter:

A-8
Appendix A-9

Backdoor[Moniker]

Where Moniker is the Backdoor variable moniker required. See


Section 7.12 - Using the Backdoor variable monikers for more
information.

Similarly Extension unit operation variables can be obtained in a similar


way by editing the VariableName parameter to use the form:

ExtensionVar[Extension Variable 'Tag']

Where the Extension Variable Tag can be determined by examining the


edf file for the extension. See Section 7.12 - Using the Backdoor
variable monikers for more information.

A.1.19 VorH
This is an optional parameter for the GetUniSimDesignArray function.
If no value is supplied then v is assumed. This parameter sets the
orientation of the array returned. If v (or nothing) is supplied then
the array returned is vertically arranged, if any other value is supplied
then the array returned is horizontal.

A-9

Vous aimerez peut-être aussi