oli alliance engine 7.0 user guidesupport.olisystems.com/documents/manuals/oli alliance engine...

54
OLI Systems, Inc. OLI Alliance Engine Basics Page1 OLI Alliance Engine 7.0 User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 1.1 Purpose of the Alliance Engine 3 1.2 Components 3 1.3 Evolution 3 1.4 Characteristics 4 1.5 Alliance Engine Data Flow 4 1.6 Build a Chemistry Model 4 1.6.1 The Chemistry Wizard 5 1.6.2 Fixed Chemistry 5 1.6.3 Component Selection Module 6 1.6.4 Retrieving Information from the Chemistry Model 6 1.7 Access the OLI Solver 6 1.7.3 Types of Solver Calls 7 1.7.2 Internal Solver Units 7 1.7.3 Memory Allocation 7 1.8 Use the results 8 2 Installation 9 2.1 Requirements 9 2.1.1 Licensing 9 2.1.2 Hardware 9 2.1.3 Windows Operating system 9 2.1.4 FORTRAN Development Environment 10 2.2 OLI Hardlock Key 10 2.3 Setup 10 2.4 Installation Verification 11 3 Getting Started 12 3.1 Select an example application 12 3.2 Select a development environment 12 3.2.1 Compaq Visual FORTRAN 6.6 Project 12 3.2.2 Intel FORTRAN 8.0 Project 12 4 Example Applications 13 4.1 isothermal example 14 4.1.1 Problem definition 14 4.1.2 Approach 14 4.1.3 Results 14 4.2 solubility example 15 4.2.1 Problem definition 15 4.2.2 Approach 15 4.2.3 Results 15

Upload: phungthu

Post on 11-Mar-2018

281 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page1

OLI Alliance Engine 7.0 User Guide

OLI Alliance Engine 7.0 1

User Guide 1 1 Overview 3

1.1 Purpose of the Alliance Engine 3 1.2 Components 3 1.3 Evolution 3 1.4 Characteristics 4 1.5 Alliance Engine Data Flow 4 1.6 Build a Chemistry Model 4

1.6.1 The Chemistry Wizard 5 1.6.2 Fixed Chemistry 5 1.6.3 Component Selection Module 6 1.6.4 Retrieving Information from the Chemistry Model 6

1.7 Access the OLI Solver 6 1.7.3 Types of Solver Calls 7 1.7.2 Internal Solver Units 7 1.7.3 Memory Allocation 7

1.8 Use the results 8 2 Installation 9

2.1 Requirements 9 2.1.1 Licensing 9 2.1.2 Hardware 9 2.1.3 Windows Operating system 9 2.1.4 FORTRAN Development Environment 10

2.2 OLI Hardlock Key 10 2.3 Setup 10 2.4 Installation Verification 11

3 Getting Started 12 3.1 Select an example application 12 3.2 Select a development environment 12

3.2.1 Compaq Visual FORTRAN 6.6 Project 12 3.2.2 Intel FORTRAN 8.0 Project 12

4 Example Applications 13 4.1 isothermal example 14

4.1.1 Problem definition 14 4.1.2 Approach 14 4.1.3 Results 14

4.2 solubility example 15 4.2.1 Problem definition 15 4.2.2 Approach 15 4.2.3 Results 15

Page 2: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page2

4.3 properties example 16 4.3.1 Problem definition 16 4.3.2 Approach 16 4.3.3 Results 16

4.4 cmdline example 17 4.4.1 Problem definition 17 4.4.2 Approach 17 4.3.3 Results 17

5 Reference for Standard Equilibrium Calls 18 5.1 Basic Access 18 5.2 Chemistry Model Generation Calls 19

5.2.1 Return molecular names from a databank 19 5.2.2 Automatic Redox/Oxidation Reactions 20 5.2.3 Setting up to run OLI Chemistry Model Generation 21 5.2.3 Setting up to run OLI Chemistry Model Generation 21 5.2.4 Generating the Chemistry Model 22 5.2.5 Chemistry Model Retrieval and Storage (Initialization) 23

5.3 Equilibrium Computation 24 5.3.1 Multi-stage Calculations 24 5.3.2 Column profile Information 27

5.4 Results organization 28 5.4.1 GVEC – Molecular Stream Description 28 5.4.2 EVEC – Aqueous Stream Description 30 5.4.3 ASAP Units 31

5.5 Memory Deallocation 33 Appendix 1: Source Code for Examples 34

A.1.1 Isothermal source 34 A.1.2 Solubility source 42 A.1.3 Properties source 48

Appendix 2: Acknowledgements 53

Page 3: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page3

1 Overview

1.1 Purpose of the Alliance Engine The OLI Alliance Engine provides an API to software developers in order for other programs to accesses OLI technology. Either OLI’s aqueous model or the mixed solvent electrolyte (MSE) model can be accessed. The Engine can be called for an equilibrium calculation and the resulting phase separations, or for properties without an equilibrium call, providing maximum flexibility and speed for the calling program.

1.2 Components The OLI Alliance Engine consists of:

• The OLI Solver • The OLI Databanks • An OLI Application Programmer Interface (API) that accesses the Solver and Databanks. • Documentation of the OLI Alliance Engine:

o This instruction manual, OLI Alliance Engine Basics o A reference guide to the API, OLI Alliance Engine Reference Manual o A user guide for intermediate-level users, OLI Alliance User Guide

1.3 Evolution The Alliance Engine has evolved from over a dozen implementations of calling the OLI Solver and Databanks, beginning as early as 1977. Interfaces between the Engine and other programs include interfaces with major flowsheet simulators such as HYSYS, AES, UniSim, and gProms, as well as interfaces with a company’s proprietary software. Early implementations were entirely in FORTRAN. There have also been C / C++ implementations to the Engine, most notably Aspentech’s HYSYS and Honeywell’s UniSim Design, as well as OLI’s own Analyzer software. In previous versions of the Engine, OLI offered the API as COM Objects. This approach has been abandoned, however, because of the need for speed at execution time. The Alliance Engine has also been used experimentally to interface with flow models, most notably with Fluent’s technology, as part of a DOE-sponsored Crystallization project. This work is not commercially available at this time, however.

Page 4: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page4

1.4 Characteristics The OLI API is written in FORTRAN, packaged as a DLL, and callable from FORTRAN and other languages, such as C / C++. FORTRAN argument lists are used at communication between the Solver and the user program. A published list of indices into the arguments’ arrays can be found in Section 5, Reference. Solver calls can be initialized from previous Solver calls, gaining the efficiency that comes from a good initialization of the Solver variables. Also, once a calculation is performed, it remains in memory until the next calculation call. This allows the user to query for auxiliary results that remain in the storage arrays. There are multiple calculation modules available through the API. These include:

• Regular equilibrium calculations • Kinetics • Multi-stage calculations • Lab reconciliation calculations

1.5 Alliance Engine Data Flow The steps needed to use the Alliance Engine include:

• Build a Chemistry Model • Access the Solver • Use the results

It is important to realize that for a given chemistry, the first step is done only once. Many calculations can be made on the same chemistry model. Each of these steps will be discussed in more detail in the following sections.

1.6 Build a Chemistry Model

DBS File

Comps to ModelDefinition

PROGRAMAUTOGEN

Model Definition toDBS

PROGRAMSOLGEN

List of componentsWhich phases to considerOther control information Model Definition

.MDL file .MOD file

Reports and warnings Reports and warnings

Files and programs needed for a Chemistry Model

Page 5: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page5

In OLI terminology, a chemistry model is a collection of components, their related components, the species for these components in four phases (vapor, liquid, solid, and second liquid if invoked), the data about the species (from the OLI databanks), and indices that will be used in the OLI Solver. As can be seen from the picture above, the chemistry model is built from a list of components into a model definition, and then the model definition is used to generate a file known as the DBS file. The DBS file is the ASCII file that contains all chemistry model information. It is the output file of the Chemistry Model Build step, and is needed for any access to the OLI Solver.

Created componentselection module

Fixed chemistry

OLI-suppliedChemistry Wizard

Developer

Data to file

Defined in code

Provide facility

Get namesfrom OLI DB

DBS File

Comps to ModelDefinition

PROGRAM

Model Definition toDBS

PROGRAM

Target

OLI Supplied

SELEC

T ON

E

There are three ways to build a chemistry model for the Alliance Engine, as shown in the diagram above. These include:

• Use the OLI-supplied Chemistry Wizard program; • Hard-code a fixed chemistry in the code; • Create a user interface (UI) that gathers the data needed for this step.

1.6.1 The Chemistry Wizard OLI provides a program called the Chemistry Wizard that is an end user tool to build a Chemistry Model. It allows the user to search for components and all the auxiliary tasks that the OLI Analyzer software allows. This is the quickest way to create a DBS file for an application. It can save the development time that would be needed to write the component selection module. The output from the Chemistry Wizard is the DBS file.

1.6.2 Fixed Chemistry When the application that needs the Alliance Engine has a fixed chemistry that will not change, it might be advantageous to simply set the chemistry within the user program. The component names

Page 6: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page6

are defined by specifying the OLI tag name for a component, and then the two OLI programs, AUTOGEN and SOLGEN, are run sequentially to create the DBS file. OLI tag names can be found in the Chemistry Wizard, in other OLI programs such as the Analyzers, or by asking for a database listing from OLI. In addition to the component names, there are other control data needed for running AUTOGEN and SOLGEN. Please refer to the reference section for the definition of the argument lists for these two required programs.

1.6.3 Component Selection Module The UI for programs that use the Alliance Engine can have infinite variety in how it collects the end user data required to build the chemistry model. The API provides utilities that retrieve the component names from the OLI database. These utilities are GETNAM1, GETNAM2, and GETNAM3. They are described in the reference section. AUTOGEN and SOLGEN are required steps here, as well, in order to produce a DBS file. As with the fixed chemistry option, the argument list definition is critical in a successful DBS file build.

1.6.4 Retrieving Information from the Chemistry Model Files are created during the course of the Chemistry Model build, and these files can be examined to learn more about the OLI model and also to ascertain that the chemistry model build was successful. Only the DBS file is required for calls to the OLI Solver. API retrieval utilities are available for querying information about the model (from the DBS file). These include EQMODxx utilities. They are described in the reference section later in this manual.

1.7 Access the OLI Solver Access to solver calculations is straightforward and can be summarized in the following diagram:

Page 7: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page7

Argument listpreparationDeveloper

CalculateCall API

Target

DBS File

Size of problemindices and details

Cal input preparation :e.g. T, P, comp

Results array allocation

Initialize a chemistryCall API

Call type selection

Results into memory

Argument list

Trace file

1.7.3 Types of Solver Calls There are utilities in the API that can solve equilibrium calculations, including calls as complicated as multi-stage equilibrium. There are also API utilities that provide properties such as fugacities, without performing an equilibrium calculation. Please refer to the reference section to determine the type of data you would like to get. Then, prepare argument lists for the call. See the applications section for examples.

