ChemCAD 5 services to visual basic applications: User Manual

Страницы работы

32 страницы (Word-файл)

Содержание работы

ChemCAD 5 services to visual basic applications

User Manual

chemstations, inc.

Introduction

Four features to link with Visual Basic applications, such as Excel, are now available in CHEMCAD 5. The first one is that CHEMCAD 5 can be activated from a Visual Basic application as an out-of-process server. This enables a VBA-enabled application to initiate communications with CHEMCAD 5. The second is the addition of a new unit operation in CHEMCAD 5 called “Excel Unit”. With this feature, a user can program user-specific tasks in VBA macros, and execute these macros in the context of a unit operation during a simulation run. The third feature allows user to enter user-specified rate expressions in use with CHEMCAD 5 built-in kinetic reactor (KREA) and batch reactor (BREA). The fourth is the capability to generate unit operation specification sheets using CHEMCAD 5 and Excel workbooks.

CHEMCAD 5 can be used as out-of-process server to provide services to VBA-enabled clients, such as Excel. By employing these CHEMCAD 5 services from a user application, the user can exchange stream and unit data exchange, locate and execute simulation jobs, acquire flowsheet information, access thermodynamic functions, retrieve physical properties, and perform engineering unit conversions. In a VBA-enabled application, the user first creates a COM object using its programmatic identifier (ProgID) in VBA command CreateObject(“CHEMCAD.VBServer”), then accesses its operations or other objects if needed. The interface of this object is called VB Server. The operations of this interface are discussed in next section.

A new unit operation, “Excel Unit”, has been added to CHEMCAD 5. With the addition of this unit, CHEMCAD 5 is capable of linking its flowsheet with Excel workbooks as its unit operations. When placing an Excel Unit icon on a flowsheet, specifying the path to an Excel workbook, and running the flowsheet, CHEMCAD can activate the specified Excel workbook and execute the given VBA macros of the workbook. Furthermore, CHEMCAD exports a set of COM interfaces to provide an adequate modeling environment to users of Excel Unit. Every time a VBA macro is executed, a handle to a COM object in CHEMCAD 5 is passed in as an argument. Through the object handle, user can access a number of CHEMCAD functions within their macros. By developing user macros, a list of tasks can be accomplished. User can retrieve the topology of the current flowsheet, such as stream and unit IDs, and their connections. From these IDs, user can retrieve and update stream data and unit specifications. For stream data, user may also apply flash calculations, K-value and enthalpy calculations. Engineering unit conversions are made available for stream data, unit specifications, and general unit conversion cases. 

The Excel Unit in CHEMCAD is developed using Microsoft COM with Excel API interfaces. The result is a versatile, user-friendly, powerful and expandable environment for CHEMCAD 5 users. Excel Unit can be designed for a variety of applications. Among these are modeling of user-specific unit operations, making presentation or documentation of CHEMCAD calculation results in Excel, passing user stream data or equipment specifications into CHEMCAD, and monitoring or regulating the calculation states of stream or units on the flowsheet. The user-specific tasks that can only be accomplished using Calculators or User-Added Modules can now be solved within Excel Units. Since VBA is an interpretive language, it does save the trouble of compiling user codes and linking with CHEMCAD libraries.

To open up CHEMCAD 5 built-in reactors to user-specified rate expressions, we provide dialog for entering user rate expressions and generating VB codes. After that, user can import the codes into an Excel workbook, and CHEMCAD 5 will activate the macros during sequent simulation runs. If needed, user can access CHEMCAD 5 information through exported interfaces within their macros.

Process engineers often need to generate unit operation specification sheets that document the process requirements of unit operations. If a user want to use the equipment data in CHEMCAD 5 to generate the specification sheets, he/she can create or modify the template on Excel worksheets to a specific format, program macros to fill in unit operation data, and use CHEMCAD 5 to activate the macros to generate the desired specification sheets.

Many CHEMCAD 5 functions are made available through its VB Server interface and to Excel Unit as a number of exported interfaces. This document presents a detailed discussion on these exported interfaces for use with CHEMCAD VB Server and Excel Units. Users will request the services of one or more interfaces in their VBA macros. The readers should be familiar with VBA syntax and some knowledge of Microsoft COM.

VB Server

Похожие материалы

Информация о работе