1.7.2 Internal Solver Units The API expects the arguments in internal solver units, which are:

• degrees Celsius for temperature • atmospheres for pressure • gmole/hr for component composition

Similarly, the API outputs data in internal units. Please see the argument lists in the utilities descriptions for specific units.

1.7.3 Memory Allocation The Alliance Engine user is responsible for allocating memory, and the memory can be re-used in subsequent calls, provided the array sizes remain the same, or get smaller. There is no array checking that is done before the API utilities write data to memory locations specified in the argument lists.

Page 8: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page8

1.8 Use the results

Target

Argument Lists

Results

Locate Information

Results to disk, screen, another function

User InformationDeveloper

Create reports

DBS File

Transform Information

The argument list will have the data from the API utility call, indexed according to the order specified in the argument lists (in the reference section). The developer locates the information, transforms it to an optimal form for the application, and uses it through reporting or using in another function.

Page 9: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page9

2 Installation The installation script is available in two forms:

• A self-extracting executable file named “OLI Engine 7.0.exe” available for download from the OLI Systems web site..

• A product distribution CD available from OLI systems

Before installing this product, you will need to install “OLI Chemistry Wizard 1.1” or later, if you plan to use the Chemistry Wizard to build your Chemistry Model.

2.1 Requirements

2.1.1 Licensing The Alliance Engine is a separate OLI product, and is licensed separately. Moreover, each application of the Alliance Engine is sold separately. For example, the OLI Engine for HYSYS OLI is an Alliance Engine application. A license is needed for the Alliance Engine (to develop new applications), and a separate license would be needed to use the OLI Engine for HYSYS OLI.

2.1.2 Hardware The following hardware is required for all OLI products:

Resource Minimum Requirements CPU Intel Pentium 3 800 MHz or comparable AMD Physical memory (RAM) At least 128 MB Virtual memory At least 2 times physical memory Hard disk space At least 100 MB free Monitor Color with at least 1024x768 resolution Pointing device 2 or 3 button Microsoft compatible mouse Ports 1 parallel port or 1 USB port

2.1.3 Windows Operating system The following table shows the versions of Windows that are supported and the preferred service pack level for each

Operating System Service Packs MS Windows NT 4.0 Service Pack 6 MS Windows 2000 (any) Service Pack 3 MS Windows XP (any) Service Pack 1

Page 10: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page10

Please contact OLI for further information in using this product on other operating systems. (Macintosh systems and Linux systems have been used successfully with the OLI Solver; however, there are security problems with earlier MAC OS’s.)

2.1.4 FORTRAN Development Environment To develop in FORTRAN, you will need one of the following FORTRAN environments:

• Compaq Visual FORTRAN 6.6 • Microsoft Visual Studio .NET 2003 with Intel FORTRAN 8.0

Please contact OLI for further information to develop in a language other than FORTRAN. (Visual Studio’s C / C++ has been used with the Alliance Engine).

2.2 OLI Hardlock Key You will need an OLI Systems’ Hardlock security key and associated serial number. This should be arranged before beginning the installation. OLI offers a choice of parallel port or USB Hardlock keys. Parallel Port Hardlock key To install this key, attach it to the parallel port located on

the back of your computer. • If you have a printer connected to the parallel port,

then unplug the printer, connect the key to the port, and reconnect your printer to the Hardlock key. The Hardlock key should not interfere with printing.

• If you have another Hardlock key for this port, please make sure that the OLI Hardlock key is connected directly to the port and is the first in the chain of keys. The Hardlock key seems to be sensitive to port power levels and works best when it is connected directly to the port.

USB Hardlock key To install the USB Hardlock key, insert it to any available

USB connection

2.3 Setup The OLI Engine installation uses InstallShield to lead you through a typical Windows installation process. Depending on the format that you have:

Type of installation format Instructions Self-extracting executable file Use Windows Explorer to locate the file and double

Page 11: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page11

click on the file to start the installation CD Insert the CD into your drive. If it does not autostart,

select Run from the Start menu and run D:\Setup.exe (where D: is the drive letter of your CD-ROM). Alternatively, use Windows Explorer to locate Setup.exe and double click on it.

During the installation, you will be asked to provide your name, organization, and a product serial number. If you received a CD, the serial number should be with it. Otherwise, OLI will email the serial number to you as part of your licensing arrangement.

2.4 Installation Verification At this point, you can verify your installation by simply making sure that files were installed in the desired installation directory, and that a program group has been added to the Start menu. 1. Open Windows Explorer and navigate to the destination directory:

C:\Program Files\OLI Systems\Alliance Engine 7.0 You should find six subdirectories: bin, doc, include, lib, src, and test. If you see only the bin directory, you do not have the correct license serial number. Please contact OLI. 2. Click on the “Start” button and navigate to:

Programs\OLI Systems\Alliance Engine 7.0

You should see a menu item for “Security Settings and Test” If you can run this short dialog successfully, the OLI security is correctly installed.

Page 12: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page12

3 Getting Started OLI recommends using workspace and project files prepared at OLI for each of the two FORTRAN development environments. These files, along with the FORTRAN source code for the examples, can be requested from OLI’s Technical Support.

3.1 Select an example application Once you have the electronic sample files, OLI recommends the isothermal example calculation to test the installation and establish your FORTRAN development environment. This is the first application described in the next section. This is the most basic access to the OLI Solvers for an equilibrium calculation. Isothermal works with a fixed chemistry to build a chemistry model and then performs an isothermal equilibrium calculation. The results are displayed to a file, isothermal.lis, that should be generated on your PC. The source for this file is listed in the application section, and the electronic source is available as described above

3.2 Select a development environment Two development environments have been pre-built at OLI. They are included with the sample files.

3.2.1 Compaq Visual FORTRAN 6.6 Project The workspace and project files for the Compaq Visual FORTRAN compiler are located in the electronic package that OLI distributes in the directory CVF66.

3.2.2 Intel FORTRAN 8.0 Project The workspace and project files for the Intel FORTRAN compiler are located in the electronic package that OLI distributes in the directory Intel80.

Page 13: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page13

4 Example Applications This section illustrates different techniques for using the API for the Alliance Engine. Sample problems include: Example name What it illustrates isothermal Shows all basic steps for working with an equilibrium calculation

solubility Shows how to setup and a calculation, and retrieve the amount of reagent needed to achieve a solubility survey

properties Shows how to retrieve the self-diffusivities without calling the equilibrium model

cmdline A complex, useful, multi-faceted example that shows how to run the API from input files, setting up many of the alternate API calls found in the reference manual (recommended for intermediate users)

lab (not yet available)

Shows how to setup ionic input, balance it, and reconcile for pH

kinetics (not yet available)

Shows how to use OLI kinetics in an example call

Page 14: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page14

4.1 isothermal example Before looking at this example, please read chapter 5.1, Basic Access to the OLI Alliance Engine. This will explain the API calls that we are making within this example.

4.1.1 Problem definition For a fixed water chemistry chemistry containing equal parts of methanol, acetone, and benzene, with nitrogen and calcium carbonate, calculate the phase equilibrium at a fixed pressure and temperature, and display the phase results in a file. Input: Molecular species flow, gmoles / hour

H2O 100 Methanol 10 Acetone 10 NaOH 0.1 HCl 0 Benzene 10 N2 2 CaCO3 1 Temperature 67 C Pressure 1.2 atm

4.1.2 Approach Using the OLI Alliance Engine, the following calls will be made to the API:

PSREDOX – to setup redox for the case AUTOGEN – to create a the model definition from molecular flows SOLGEN – to generate the thermodynamic file .DBS for the OLI Solver HYPINIT – to bring the .DBS file into memory HYPCALC – to calculate the isothermal equilibrium

4.1.3 Results FORTRAN File 93 will contain formatted output showing the model’s speciation and also the calculation results. The format for the output arrays can be found in the reference section. The source code and output can be found in Appendix 1, “Source code and results for examples.”

Page 15: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page15

4.2 solubility example Before looking at this example, please work example 4.1, isothermal. This will explain the API calls that we are making within this example.

4.2.1 Problem definition What is the solubility of CaCO3 in a mixture of water, CaCl2 and MgCl2, and CO2? This example calculates the precipitation point of CaCO3, also called the solubility, in the defined chemistry Input: Molecular species flow, gmoles / hour

H2O 55.5087 CaCl2 .1 MgCl2 .1 CO2 .01 CaCO3 0.0 Temperature 25 C Pressure 1 atm

4.2.2 Approach Using the OLI Alliance Engine, the following calls will be made to the API:

AUTOGEN – to create a the model definition from molecular flows SOLGEN – to generate the thermodynamic file .DBS for the OLI Solver HYPINIT – to bring the .DBS file into memory HYPCALC – to calculate the precipitation point equilibrium

4.2.3 Results FORTRAN File 93 will contain formatted output that shows the amount of CaCO3 that must be added. The source code and output can be found in Appendix 1, “Source code for examples.”

Page 16: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page16

4.3 properties example Before looking at this example, please work example 4.1, isothermal. This will explain the API calls that we are making within this example to build the chemistry model, and to perform a preparatory equilibrium calculation.

4.3.1 Problem definition Calculate the self-diffusivities for KCl and water, at 1 molal KCl. Input: Molecular species flow, gmoles / hour

H2O 55.5087 KCl 1 Temperature 25 C Pressure 1 atm

4.3.2 Approach For this example only, you will use the OLI equilibrium calculation routine to get the aqueous species amounts. In a real application, the aqueous phase composition must be known, but it does not have to be calculated by OLI. Using the OLI Alliance Engine, the following calls will be made to the API:

AUTOGEN – to create a the model definition from molecular flows SOLGEN – to generate the thermodynamic file .DBS for the OLI Solver HYPINIT – to bring the .DBS file into memory

** HYPCALC – to calculate the precipitation point equilibrium EQPROPD - to calculate self-diffusivities ** HYPCALC is called only to arrive at a slate of aqueous phase compositions

4.3.3 Results FORTRAN File 93 will contain the aqueous phase composition calculated by HYPCALC, and also the self-diffusivities returned from EQPROPD The source code and output can be found in Appendix 1, “Source code and results for examples.”

Page 17: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page17

4.4 cmdline example This example documents many techniques for applying advanced OLI technology by using the OLI API. It is recommended for users who have mastered the concepts in the first three examples.

4.4.1 Problem definition Perform a variety of calculations on a mixed solvent system.

4.4.2 Approach This example is setup to run by following the directions in the OLI Alliance Engine User Guide, with one note: You must run the first argument as NaClAQ1.dbs, and not NaClAQ1.mod.

4.3.3 Results Please refer to the .OUT file in the /test directory of this problem.

Page 18: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page18

5 Reference for Standard Equilibrium Calls

5.1 Basic Access The recommended procedure for accessing the OLI Alliance Engine is to use the basic calls as described below, to create the chemistry model and make equilibrium calculations. These calls include:

API Call Purpose GETNAM This API call is used to as part of creating your own UI to select

components. This utility retrieves the names of the molecular species from the OLI databanks. Variations of this utility also retrieve species, get the molecular weights along with the name, etc.

PSREDOX This API call is used to get the redox reactions when the developer would like to consider redox in the chemistry. It is not needed otherwise.

AUTOGEN This API call creates a readable model definition of the chemistry model, and is a necessary pre-requisite to SOLGEN Input is a list of molecular species names. It returns a list of all the species and chemistry that can arise from the given molecular species.

SOLGEN This API call takes the output from AUTOGEN – the model definition - and creates a disk file (.DBS) containing the thermodynamic data for this model, and indices necessary to access the solver

HYPINIT This API call sets up the data structure necessary for equilibrium calculations by reading the .DBS file into memory.

HYPCALC This API call calculates the equilibrium conditions and returns the results in argument list arrays

HYPFRC This API call is used to solve distillation columns. The input and output for these basic access calls are described in the remainder of this section.. In addition, there are many other ways to access the API, and they are described in the companion Manual, OLI Alliance Engine Reference Manual.

Page 19: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page19

5.2 Chemistry Model Generation Calls

5.2.1 Return molecular names from a databank Retrieves a list of all molecular species names from a databank. CALL GETNAM (DBNAME, MXLIS, NLIS, NAMLIS, PATH1) DBNAME - I CHAR*8 Databank name MXLIS - I/O INT*4 Maximum length of NAMLIS(I) if MXLIS = 0 then only get number of species (not names) and return number in MXLIS NLIS - O INT*4 Number of names returned in NAMLIS NAMLIS(I) - O CHAR*16 NAMES of molecular species in databank Dim NAMLIS(MXLIS) PATH1 - I char*300 Full path name to the databank CALL GETNAM1 (DBNAME, MXLIS, NLIS, NAMLIS, FORMULA, SYNLIS, PATH1) DBNAME - I CHAR*8 Databank name MXLIS - I/O INT*4 Maximum length of NAMLIS(I) if MXLIS = 0 then only get number of species (not names) and return number in MXLIS NLIS - O INT*4 Number of names returned in NAMLIS NAMLIS(I) - O CHAR*16 NAMES of molecular species in databank Dim NAMLIS(MXLIS) FORMULA(I)- O CHAR*30 Chemical formula SYNLIS(I) - O CHAR*75 Long name for the species PATH1 - I char*300 Full path name to the databank CALL GETNAM2 (DBNAME, MXLIS, NLIS, NAMLIS, FORMULA, SYNLIS, IDSTART, IDNO, PATH1) DBNAME - I CHAR*8 Databank name MXLIS - I/O INT*4 Maximum length of NAMLIS(I) if MXLIS = 0 then only get number of species (not names) and return number in MXLIS NLIS - O INT*4 Number of names returned in NAMLIS NAMLIS(I) - O CHAR*16 NAMES of molecular species in databank Dim NAMLIS(MXLIS) FORMULA(I)- O CHAR*30 Chemical formula SYNLIS(I) - O CHAR*75 Long name for the species IDSTART - I/O INT*4 Start ID number for species missing ID Min value 20000 – updated to last number used on return. IDNO - O INT*4 ID number assigned to species PATH1 - I char*300 Full path name to the databank

Page 20: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page20

5.2.2 Automatic Redox/Oxidation Reactions Retrieves Oxidation/Reduction reactions from the databank. The first call to this routine with the first argument equal to zero returns a list of all possible redox sub-system in the databank for the specified inflows. The User then selects the sub-systems to be include and makes a second call with the first argument equal to one. CALL PSREDOX (ICALL, NPRIV, NMOLEC, MOLNAM, NSETS, SUBSYS, INCLFLAG, PATH1, PATH2, PATH3, IERR) ICALL - I int*4 Control Flag 0 – Return a list of the possible redox sub-systems 1 – Get redox equations based on user selections NPRIV(10) - I char*8 Names of private databanks dim 10 NMOLEC - I int*4 Number of molecular species MOLNAM(I) - I char*16 Molecular species names dim 300 NSETS - O int*4 Number of redox sub-systems (ICALL=0) SUBSYS(I) - O char*80 Names of redox sub-systems dim 50 INCLFLAG(I)- I/O int*4 Include/exclude flag for sub-system dim 50 0 – means to exclude sub-system (ICALL=1) 1 – include sub-system (ICALL=1) PATH1 - I char*300 Path name to public databases PATH2 - I char*300 Path name to private databases PATH3 - I char*300 Path name to create/read model files IERR - O int*4 Error number - 0 means no errors

Page 21: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page21

5.2.3 Setting up to run OLI Chemistry Model Generation Utility to run AUTOGEN and create the .MOD chemistry file. CALL AUTOGEN (NAMMOD, MXSIZ, NPRIV, NMOLEC, MOLNAM, PHASE, NSOLM, * SOLMOD, SEL1, NIN1, INSP1, NSP1, * SP1, NEQUAT, EQUAT1, JDUMC, PATH1, * PATH2, PATH3, IDBSW, IAER, MSG) NAMMOD - I char*8 Name of chemistry model MXSIZ - I INT*4 Maximum number of species NPRIV(10) - I char*8 Names of private databanks dim 10 NMOLEC - I int*4 Number of molecular species MOLNAM(I) - I char*16 Molecular species names dim 300 PHASE(4) - I char*3 VAP - Include vapor phase dim 4 SOL - Include solid phase ORG - 2nd liquid organic phase RED – Include redox reactions NSOLM -I/O int*4 Number of solids in model SOLMOD(L) -I/O char*16 Solid names dim 300 SEL1(L) -I/O char*1 Include/Exclude flag for solid dim 300 blank - means to include solid S - SCALING TENDENCY ONLY N - EXLUDE SOLID NIN1 - O int*4 Number of inflow species (molecular) INSP1(I) - O char*16 Inflow species names dim 300 NSP1 - O int*4 Number of species SP1(J) - O char*16 Species names dim 300 NEQUAT - O int*4 Number of equilibrium equations EQUAT1(K) - O char*80 Equilibrium equation dim 300 JDUMC(I) - O int*4 Dummy inflow species (no thermo data) dim 300 PATH1 - I char*300 Path name to public databases PATH2 - I char*300 Path name to private databases PATH3 - I char*300 Path name to create/read model files IDBSW - I int*4 DATABANK TYPE IDBSW=3 IAER - O int*4 Error number - 0 means no errors MSG - O char*80 Error message

Page 22: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page22

5.2.4 Generating the Chemistry Model Utility to run generator and create the .DBS chemistry file. CALL SOLGEN (NAMMOD, NPRIV, ITERM, PATH1, PATH2, PATH3, IER) NAMMOD - I char*8 Name of chemistry model NPRIV(10) - I char*8 Names of private databanks dim 10 ITERM - I int*4 Output print flag 0 - no terminal output 1 - output to terminal PATH1 - I char*300 Path to public databanks PATH2 - I char*300 Path to private databanks PATH3 - I char*300 Path to model files IER - O int*4 Error return code ( 0 – no errors)

Page 23: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page23

5.2.5 Chemistry Model Retrieval and Storage (Initialization) Utility to read a previously generated chemistry model and prepare for calculations (should be called once before any flash calculations). This routine is the same as EQMODEL except that it returns more information. Either routine may be used. CALL HYPINIT (MODNAM, NINFL, NAMIN, XMWIN, NOUFL, NAMOU, * NOUSL, NAMSL, NNSPX, NKIN, ISPEQ, PATH3) MODNAM - I char*8 Chemistry model name NINFL - O int*4 Number of molecular inflow species NAMIN(J) - O char*16 Names of molecular inflows dim 300 XMWIN(J) - O real*8 Molecular weight of inflows dim 300 NOUFL - O int*4 Number of species NAMOU - O char*16 Names of species dim 300 NOUSL - O int*4 Number of solids in model NAMSL - O char*16 Names of solids dim 300 NNSPX - O INT*4 Required dimension for species vectors NKIN - O INT*4 The total number of species that must be set for kinetics. ISPEQ(I) - O INT*4 The number of the species that must be set in the call to HYPCALC. ISPEQ(I) is the index into NAMOU (the true species vector) The dimensions for this vector must be at least equal to the number of kinetic reactions. (ISPEQ(I),I=1,NKIN) PATH3 - I char*300 Full path name to model files

Page 24: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page24

5.3 Equilibrium Computation Computes equilibrium conditions and retains results in Solver until the next call to HYPCALC. This routine is the same as EQSOLVE except for some additional arguments. Either routine may be used. CALL HYPCALC (IFUNC, IREST, TEMP, PRES, COMP, SPEC1,

• SPEC2, SPEC3, JSOLID, HOLDUPT, KISTEP, EVECIN, • NIPROP, IPROP, GVEC, EVEC, SCALE, PATH3, IPRINT, IGCPT, IERR)

IFUNC - I int*4 Type of equilibrium calc (see EQSOLVEK) IREST - I int*4 Restart indicator = 0 No restart - initialize case = 1 use the values in EVEC to initialize TEMP - I REAL*8 Temperature, C PRES - I real*8 Pressure, atm COMP(I) - I real*8 Inflows, gmole/hr dim 300 SPEC1 - I real*8 Equilibrium specifications (see EQSOLVEK) SPEC2 - I real*8 Equilibrium specifications (see EQSOLVEK) SPEC3 - I real*8 Equilibrium specifications (see EQSOLVEK) JSOLID(I) I int*4 Solid inclusion indicator dim 300 = 0 include solid = 1 exclude solid HOLDUPT – I REAL*8 Residence time,hr for kinetics KISTEP - I int*4 Number of CSTR reactors Residence in each cstr = holdupt/kistep EVECIN(I) - I REAL*8 True gmole/hr of species ISPEQ(I) entering the reactor (ISPEQ(I) is the true species number returned by HYPINIT). The dimensions for EVECIN must be at least equal to the number of kinetic reactions (EVECIN(I),I=1,NKIN) NIPROP - I INT*4 Number of property specifications IPROP(I) – I INT*4 Flag for transport property calculations dim 6 1 = Include Electr Conduc calc 2 = Include Viscosity calc 3 = Include Self-Diffusivity calc 4 = Include heat capacity 98 = Include all trans prop 99 = exclude all prop GVEC(J) - O real*8 Calculated results (See GVEC doc) dim 1330 EVEC(K) - O real*8 Aqueous stream output vector dim 610 ( See EVEC doc) SCALE(I) -O real*8 Solid scaling indexs dim 300 PATH3 - I char*300 Full path name to model files IPRINT - I int*4 Print control = 0 No printed output = 1 disk output = 2 terminal output = 3 disk and terminal output IGCPT(I)- O INT*4 Pointer into GVEC array dim 12 IERR - O int*4 Error return code ( 0 = no errors)

5.3.1 Multi-stage Calculations Routine to calculate multi-stage columns CALL HYPFRC (COLNAM, RESFIL, STRM, UPARM, PPRODU, PPIONIC, PATH3, * IGC, IERR) COLNAM - I char*8 Unique name for the column RESFIL - I char*8 Restart file name STRM(I,J) I real*8 Feed stream flow rates, gmole/hr dim (nnsp+5,10) UPARM(K) I real*8 Column parameters (see below)

Page 25: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page25

dim 349 PPRODU(I,J) O real*8 Calc output stream (GVEC format) dim (4*(nnsp+20)+50,12) PPIONIC(K,J) O real*8 Calc output stream (EVEC format) dim (2*nnsp+10,12) PATH3 - I char*300 Full path name to model files IGC(L) - O int*4 Pointers into GVEC array Dim(12) IERR - O int*4 Error code = 0 no errors) UPARM vector description PARM DIM 1 1 R NUMBER OF STAGES IN COLUMN 2 1 R CONDENSER PRES, ATM 3 1 R TOP STAGE PRES, ATM 4 1 R BOTTOM STAGE PRES, ATM 5 1 G REFLUX RATE FROM CONDENSER, GMOLE/HR 6 1 G VAPOR DISTILATE RATE, GMOLE/HR 7 1 G CONDENSER TEMP, C 8 1 G TOP STAGE TEMP, C 9 1 G BOTTOM STAGE TEMP, C 10 1 O INIT FLAG 1 - FORCE INITIALIZATION 0 - PREVIOUS SOLUTION IF AVAILABLE 11 1 O MAXIMUN NUMBER OF ITERATIONS 12 1 R TOTAL NUMBER OF FEEDS TO THE COLUMN 13 1 O CONSTANT EFFICIEMCY FOR ALL STAGE , FRACTION 14 1 O PRINT CODE 0 - noprint 1 - calls hypterm to print norm 2 - standard frachem output 15-24 10 R STAGE NUMBERS FOR FEEDS 25-34 10 O STAGE NUMBERS FOR EXCHANGERS 35-44 10 O EXCHANGER DUTY, MILLION CAL/HR 45-54 10 O STAGE NUMBERS FOR SIDE DRAW-OFFS Note: all vapor draws first 55-59 5 O SIDE-STREAM VAPOR RATE, GMOLE/HR 60-64 5 O SIDE-STREAM LIQUID RATE, GMOLE/HR 65-69 5 O SPEC CONTROL VARIABLE 1 - HEAT EXCHANGER 2 - LIQ SIDE-DRAW 3 - VAP SIDE-DRAW 4 - FEED RATE 5 - EFFICIENCY 70-74 5 O SPEC CONTROL STAGE 75-79 5 O SPEC VARIABLE 1 - TRAY TEMP 2 - LIQUID RATE FROM A STAGE 3 - VAPOR RATE FROM A STAGE 4 - VAPOR RATE FOR A GROUP OF COMPONENTS 5 - VAPOR FRACTION FOR A GROUP OF COMPONENTS 6 - LIQ SIDE DRAW RATE FOR A GROUP OF COMPONENTS 7 - LIQ FRACTION FOR A GROUP OF COMPONENTS 8 - BOTTOMS RATE FOR A GROUP OF COMPONENTS 9 - VAPOR SIDE RATE FOR A GROUP OF COMPONENTS 80-84 5 O SPEC STAGE 85-89 5 O SPEC VALUE, METRIC UNITS, C,ATM,GMOLE 90-94 5 0 COMPONENT NUMBERS FOR PURITY SPEC 1 95-99 5 0 COMPONENT NUMBERS FOR PURITY SPEC 2 100-104 5 0 COMPONENT NUMBERS FOR PURITY SPEC 3 105-109 5 0 COMPONENT NUMBERS FOR PURITY SPEC 4 110-114 5 0 COMPONENT NUMBERS FOR PURITY SPEC 5 115-134 20 O STAGE NUMBERS FOR LIQUID HOLDUP (HHOLD) 135-154 20 O LIQUID STAGE HOLD-UP TIME, HR 155-174 20 O STAGE NUMBERS FOR VAPOR HOLDUP (HHOLDV) 175-194 20 O VAPOR STAGE HOLD-UP TIME, HR 195-214 20 O STAGE NUMBERS FOR STAGE EFFIC. 215-234 20 O STAGE EFFICIENCYS, FRACTION 235-239 5 O PUMP AROUND FROM STAGE 240-244 5 O PUMP AROUND TO STAGE 245 1 O DECANT CONDENSER WHEN =1

Page 26: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page26

246 1 O CONDENSER TYPE 0 PARTIAL CONDENSER 1 SUB-COOLED LIQ -- MUST SPEC DISTILLATE RATE 2 SUB-COOLED LIQ -- MUST SPEC REFLUX RATE 3 SUB-COOLED LIQ -- MUST SPEC REFLUX RATIO RR/DD 4 SUB-COOLED LIQ -- SET TEMP AND DISTILLATE 5 SUB-COOLED LIQ -- SET TEMP AND REFLUX RATE 6 SUB-COOLED LIQ -- SET TEMP AND REFLUX RATIO NOTE: TEMP USED IS PARM(7) ABOVE 247 1 O SPEC VALUE FOR CONDENSER 248 1 R 0 - STANDARD ELEC VLE OR VLEE COLUMN 1 - EXTRACTION COLUMN 249-349 100 O STAGE NUMBER FOR COMPONENT EFFICIENCY COMPONENT NUMBER FOR EFF EFFICIENCY R - REQUIRED INPUT G - Optional ESTIMATED VALUE O - OPTIONAL INPUT

Page 27: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page27

5.3.2 Column profile Information Get column profile information after call to HYPFRC CALL FRPROF (NST, NCMP, NUSLD, TPROF, PPROF, XPROF, YPROF, XL2PROF, RLPROF, RVPROF, RL2PROF, HLPROF, HVPROF, HL2PROF, RDENSL, RDENSV, RDUTY,PHPROF, STRION, SCPROF) Dim NST - O I*4 Number of stages NCMP - O I*4 Number of true components NUSLD - O I*4 Number of solids TPROF - O R*8 Temp profile, C (nst) PPROF - O R*8 Press profile, atm (nst) XPROF - O R*8 Aq true mole fraction (ncmp*nst) YPROF - O R*8 Vapor mole fractions (ncmp*nst) XL2PROF – O R*8 2nd liq mole fraction (ncmp*nst) RLPROF - O R*8 Aq mole flows, gmole/hr (nst) RVPROF - O R*8 Vapor mole flows, gmole/hr (nst) RL2PROF – O R*8 2nd liq mole flows, gmole/hr (nst) HLPROF - O R*8 Aqueous enthalpy, cal/hr (nst) HVPROF - O R*8 Vapor enthalpy, cal/hr (nst) HL2PROF – O R*8 2nd liquid enthalpy, cal/hr (nst) RDENSL - O R*8 Aqueous density, g/liter (nst) RDENSV - O R*8 Vapor density, g/liter (nst) RDUTY - O R*8 Heat duty, cal/hr (nst) PHPROF - O R*8 pH profile (nst) STRION - O R*8 Ionic strength, molality (nst) SCPROF - o R*8 Scaling index (nusld*nst) Note: The component order for XPROF, YPROF and XL2PROF has been changed to be that returned by HYPINIT in NAMOU. The order for the scaling index is the order returned by HYPINIT in NAMSL.

Page 28: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page28

5.4 Results organization

5.4.1 GVEC – Molecular Stream Description GVEC(I), I = 1 , LQGSTR (For NNIN=300, LQGSTR=1280) Element Number(s) Current IGC Entry I = IGC(1)+1, IGC(1)+300 = 1,300 Molecular, aqueous liquid, gmole = IGC(2)+1 = 301 Total, gmole = +2 = 302 Temperature, °C = +3 = 303 Pressure, atm = +4 = 304 Enthalpy, cal = +5 = 305 Density, gmole/liter = +6 = 306 pH = +7 = 307 Ionic strength, molality = +8 = 308 Volume, m3 = +9 = 309 Osmotic pressure, atm = +10 = 310 Mass, gram = IGC(3)+1, IGC(3)+300 = 311,610 Molecular, solids, gmole = IGC(4)+1 = 611 Total flow, gmole = +2 = 612 Temperature, °C = +3 = 613 Pressure, atm = +4 = 614 Enthalpy, cal = +5 = 615 Density, gmole/liter = +6 = 616 = +7 = 617 Heat Capacity, cal/gram/K = +8 = 618 Volume, m3 = +9 = 619 = +10 = 620 Mass, gram = IGC(5)+1, IGC(5)+300 = 621,920 Molecular, vapor, gmole = IGC(6)+1 = 921 Total flow, gmole = +2 = 922 Temperature, °C = +3 = 923 Pressure, atm = +4 = 924 Enthalpy, cal = +5 = 925 Density, gmole/liter = +6 = 926 = +7 = 927 Heat Capacity, cal/gram/K = +8 = 928 Volume, m3 = +9 = 929 = +10 = 930 Mass, gram = IGC(7)+1, IGC(7)+300 = 931,1230 Molecular, 2nd liquid, gmole = IGC(8)+1 = 1231 Total, gmole = +2 = 1232 Temperature, °C = +3 = 1233 Pressure, atm = +4 = 1234 Enthalpy, cal = +5 = 1235 Density, gmole/liter = +6 = 1236 = +7 = 1237 Heat Capacity, cal/gram/K = +8 = 1238 Volume, m3 = +9 = 1239 = +10 = 1240 Mass, gram = IGC(10)+1 = 1241 = +2 = 1242 Total Mass, gmole = +3 = 1243 Total Volume, m3 = +4 = 1244 = +5 = 1245 Total Mass, gram = +6 = 1246 Total Enthalpy, cal = +7 = 1247 Mixture Heat Capacity, cal/gram/K = +8 = 1248 = +9 = 1249 = +10 = 1250

Page 29: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page29

GVEC – Molecular Stream Description (continued)

GVEC(I), I = 1 , LQGSTR (For NNIN=300, LQGSTR=1280) Element Number(s) Current IGC Entry I = IGC(11)+1 = 1251 ORP, volt = +2 = 1252 Specific Electrical Conductivity, 1/ohm-cm = +3 = 1253 Molar Electrical Conductivity, cm2/ohm-gmole = +4 = 1254 Absolute Viscosity, cP = +5 = 1255 Relative Viscosity = +6 = 1256 Vapor Compressibility Factor (z) = +7 = 1257 Aqueous Phase Heat Capacity, cal/gram/K = +8 = 1258 = +9 = 1259 = +10 = 1260 = +11 = 1261 Crystallization – Zeroth Moment, m0, 1/cm3

= +12 = 1262 Crystallization – First Moment, m1, cm/cm3

= +13 = 1263 Crystallization – Second Moment, m2, cm2/cm3

= +14 = 1264 Crystallization – Third Moment, m3, cm3/cm3

= +15 = 1265 Crystallization – Fourth Moment, m4, cm4/cm3

= +16 = 1266 Crystallization – Fifth Moment, m5, cm5/cm3

= +17 = 1267 Crystallization – Specific Surface Area, AT, cm2/cm3

= +18 = 1268 Crystallization – Crystal Mass Density, MT, gm/cm3

= +19 = 1269 Crystallization – Area Shape Factor, kA = +20 = 1270 Crystallization – Volume Shape Factor, kV = +21 = 1271 Crystallization – Density of Crystals, gm/cm3

= +22 = 1272 = +23 = 1273 = +24 = 1274 = +25 = 1275 = +26 = 1276 = +27 = 1277 = +28 = 1278 = +29 = 1279 = +30 = 1280 Crystal Size Distribution (CSD) = IGC(12)+1 = 1281 Number of Crystal Size Categories (NSIZE) = +2 = 1282 Size of Crystal, Category 1, micron = +3 = 1283 Crystal Size Distribution, Size 1, number/cm3-micron = +4 = 1284 Size of Crystal, Category 2, micron = +5 = 1285 Crystal Size Distribution, Size 2, number/cm3-micron

: : : : : : : : : : : : : :

= +2*NSIZE = 1280+2*NSIZE Size of Crystal, Category NSIZE, micron = +2*NSIZE+1 = 1281+2*NSIZE Crystal Size Distribution, Size NSIZE, number/cm3-micron

Page 30: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page30

5.4.2 EVEC – Aqueous Stream Description EVEC(I), I = 1 , LQESTR (For NNSP=300, LQESTR=610) I = 1 H2O in aqueous phase, gmole = 2,NU Species quantity in aqueous phase, –AQ, –ION - molality –PPT, –.nH2O, –SUS, –LT - gmole –VAP - mole fraction –SOL - gmole/kg solid medium –CPI, –CPM - gmole/kg H2O

= NNSP+1 Temperature, K = NNSP+2 Pressure, atm

= NNSP+3 Vapor, gmole = NNSP+4 VELIM

= NNSP+5 SOLMAS, kg = NNSP+6,NNSP+5+NU Species concentration in organic phase, mole fraction = NNSP+5+NNSP+1 Total Organic, gmole = NNSP+5+NNSP+2 SELIM

Page 31: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page31

5.4.3 ASAP Units Variable Name Value Units T temperature Kelvin PT pressure atmosphere I ionic strength gmole/kg H2O PH pH -- OSPRES osmotic pressure atmosphere ORP oxidation reduction potential volt ECOND specific electrical conductivity 1/ohm-cm ECONDM molar electrical conductivity cm2/ohm-gmole VISABS absolute viscosity cP VISREL relative viscosity –IN inflows gmole –AQ, –ION aqueous solution molalities gmole/kg H2O –CPM, –CPI surface complex molalities gmole/kg H2O –PPT, –.nH2O precipitates and hydrates gmole –SUS suspended phase solids gmole –LT lattice species (coprecipitation) gmole H2O water in solution gmole –SOL solid solution molalities gmol/kg solid medium Y– vapor mole fractions -- X–O 2nd liquid phase mole fractions -- D_H2O diffusivity, water m2/sec D_–AQ, –ION diffusivities, aqueous species m2/sec SOLMAS solid medium mass kg

Note: For cation exchange medium, SOLMAS based upon H-Solid molecular weight. LIQMAS total aqueous liquid mass gram LIQMAS2 total organic phase mass gram LIQMOL total aqueous liquid moles gmole V total vapor moles gmole SOLMOL total solid moles gmole TOTO total organic liquid moles gmole ENTHALPY total enthalpy cal ENTHAL aqueous liquid phase enthalpy cal ENTHAL2 organic liquid phase enthalpy cal ENTHAV vapor phase enthalpy cal ENTHAS solid phases enthalpy cal ENTHAI inert phases enthalpy cal DENLIQ aqueous liquid molar density gmole in soln/liter DENLIQ2 organic liquid molar density gmole in soln/liter DENMAS aqueous liquid density gram/liter DENMAS2 organic liquid density gram/liter ZCOMP vapor compressibility --

Page 32: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page32

ASAP Units (continued) Variable Name Value Units VOL total volume liter VOLLIQ aqueous liquid volume liter VOLLIQ2 organic liquid volume liter VOLVAP vapor volume liter VOLSOL solid volume liter RATEi kinetics rate of reaction, reaction i gmole/hr EXTi kinetics extent of reaction, reaction i gmole TSTEP kinetics time step hr BRATESi rate of reaction – synthesis, bioreaction i gmole/liter-hr BEXTSi extent of reaction – synthesis, bioreaction i gmole BRATEEAi rate of reaction – aerobic energy, bioreaction i gmole/liter-hr BEXTEAi extent of reaction – aerobic energy, bioreaction i gmole BRATEENi rate of reaction – anoxic energy, bioreaction i gmole/liter-hr BEXTENi extent of reaction – anoxic energy, bioreaction i gmole BRATEECi rate of reaction – anaerobic energy, bioreaction i gmole/liter-hr BEXTECi extent of reaction – anaerobic energy, bioreaction i gmole BRATDEAi rate of reaction – aerobic decay, bioreaction i gmole/liter-hr BEXTDAi extent of reaction – aerobic decay, bioreaction i gmole BRATDENi rate of reaction – anoxic decay, bioreaction i gmole/liter-hr BEXTDNi extent of reaction – anoxic decay, bioreaction i gmole REACVOL bioreactor volume liter A–AQ, A–ION loge (aq phase activity coef) --

Note: When AQ also appears in organic phase, then A-AQ is the activity, rather than activity coefficient.

A–CPM, A–CPI loge (aq phase activity coef) -- AH2O loge (aq phase H2O activity) -- A–AQO loge (organic phase activity) -- AY– loge (vapor phase fugacity coef) -- K- loge (equilibrium K-values) -- L–AQ, L–ION loge (aq phase molalities) -- L–CPM, L–CPI loge (aq phase molalities) --

Page 33: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page33

5.5 Memory Deallocation Utility to deallocate memory. CALL EQSDEALL This routine deallocates all of the memory set up by the call to HYPINIT. Routine HYPINIT must again be called before any calls to HYPCALC.

Page 34: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page34

Appendix 1: Source Code for Examples

A.1.1 Isothermal source program isothermal c c example mainline routine to generate chemistry model c and calculate equilibrium composition c january, 2006 c c implicit real(8) (A-H,O-Z) ! keep older FORTRAN conventions parameter (MXSIZ=300) ! this is the maximum number of species c character (len=300) path1, path2, path3 ! paths to DB, to working dir character (len=8) nammod ! name of the chemistry model character (len=16) cvalue, cunit ! report writing TEMPoraries character (len=80) errmsg(6) ! error flag c c character (len=16),allocatable :: namin(:) ! component inflows character (len=16),allocatable :: namou(:) ! species names character (len=16),allocatable :: namsl(:) ! solids names real(8) , allocatable :: amwt(:) ! molecular weights integer , allocatable :: ikinsp(:) ! kinetics flag C real(8) , allocatable :: comp(:) ! composition values integer , allocatable :: jsolid(:) ! flag: include solids real(8) , allocatable :: gout(:) ! output vector (see ref) real(8) , allocatable :: eout(:) ! output vector (see ref) real(8) , allocatable :: evecin(:) ! kinetics real(8) , allocatable :: scale(:) ! scaling tendencies integer , allocatable :: igc(:) ! pointer into the gvec array integer , allocatable :: iprop(:) ! transport property calc flag c c c Setup: set parameters / max species is 300 / do not overrun!! c NNSP=MXSIZ ! the number of species NNIN=MXSIZ ! the number of inflows NNSOLI=MAX(300,MXSIZ) ! number of solids for scaling analysis LQNNPH=4 ! number of phases C C Setup: allocate memory for the HYPINIT call and HYPCALC call C allocate ( namin(NNIN) ) allocate ( namou(NNSP) ) allocate ( namsl(NNSOLI) ) allocate ( amwt(NNIN) ) allocate ( ikinsp(20) ) allocate ( comp(NNIN) ) allocate ( jsolid(NNSP) ) allocate ( scale(NNSOLI) ) allocate ( igc(12) ) C C C Setup: define the directory names and open an output file c c ! public db path1='C:\Program files\OLI Systems\ESP 7.0\Databanks' path2=' ' ! private db path3='C:\callableEngine\isothermal' ! working directory C

Page 35: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page35

nammod='isothermal' ! name of the model IR=len_TRIM(nammod) ! remove blanks from model name IR1=len_TRIM(path3) ! remove blanks from path name c c c Open a file to store results c c open(unit=93,file=path3(1:IR1)//'\'//nammod(1:IR)//'.LIS', * status='UNKNOWN') c c-------------------------------------- c Step 1: build the chemistry model c-------------------------------------- c call buildChemistry(nammod, path1, path2, path3) ! uses fixed chemistry c c c----------------------------- c Step 2: acces the Solver c------------------------------ c c c A. Read the .dbs file into memory to prepare for equilibrium call c c call HYPINIT (nammod,NIN,namin,amwt,NOU,namou,NOUSL,namsl,NNSP, $ NKIN,ikinsp,path3) c c c B. Set the T, P, for the call (Work in double precision!) c c TEMP = 67.D0 ! set the TEMPerature in degrees C PRES = 1.2D0 ! set the PRESsure in atm C c C C. Component inflow flowrates (fixed chemistry is easy) C comp=0.D0 do i=1,NIN if (namin(i).eq.'H2O') comp(i) = 100.0D0 if (namin(i).eq.'ACETONE') comp(i) = 10.0D0 if (namin(i).eq.'HCL') comp(i) = 0.0D0 if (namin(i).eq.'NAOH') comp(i) = 0.1D0 if (namin(i).eq.'METHANOL') comp(i) = 10.0D0 if (namin(i).eq.'BENZENE') comp(i) = 10.0D0 if (namin(i).eq.'N2') comp(i) = 2.0D0 if (namin(i).eq.'CACO3') comp(i) = 1.0D0 enddo C c c D. .Set the control information for the call (each calc type different) c c ifunc=1 ! set the type of equilibrium calc (1 = T,P flash) spec1 = 0 ! set the specifications for the type of call spec2 = 0 ! isothermal calcs have no extra specs spec3 = 0. C NNIN=NNSP ! number of inflow component NNSOLI=300 ! max number of solids for scaling analysis LQNNPH=4 ! number of phases LQGSTR=LQNNPH*(NNSP+20)+50 ! number of entries in gout output array LQESTR=2*(NNSP+5) ! number of entries in eout output array C allocate ( gout(LQGSTR) ) allocate ( eout(LQESTR) ) allocate ( evecin(LQESTR) ) allocate ( iprop(6) ) C do i=1,NNSP

Page 36: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page36

jsolid(i)=0 ! Set flags to include all solids enddo C irest=0 ! This is not a restart case holdupt=0.D0 ! There is no holdup time C jprint=1 niprop=3 iprop(1)=1 ! calc electrical conductivity (see reference) iprop(2)=2 ! calc viscosity iprop(3)=4 ! calc Cp C C E. call the OLI API for equilibrium calculation C call HYPCALC (ifunc,irest,TEMP,PRES,comp,spec1, $ spec2,spec3,jsolid,holdupt,kistep,evecin,niprop, $ iprop,gout,eout,scale,path3,jprint,igc,ierr) c c if (ierr.ne.0) then write(*,'(A,I5)') ' Calculation errors: ',ierr write(93,'(A,I5)') ' Calculation errors: ',ierr do i=1,ierr call GETERRS(I,iercod,6,errmsg) do J=1,6 if (errmsg(J).ne.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo enddo STOP endif C C F. make sure there are no errors / warnings C I=1 89 call GETWARNS(I,iwarncod,6,errmsg) if (iwarncod.ne.0) then DO J=1,6 if (errmsg(J).ne.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo GO TO 89 endif c c------------------------------------------ c Step 3: use results (print to a file) c------------------------------------------ c c C write(93,'(//A/)') ' EVEC OUTPUT:' do iI=1,NOU write (93,1010) ii,namou(II),eout(II) enddo 1010 FORMAT (I4,1X,A,1p,E15.6) C write(93,'(T5,A,T22,G13.5,A)') 'TEMP, K ',eout(NNSP+1) write(93,'(T5,A,T22,G13.5,A)') 'PRES, ATM ',eout(NNSP+2) write(93,'(T5,A,T22,G13.5,A)') 'VAPOR GMOLES ',eout(NNSP+3) write(93,'(T5,A,T22,G13.5,A)') 'LIQUID GMOLES ',eout(NNSP+4) write(93,'(//A/)') ' GVEC OUTPUT:' do i=1,7,2 write(93,'(/)') DO J=1,NIN write(93,'(A,I2,A,I3,3X,A,G13.5)') * 'igc(',I,')+',J,namin(J),gout(igc(i)+J)

Page 37: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page37

enddo write(93,'(/)') CVALUE='TOTAL' Cunit='gmoles' IX=1 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit CVALUE='TEMPERATURE' Cunit='C' IX=2 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit CVALUE='PRESSURE' Cunit='atm' IX=3 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit CVALUE='ENTHALPY' Cunit='cal' IX=4 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit CVALUE='DENSITY' Cunit='gmole/liter' IX=5 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit if (I.eq.1 .OR. I.eq.7) then CVALUE='pH' Cunit=' ' IX=6 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit CVALUE='IONIC STRENGTH' Cunit=' ' IX=7 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit endif CVALUE='VOLUME' Cunit='m3' IX=8 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit if (I.eq.1 .OR. I.eq.7) then CVALUE='OSMOSTIC PRESS' Cunit='atm' IX=9 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit endif CVALUE='MASS' Cunit='grams' IX=10 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit CVALUE='HEAT CAPACITY' Cunit='cal/g/K' IX=11 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit if (I.eq.1 .OR. I.eq.7) then CVALUE='ORP' Cunit='volts' IX=12 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit endif if (I.eq.1 .OR. I.eq.7) then CVALUE='SP ELECT COND' Cunit='1/ohm-cm' IX=13 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)')

Page 38: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page38

* 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit endif if (I.eq.1 .OR. I.eq.7) then CVALUE='MOLAR ELECT COND' Cunit='cm2/ohm-gmole' IX=14 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit endif if (I.eq.1 .OR. I.eq.7) then CVALUE='ABSOLUTE VISCOSITY' Cunit='cP' IX=15 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit endif if (I.eq.1 .OR. I.eq.7) then CVALUE='RELATIVE VISCOSITY' Cunit=' ' IX=16 write(93,'(A,I2,A,I3,3X,A,G13.5,2X,A)') * 'igc(',I+1,')+',IX,CVALUE,gout(igc(I+1)+IX),Cunit endif enddo C write(93,'(//1X,A/)') ' scale INDEX' do i=1,NOUSL write(93,'(I5,1X,A,E15.6)') I,namsl(i),scale(i) enddo C call EQSDEALL !deallocate STOP END subroutine buildChemistry (nammod, path1, path2, path3) c c example of building a fixed chemistry model c january, 2006 c implicit real(8) (A-H,O-Z) ! keep older FORTRAN conventions c parameter (MXSIZ=300) ! this is the maximum number of species c character (len=300) path1, path2, path3 ! paths to database, working dir character (len=8) nammod ! name of model, name of dbs file character (len=80) errmsg(6) character (len=80) msg ! needed for AUTOGEN, SOLGEN call C character(len=8) , allocatable :: priv(:) ! setting private databanks character(len=3) , allocatable :: phase(:) ! setting phases character(len=16), allocatable :: molnam(:)! fixed chemistry: OLI TAGS character(len=1) , allocatable :: sel(:) ! solids calc character(len=16), allocatable :: solids(:)! solids names character(len=16), allocatable :: inflow(:)! component inflow names character(len=16), allocatable :: specie(:)! species names integer , allocatable :: jdumc(:) ! dummy inflo names (no data) character(len=80), allocatable :: eqs(:) ! equilibrium equations C character(len=80), allocatable :: redset(:) ! redox array integer , allocatable :: jredinc(:)! redox array C C C******************************************************* C NNSP=MXSIZ ! max number of species NNIN=MXSIZ ! max number of inflows NNSOLI=MAX(300,MXSIZ) ! max number of solids for analysis

Page 39: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page39

LQNNPH=4 ! number of phases c C Setup: memory allocations for AUTOGEN and PSREDOX C allocate ( priv(10) ) allocate ( phase(4) ) allocate ( molnam(NNSP) ) allocate ( sel(NNSP) ) allocate ( solids(NNSP) ) allocate ( inflow(NNSP) ) allocate ( specie(NNSP) ) allocate ( jdumc(NNSP) ) allocate ( eqs(NNSP) ) allocate ( redset(50) ) allocate ( jredinc(50) ) C C Setup: phases, databanks, components C do j=1,10 priv(J)=' ' enddo priv(1)='MSEPUB' ! use mixed solvent databank C phase(1)='VAP' ! consider VAPOR phase phase(2)='SOL' ! consider SOLID phaseS phase(3)='ORG ' ! consider 2nd liquid phase when phase(3)='ORG' phase(4)=' ' ! consider redox when phase(4)='RED' C NSOLM=0 ! number of solids NMOLEC=8 ! number of component inflow molnam(1)='H2O' ! H2O must be first and must be included molnam(2)='METHANOL' ! Names must be valid OLI Tags molnam(3)='ACETONE' ! Order entered in here will be order in model molnam(4)='NAOH' molnam(5)='HCL' molnam(6)='BENZENE' molnam(7)='N2' molnam(8)='CACO3' C IDBSW=1 do I=1,NNSP sel(i)=' ' ! GENERATE ALL solids enddo C C-----------Set up redox equoations only if redox on (set in phase) C do I=1,4 if (phase(I).EQ.'RED') go to 10 enddo go to 20 C C Two part call: first call gets list of redox reactions C C 10 icall=0 call PSREDOX(icall,priv,NMOLEC,molnam,NSET,redset,jredinc, * path1,path2,path3,IERR) c c c After first call, display the systems, let user select c Set the array jredinc for all systems to be included

Page 40: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page40

c c 887 write(*,'(//A/)') ' POSSIBLE REDOX SUB-SYSTEMS' do I=1,NSET write(*,'(1X,I2,1X,I1,1X,A)') I,jredinc(I),redset(I)(1:70) enddo C 888 write(*,'(/A)') * ' ENTER SET NUMBER TO BE CHANGED (1 MEANS TO INCLUDE)' write(*,'(A)') ' ENTER 0 TO continue' read(*,'(I1)') INUM if (INUM.LE.0) go to 889 if (INUM.GT.NSET) go to 887 if (jredinc(INUM).EQ.1) then jredinc(INUM)=0 else jredinc(INUM)=1 endif go to 887 889 continue C C Second call sets up the data structure for the redox reactions C C icall=1 call PSREDOX(icall,priv,NMOLEC,molnam,NSET,redset,jredinc, * path1,path2,path3,IERR) C C-------------End Redox---------------------------------------- c c call AUTOGEN to create the model definition c c 20 call AUTOGEN(nammod,MXSIZ,priv,NMOLEC,molnam,phase,NSOLM, * solids,sel,NIN,inflow,NSP,specie, * Neqs,eqs,jdumc,path1,path2,path3, * IDBSW,IERR,msg) c if (ierr.gt.0) then write(*,'(a)') msg stop endif C C write the species names to the file and the screen C do I=1,NSP if (I.LE.NIN) then write(*,'(1X,I5,1X,A,1X,A,I3)') * I,inflow(I),specie(I),jdumc(I) write(93,'(1X,I5,1X,A,1X,A,I3)') * I,inflow(I),specie(I),jdumc(I) else write(*,'(1X,I5,17X,1X,A)') I,specie(I) write(93,'(1X,I5,17X,1X,A)') I,specie(I) endif enddo write(*,'(//)') write(93,'(//)') do I=1,NSOLM write(*,'(1X,I5,1X,A,1X,A)') I,solids(I),sel(I) write(93,'(1X,I5,1X,A,1X,A)') I,solids(I),sel(I) enddo write(*,'(//)') write(93,'(//)') do I=1,Neqs

Page 41: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page41

write(*,'(1X,I3,1X,A)') I,eqs(I)(1:74) write(93,'(1X,I3,1X,A)') I,eqs(I)(1:74) enddo C C call SOLGEN to create the DBS file C call SOLGEN(nammod,priv,1,path1,path2,path3,IERT) C C check for errors C if (IERT.NE.0) then write(*,'(A,I5)') ' Genrate errors: ',iert write(93,'(A,I5)') ' Genrate errors: ',iert do I=1,IERT call GETERRG(I,IERCOD,6,errmsg) do j=1,6 if (errmsg(J).NE.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo enddo STOP endif C check for warnings C I=1 88 call GETWARNG(I,IWARNCOD,6,errmsg) if (IWARNCOD.NE.0) then do j=1,6 if (errmsg(J).NE.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo go to 88 endif return END

Page 42: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page42

A.1.2 Solubility source program solubility c c example mainline routine to generate chemistry model c and calculate a precipitation point c january, 2006 c c implicit real(8) (A-H,O-Z) ! keep older FORTRAN conventions parameter (MXSIZ=300) ! this is the maximum number of species c character (len=300) path1, path2, path3 ! paths to DB, to working dir character (len=8) nammod ! name of the chemistry model character (len=16) cvalue, cunit ! report writing TEMPoraries character (len=80) errmsg(6) ! error flag c c character (len=16),allocatable :: molnam(:) ! AUTOGEN argument, user inflw character (len=16),allocatable :: namin(:) ! all inflows, user+ related character (len=16),allocatable :: namou(:) ! species names character (len=16),allocatable :: namsl(:) ! solids names real(8) , allocatable :: amwt(:) ! molecular weights integer , allocatable :: ikinsp(:) ! kinetics flag C real(8) , allocatable :: comp(:) ! composition values integer , allocatable :: jsolid(:) ! flag: include solids real(8) , allocatable :: gout(:) ! output vector (see ref) real(8) , allocatable :: eout(:) ! output vector (see ref) real(8) , allocatable :: evecin(:) ! kinetics real(8) , allocatable :: scale(:) ! scaling tendencies integer , allocatable :: igc(:) ! pointer into the gvec array integer , allocatable :: iprop(:) ! transport property calc flag real(8) , allocatable :: results(:) ! pointer into gvec c c c Setup: set parameters / max species is 300 / do not overrun!! c NNSP=MXSIZ ! the number of species NNIN=MXSIZ ! the number of inflows NNSOLI=MAX(300,MXSIZ) ! number of solids for scaling analysis LQNNPH=4 ! number of phases C C Setup: allocate memory for the HYPINIT call and HYPCALC call C allocate ( molnam(NNIN) ) allocate ( namin(NNIN) ) allocate ( namou(NNSP) ) allocate ( namsl(NNSOLI) ) allocate ( amwt(NNIN) ) allocate ( ikinsp(20) ) allocate ( comp(NNIN) ) allocate ( jsolid(NNSP) ) allocate ( scale(NNSOLI) ) allocate ( igc(12) ) allocate ( results(1) ) C C Setup: define the directory names and open an output file c c ! public db path1='C:\Program files\OLI Systems\ESP 7.0\Databanks' path2=' ' ! private db

path3='C:\callableEngine\solubility' ! working directory C nammod='solubility' ! name of the model

Page 43: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page43

IR=len_TRIM(nammod) ! remove blanks from model name IR1=len_TRIM(path3) ! remove blanks from path name c c c Open a file to store results c c open(unit=93,file=path3(1:IR1)//'\'//nammod(1:IR)//'.LIS', * status='UNKNOWN') c c-------------------------------------- c Step 1: build the chemistry model c-------------------------------------- c NMOLEC=5 ! number of component inflow molnam(1)='H2O' ! H2O must be first and must be included molnam(2)='CACL2' ! Names must be valid OLI Tags molnam(3)='MGCL2' ! Order entered in here will be order in model molnam(4)='CO2' molnam(5)='CACO3' call buildChemistry(nammod, NMOLEC, molnam, path1, path2, path3) c c c----------------------------- c Step 2: acces the Solver c------------------------------ c c c A. Read the .dbs file into memory to prepare for equilibrium call c c call HYPINIT (nammod,NIN,namin,amwt,NOU,namou,NOUSL,namsl,NNSP, $ NKIN,ikinsp,path3) c c c B. Set the T, P, for the call (Work in double precision!) c c TEMP = 25.D0 ! set the TEMPerature in degrees C PRES = 1.0D0 ! set the PRESsure in atm C c C C. Component inflow flowrates (fixed chemistry is easy) C comp=0.D0 do i=1,NIN if (namin(i).eq.'H2O') comp(i) = 55.5087D0 if (namin(i).eq.'CACL2') comp(i) = .1D0 if (namin(i).eq.'MGCL2') comp(i) = .1D0 if (namin(i).eq.'CO2') comp(i) = .01D0 if (namin(i).eq.'CACO3') comp(i) = 0.0D0 enddo C c c D. .Set the control information for the call (each calc type different) c c ifunc= 16 ! set the type of equilibrium calc (16 = T,P precip) do i=1, NOU ! spec1 is the species number of the precipitant if (namou(i) .eq. 'CACO3PPT') then ! PPT is the solid spec1 = i endif ! when we find this, we set spec1 enddo do i=1, NIN ! spec2 is the inflow number of the inflow if (namin(i).eq.'CACO3') then ! when we match CACO3 inflow spec2 = i ! we get the index endif enddo spec3 = 0. ! we're not using spec3 C

Page 44: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page44

NNIN=NNSP ! number of inflow component NNSOLI=300 ! max number of solids for scaling analysis LQNNPH=4 ! number of phases LQGSTR=LQNNPH*(NNSP+20)+50 ! number of entries in gout output array LQESTR=2*(NNSP+5) ! number of entries in eout output array C allocate ( gout(LQGSTR) ) allocate ( eout(LQESTR) ) allocate ( evecin(LQESTR) ) allocate ( iprop(6) ) C do i=1,NNSP jsolid(i)=0 ! Set flags to include all solids enddo C irest=0 ! This is not a restart case holdupt=0.D0 ! There is no holdup time jprint=1 niprop=0 ! calculate no properties c c c E. call the OLI API for equilibrium calculation c c call HYPCALC (ifunc,irest,TEMP,PRES,comp,spec1, $ spec2,spec3,jsolid,holdupt,kistep,evecin,niprop, $ iprop,gout,eout,scale,path3,jprint,igc,ierr) c c if (ierr.ne.0) then write(*,'(A,I5)') ' Calculation errors: ',ierr write(93,'(A,I5)') ' Calculation errors: ',ierr do i=1,ierr call GETERRS(I,iercod,6,errmsg) do J=1,6 if (errmsg(J).ne.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo enddo STOP endif C C F. make sure there are no errors / warnings C I=1 89 call GETWARNS(I,iwarncod,6,errmsg) if (iwarncod.ne.0) then DO J=1,6 if (errmsg(J).ne.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo GO TO 89 endif c c-------------------------------------------------- c Step 3: get results (see EQSOLD documentation) c-------------------------------------------------- c c IVALR = 1001 ! call to the frac(inflow) added NVALR = 1 ! number of items in the result array c call EQSOLD (1001,NVALR, results, IERR) c c c Report results c write (93, '(//A/)') 'CaCO3 Solubility Report'

Page 45: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page45

write (*, '(//A/)') 'CaCO3 Solubility Report' c do i=1,NIN do j=1,NMOLEC-1 if (namin(i).eq.molnam(j)) then write (93,'( A,3X, G13.5,A)') namin(i), comp(i), $ ' gmoles' write (*, '( A,3X, G13.5,A)') namin(i), comp(i), $ ' gmoles' endif enddo enddo c c write(93,'(//A,3X, G13.5,A/)') 'CaCO3 solubility', results(1), $ ' gmoles' write(*, '(//A,3X, G13.5,A/)') 'CaCO3 solubility', results(1), $ ' gmoles' c c call EQSDEALL ! deallocate STOP END subroutine buildChemistry (nammod,NMOLEC,molnam,path1,path2,path3) c c example of building a fixed chemistry model c january, 2006 c

implicit real(8) (A-H,O-Z) ! keep older FORTRAN conventions parameter (MXSIZ=300) ! this is the maximum number of species c character (len=16) molnam(NMOLEC) c

character (len=300)path1, path2, path3 ! paths to database, working dir character (len=8) nammod ! name of model, name of dbs file character (len=80) errmsg(6) character (len=80) msg ! needed for AUTOGEN, SOLGEN call C character(len=8) , allocatable :: priv(:) ! setting private databanks character(len=3) , allocatable :: phase(:) ! setting phases character(len=1) , allocatable :: sel(:) ! solids calc character(len=16), allocatable :: solids(:)! solids names character(len=16), allocatable :: inflow(:)! component inflow names character(len=16), allocatable :: specie(:)! species names integer , allocatable :: jdumc(:) ! dummy inflo names (no data) character(len=80), allocatable :: eqs(:) ! equilibrium equations C character(len=80), allocatable :: redset(:) ! redox array integer , allocatable :: jredinc(:)! redox array C C C******************************************************* C NNSP=MXSIZ ! max number of species NNIN=MXSIZ ! max number of inflows NNSOLI=MAX(300,MXSIZ) ! max number of solids for analysis LQNNPH=4 ! number of phases c C Setup: memory allocations for AUTOGEN and PSREDOX (molnam is bing passed) C allocate ( priv(10) ) allocate ( phase(4) ) allocate ( sel(NNSP) ) allocate ( solids(NNSP) ) allocate ( inflow(NNSP) ) allocate ( specie(NNSP) ) allocate ( jdumc(NNSP) ) allocate ( eqs(NNSP) ) allocate ( redset(50) ) allocate ( jredinc(50) ) C C Setup: phases, databanks, components

Page 46: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page46

C do j=1,10 priv(J)=' ' ! aqueous model enddo C phase(1)='VAP' ! consider VAPOR phase phase(2)='SOL' ! consider SOLID phaseS phase(3)=' ' ! consider 2nd liquid phase when phase(3)='ORG' phase(4)=' ' ! consider redox when phase(4)='RED' C NSOLM=0 ! number of solids IDBSW=1 do I=1,NNSP sel(i)=' ' ! GENERATE ALL solids enddo c c call AUTOGEN to create the model definition c c 20 call AUTOGEN(nammod,MXSIZ,priv,NMOLEC,molnam,phase,NSOLM, * solids,sel,NIN,inflow,NSP,specie, * Neqs,eqs,jdumc,path1,path2,path3, * IDBSW,IERR,msg) c if (ierr.gt.0) then write(*,'(a)') msg stop endif C C write the species names to the file and the screen C write(*,'(1X,A)')'Created Chemistry Model Definition' C C call SOLGEN to create the DBS file C call SOLGEN(nammod,priv,1,path1,path2,path3,IERT) C C check for errors C if (IERT.NE.0) then write(*,'(A,I5)') ' Genrate errors: ',iert write(93,'(A,I5)') ' Genrate errors: ',iert do I=1,IERT call GETERRG(I,IERCOD,6,errmsg) do j=1,6 if (errmsg(J).NE.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo enddo STOP endif C check for warnings C I=1 88 call GETWARNG(I,IWARNCOD,6,errmsg) if (IWARNCOD.NE.0) then do j=1,6 if (errmsg(J).NE.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo go to 88 endif write(*,'(1X,A)')'Generated DBS File for Thermodynamics' c return

Page 47: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page47

END

Page 48: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page48

A.1.3 Properties source

program properties c c example program to generate chemistry model c and query the OLI API for properties: Diffusivities for KCL/water c january, 2006 c c implicit real(8) (A-H,O-Z) ! keep older FORTRAN conventions parameter (MXSIZ=300) ! this is the maximum number of species c character (len=300) path1, path2, path3 ! paths to DB, to working dir character (len=8) nammod ! name of the chemistry model character (len=16) cvalue, cunit ! report writing TEMPoraries character (len=80) errmsg(6) ! error flag c character (len=16),allocatable :: molnam(:) ! user component inflows character (len=16),allocatable :: namin(:) ! all component inflows character (len=16),allocatable :: namou(:) ! species names character (len=16),allocatable :: namsl(:) ! solids names real(8) , allocatable :: amwt(:) ! molecular weights integer , allocatable :: ikinsp(:) ! kinetics flag C real(8) , allocatable :: comp(:) ! composition values integer , allocatable :: jsolid(:) ! flag: include solids real(8) , allocatable :: gout(:) ! output vector (see ref) real(8) , allocatable :: eout(:) ! output vector (see ref) real(8) , allocatable :: evecin(:) ! kinetics real(8) , allocatable :: scale(:) ! scaling tendencies integer , allocatable :: igc(:) ! pointer into the gvec array integer , allocatable :: iprop(:) ! transport property calc flag real(8) , allocatable :: diffusiv(:) ! to store diffusivities real(8) , allocatable :: aqvalue(:) ! to store aqphase character (len=16),allocatable :: aqname(:) ! aq phase names c c Setup: set parameters / max species is 300 / do not overrun!! c NNSP=MXSIZ ! the number of species NNIN=MXSIZ ! the number of inflows NNSOLI=MAX(300,MXSIZ) ! number of solids for scaling analysis LQNNPH=4 ! number of phases C C Setup: allocate memory for the HYPINIT call and HYPCALC call C allocate ( molnam(NNIN) ) allocate ( namin(NNIN) ) allocate ( namou(NNSP) ) allocate ( namsl(NNSOLI) ) allocate ( amwt(NNIN) ) allocate ( ikinsp(20) ) allocate ( comp(NNIN) ) allocate ( jsolid(NNSP) ) allocate ( scale(NNSOLI) ) allocate ( igc(12) ) C C C Setup: define the directory names and open an output file c c ! public db path1='C:\Program files\OLI Systems\ESP 7.0\Databanks' path2=' ' ! private db path3='C:\callableEngine\properties' ! working directory C nammod='properties' ! name of the model

Page 49: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page49

IR=len_TRIM(nammod) ! remove blanks from model name IR1=len_TRIM(path3) ! remove blanks from path name c c c Open a file to store results c c open(unit=93,file=path3(1:IR1)//'\'//nammod(1:IR)//'.LIS', * status='UNKNOWN') c c-------------------------------------- c Step 1: build the chemistry model c-------------------------------------- NMOLEC=2 ! number of component inflow molnam(1)='H2O' ! H2O must be first and must be included molnam(2)='KCL' ! Names must be valid OLI Tags call buildChemistry(nammod, NMOLEC, molnam, path1, path2, path3) c c----------------------------- c Step 2: acces the Solver ONLY TO GET THE AQ COMPOSITION c------------------------------ c c c A. Read the .dbs file into memory to prepare for equilibrium call c c call HYPINIT (nammod,NIN,namin,amwt,NOU,namou,NOUSL,namsl,NNSP, $ NKIN,ikinsp,path3) c c c B. Set the T, P, for the call (Work in double precision!) c c TEMP = 25.D0 ! set the TEMPerature in degrees C PRES = 1.0D0 ! set the PRESsure in atm C c C C. Component inflow flowrates (fixed chemistry is easy) C comp=0.D0 do i=1,NIN if (namin(i).eq. molnam(1)) comp(i) = 55.5087D0 if (namin(i).eq. molnam(2)) comp(i) = .1D0 enddo C c c D. .Set the control information for the call (each calc type different) c c ifunc= 1 ! isothermal for setting up the aq / ions spec1 = 0. ! no specs for these spec2 = 0. spec3 = 0. C NNIN=NNSP ! number of inflow component NNSOLI=300 ! max number of solids for scaling analysis LQNNPH=4 ! number of phases LQGSTR=LQNNPH*(NNSP+20)+50 ! number of entries in gout output array LQESTR=2*(NNSP+5) ! number of entries in eout output array C allocate ( gout(LQGSTR) ) allocate ( eout(LQESTR) ) allocate ( evecin(LQESTR) ) allocate ( iprop(6) ) C do i=1,NNSP jsolid(i)=0 ! Set flags to include all solids enddo C irest=0 ! This is not a restart case

Page 50: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page50

holdupt=0.D0 ! There is no holdup time C jprint=1 niprop=0 ! calculate no properties C C E. call the OLI API for equilibrium calculation C call HYPCALC (ifunc,irest,TEMP,PRES,comp,spec1, $ spec2,spec3,jsolid,holdupt,kistep,evecin,niprop, $ iprop,gout,eout,scale,path3,jprint,igc,ierr) c c if (ierr.ne.0) then write(*,'(A,I5)') ' Calculation errors: ',ierr write(93,'(A,I5)') ' Calculation errors: ',ierr do i=1,ierr call GETERRS(I,iercod,6,errmsg) do J=1,6 if (errmsg(J).ne.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo enddo STOP endif C C F. make sure there are no errors / warnings C I=1 89 call GETWARNS(I,iwarncod,6,errmsg) if (iwarncod.ne.0) then DO J=1,6 if (errmsg(J).ne.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo GO TO 89 endif c c--------------------------------------------------------------- c Step 3: extract the aqueous phase for calls for properties c--------------------------------------------------------------- c allocate ( aqname(NOU+2) ) allocate ( aqvalue(NOU+2) ) allocate ( diffusiv(NOU) ) iaqphase = 1; aqname(1)='TEMP' ! see EQPROPD documentation TEMP = 1 aqname(2)='PRES' ! see EQPROPD documentation PRES = 2 aqvalue(1)=TEMP aqvalue(2)=PRES write(93,'(//A/)') ' AQUEOUS CONCENTRATIONS:' write(*,'(//A/)') ' AQUEOUS CONCENTRATIONS:' do ii=1,NOU aqname(2+ii)=namou(ii) aqvalue(2+ii)=eout(ii) enddo do ii=1,NOU+2 write (93,1010) ii, aqname(ii), aqvalue(ii) write (* ,1010) ii, aqname(ii), aqvalue(ii) enddo 1010 FORMAT (I4,1X,A,1p,E15.6) c--------------------------------------------- c Step 4: call property extraction routine c---------------------------------------------

Page 51: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page51

IVAL = 8 ! diffusivities call EQPROPD (IVAL, aqvalue, nou, diffusiv, ierr) write(93,'(//A/)') ' SELF-DIFFUSIVITIES:' write(*,'(//A/)') ' SELF-DIFFUSIVITIES:' do I = 1, NOU write (93,1010) i, namou(i), diffusiv(i) write (* ,1010) i, namou(i), diffusiv(i) enddo STOP END subroutine buildChemistry (nammod,NMOLEC,molnam,path1,path2,path3) c c example of building a fixed chemistry model c january, 2006 c implicit real(8) (A-H,O-Z) ! keep older FORTRAN conventions parameter (MXSIZ=300) ! this is the maximum number of species character (len=16) molnam(NMOLEC) c character (len=300) path1, path2, path3 ! paths to database, working dir character (len=8) nammod ! name of model, name of dbs file character (len=80) errmsg(6) character (len=80) msg ! needed for AUTOGEN, SOLGEN call C character(len=8) , allocatable :: priv(:) ! setting private databanks character(len=3) , allocatable :: phase(:) ! setting phases character(len=1) , allocatable :: sel(:) ! solids calc character(len=16), allocatable :: solids(:)! solids names character(len=16), allocatable :: inflow(:)! component inflow names character(len=16), allocatable :: specie(:)! species names integer , allocatable :: jdumc(:) ! dummy inflo names (no data) character(len=80), allocatable :: eqs(:) ! equilibrium equations C character(len=80), allocatable :: redset(:) ! redox array integer , allocatable :: jredinc(:)! redox array C C C******************************************************* C NNSP=MXSIZ ! max number of species NNIN=MXSIZ ! max number of inflows NNSOLI=MAX(300,MXSIZ) ! max number of solids for analysis LQNNPH=4 ! number of phases c C Setup: memory allocations for AUTOGEN and PSREDOX C allocate ( priv(10) ) allocate ( phase(4) ) allocate ( sel(NNSP) ) allocate ( solids(NNSP) ) allocate ( inflow(NNSP) ) allocate ( specie(NNSP) ) allocate ( jdumc(NNSP) ) allocate ( eqs(NNSP) ) allocate ( redset(50) ) allocate ( jredinc(50) ) C C Setup: phases, databanks, components C do j=1,10 priv(J)=' ' enddo C phase(1)='VAP'! consider VAPOR phase phase(2)='SOL'! consider SOLID phaseS phase(3)=' ' ! consider 2nd liquid phase when phase(3)='ORG' phase(4)=' ' ! consider redox when phase(4)='RED' NSOLM=0 ! number of solids

Page 52: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page52

C IDBSW=1 do I=1,NNSP sel(i)=' ' ! GENERATE ALL solids enddo c c call AUTOGEN to create the model definition c c 20 call AUTOGEN(nammod,MXSIZ,priv,NMOLEC,molnam,phase,NSOLM, * solids,sel,NIN,inflow,NSP,specie, * Neqs,eqs,jdumc,path1,path2,path3, * IDBSW,IERR,msg) c if (ierr.gt.0) then write(*,'(a)') msg stop endif C C write the species names to the file and the screen C write(*,'(1X,A)')'Created Chemistry Model Definition' C C call SOLGEN to create the DBS file C call SOLGEN(nammod,priv,1,path1,path2,path3,IERT) C C check for errors C if (IERT.NE.0) then write(*,'(A,I5)') ' Genrate errors: ',iert write(93,'(A,I5)') ' Genrate errors: ',iert do I=1,IERT call GETERRG(I,IERCOD,6,errmsg) do j=1,6 if (errmsg(J).NE.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo enddo STOP endif C check for warnings C I=1 88 call GETWARNG(I,IWARNCOD,6,errmsg) if (IWARNCOD.NE.0) then do j=1,6 if (errmsg(J).NE.' ') then write(*,'(1X,A)') errmsg(J) write(93,'(1X,A)') errmsg(J) endif enddo go to 88 endif write(*,'(1X,A)')'Generated DBS File for Thermodynamics' c return END

Page 53: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page53

Appendix 2: Acknowledgements This User Guide was authored by several individuals: Primary Author: Patrice McKenzie AQSim, Inc. [email protected] Secondary Authors: Robert Young OLI Systems, Inc. [email protected] Chris Depetris OLI Systems, Inc. [email protected] Editor: James Berthold OLI Systems, Inc. [email protected]

Page 54: OLI Alliance Engine 7.0 User Guidesupport.olisystems.com/Documents/Manuals/OLI Alliance Engine User... · User Guide OLI Alliance Engine 7.0 1 User Guide 1 1 Overview 3 ... AES, UniSim,

OLI Systems, Inc. OLI Alliance Engine Basics Page54