UNIVERSITY OF CALGARY

Process Design and Control for Eco-Efficiency

by

Juan Manuel Montelongo Luna

A THESIS

SUBMITTED TO THE FACULTY OF GRADUATE STUDIES

IN PARTIAL FULFILMENT OF THE REQUIREMENTS FOR THE

DEGREE OF DOCTOR OF PHILOSOPHY

DEPARTMENT OF CHEMICAL AND PETROLEUM ENGINEERING

CALGARY, ALBERTA

MAY, 2010

© Juan M Montelongo-Luna 2010

Library and Archives Bibliothèque et Canada Archives Canada

Published Heritage Direction du Branch Patrimoine de l’édition

395 Wellington Street 395, rue Wellington Ottawa ON K1A 0N4 Ottawa ON K1A 0N4 Canada Canada

Your file Votre référence ISBN: 978-0-494-69529-6 Our file Notre référence ISBN: 978-0-494-69529-6

NOTICE: AVIS:

The author has granted a non- L’auteur a accordé une licence non exclusive exclusive license allowing Library and permettant à la Bibliothèque et Archives Archives Canada to reproduce, Canada de reproduire, publier, archiver, publish, archive, preserve, conserve, sauvegarder, conserver, transmettre au public communicate to the public by par télécommunication ou par l’Internet, prêter, telecommunication or on the Internet, distribuer et vendre des thèses partout dans le loan, distribute and sell theses monde, à des fins commerciales ou autres, sur worldwide, for commercial or non- support microforme, papier, électronique et/ou commercial purposes, in microform, autres formats. paper, electronic and/or any other formats. . The author retains copyright L’auteur conserve la propriété du droit d’auteur ownership and moral rights in this et des droits moraux qui protège cette thèse. Ni thesis. Neither the thesis nor la thèse ni des extraits substantiels de celle-ci substantial extracts from it may be ne doivent être imprimés ou autrement printed or otherwise reproduced reproduits sans son autorisation. without the author’s permission.

In compliance with the Canadian Conformément à la loi canadienne sur la Privacy Act some supporting forms protection de la vie privée, quelques may have been removed from this formulaires secondaires ont été enlevés de thesis. cette thèse.

While these forms may be included Bien que ces formulaires aient inclus dans in the document page count, their la pagination, il n’y aura aucun contenu removal does not represent any loss manquant. of content from the thesis.

UNIVERSITY OF CALGARY

FACULTY OF GRADUATE STUDIES

The undersigned certify that they have read, and recommend to the Faculty of Graduate

Studies for acceptance, a thesis entitled "Process Design and Control for Eco-Efficiency" submitted by Juan Manuel Montelongo Luna in partial fulfilment of the requirements of the degree of Doctor of Philosophy.

Supervisor, Dr. William Y. Svrcek, Chemical and Petroleum Engineering

Co-Supervisor, Dr. Brent R. Young, Chemical and Materials Engineering, University of Auckland

Dr. Abdulmajeed Mohamad, Mechanical and Manufacturing Engineering

Dr. Wayne D. Monnery, Chemical and Petroleum Engineering

Dr. Harvey Yarranton, Chemical and Petroleum Engineering

Dr. Om P. Malik, Electrical and Computer Engineering

External Examiner, Dr. Paul Stuart, École Polytechnique de Montréal

Date

ii Abstract

The main objective of process design is to develop processes or plants that will produce goods of higher value than the raw materials used. Consequently, process design is mostly driven by the economics of production. However, many other factors, such as operability and environmental regulations have to be considered in the design of a process.

Due to the dynamic nature of chemical and petrochemical processes, without process control a plant could not be operated safely and at design conditions.

Disturbances drive the process in directions that are not the desired/designed operating levels. Process control is the means by which disturbances are rejected.

Exergy can be derived from the application of the first and the second laws of thermodynamics to a process. Exergy can be used as a measurement of how valuable the process is, that is, if the exergy values of the products of the process are close to those of the raw materials the process is highly (thermodynamically) efficient.

An eco-efficient process can be defined as one that is ecologically friendly and economically viable. This means the process should reduce energy consumption (or exergy destruction), which in turn reduces operating expenses.

Exergy along with an integrated framework for process design and process control can be used to develop more efficient processes in a faster and less costly manner than conventional process design.

The objectives of this research project were to develop an exergy calculator for chemical process streams and to develop a controllability index based on exergy. These tools will allow the design engineer to gain insight into the eco-efficiency of the process

iii from the early design stages and will reduce the number of design and control structure alternatives that need to be evaluated in detail.

The Exergy Calculator was developed and implemented in a commercial process simulator (HYSYS®) and in an open source chemical process simulator (Sim42®). This tool facilitates the generation of an exergy analysis for any process for which a simulation exists.

The new Relative Exergy Array (REA) is a controllability index that, when used with the RGA, provides information about the process interactions of a control structure and its relative thermodynamic efficiency.

iv Acknowledgements

Six years may seem like a lot of time but they surely have passed very fast.

During this time I had the honour and pleasure of having wonderful people around me from which I have learned many things about and about life.

I will always be in debt to my supervisor and friend Dr. William Y. Svrcek. It is very hard to find words to express my gratitude to you Bill. Thank you for all the support and encouragement so I could complete this thesis. I learned many things from you and from the side projects you trusted me and I am sure I can still learn more. Thank you for all the cups of coffee and the occasional “chat and walk” sessions through the university’s campus.

I deeply appreciate the help, support and encouragement from my co-supervisor and friend Dr. Brent R. Young. Although separated by almost 12000 km during the last three years of this research project, Brent has never stopped guiding me through the tortuous paths of process control. Thank you for trusting in me when I first arrived to

Calgary. I also want to thank you and your family for hosting me during my trip to New

Zealand.

I would like to acknowledge the financial support from the Alberta Energy

Research Institute (AERI) through its COURSE program. The financial support from the

Chemical and Petroleum Engineering Department is also greatly appreciated.

I would like to thank the administrative staff at the Chemical and Petroleum

Engineering Department, particularly to Ms. Andrea Cortes and Ms. Arlene Wallwork, for all their help.

v Undoubtedly, the encouragement from many friends helped me continue and cheered me up when I most needed it. Special thanks to Mr. Raul Cota for all his help with Sim42 and for his friendship and the support he has continuously given me since we met in Mexico during our undergraduate studies.

I am particularly thankful to Mr. Mahyar Mohajer whom always was there for me whenever I needed to discuss process control, process simulation or just to grab a cup of coffee. Mahyar you are a true friend and I am lucky to have met you.

I would have never been able to finish this thesis without the support and encouragement of Miss Maryam Rajayi. Thank you for believing in me and for staying up late at night with me while I was writing this thesis. I promise you won’t hear the word “thesis” from me anymore. I love you.

Last but certainly not least I am eternally grateful to my parents, Argelia and Juan, and to my sister, Isadora, for all the love and support they have given me throughout my life and especially during these last six years. Thank you for never giving up on me and for encouraging me to continue the pursuit of my dream... I love you.

vi Dedication

To my parents, Maria B. Argelia Luna and Juan M Montelongo.

vii Table of Contents

Approval Page ...... ii Abstract ...... iii Acknowledgements ...... v Dedication ...... vii Table of Contents ...... viii List of Tables ...... xi List of Figures and Illustrations ...... xii List of Symbols, Abbreviations and Nomenclature ...... xiii

CHAPTER ONE: INTRODUCTION ...... 1 1.1 Process Design ...... 2 1.2 Process Control ...... 4 1.3 Thermodynamics ...... 6 1.3.1 Eco-efficiency ...... 8 1.4 Integration of Process Design and Process Control ...... 9 1.5 Objective and Justification ...... 11 1.5.1 Research Approach ...... 12 1.5.2 Expected Contribution ...... 12 1.6 Thesis Structure ...... 13 1.7 Summary ...... 14

CHAPTER TWO: LITERATURE REVIEW ...... 16 2.1 Process Design Philosophy ...... 16 2.2 Process control structure design procedures ...... 22 2.2.1 Operability ...... 24 2.2.2 Controllability ...... 25 2.3 Thermodynamic analyses ...... 27 2.4 The integration of process design, process control and thermodynamic analysis ...28 2.4.1 Process design and process control ...... 29 2.4.2 Exergy and process design ...... 30 2.4.3 The second law of thermodynamics and process control ...... 32 2.5 The need for new tools ...... 33 2.6 Summary ...... 33

CHAPTER THREE: EXERGY CALCULATOR ...... 35 3.1 The exergy concept ...... 35 3.1.1 Exergy definition ...... 36 3.1.2 Exergy components ...... 40 3.1.2.1 Chemical exergy ...... 42 3.1.2.2 Physical exergy ...... 43 3.1.2.3 Exergy change of mixing ...... 44 3.2 Exergy as a measure of eco-efficiency ...... 45 3.2.1 Exergetic efficiency ...... 46 3.3 Exergy calculator tool ...... 47 3.4 Software implementation ...... 49

viii 3.4.1 Sim42 Implementation ...... 49 3.4.2 Aspen HYSYS implementation ...... 50 3.4.3 Software verification ...... 53 3.5 Summary ...... 55

CHAPTER FOUR: CONTROLLABILITY INDEX ...... 56 4.1 Multivariable control systems ...... 56 4.1.1 Pairing controlled and manipulated variables ...... 57 4.2 Relative Gain Array ...... 57 4.2.1 RGA definition ...... 58 4.2.2 RGA calculation ...... 59 4.2.2.1 Using the process model ...... 59 4.2.2.2 Using process identification ...... 60 4.2.3 RGA interpretation ...... 60 4.2.4 Caveats of the RGA results ...... 62 4.3 Exergy-based extension to the RGA ...... 63 4.3.1 Calculating the exergy-based RGA ...... 64 4.3.2 Interpreting the exergy-based RGA ...... 66 4.4 Summary ...... 67

CHAPTER FIVE: SAMPLE APPLICATIONS AND RESULTS ...... 69 5.1 Exergy analysis case study ...... 69 5.1.1 TEG dehydration process and model description ...... 69 5.1.2 Exergy analysis sample results and discussion ...... 74 5.2 Exergy Relative Gain Array case study ...... 78 5.2.1 Multi-component distillation column process and model definition ...... 78 5.2.2 Controllability index calculation (RGA) ...... 81 5.2.3 Relative exergy gain array (REA) ...... 83 5.3 Combined Exergy and Relative Exergy Array case study ...... 84 5.3.1 Separation of MCB process and model description ...... 84 5.3.2 Exergy analysis results and discussion ...... 88 5.3.3 Controllability index calculation (RGA) ...... 91 5.3.4 Relative exergy gain array calculation (REA) ...... 94 5.4 Summary ...... 95

CHAPTER SIX: DISCUSSION, CONCLUSIONS AND RECOMMENDATIONS ...... 97 6.1 Benefits of the Exergy Calculator ...... 97 6.1.1 Limitations of the current Exergy Calculator ...... 97 6.2 A New Controllability Index ...... 98 6.2.1 Limitations of the REA ...... 98 6.3 Conclusions ...... 99 6.4 Recommendations for future research ...... 100

REFERENCES ...... 102

APPENDIX A: CALCULATION OF THE STANDARD CHEMICAL EXERGY ...... 111

ix APPENDIX B: COMPUTER CODE DEVELOPED FOR THE EXERGY CALCULATOR ...... 114 B.1. VBA code developed for the Aspen HYSYS implementation of the Exergy Calculator ...... 114 B.1.1. Main module ...... 114 B.1.2. PublicVars module ...... 137 B.1.3. Auxiliary module ...... 138

x List of Tables

Table 1. Tasks Involved in the Process Design Procedure ...... 17

Table 2. Standard Chemical Exergy for Reference Species ...... 42

Table 3. Exergy Calculator Validation (Exergy Components) ...... 54

Table 4. Exergy Calculator Validation (Exergy Changes) ...... 54

Table 5. Inlet Gas Composition for a Saturated Lean Natural Gas ...... 72

Table 6. Specifications for the Simulation Model ...... 73

Table 7. Reference Chemical Exergy for Selected Elements ...... 74

Table 8. Material Streams Exergy ...... 75

Table 9. Equipment Exergy Flows...... 76

Table 10. Distillation Column Feed Flow Rate and Composition ...... 79

Table 11. Variable Pairing for the Proposed Control Configurations ...... 81

Table 12. Configuration for the Step Change Experiments ...... 82

Table 13. Inlet Composition for the MCB Separation Process ...... 85

Table 14. Specifications for the MCB Simulation Model ...... 87

Table 15. Reference Chemical Exergy for Selected Elements ...... 88

Table 16. Material Streams Exergy ...... 89

Table 17. Equipment Exergy Flows...... 90

Table 18. Variable Pairing for the Proposed Control Configuration ...... 92

Table 19. Specifications for Step Change Experiments ...... 93

Table 20. Reference environment composition ...... 111

Table 21. Standard Chemical Exergy for Reference Species ...... 112

Table 22. Standard Chemical Exergy for Selected Compounds ...... 113

xi List of Figures and Illustrations

Figure 1. General Process Design Procedure ...... 18

Figure 2. Onion Diagram ...... 20

Figure 3. Example of a Cost Diagram ...... 21

Figure 4. Loop Interactions for a 2 x 2 System ...... 24

Figure 5. A General Process ...... 37

Figure 6. Exergy Components ...... 41

Figure 7. Exergy Calculator General Algorithm ...... 48

Figure 8. Natural Gas TEG Dehydration Plant Schematic ...... 71

Figure 9. Distillation Column Schematic...... 80

Figure 10. MCB Separation Process Schematic ...... 86

xii List of Symbols, Abbreviations and Nomenclature

Some of the symbols presented are context dependent.

Symbol Definition b Exergy gain

B Exergy or

Bottoms Flow

퐵 Steady-state Exergy Gain Matrix

D Process Draw or

Distillate Flow

F Process Feed g Gain

G Gibbs Free Energy or

Steady-State Gain Matrix

H Enthalpy

L Liquid Phase Fraction or Flow or

Reflux Flow m Process Input or

Manipulated Variable

M Thermodynamic Property n Number of Items

P Pressure q, Q Heat or Thermal Energy

S Entropy

xiii T Temperature

U Internal Energy

V Volume or

Vapour Phase Fraction or Flow or

Boil-up Rate w Work x Liquid Phase Composition y Vapour Phase Composition or

Process Output or

Controlled Variable z Overall composition

⨂ Hadamard Product (Element by Element Matrix Multiplication)

Subscripts Description

0 Reference

00 Dead State

1, 2... Items or

Control Loops chem Chemical i Item or

Species or Compound or

Control Loop j Control Loop

xiv mix Mix or Mixture phys Physical

REF Reference Environment t Total

Superscripts Description

0 Standard l Liquid Phase v Vapour Phase

Greek Letters Description

α Phase

β Relative Exergy Gain; Phase

ℬ Relative Exergy Array (REA)

∆ Increment; Change

λ Relative Gain

Λ Relative Gain Array (REA)

σ Created Entropy

ψ Exergetic Efficiency

xv 1

Chapter One: Introduction

Process control is a very important aspect of the design and operation of any chemical or petrochemical process. Also, not a single process plant is ever at steady state since there are always disturbances, measured or unmeasured, that are driving the process variables away from their desired set points. It is a well designed process control strategy that maintains these variables at, or as close as possible to, the designed set point. Hence, one could imagine that being this important process control would be taken into account very early in the design stage of a new or improved process. However, this is rarely the case in process design practice.

In addition to the limitations imposed by disturbances, all processes are further constrained by thermodynamic reality. The first and second laws of thermodynamics

“dictate” the maximum efficiency that a particular process can achieve; that is, in order to obtain a higher value product from a raw material, energy or work must be used during its processing. During the processing some energy is dissipated and lost to the environment, thus, reducing the process efficiency. However, it is the design of the process which determines how close to the maximum efficiency the plant can be built or operated. Hence, during the process design it is common practise to maximize or minimize various process variables that lead to an optimum steady state operation, at least in terms of operation costs.

A more detailed introduction to these topics is presented in the following sections.

It will also be shown that only the integration of all these concepts can lead to a process which is designed and operated in a manner that can improve its thermodynamic efficiency, and consequently the economic efficiency.

2

1.1 Process Design

The effective design of a chemical or petrochemical process requires a deep understanding of all areas of chemical engineering (Koolen 2001). For example, in order to design a chemical process that involves materials reacting and the separation of the resulting mixture, knowledge of chemical thermodynamics, reaction kinetics, and heat and concepts are necessary to design each of this process’s sections. The understanding of these concepts does not involve only theory but has to be complemented by extensive empirical knowledge and experience. Process design is an art complemented by the application of engineering principles.

The main objective of process design is to develop processes or plants that will produce goods of higher value than that of the raw materials. It is evident then that process design is mostly driven by the economics of the production. However, many other factors, such as environmental regulations have to be considered in the design of a process. Thus, environmental regulations as applied to chemical or petrochemical process do affect/influence its design. Government agencies require that all industries comply with certain rules regarding environmental impact. These regulations come in several forms such as emission limits, intensity targets, and energy consumption levels.

Many paths do often exist to produce a certain product using the same or different unit operations in an alternative sequence. The design engineer is faced with the problem of deciding which unit operations can perform the required task, while at the same time maximizing production or profit while minimizing the environmental impact, or at least meeting government regulation.

3

Process integration is one way to minimize energy consumption levels while maintaining high production rates. Process integration is, in simple words, the combination or use of surplus energy from one part of the process in some other section of the plant. Although, process integration results in economic savings it often produces a more complex plant that will not necessarily be easier to operate. Consequently, most of the actual process optimization takes place during the operating life of a plant. This is due to the state of practical process design, in which, in the early stages of the process design the operation of the plant is only viewed in general terms. Often the dynamics of the process are not dealt with in enough detail, other than empirical experience, to make a comprehensive assessment of how the plant will operate under start-up and shutdown procedures. Day-to-day disturbances and changes to the operation are also tested at only a cursory level or not at all.

In the early design stages there is not enough information about the process and equipment to develop dynamic models with the appropriate level of fidelity to characterize the dynamic behaviour of the process. It is only in the late design stages that details of the operation are taken into consideration or when the process control scheme for the “final design” of the plant is being developed. Even with modern simulation tools it is unusual that during the design stages is dynamic modeling and simulation used to assess the ease of operation or dynamic behaviour of the process. Furthermore, the use of these simulation tools requires a high level of expertise in dynamic modeling that is not common to all process design engineers.

As will be shown in Chapter 2 process design is performed in stages, each with an increased level of detail (Douglas 1988; Peters and Timmerhaus 1991; Ulrich and

4

Vasudevan 2004; Sinnott 2005). Only a few of the factors involved in process design have been presented above. This broad overview is intended to show the complexity of process design and that it is in fact the concurrency of many areas of chemical engineering (Koolen 2001).

1.2 Process Control

The notion of a “perfect process” where all the variables are static is a useful approximation for design purposes. However, the concept of a steady state is not very useful for operating purposes because chemical and petrochemical processes are in fact dynamic entities, which are constantly undergoing changes that void the assumption of steady state. Hence, these disturbances in the process variables are always driving the process in directions that are not the desired/designed operating levels. These disturbances can be internal, such as heat exchanger fouling, or external, such as changes in the ambient temperature. They can also be measured or unmeasured. In fact, any unexpected change in the process variables is considered a disturbance. Thus, process control is the means by which these disturbances are rejected. It is process control that, by means of sensors, controllers and manipulated variables, maintains a process in an apparent steady state despite the effects of disturbances. Without process control a plant could not be operated safely and at design conditions (Seborg et al. 1989).

Arguably, all chemical and petrochemical industrial processes are in fact multivariable in nature. This means that the process depends on several variables and these can affect it in different ways. In other words, it is very rare that an industrial process depends only on a single variable. This dependency makes process control even

5 more challenging because many variables must be controlled simultaneously to properly operate the process.

In process control, multivariable processes are called multi-input multi-output

(MIMO) processes (Skogestad and Postlethwaite 2005). MIMO processes tend to be interactive, that is, any change in one of the inputs can affect more than one of the outputs. Interaction thus adds more complexity to the design of a control structure and it can also make some control structures less useful or even unstable and undesirable

(Coughanowr 1991).

The design of the control structure that will suit a particular process or is not a simple task. In fact, this task is often delayed to the later design stages and it is performed mainly by experienced engineers. A complete understanding of how the process operates (unit operations interact) and how it can be controlled is necessary in order to provide a successful process control solution/strategy. Even during or after a control structure has been proposed it must be evaluated or tested. This evaluation is necessary to assure that the desired control strategy, both unit and plant-wide, will be stable despite the effect of all foreseeable disturbances. Simulation is a means for the evaluation of control structures. However, dynamic simulation is rarely used because it does require detailed unit operation data and skilled engineers.

Steady-state simulation combined with the appropriate tools can to some extent be used for a preliminary screening of control structures. The selection of one or two of these candidate structures will result in time savings as fewer control structures will need to be thoroughly tested via dynamic simulation. Even if only one control structure is

6 proposed in the early design stages, the use of advanced simulation tools can give some information about the expected performance of the proposed control structure.

Tools based on steady-state information can be used not only by a process control expert but also by the novice engineers. Novice engineers will gain experience from designing and evaluating many control structures, while the experienced engineers will make the best decision by choosing the appropriate control structure from a small pool of options. Hence, by using tools based on steady-state process information the process control structure can be selected at an earlier stage during the process design.

The design of the process control structure for a particular plant involves a great deal of complexity. Just a few of these difficulties have been noted above, however, it should be noted that process control strategies can benefit from the use of simple but powerful tools that allow for fast design and selection. Especially if these tools can be used early in the process design stage by both novice and experienced engineers.

1.3 Thermodynamics

Core to the chemical engineering discipline is the performance of mass and energy balances on chemical processes. These analyses provide engineers with a means to account for the materials and energy that a process requires, as well as, where and how those materials and energy are used within the process. For the most part, to track the use of energy, chemical engineers limit themselves to the use of the first law of thermodynamics (i.e. energy balance) (Himmelblau and Riggs 2004). However, the use of the second law of thermodynamics along with the first law provides a better understanding of the process energy usage (Denbigh 1956). A major advantage of including the second law of thermodynamics is that it can be used to identify how much

7 of the energy being “wasted” could potentially be used elsewhere in the process (energy integration).

Exergy can be derived from the application of the first and the second laws of thermodynamics to a system (or process). Exergy is a property that indicates the available work that exists in a system. This is the amount of work that a system can potentially deliver if it is brought to a complete thermodynamic equilibrium with its surroundings. Exergy will be discussed in detail in Chapter 3.

The second law of thermodynamics states that all irreversible processes have a net generation of entropy, or only reversible processes can be accomplished at constant entropy (Kotas 1985). Exergy, on the other hand, is destroyed every time a process occurs, i.e. the system loses some of its potential to generate work (Denbigh 1956; Kotas

1985). Thus, Exergy can be used as a measure of how valuable a system is, that is, if the exergy content of the products of a process are close to those of the raw materials the process is highly (thermodynamically) efficient. This efficiency, of course, depends on the amount of work or energy required by the process. This relation to efficiency makes exergy a viable candidate to monitor the economic performance of a process; in fact there are several techniques that can be used (Wall 2003). In Chapter 2 a survey of the open exergy literature will be presented.

Thermodynamic concepts are an extremely useful tool for achieving the best possible design when several alternatives exist. Thermodynamics itself indicates “how far” a process can go and which path is the least expensive, thermodynamically speaking.

When this is translated into economic terms, this information can be used to evaluate the eco-efficiency of a particular process design alternative.

8

1.3.1 Eco-efficiency

The World Business Council for Sustainable Development (WBCSD) describes

Eco-efficiency as a “management philosophy that encourages business to search for environmental improvements that yield parallel economic benefits” and defines it as:

The delivery of competitively priced goods and services that satisfy human needs and bring quality of life, while progressively reducing ecological impacts and resource intensity throughout the life-cycle, to a level at least in line with the Earth’s estimated carrying capacity (WBCSD 2006, p. 3).

Analyzing the “eco-efficiency” term it is possible to arrive at a shorter but equivalent definition. Ecology, a branch of biology, is the science that studies the distribution and abundance of living organisms and how they interact with their environment (“life management”). Economics, a social science, is concerned with the production, distribution, and consumption of goods and services (“household management”).

The prefix “eco”, which comes from the Greek oikos (house, household or estate), is mainly used to refer to anything related to the environment. Therefore, for purposes of this research project, the equivalent definition of the term “eco-efficiency” by using both ecology and economics states that an eco-efficient process will be one that is highly ecologically friendly and economically viable. Which is, in fact, an equivalent definition to the one coined by the WBCSD. Furthermore, by proposing that an ecologically friendly process reduces the consumption of energy (or destruction of exergy), which in turn reduces operating expenses; exergy can be also used as a central tool to determine the eco-efficiency of a process.

9

1.4 Integration of Process Design and Process Control

As stated, process design is performed in several stages which involve tasks of increasing complexity and detail. The design of the process control strategy for the process design is usually delayed to the late stages because it is a complicated task and requires a great deal of process information. Nevertheless, with the appropriate tools process control design can be performed in the earlier design stages. That is, an integrated approach to process design would result in an eco-efficient process. By integrating process design with process control earlier in the design sequence a more efficient process can be designed.

A major advantage, of integrating the design of the control structure with the design of the process, is the possibility of making process configuration changes in order to achieve a process that will be easier to control. It is common practice to design an

“optimum” process for maximum profitability, however, this often leads to a process with heat integration or other equipment arrangements that are difficult to operate and control.

If some modifications were made to this process design at an early stage, it would be possible to still achieve high efficiency with a much better process control.

Obviously, simple process modifications are easy to make during the early design stages and also changes made early are inexpensive at the design stage. It is much more expensive to change a part of the process during construction or start up. However, some small changes can have a large impact in the control of the process. Something as simple as a larger surge tank on a recycle stream can result in the process having a higher resiliency to disturbances.

10

By designing the control structure at the same time as the initial process design many control structure candidates can be evaluated simultaneously. Furthermore, performing this during the early design stages is much more cost effective than delaying it to the late stages. Steady-state process simulation is less expensive than dynamic simulation, therefore, only the best candidate will be simulated dynamically during the final process design phase.

A more operationally effective process can also be designed by integrating process design and control. Only the necessary allowances for good process control will be made instead of substantially over or under sizing critical equipment. Again, it is more cost effective to do this during early design than when the plant has been completely designed and equipment ordered.

From a logistics point of view, it is also advantageous to integrate the design procedure as a better flow of information can be established between the process and control teams. Furthermore, these teams can actually be one group resulting in even better design practices (Seferlis and Georgiadis 2004); the combined experience of the design and the control engineers is beneficial for the design of the process. Process engineers can benefit from the knowledge process control engineers possess on the plant/unit dynamics. On the other hand, control engineers will definitively benefit from the knowledge process engineers have about process alternatives. Other advantage of integrating the design of the process and its control is improved safety in the operation of the process. Hazard and Operability (HAZOP) analysis can be carried out with the design and control engineers during the early stages of the design allowing a better design

11 of the process and an adequate control system that, not only is eco-efficient but also safe to operate.

The integration of process control and process design has other advantages that not only include a better process design but also faster and more cost effective process design and control structure design. Practical tools that aid this integration are definitively needed to enhance the design procedure, especially if these new tools are applicable to both the process and the control engineers.

1.5 Objective and Justification

The objective of this research project was to explore the use of exergy as a tool to develop a controllability index for chemical and petrochemical processes. The use of exergy as a potential tool for improved process design is also addressed as part of this research project. These tasks required the development and application of tools and techniques that can be effectively implemented during the various stages of the process design procedure. Therefore, the specific aims of this research project were to:

1. Develop and implement an exergy calculator tool for a chemical process’ material

streams.

2. Develop a controllability index based on exergy.

3. Apply these tools and techniques to sample processes.

The need to mitigate the existing gap between the design of a process and the selection of an appropriate control structure is evident. In practice, the control structure is only dealt with when most of the process has been designed and changes cannot be made without difficulty and excessive costs. This can, sometimes, lead to processes that are difficult to control or that cannot be operated at the designed capacities. Using tools

12 to evaluate the controllability of a process before detailed design or construction can be the difference between a success and a failure. Additionally, the process design has to be energy efficient and comply with government regulations throughout the plant operating life. The availability of a means for the measurement of the process efficiency during the design stage is limited to a few methodologies. These methodologies, to a large extent, do not provide a useful tool to evaluate the interactive nature of the plant operation.

Currently, there are no practical tools that can evaluate the controllability of a process while at the same time providing a measure of its eco-efficiency. This is the main motivation and justification for the present research project. The tool developed here is aimed at bridging this gap.

1.5.1 Research Approach

In order to address the proposed research objectives, this research project was divided into three stages: (i) the development of an exergy calculator, (ii) the development of the controllability index and, (iii) the selection of sample chemical and petrochemical processes. Once the first two stages were completed, calculations of the controllability index for the sample cases were performed and are presented in Chapter 5.

1.5.2 Expected Contribution

The two major contributions achieved in this research project, are the development of the exergy calculator and the development of a controllability index. The exergy calculator is a useful tool to evaluate the eco-efficiency of processes, as it can be used during the design of new chemical and petrochemical processes or for analysing currently operating processes. The output of the exergy calculation is a key performance indicator (KPI) for energy efficiency.

13

The second major contribution of this research is the development of a new controllability index. This index measures the interactions in the control structure for a chemical or petrochemical process while identifying its eco-efficiency. Thus, it points to potential process improvements during the early design stages and not during process start up and operation.

The application of the developed tools to case studies in Chapter 5 demonstrates how a process can be identified as eco-efficient. Even though the possibility of changing the process design paradigm to include the design of the control structure while assuring the process is eco-efficient is not explicitly investigated in this research, by including the tools developed in this research project, the design process is improved by allowing the simultaneous design of the process and its control structure at the same time as assessing its eco-efficiency.

1.6 Thesis Structure

A brief and broad overview of the main topics related to this research project has been presented in this introductory chapter. Chapter 1 also presented the objectives of this research project and its importance.

Chapter 2 presents an up-to-date literature review of the interaction between process design, control and exergy (second law) as well as the most relevant aspects of each of these topics.

In Chapter 3 the focus is on the development of the exergy calculator and its implementation in two process simulators (i.e. Sim42™ and HYSYS™). Details presented include the theory, the thermodynamics, the relation to eco-efficiency and the program structure (how it interacts with the simulators).

14

Chapter 4 presents the development of the exergy-based controllability index

(REA) and does show how the idea of the Relative Gain Array (RGA) can be translated into an exergy-based index, thus creating a new tool for process design and control. The theory behind the RGA and how it is extended to take into account the exergy of the process is presented in detail.

Sample controllability index calculations for selected processes are presented in

Chapter 5. This will show the difference in the information that can be obtained with the

RGA and the proposed REA index, as well as, the potential of the proposed REA index to give insight into the thermodynamic performance of the particular control configuration.

Finally, Chapter 6 focuses on the general discussion of the proposed tools and how these can be used in the integration of process design and control in the early stages of design without the need for more advanced and complex mathematical tools. Also, conclusions regarding the exergy calculator and the controllability index, as well as, recommendations for future work are presented.

1.7 Summary

Process design groups methodologies in order to develop chemical and petrochemical industrial processes. Process design relies largely on the economics of the chemical and petrochemical processes being developed, while thermodynamics imposes constraints on the process design.

Process control is a very important part of process design, in that process control deals with the process dynamics, hence is performed by experienced engineers during the late stages of process design. By integrating the design of the control structure into the early stages of process design economic operation of less costly processes is a result.

15

Furthermore, a quicker, less expensive design cycle can be achieved by integrating process design and process control. Better designs can also result from this integration as experience from process and control engineering can be used in a synergetic way.

The objectives for this research project were explained and justified. The development of an exergy calculator tool and a controllability index that can be used in early design stages will result in the design of eco-efficient processes.

16

Chapter Two: Literature Review

This chapter presents an up-to-date literature review of the most relevant aspects of process design, process control and exergy (second law) in the chemical and petrochemical industry, as well as the interaction between each of these topics. A review of the current efforts in integrating process design and process control is also presented.

This review will shed some light into the necessity for simple and practical, yet powerful, tools that can be used to quickly screen a design alternative or evaluate the operation of a process in terms of its controllability and its thermodynamic efficiency. This research project attempts to fill this knowledge gap by proposing new tools for process design and process control evaluation at the early design stage.

2.1 Process Design Philosophy

The design of a chemical process is a key activity in applied chemical engineering that involves many areas of expertise and is often complemented with empirical knowledge (i.e. experience and rules of thumb). Process design is a broad task and should be under taken concurrently with related engineering disciplines in order to achieve the best possible design that will result on the most efficient process operation

(Koolen 2001).

Process design is a creative activity and, by its nature, an iterative task, which typically begins with a conceptual view of the process to be developed followed by the collection of data and synthesis of the process. Economics are always present and need to be revised at every stage of the process design procedure. At the end of the design procedure the process can be optimized and appropriate changes are made. A top level depiction of the traditional process design procedure is shown in Figure 1, which is a

17 combination of the descriptions given by Ulrich and Vasudevan (2004) and Sinnott

(2005). Figure 1 shows the iterative nature of the general process design procedure and not the details of each of the steps involved. Each of these steps is a large and complex task in itself. Table 1 shows a partial list of the tasks involved in each of the steps shown in Figure 1.

Table 1. Tasks Involved in the Process Design Procedure

Step Tasks

1 Conception and Definition

 Opportunity assessment

 Block flow diagram (BFD)

2 Flow Sheet Development and Collection of Data

 Collection of physical and thermodynamic data

 Preliminary process flow diagram (PFD)

 Preliminary material and energy balance

3 Generation of Possible Designs

 Unit operations and equipment design

 Material and energy balance

 Preliminary process and instrumentation diagram (P&ID)

4 Economic Analysis and Evaluation

 Costing of utilities and equipment

5 Optimization

 Selection of objective function

18

Conception and Definition

Flow Sheet Development and Collection of Data

Generation of Possible Designs

Economic Analysis and Evaluation

Optimization

Final Design

Figure 1. General Process Design Procedure

19

Arguably, the most intensive engineering work is done in steps 2 (Flow sheet development and collection of data) and 3 (Generation of possible designs) of the general process design procedure. In order to generate possible designs for a process a systematic approach is desirable. Douglas (1985; 1988) first popularized the so called hierarchical approach to process design. This approach addresses the sequence in which the unit operations or sections of a process should be designed in order to achieve a better final process design.

The onion diagram (Smith 2005; Kemp 2007) shown in Figure 2 graphically depicts the sequence followed in the hierarchical approach to process design for a generic chemical process involving reactions. Starting at the reaction step, which is the core of the process (i.e. transformation of raw materials into products), the design then moves outwards to the separation and recycle systems (i.e. recovery of valuable products), the heat recovery (heat integration) system, the utilities system, and the water and effluent treatment systems (i.e. complying with environmental regulations).

This hierarchical approach is the basic logical sequence to be followed in efficient process design. Each of the design steps is further broken down into a detailed sequence, which is also iterative, in order to obtain the desired particular characteristics of the process. Even though the full economic analysis for the process is carried at a later stage

(step 4 in the general process design procedure), the design engineer must always keep the economics in mind, for instance by using simple tools like cost diagrams (Douglas and Woodcock 1985) for each process design alternative. Cost diagrams are a simple way to summarize and track overall annualized cost of each piece of equipment in a design alternative. Figure 3, adapted from the work of Douglas and Woodcock (1985),

20 shows an example of a cost diagram for a preliminary design of the hydrodealkylation of toluene. In this figure, the numbers represent the annualized cost (in thousands of dollars) of each section of the process as estimated in the preliminary design.

Reactor

Separation and Recycle System

Heat Recovery System

Heating and Cooling Utilities

Water and Effluent Treatment

Figure 2. Onion Diagram

Only recently, have heat integration procedures (i.e. pinch technology) been systematically presented as an integral part of the chemical process design to engineering students (Seider et al. 2003; Turton et al. 2003; Smith 2005) and practitioners (Kemp

2007). However, these efforts are still part of the hierarchical approach to process design and, as such, are applied in the logical sequence depicted in Figure 2.

21

Recycle Compressor 109

Feed and Recycle Product Reactor Purge Toluene Heating Cooling 198 600 Hydrogen 371 153

Toluene Benzene Stabilizer Column Column 28 76 174

Diphenyl Benzene

Figure 3. Example of a Cost Diagram

Beyond the “classical” logical/hierarchical approach to process design where experience and rules of thumb are the norm, a more systematic approach in process design is the application of optimization techniques to automatically synthesize processes. Biegler and coworkers present a compilation of state-of-the-art techniques to be used in process synthesis and design (Biegler et al. 1997). Mixed integer non-linear programming (MINLP) is among the mathematical tools used to reduce a superstructure to achieve an optimized process design. This and other tools and techniques can systematically and automatically generate entire process flow sheets with optimized parameters based on the set objectives. Such objectives are invariably monetary in nature.

However, in process design practice, the optimization of a chemical process is generally carried out after at least a preliminary design has been prepared and not from a superstructure as mentioned previously. Once again, the optimization is driven by an

22 objective function defined by economic terms (Peters and Timmerhaus 1991; Biegler et al. 1997; Ulrich and Vasudevan 2004).

2.2 Process control structure design procedures

As was noted in Chapter 1, chemical and petrochemical processes are dynamic, that is, they are constantly changing with time as a result of their inherent nature or due to disturbances. In chemical engineering most processes, and especially the most important ones, are multivariable (Svrcek et al. 2006), that is, they have multiple inputs and multiple outputs (MIMO) making these processes more difficult to control. Furthermore, the control of the whole plant is not guaranteed by the optimal control of individual unit operations (Luyben et al. 1997). This is due to interactions in units located in recycle loops and disturbances passed downstream from upstream unit operations.

The determination of a process control structure for a particular chemical process is a task that is usually tackled after the process design is almost complete. This causes the process control structure to be constrained to a particular process topology. However, it is well known that the process topology (unit operations sequence, inventory, etc.) has a direct impact on the dynamic behaviour of the process (Papadourakis et al. 1987;

Luyben and Floudas 1994a; Luyben and Floudas 1994b; Luyben et al. 1997). Alternative methods of synthesizing control structures along with the process flow sheet fall in the same category as the automatic synthesis (Biegler et al. 1997) of optimal designs mentioned in the previous section.

The importance of addressing the control structure design for a complete chemical process (plant-wide) has been studied by several authors. Perhaps, the publication of the problem formulation of the so-called Tennessee Eastman Process by Downs and Vogel

23

(1993) originated the most recent wave of efforts towards the development of better tools for designing plant-wide control structures. Many tools for control structure design have been inspired or evolved from this problem formulation. However, all of them require a level of expertise exclusive of seasoned design and control engineers.

Several authors have directed their attention to provide a systematic approach to the design of process control structures for chemical plants. During the mid and late

1990s Luyben and collaborators published their work on the design of process control structures for multi-unit systems (Luyben and Floudas 1994b; Luyben et al. 1997;

Luyben et al. 1998). More recently, Skogestad (2004) also presented a systematic approach to the design of plant-wide process control structures and also a discussion on the selection of decentralized structures versus MIMO MPC (Model Predictive Control) structures.

Generally, the preferred control structure for MIMO processes, due to their interactive nature, is a decentralized control structure (Zeghal and Palazoglu 1993).

There is a wealth of literature concerning tools and methodologies to determine the degree of interaction of a proposed decentralized control structure. Figure 4 depicts a 2 x

2 system, that is a system with 2 inputs and 2 outputs, and the interactions that can occur between its input and output variables. The interactions represented in Figure 4 are the base to understanding how a control loop affects other loops when it is acting to reject disturbances.

One of the advantages of a decentralized control structure is that it can be used to decouple the interactions that exist between the several process inputs and outputs.

However, it is necessary to have a measurement of these interactions in order to

24 determine the best approach for the design of the control structure and assess its performance.

- Loop 1 + m1 + y1 Gc1 G11

+

G12

G21

+

+ m2 + y2 Gc2 G22

- Loop 2

Figure 4. Loop Interactions for a 2 x 2 System

Two current indicators used to assess the performance of a process control structure design are the controllability index and the dynamic operability (index).

Although both have an important role in determining the performance of the plant-wide control structure only the former is of concern in this research project.

2.2.1 Operability

The process dynamic operability is determined in part by the process controllability but most importantly by its inherent capacity to operate even without a control system structure (Fisher et al. 1988b; Georgakis et al. 2003). A comprehensive operability study includes the determination of the steady-state operability and the dynamic operability of the process (Georgakis et al. 2003). In some instances a poorly

25 designed control structure can lead to a process that will suffer from operability issues

(Palazoglu and Arkun 1986).

In general, the operability analysis requires more information from the process

(e.g. proper sizing information of all equipment and a detailed plant model) and thus will be done after a preliminary controllability analysis is performed (Palazoglu and Arkun

1986; Fisher et al. 1988a; Fisher et al. 1988b). This is the main reason for this research to focus on controllability only.

2.2.2 Controllability

Controllability can be defined as the possibility of moving or the ease with which a process can be put into a particular steady state by using an appropriate control signal

(Weitz and Lewin 1996). If a state (e.g. a given temperature in a reactor or a certain composition in a distillate stream) is not controllable, then no control signal will ever be able to force or maintain the system at a prescribed/desired level of controllability.

The definition above conveys the importance of controllability in the design of control structures. If a particular process or state is not controllable, then there is no possible control structure that can be designed to control such process or state. Hence, in order to design a “best” control structure the controllability of the process should be known as early as possible in the design sequence.

There are several tools available to measure the achievable performance

(controllability) of a plant. Undoubtedly, the Relative Gain Array (RGA) (Bristol 1966) has been the most popular tool since it was first introduced in the 1960s. Its simplicity has attracted many practitioners while academics have focused their efforts on trying to extend its range of applicability. The RGA will be discussed in detail in Chapter 4.

26

The original RGA application is considered to be rather empirical. However, its properties have been theoretically proven and extended. McAvoy (1981; 1983) was among the first to take a more rigorous approach to prove the RGA’s properties.

Grosdidier and collaborators (Grosdidier et al. 1985) extended the RGA application to prove closed-loop stability, feasibility, and robustness using steady-state values only. In a separate study they also used the notion of structured singular value (SSV) to measure the performance loss resulting from decentralized control structures (Grosdidier and

Morari 1986). These studies further extended the application of the RGA to non-square decentralized control structures (i.e. when the number of manipulated variables is not the same as the number of controlled variables).

The RGA can be calculated by the use of a rigorous process model, however, a major advantage is that the process model is not necessary for its calculation when an actual process is available, as in retrofit situations (Svrcek et al. 2006). This aspect of the

RGA calculation is also an advantage when the available model is in the form of a process simulation and not in the “classical control theory” format (i.e. using transfer functions).

Unfortunately the RGA has certain limitations. It has been pointed out that care must be taken when using the RGA to analyze a single unit operation in a plant with recycles. It is likely that the recycle stream(s) will cause a change in the gain matrix and, therefore, in the RGA (Papadourakis et al. 1987). In these cases, the RGA analysis should be applied to the plant-wide control structure.

It has also been shown that in some cases the RGA reports misleading results because of it being based in steady-state (zero-frequency behaviour) information rather

27 than initial response (high-frequency behaviour) information (Skogestad et al. 1990).

These cases include highly non-linear systems and systems where the dynamics of the process loops involved are very different (i.e. some loops are very fast while others are very slow). McAvoy (1983) presents a detailed analysis on the effects the process dynamics has on the RGA results.

There are numerous research articles dealing with applications of- and enhancements to the RGA. However, listing these here is not necessary to demonstrate that the use of RGA in control structure design is extensive and valuable despite the known limitations.

2.3 Thermodynamic analyses

The ultimate performance of a chemical process is dictated by the laws of thermodynamics. Conservation of mass and energy and entropy production determine how “far” and in what direction a particular process can go. It is well known that the use of thermodynamic analyses is indispensable for the study and design of chemical processes. A general energy efficiency analysis of a process is usually defined in terms of its energy inputs, and energy losses. Even this basic analysis provides an insight into the way the process is performing with respect to its maximum possible energy efficiency

(Smith et al. 2005; Smith 2005).

An example of a more “advanced” thermodynamic analysis is the pinch analysis used for heat integration (Kemp 2007). In this energy analysis the maximum allowable recoverable energy for a particular process is determined by finding the “pinch” temperature. This temperature divides the process into areas where thermodynamics

28 indicates if additional heating or cooling is required to meet the heat integration objectives.

Another example of thermodynamic analysis is derived from the application of the exergy concept to a process. In this analysis the exergy being destroyed by the process is accounted for and thus related to the maximum available work in the process.

The use of exergy as a process energy analysis tool has grown as shown by the steady growth of literature on Exergy. It has been more than 20 years since two of the most useful books on exergy analysis and its applications in the chemical industries were published (Kotas 1985; Szargut et al. 1988). Since then, and prior to that, the application of exergy analyses is well documented in numerous publications.

Goran Wall published a compilation of several tools that can be used to assess the exergetic efficiency of a process in order to gain insight for improving it (Wall 2003).

Recently, Exergy applications have been extended beyond the process industries into sustainable development concepts and even policy making (Dincer 2002; Dincer and

Rosen 2007). In effect these new applications do make the Exergy concept a useful tool for assessing the eco-efficiency of a chemical process.

2.4 The integration of process design, process control and thermodynamic analysis

Arguably, only projects dealing with the simultaneous synthesis of heat exchanger networks (HEN) and their process control structure would fall into the category of combining the three topics of this section into a single framework. One of such example projects is that by Young and co-workers (2006). Other efforts for integrating chemical

29 process design with chemical process control structure design and thermodynamic efficiency can be divided into three main topics:

1. The integration of process design and process control

2. The application of exergy to process design

3. The application of the second law of thermodynamics and process control

Each of these topics is reviewed below.

2.4.1 Process design and process control

This is a much studied topic in chemical engineering academia and in industry.

However, in chemical engineering practice, only recently an effort to combine the design of the process with the design of its control structure has been made (Koolen 2001).

Generally, as noted, the approach is to first proceed with the process design before attempting the design of the control structure. The nature of the resulting problem formulation of the simultaneous design of the process and its control structure is perhaps one of the factors for the relatively slow pace in this research area (Kookos and Perkins

2001).

Examples of the complexity of the resulting problem formulation can be seen in the publications of Luyben and Floudas (1994a; 1994b) where the problem is posed as a mixed-integer nonlinear (MINLP) optimization of a superstructure of design alternatives;

Bahri and co-workers (Bahri et al. 1997) also used MINLP to optimize a proposed flow sheet for several proposed control schemes. Although these applications are powerful they are complex and required a detailed model of the process and expertise not common to many process and design engineers. It is in this area where the use of the RGA has been shown to be a useful design tool as is presented in the publications of Arkun and

30

Downs (1990), Cao and Rossiter (1997), Koooks and Lygeros (1998) and several others.

In these publications the steady state gain matrix and RGA are used to derive tools of relative ease of use but powerful enough to screen proposed control structures.

A recent compilation of research aimed at combining process design with process control in chemical engineering have been provided in the literature (Seferlis and

Georgiadis 2004). This book does present the current state-of-the-art procedures for simultaneously performing the design of processes and their control structures. For instance, chapters relevant to this research are the ones by Luyben (2004) where a compelling explanation of the need for simultaneous process design and control education is made; the contribution of Meeuse and Grievink (2004) presents ideas related to linking non-equilibrium thermodynamics with process synthesis systems; in a different section Alhammadi and Romagnoli (2004) present a framework to include environmental, economics, heat integration and controllability concepts into process design and operation; Seferlis and Grievink (2004) develop a procedure for the evaluation and screening of alternative process flow sheet and control structure configurations using nonlinear sensitivity analysis; in the chapter by Engell and co- workers (Engell et al. 2004) an analysis of several controllability measurements and tools and how they help in selecting an appropriate control structure is presented.

2.4.2 Exergy and process design

Integrating concepts of thermodynamic analyses and chemical process design is arguably a fairly well exploited concept. Beyond, the fact that a basic thermodynamic analysis is always present in chemical process design (i.e. energy balance), the

31 thermodynamic efficiency of several alternative processes is usually taken into account in early and late design stages (Peters and Timmerhaus 1991; Seider et al. 2003).

Several studies have been attempted to integrate the concept of exergy into the process design methodologies. The majority of these studies concentrate on the design of processes that are more energy efficient, destroy less exergy or reduce costs. For instance, a general framework for using exergy as a process design tool to reveal lower cost and higher efficiency is available (El-Sayed 2002). One of the techniques of this work includes assigning a monetary value to the exergy destruction as part of the operating cost and constructing objective functions in economic terms.

A systematic approach for the optimal design of chemical processes by minimizing exergy destruction was published as early as 1980 (Fan and Shieh 1980). In this work a straightforward approach for the constructing the objective function in terms of energy (enthalpy) and available energy (exergy) is used. On the other hand,

“Exergoeconomic” optimization was performed by dividing exergy into an intrinsic and an extrinsic part (Chang and Li 2005). In this work Chang and Li conceptualize the exergy destruction as the summation of two parts, one caused by configuration constraints (intrinsic) and the other one caused by transport rate limitations (extrinsic).

A procedure to generate process designs that reduce energy consumption as well as raw material consumption is based on a reducible superstructure and exergy load distribution (Sorin et al. 2000). In this work the evaluation of several alternatives included in the superstructure is based on utilizable exergy as a function of three aspects of the process design: efficient use of raw materials, energy efficiency and waste reduction.

32

Wall has also presented tools that can be used to quickly evaluate process design alternatives (Wall 2003). These tools are mostly in the form of exergetic efficiency formulations by which the process can be thermodynamically assessed. In fact, some of these formulations have been used before by others as it has been mentioned in this section.

It is this use of exergy in process design that permits a link between thermodynamic efficiency and economic efficiency.

2.4.3 The second law of thermodynamics and process control

Efforts to include thermodynamic concepts into the design of process control structures have been attempted. An appendix in the book by Luyben and co-workers

(1998) sets a basic framework for the development of a dynamic exergy balance for process control evaluation purposes.

A few papers dealing with the theoretical development and application of process control linked to entropy production have appeared in the recent literature (Ydstie and

Alonso 1997; Farschman et al. 1998; Tyréus 1999; Alonso et al. 2002; Ydstie 2002;

Ruszkowski et al. 2005). Although their formulations are rather complex, these developments have shown the potential for using a thermodynamic property as an essential part of the development of process control structures. Note, entropy production minimization however, does not necessarily mean that all the savings in energy are of a

“good quality”. Exergy, on the other hand can potentially be used to assess control schemes that account for the “quality” of the energy being saved.

A controllability analysis based on passivity theory has been presented (Santoso et al. 2007). Also, a systematic approach to the design of plant-wide control structures

33 extending from these passivity concepts has been recently presented by Antelo and co- workers (2007). To extend their work, Antelo and co-workers (2008) presented the optimal tuning of PI controllers, derived from the application of the thermodynamically- based decentralized control structure design for the Tennessee Eastman Process.

2.5 The need for new tools

There is no doubt that major efforts have been made in the integration of the techniques and knowledge from chemical process design, chemical process control and thermodynamics into a single unified framework. This is not an easy task and, as such, there are significant contributions yet to be made. It is also clear that the current practices and tools available for chemical process design and chemical process control structure evaluation lack the capabilities to fully integrate concepts of thermodynamics in a sensible manner for practitioners lacking the deep understanding of these three topics.

The application of the tools available today can be an intimidating task for the practising, less “academic-oriented” engineer.

The development of a tool that can combine the principles of chemical process design, chemical process control and thermodynamic efficiency while maintaining an understandable framework would be welcomed by practising process design engineers.

The goal of this study is to provide a new tool to close this gap.

2.6 Summary

An up-to-date literature review of the most current and relevant topics on the integration of chemical process design, chemical process control structure design and thermodynamic analysis showed that these three topics are seldom applied simultaneously in process design and existing process evaluation. Research towards this

34 goal have been made and presented by several authors, however, there is still a major need for the development of usable, understandable new tools.

This new tool must address the existing gap between the design of a process and the design of its control strategy while addressing thermodynamic limitations. Such a tool should be capable of addressing the chemical process’ economic or thermodynamic efficiency, as well have the potential to be easily understood by practising engineers.

35

Chapter Three: Exergy Calculator

As was noted in Chapter 2, Exergy has been used as an indicator for energy efficiency in chemical and petrochemical processes and plants; however, exergy has not been formally defined in this document. Chapter 3 will provide a definition of exergy and its components, as well as justification for its use as an eco-efficiency indicator.

Also, a major contribution of this chapter is a detailed description of the development and structure of the “Exergy Calculator”. This discussion includes the implementation of the calculator tool in two process simulators (Sim42™ and Aspen HYSYS™). Note, the

Exergy Calculator tool is an integral part of this research as it is the foundation for calculating the necessary values for the controllability index to be discussed in detail in

Chapter 4.

3.1 The exergy concept

Exergy is a thermodynamic property of state based on the application of the first and second laws of thermodynamics to a system. While the application of the first law accounts for the energy transferred in and out of the system, as well as energy generated or consumed in the system (e.g. chemical reactions), exergy also takes into account the system’s irreversibilities. This provides a more detailed, and realistic, tracking mechanism for the energy usage. Furthermore, by using environmental parameters

(pressure, temperature and composition) as the reference state, exergy provides a convenient standard for the maximum work which can be obtained from a given form of energy (Kotas 1985). Accounting for exergy destruction (or conservation) can be used as a measure of the thermodynamic efficiency of the system and, consequently, a measure of eco-efficiency.

36

3.1.1 Exergy definition

The exergy of a stream of matter can be defined as:

... the maximum amount of work obtainable when the stream is brought from its initial state to the dead state by [reversible] processes during which the stream may interact only with the environment (Kotas 1985, p. 37).

Dead state is the state determined by the unrestricted equilibrium (chemical, thermal and mechanical) of the process with the environment. This means, at the dead state the process would have the same temperature, pressure and chemical potentials as those of the surroundings. By subjecting the system to these conditions of full thermodynamic equilibrium with the environment, there cannot be any changes of state due to interaction with the environment and thus no work can be obtained from the system. For example, if pure nitrogen [N2] is contained in a vessel or is flowing through a pipe at temperature T0, and pressure P0, it is at the environmental state. However, only if nitrogen is at T0 and (P00)N2 (i.e. the partial pressure of nitrogen in the atmosphere) can be in unrestricted equilibrium with the environment, the dead state. In the dead state nitrogen (in this example) cannot undergo any further changes because there is no potential or force (chemical, thermal or mechanical) to drive a change.

In order to define exergy mathematically we consider an open process interacting with the environment as shown in Figure 5. An arbitrary number of material streams can flow in and out of the process boundary. The process is being heated from several sources that can be at different temperatures. The process can produce shaft work and deliver it to the environment. However, the environment is at fixed pressure, temperature and composition.

37

Q1 Q2 Qp T1 T2 Tp

F1 D1

F2 D2 Process T, P, z

Fn-1 Dm-1

Fn Dm

wshaft Environment T0, P0, z0

Figure 5. A General Process

Following an approach similar to that of Denbigh (1956), we start by defining a steady state energy balance (first law of thermodynamics) around the process, Equation

(1).

∆푈 = 푞 − 푤′ (1)

We consider the change in the internal energy of the process [∆U] to be due to the addition of energy through the heat sources [q] and work done [w’]. Assume that at this point the process requires work (e.g. a pump) so its sign can be changed. Furthermore, the energy balance, Equation (1) can be re-written in more detail, Equation (2).

38

(2) ∆푈 = −푞0 + 푞푖 − 푃0∆푉 + 푤 푖

We have now individual terms for the heat provided to the medium [q0], all other heat effects [Σqi], for the work done in displacing the atmosphere at constant pressure

[-P0ΔV] and for all other work terms [w].

Using the second law of thermodynamics, which states that the sum of all entropy changes caused by the process can only be positive or zero, as it is shown in Equation (3).

(3) ∆푆 + ∆푆0 + ∆푆푖 ≥ 0 푖

For convenience it is appropriate to define the total created entropy [σ] by

Equation (4).

(4) ∆푆 + ∆푆0 + ∆푆푖 ≡ 휎 푖

The second law will only apply for cases/situations shown by Equation (5).

휎 ≥ 0 (5)

Recall that the medium is acting only as a heat reservoir at constant temperature

[T0] hence, its change in Entropy is shown by Equation (6).

푞0 (6) ∆푆0 = 푇0

And Equation (4) may be rewritten as Equation (7).

푞0 (7) ∆푆 + + ∆푆푖 = 휎 푇0 푖

Substituting [q0] from Equation (2) into Equation (7) we obtain Equation (8).

39

1 (8) Δ푆 + −Δ푈 + 푞푖 − 푃0Δ푉 + 푤 + Δ푆푖 = 휎 푇0 푖 푖

Multiplying Equation (8) by the reference temperature [T0] results in Equation

(9).

(9) 푇0Δ푆 − Δ푈 + 푞푖 − 푃0Δ푉 + 푤 + 푇0 Δ푆푖 = 푇0휎 푖 푖

Rearranging, we can write Equation (10) which is a combined statement of the first and second laws.

(10) 푤 + 푞푖 + 푇0Δ푆푖 = 푇0휎 + Δ푈 + 푃0Δ푉 − 푇0Δ푆 푖

If we assume that the heat reservoir does not undergo any change except for the medium (from the definition of exergy), the [qi] and [ΔSi] terms in Equation (10) will be zero resulting in Equation (11).

푤푡 = 푇0휎 + Δ푈 + 푃0Δ푉 − 푇0Δ푆 (11)

Equation (11) is the total amount of work [wt] which would be needed for the given process with a particular amount of created entropy [σ] when only the process materials and the medium undergo changes.

Now assume that the process is carried reversibly, then the created entropy will be zero and the definition of exergy is given by Equation (12).

Δ퐵 ≡ ∆푈 + 푃0∆푉 − 푇0∆푆 (12)

Therefore, the exergy will be the minimum amount of work required for the process to occur or, in the case of the process providing work, the maximum amount of work obtainable from the process when this process is carried out reversibly.

40

Henley and Seader (1981) have an alternative approach to exergy definition, which is a completely equivalent form shown in Equation (13).

∆퐵 = ∆퐻 − 푇0∆푆 (13)

3.1.2 Exergy components

Exergy can be calculated in several ways, however, in order to use exergy in processes involving chemical composition changes it is convenient to subdivide it into three components that allow easier tracking of different types of exergy changes.

Chemical exergy [Bchem], physical exergy [Bphys] and exergy change of mixing [∆mixB]

(Hinderink et al. 1996). Exergy can be defined so that the addition of these three components provides the exergy of the material stream, Equation (14).

퐵 = 퐵푐푕푒푚 + 퐵푝푕푦푠 + ∆푚푖푥 퐵 (14)

One of the major advantages to the subdivision of exergy into these three components is that simple calculations using thermodynamic data relatively easy to obtain in a chemical process simulator can be used. The chemical exergy term represents the exergy in the system or material stream contained in the components at different compositions [z] than those of the dead state [z00]. The physical exergy term represents the exergy contained in the pure components at the process conditions [P, T] and not at the reference [P0, T0] or dead state [P00, T00]. Finally, the exergy change of mixing represents the exergy change involved in mixing the pure components at the process conditions [P, T] to obtain the process mixture composition. Figure 6 depicts the relations between these three terms and the total exergy.

41

Pure Components at Process Conditions (P, T) Exergy Change of Mixed Components at Mixing Process Conditions (∆mixB) (P, T, z)

Physical Exergy (Bphys)

Pure Components at Total Exergy Reference Conditions (B) (P0, T0) Usually, P0 = P00 Chemical Exergy T = T (B ) Dead State 0 00 chem (P00, T00, z00)

Figure 6. Exergy Components

Figure 6, the graphical representation of the exergy components, clearly shows that the pure components at process conditions would have a higher exergy value than the actual component mix at process conditions. Furthermore, note that the pure components at reference conditions would also have a higher exergy value than the component mix of the dead state. This means that pure components by themselves are more valuable (i.e. contain more exergy) than a mixture of them. Figure 6 also points out that as long as the process conditions differ from the reference (environment) conditions the system or material stream will have the potential to perform work (exergy). It is interesting to note that the pressure and temperature of the reference conditions [P0, T0] are usually the same as the pressure and temperature of the dead state [P00, T00].

Following is the calculation methodology for each of the three exergy components as used in the developed Exergy Calculator.

42

3.1.2.1 Chemical exergy

The chemical exergy term can be interpreted as the exergy content due to the chemical composition difference between the pure components at the process conditions and the reference state [P0, T0] or dead state conditions [P00, T00]. In order to calculate the chemical exergy it is necessary to first calculate a standard chemical exergy for the reference or dead state. Appendix A shows details of the standard chemical exergy calculation for several chemical compounds. Table 2 below presents the Standard

Chemical Exergy for reference species derived from the average atmosphere.

Table 2. Standard Chemical Exergy for Reference Species

Compound Standard Chemical Exergy [J/mol]

(v) H2O 9493.57

N2 720.09

CO2 19866.60

O2 3974.26

Ar 11692.71

An equilibrium calculation is necessary at the reference or dead state conditions to calculate the chemical exergy of a stream of matter using the standard chemical exergy of its components. Equation (15) shows this calculation.

푛 푛 (15) 0푙 0푣 퐵푐푕푒푚 = 퐿0 푥0,푖퐵푐푕푒푚 ,푖 + 푉0 푦0,푖퐵푐푕푒푚 ,푖 푖=1 푖=1

Where [L0] represents the liquid phase fraction or flow at the reference or dead state conditions with a composition [x0] and [V0] represents the vapour phase fraction or

43 flow at the reference or dead state conditions with a composition [y0]. This Equation (15) assumes there are two phases in equilibrium, if there were more phases in equilibrium additional terms for accounting each phase’s chemical exergy contribution should be added.

3.1.2.2 Physical exergy

The physical exergy term can be seen as the exergy content due to the thermo- mechanical difference between the pure components at the process conditions and the reference state conditions. From this point of view, it should be clear that thermodynamic properties from both the process and the reference state conditions will be necessary to calculate the physical exergy term, Equation (16). It is interesting to note that the Physical Exergy can be calculated with a definition similar to that of Equation

(13) applied to each of the phases in equilibrium at the process conditions and reference state.

푛 푛 푛 푛 푇,푃 (16) 푙 푙 푣 푣 퐵푝푕푦푠 = 퐿 푥푖퐻푖 − 푇0 푥푖푆푖 + 푉 푦푖퐻푖 − 푇0 푦푖푆푖

푖=1 푖=1 푖=1 푖=1 푇0,푃0

Equation (16) shows that flash calculations are required at both the process conditions and at the reference state. The result of the calculation is the physical exergy as the difference of exergy content between the two thermo-mechanical states.

Equation (16) assumes there are two phases in equilibrium [L] and [V] at both the process and the reference state conditions, if there were more phases in equilibrium additional terms for accounting each phase’s physical exergy contribution should be added.

44

3.1.2.3 Exergy change of mixing

Since the calculation of the exergy of a stream of matter has been divided into suitable contributions from the pure chemical components and the actual mixture of the stream, it is necessary to account for the effects of mixing the pure components to obtain the actual concentrations in the stream of matter. The concept of property change of mixing1 is used for this purpose (Smith et al. 2005).

For an arbitrary thermodynamic property [M] Equation (17) shows the property change of mixing.

푛 푛 (17) 푙 푙 푣 푣 ∆푚푖푥 푀 = 퐿 푀 − 푥푖 푀푖 + 푉 푀 − 푦푖푀푖 푖=1 푖=1

Equation (17) assumes there are two phases in equilibrium [L] and [V], if there were more phases in equilibrium additional terms for accounting each phase’s property change of mixing contribution should be added. The assumption of two phases in equilibrium holds for the remaining of the equations in this section.

Applying the property change of mixing concept to enthalpy and entropy we obtain Equation (18) and Equation (19), respectively.

푛 푛 (18) 푙 푙 푣 푣 ∆푚푖푥 퐻 = 퐿 퐻 − 푥푖 퐻푖 + 푉 퐻 − 푦푖퐻푖 푖=1 푖=1

푛 푛 (19) 푙 푙 푣 푣 ∆푚푖푥 푆 = 퐿 푆 − 푥푖 푆푖 + 푉 푆 − 푦푖푆푖 푖=1 푖=1

Once the changes of mixing for the enthalpy and the entropy have been calculated, the exergy change of mixing can be obtained, Equation (20).

1 This is also known as Mixing Property (Walas 1985).

45

∆푚푖푥 퐵 = ∆푚푖푥 퐻 − 푇0∆푚푖푥 푆 (20)

Similar to the Physical Exergy calculation, it is interesting to note that the Exergy

Change of Mixing can be calculated with a definition similar to that of Equation (13) applied to each of the phases in equilibrium at the process conditions.

3.2 Exergy as a measure of eco-efficiency

In Chapter 1 the concept of eco-efficiency was introduced and it determined that a process is eco-efficient by being ecologically friendly and economically viable. In

Chapter 2 it was stated that thermodynamic analyses are carried for a process to determine the viability of the particular process or operating conditions. The definition of

Exergy given in the previous sections of this Chapter demonstrated that exergy is indeed a combination of the First and Second Laws of Thermodynamics.

Recall that, invariably, all chemical and petrochemical processes need energy transfer to occur. In most cases this transfer involves supplying the process with energy from several sources. For instance, a pump will need electricity or fuel gas to increase the pressure of a liquid; an air cooler will need air to be pushed through a bundle of tubes to transfer heat from the process fluid to the air. Furthermore, any form of energy supplied to the process must come from an external source (power generation plant, for instance) which in turn requires transformation of energy from several sources into an easier form for transport and use.

It is clear that, the more energy a process requires the more energy it needs to be supplied from the external sources. This direct dependency justifies the use of exergy and thermodynamic efficiency as a measure of eco-efficiency. Energy efficiency, as used from a First Law balance, is commonly used to determine how a process is performing

46 with respect to energy waste. This same concept of efficiency can be extended to exergy in order to determine how the process is performing with respect to eco-efficiency.

3.2.1 Exergetic efficiency

Dimensionless ratios of quantities are the preferred way to measure or determine efficiencies in science and engineering applications. It has been shown that exergy is a measure of the ability to perform work, thus, from the viewpoint of exergy, the maximum efficiency should be achieved in a process in which exergy is conserved.

Exergy efficiency can be defined in several ways depending on the detail of the information available and the desired comparison for the processes under study (Wall

2003; Dincer and Rosen 2007). Equation (21) defines the Exergy Efficiency [ψ] for a process as the ratio of the exergy in the product outputs [Bout] to the exergy in the inputs

[Bin].

퐵 퐸푥푒푟푔푦 푙표푠푠 푝푙푢푠 푐표푚푠푢푚푝푡푖표푛 (21) 휓 = 표푢푡 = 퐵푖푛 퐸푥푒푟푔푦 푖푛 푖푛푝푢푡푠

Two other efficiency definitions based on exergy are useful for analysis of a particular piece of equipment or device in chemical and petrochemical processes, the

Rational Exergy Efficiency and the Task Exergy Efficiency. Equation (22) defines the

Rational Exergy Efficiency [ψrational] as the ratio of the total exergy output [Btot-out] to the total exergy input [Btot-in].

퐵푡표푡 −표푢푡 퐸푥푒푟푔푦 푐표푛푠푢푚푝푡푖표푛 (22) 휓푟푎푡푖표푛푎푙 = = 1 − 퐵푡표푡 −푖푛 푇표푡푎푙 푒푥푒푟푔푦 푖푛푝푢푡

Equation (23) defines the Task Exergy Efficiency [ψtask] as the ratio of the

Theoretical minimum exergy input required to the Actual exergy input for the equipment.

47

푇푕푒표푟푒푡푖푐푎푙 푚푖푛푖푚푢푚 푒푥푒푟푔푦 푖푛푝푢푡 푟푒푞푢푖푟푒푑 (23) 휓 = 푡푎푠푘 퐴푐푡푢푎푙 푒푥푒푟푔푦 푖푛푝푢푡

These efficiencies give a better insight into the performance and eco-efficiency of the process than energy-based efficiencies because they take into account the actual quality of the energy (exergy) and they can, in general, offer a measure of potential improvement.

3.3 Exergy calculator tool

The exergy calculation is completed by adding the effects of three components

(chemical exergy, physical exergy and exergy change of mixing). In order to automate this calculation an exergy calculator was developed. This calculator deals only with the exergy calculation for material streams and utilizes a chemical process simulator to retrieve all the necessary physical and thermodynamic properties.

Figure 7 shows a flow diagram of the algorithm developed to integrate the exergy calculator into a process simulation. Note, the actual implementation of the calculator varies depending on the process simulator used. If the source code of the simulator is available (e.g. Sim42) the calculator can be directly programmed into the core of the process simulator. If a COM (Component Object Model) interface is the communication means of the simulator (e.g. Aspen HYSYS) then an external routine can be written to interact with the simulator in order to perform the appropriate calculations.

The following section deals with the details of the implementation for each of the chosen simulators.

48

Figure 7. Exergy Calculator General Algorithm

49

3.4 Software implementation

Two separate implementations of the exergy calculator have been developed. For the case of Sim42™, routines were added to the process simulator kernel (Montelongo-

Luna et al. 2005; Montelongo-Luna et al. 2007). For the case of Aspen HYSYS™

(HYSYS), routines were written in Visual Basic for Applications™ (VBA) for Microsoft

Excel™ (Excel).

3.4.1 Sim42 implementation

Sim42™ is an open source chemical process simulator originally developed at the

University of Calgary in 2003 (Cota Elizondo 2003). It was written in Python due to the programming language’s object oriented capabilities and ease of prototyping. Since

Sim42 is an open source simulator the source code is available to users and developers so that it can be modified as long as the license requirements are met.

The approach followed in this implementation consisted of adding the methods and functions necessary to calculate the exergy components directly to the simulator kernel which then permits calculation of the exergy during the building of a process simulation.

Two main modules of Sim42 had to be modified to include the exergy calculator: thermo and solver. The thermo module contains all the files to interface the simulator with the property package provider. The solver module contains all the files used for solving process simulations (Cota Elizondo 2005).

It is necessary to add the exergy property to the list of variables supported by the simulator. This is accomplished in the Variables.py file of the solver module, and allows the simulator to recognize exergy as one more property and therefore, to display it in the

50 results as required. In fact, this is how the total exergy is displayed to the user, just as one more property in the material port of Sim42.

The exergy calculator as programmed in a separate file, ExergyCalc.py, and only the calls to the methods and functions were embedded in the appropriate places. The actual calculation is triggered in the VirtualMaterials.py files of the thermo module. It is in this module where the simulator performs the flash calculations when a unit operation or port requires solving.

In the ExergyCalc.py file the exergy calculation is performed as per the same algorithm shown in Figure 7. The property package and the chemical compounds in the simulation are detected, and the current conditions for the material port in turn are identified. With this information flash calculations are performed to obtain the required values for the exergy components. When these calculations are complete the result for the total exergy is stored in the property list for the material port which can then be displayed along with all other properties.

The process engineer can extract the exergy information directly from the simulation and perform further analysis, for example, controllability index calculations for preliminary process control structures.

3.4.2 Aspen HYSYS implementation

AspenTech’s Aspen HYSYS™ (HYSYS) is a commercial process simulator that can be further customized by embedding computer code in its own macro language or through a COM interface. HYSYS exposes almost all of its functionality through objects, functions and methods accessible programmatically (Aspen Technology 2005).

This capability made HYSYS a suitable choice for integrating the exergy calculator.

51

Microsoft Excel™ (Excel) is arguably the most widely used spreadsheet in industry. Its user interface is familiar to most process engineers, and Excel can extend its capabilities by programming custom functions in its embedded VBA editor. This VBA editor can be further extended by using references to external COM interfaces so that it can recognize objects, functions and methods already available in other sources.

Excel was chosen as the front-end implementation of the exergy calculator. All the routines necessary to calculate the exergy from a HYSYS simulation were written in the Excel’s VBA editor and the results presented in spreadsheets. This procedure/implementation allowed the calculation of the exergy for any previously built simulation.

In order to use the objects, methods, and functions provided in the HYSYS COM, this had to be made available to VBA in Excel. This is accomplished by adding the

HYSYS 3.0 Type library from the References option in the Tools menu in the Excel’s

VBA editor.

Three developed VBA modules contain all the routines required in the implementation of the exergy calculator: Main, PublicVars, and Auxiliary. The

PublicVars module contains the definition of special public (global) objects and variables necessary to exchange information with the HYSYS COM. At least two of these variables are required: one to access the HYSYS Application object and one to access the

HYSYS Simulation Case object.

The Main module contains all the computer code to perform the calculation of the three exergy components. In general, it uses HYSYS and the simulation case the user has selected to extract the information about the material streams in the simulation. First, the

52 property package and the chemical compounds in the simulation are extracted, then the calculator extracts the current conditions and data for each material stream. With this information the calculator asks the simulator to perform the appropriate flash calculations in order to obtain the necessary information to calculate the exergy components. When the calculations are complete the results are sent to the spreadsheet.

The Auxiliary module contains ancillary routines to perform basic tasks. For instance, the computer code to parse the chemical compounds formulas and to calculate the standard chemical exergy is contained in this module. Other routines used to clear old results in the spreadsheet and to open the simulation case also reside in this module.

Three main spreadsheets are used in the exergy calculator Excel file: Main,

Exergy DB, and Atoms. If the selected simulation has sub-flowsheets then SubFlowsheet spreadsheets are added.

The Main spreadsheet presents the simulation case name that has been selected as well as the property package being used. It also displays the number of chemical components in the simulation and the number of material streams. For each material stream it presents the process conditions (P, T, Flow) and the thermodynamic properties of interest (H, S, B, Bchem, Bphys, ΔmixB). If any, the SubFlowsheet spreadsheets contain the same type of information as the Main spreadsheet for each sub-flowsheet.

The Exergy DB spreadsheet is a depository of the values used and calculated during the process of obtaining the standard chemical exergy for each chemical compound in the simulation.

53

Finally, the Atoms spreadsheet presents the results of parsing each of the chemical formulas for each of the chemical compounds in the simulation. This is required to calculate the standard chemical exergy of each compound.

The process engineer can use all the information generated to perform an exergy analysis of the simulated process. Furthermore, as in this research project, the process engineer can then use the results to gain an insight into the controllability of candidate process control structures.

3.4.3 Software verification

In order to validate the developed software published values of exergy were used to compare the results obtained with each of the implementations of the algorithm. Since exergy values cannot be measured experimentally, available point and change values calculated in the open literature were reproduced as a means to verify the developed computer programs for the Exergy Calculator.

The literature reference used to compare the calculation of each of the exergy term (Chemical, Physical and Change of mixing) is the work of Hinderink and coworkers

(1996). They present one numerical example of a multi-component material stream for which they calculate the exergy term mentioned above and the total exergy flow of the stream. Table 3 shows the values obtained with the Exergy Calculator developed in this work and the literature values.

54

Table 3. Exergy Calculator Validation (Exergy Components)

Quantity [kW] This work Literature

Chemical Exergy 3190 3123

Physical Exergy 2531 2532

Exergy Change of Mixing -1683 -1678

Total Exergy Flow 4038 3977

Seider and coworkers (2009) presented a series of numerical examples where they calculate the change in exergy for steam, air or water streams subject to several processes. Table 4 shows the values obtained with the Exergy Calculator developed in this work and the literature values.

Table 4. Exergy Calculator Validation (Exergy Changes)

Process [kJ/kg] This work Literature

Steam superheating 119.71 119.56

Steam throttling -122.80 -122.53

Water mixing -15.15 -15.16

Air liquefying 728.96 731.02

Air mixing -44.16 -44.16

The minor discrepancies seen in Table 3 and Table 4 are due to small differences in the reference state used in the literature and the fact that the thermodynamic properties

55 provider is different in each case. However, the magnitude of these differences would not affect any conclusions when determining potential for improvement.

3.5 Summary

A formal definition of exergy has been presented in this chapter. Exergy was conveniently divided into three components to easily track different types of exergy changes and to develop an exergy calculator that could be used in conjunction with a chemical process simulator.

It was shown that Exergy can be used as a measure of eco-efficiency by means of exergetic efficiency. Three important definitions of exergetic efficiency were presented.

The algorithm for the exergy calculator was also presented in this chapter along with the details of its implementation in two different chemical process simulators. The exergy calculator was first implemented in the open source chemical process simulator

Sim42. VBA for Excel was used to implement the exergy calculator in the commercial chemical process simulator Aspen HYSYS. The complete computer code for the exergy calculator implementation is available in Appendix B.

56

Chapter Four: Controllability Index

It has been shown in Chapter 2 that a variety of tools exist to assess the controllability of a chemical process or plant, the focus being the operability from a purely process control perspective. Nonetheless, a few tools have integrated process design or thermodynamic concepts into the definition of controllability indexes.

In this chapter, a review of the Relative Gain Array (RGA) definition is presented first and then extended to include the exergy of the process. This results in a new tool that assesses the controllability of a chemical or petrochemical process from both the process design and thermodynamic efficiency perspectives.

Using the concept of exergy and the Exergy Calculator developed in Chapter 3 it is shown that the new controllability index provides an insight into the process controllability as well as the process thermodynamic efficiency, and consequently the eco-efficiency of the process.

4.1 Multivariable control systems

Chapter 1 and Chapter 2 presented a basic notion of chemical process control for chemical and petrochemical plants. Chemical and petrochemical processes are dynamic and multivariable, therefore control of the processes important variables is necessary.

Decentralized control is an approach in which the control of a process is carried out by individual (single) control loops working together but independent from each other.

Multi-Input Multi-Output (MIMO) processes are typically interactive and these interactions should be taken into account when designing the decentralized control structure. Minimizing the interaction between the control loops can positively affect the process while having a high degree of interaction will require a different but still effective

57 control structure. In the latter case the most likely alternative is to decouple the interactions by means of combining variables (e.g. using ratios instead of single variables) or by manipulating the variables in such a way that the interactions are reduced

(e.g. applying a square root operand to the variable).

4.1.1 Pairing controlled and manipulated variables

Selecting the right pairing of a controlled variable with a corresponding manipulated variable is essential in decentralized control structures. The proper pairing can maintain loop interaction at a minimum while the wrong pairing can lead to an unstable or uncontrollable process. Several tools exist that aid in the selection of variable pairs and in this research project the focus is on the RGA. The information provided by the RGA, considering the ease with which it can be calculated, makes it a very useful tool for the screening of control structure candidates (McAvoy 1983).

4.2 Relative Gain Array

Originally developed by Bristol in 1966 (Bristol 1966), the RGA has received much attention in the literature and in process control practice, as it does provide a quantitative comparison of the interaction between control loops. However, its major drawback is that this information corresponds to the final steady-state of the process

(Svrcek et al. 2006).

The engineer should always keep in mind that the results obtained from the RGA could be misleading in certain situations (McAvoy 1983), to be described in section

4.2.4. However, the value of the RGA as a tool for fast control structure screening overcomes its drawbacks by permitting the engineer to reduce the control structure candidates that will be studied in more detail (i.e. by performing dynamic simulations).

58

4.2.1 RGA definition

Bristol defined the Relative Gain [λ] as:

... the ratio of two gains representing first the process gain in an isolated loop and, second, the apparent process gain in that same loop when all other control loops are closed (Bristol 1966, p. 133).

In other words, the relative gain [λij] is the ratio of the gain change in the steady- state value of the output variable [yi] with respect to the input variable [mj] when all loops are open to the gain change in the steady-state value of [yi] with respect to [mj] when all other loops are closed in “perfect control”2 (Svrcek et al. 2006). Equations (24) through (26) present these definitions.

휕푦 (24) 푖 휕푚 푗 all loops open 휆 = 푖푗 휕푦 푖 휕푚푗 all loops closed and in perfect control except the 푚푗 loop

Equation (24) is equivalent to the interpretation given by Equation (25) below.

open-loop gain (25) 휆 = 푖푗 closed-loop gain for loop 푖 with 푚푗

The generic gain [gij] for the control loop is defined by Equation (26).

휕푦푖 (26) 푔푖푗 = 휕푚푗

The Relative Gain Array [Λ] is obtained when the relative gains for all pairing combinations in a multi-loop Single-Input Single-Output (SISO) system are calculated,

Equation (27).

2 “Perfect control” refers to the condition of a control loop where no offset is present in the controlled variable.

59

휆11 휆12 … 휆1푛 (27) 휆 휆 … 휆 Λ = 21 22 2푛 ⋮ ⋮ ⋱ ⋮ 휆푛1 휆푛2 … 휆푛푛

4.2.2 RGA calculation

The two procedures for calculating the RGA depend on the available information.

If a mathematical model of the process exists then it can be used in a very direct manner.

If a model does not exist then a procedure using process identification can be used to calculate the RGA.

4.2.2.1 Using the process model

In this case the calculation is straightforward because all the information is readily available. Consider the process described by Equation (28);

풚 = 퐺풎 (28)

where [y] is a vector of the outputs or controlled variables, [m] is a vector of the inputs or manipulated variables and [G] is the steady-state gain (open-loop) matrix of the process as described by Equation (29) with [gij] previously defined in Equation (26).

푔11 푔12 … 푔1푛 (29) 푔21 푔22 … 푔2푛 퐺 = ⋮ ⋮ ⋱ ⋮ 푔푛1 푔푛2 … 푔푛푛

The RGA is calculated using the Hadamard product (element by element multiplication) to the G matrix and the transpose of its inverse. Equation (30) describes this procedure.

Λ = 퐺⨂ 퐺−1 T (30)

60

4.2.2.2 Using process identification

In the current chemical and petrochemical process industry, it is not uncommon to skip the more mathematical description of the process and rely on simulation tools. Or perhaps the process is of such complexity that the development of its mathematical model would be a cumbersome task. In these cases an experimental procedure can be used to calculate the RGA.

To calculate the steady-state gain we introduce a change in the manipulated variable [mj] while all other manipulated variables are held constant. The change in the controlled variable [yi] can only be attributed to the change in [mj]. This step-change procedure delivers the information to calculate [gij], Equation (31).

Δ푦푖 휕푦푖 (31) 푔푖푗 = = Δ푚푗 휕푚푗 푚≠푗 =푐표푛푠푡푎푛푡

Once all the gains are calculated the steady-state gain matrix can be assembled and used to obtain the RGA, Equation (27).

4.2.3 RGA interpretation

The properties and values of the RGA provide the information necessary to determine the best possible pairings for the MIMO system so that interactions at zero frequency are at a minimum (McAvoy 1983). A number of useful properties of the RGA are as follows:

 All of the rows or columns in the RGA sum to one, Equation (32).

푛 푛 (32) 휆푖푗 = 휆푖푗 = 1 푖=1 푗 =1

 It is independent of scaling.

61

 If an element in the RGA is equal to zero then the manipulated variable [mj] has

no effect on the output or controlled variable [yi]. Do not pair these variables.

 If an element in the RGA is equal to one then the manipulated variable [mj] is the

only variable affecting the output or controlled variable [yi]. Use this pair of

variables as it indicates that no interaction is affecting the loop (“perfect pairing”).

 If an element in the RGA is less than zero then this pair will potentially

destabilize the system because the open-loop response is opposite in direction to

the closed-loop response. Do not pair these variables.

 If an element in the RGA is between zero and one then the other control loops

interact with the [mj-yi] loop. It follows that, when the element value is equal to

0.5 the effect of this control loop is equal to the retaliatory effect of the other

loops. Avoid using this pairing because there will be no net effect and the other

loops are being affected as well. If the element value is between zero and 0.5 then

the retaliatory effect of the other loops is greater. Avoid this pairing because the

effect on the output variable [yi] is minimal and other loops are being affected. If

the element value is between 0.5 and one then the effect of this control loop is

greater than the retaliatory effect of the other loops. Use the pairing only when

the element value is greater than 0.5.

 If an element in the RGA is greater than one then this loop is dominant but the

other loops are acting in the opposite direction. Avoid this pairing if the value is

much greater than one.

62

In summary, always pair on positive RGA elements that are closest to one.

However, there are exceptions to this rule as described in the next section (4.2.4) and in deeper detail in the work of McAvoy (1983).

4.2.4 Caveats of the RGA results

In certain cases of higher-order systems (i.e. 3 x 3 or more) care should be taken when pairing manipulated and controlled variables. McAvoy (1983) presents two examples where the results obtained from the RGA are misleading. One of them will be shown below to illustrate the procedure required to achieve a correct answer.

The first example considers a system whose open-loop steady-state matrix is shown below in Equation (33).

5 (33) 1 1 3 1 퐺 = 1 1 3 1 1 1 3

This system has an RGA given by Equation (34).

10 −4.5 −4.5 (34) Λ = −4.5 1 4.5 −4.5 4.5 1

Following the pairing guidelines presented in the previous section one would be inclined to use the pairings defined by the main diagonal. The only feasible variable to control [y1] is [m1]. For the other two pair of variables the value of one in the main diagonal indicates that the pairing will be “perfect”.

However, when a stability test is applied to this system, Equation (35), as defined by the Niederlinski index (Niederlinski 1971) the result indicates that the choice of

63 variables will be unstable. If the value of the Niederlinski index [NI] is less than zero the system will be unstable.

G (35) 푁퐼 = 푛 푖=1 푔푖푖

For this example the |G| is equal to -0.148 and all the diagonal elements are positive. This leads to a NI < 0 and thus the system is unstable. In order to obtain a stable system the pairing with the 4.5 value should be used, contrary to the expected

“perfect” value of 1.

4.3 Exergy-based extension to the RGA

The extension of the RGA by using exergy in its calculation permits a deeper insight into the interactions of the process control structure. Note, exergy is a tool for determining the maximum efficiency of a process.

The exergy-based extension to the RGA (or Relative Exergy Array, REA) is defined analogously to the original RGA, Equation (36).

훽11 훽12 … 훽1푛 (36) 훽 훽 … 훽 ℬ = 21 22 2푛 ⋮ ⋮ ⋱ ⋮ 훽푛1 훽푛2 … 훽푛푛

The relative exergy gain [β] is the ratio of the gain change in the steady-state exergy of the stream of [yi] with respect to that of the stream of [mj] when all loops are open to the gain change in the steady-state exergy of the stream of [yi] with respect to that of the stream of [mj] when all other loops are closed in “perfect control”, given by

Equation (37) and Equation (38).

64

ΔB 푦 (37) 푖 ΔB 푚푖 all loops open 훽푖푗 = ΔB 푦 푖 ΔB 푚푗 all loops closed and in perfect control except the 푚푗 loop

The generic exergy gain ratio [b] for the control loop is defined by Equation (38),

ΔB 푦푖 (38) 푏푖푗 = ΔB 푚푗

These relative exergy changes indicate the exergetic efficiency effects of pairing each of the manipulated variables to the output or controlled variables. Since the change in exergy in the manipulated variable [mj] (input) causes a change in exergy in the controlled variable [yi] (output), the exergy gain ratio can be seen as the definition of exergetic efficiency for the [mj-yi] pairing.

A major difference between the true exergetic efficiency, Equation (21), and the exergy gain ratio is that the latter is not bound to remain between 0 and 1 because the variable pairing can involve separate parts of the process. However, this ratio will indicate the relative “exergetic efficiency” effect of pairing the two variables.

4.3.1 Calculating the exergy-based RGA

The development of mathematical models involving the exergy calculation for a generic stream of material is not simple. On the contrary, as shown in Chapter 3, it is rather complex and requires extensive use of thermodynamic properties for the stream at the process conditions and at the condition of the reference environment. The approach taken in this research project for the RGA/REA calculation is experimental and analogous to the one described in section 4.2.2.2. Note, the use of the Exergy Calculator developed in Chapter 3 within a process simulator will permit the simultaneous

65 calculation of the values necessary to calculate both the original RGA and the new exergy-based extension (REA).

Similarly to the RGA, to calculate the steady-state exergy gain we introduce a change in the manipulated variable [mj] while all other manipulated variables are held constant. The change in the stream of the controlled variable [yi] can only be attributed to the change in [mj]. This step-change procedure provides the information to calculate

[bij] as described by Equation (39) below.

(39) Δ퐵 푦푖 휕퐵 푦푖 푏푖푗 = = Δ퐵 푚푗 휕퐵 푚푗 푚≠푗 =푐표푛푠푡푎푛푡

Once all the exergy gains are calculated the steady-state exergy gain matrix can be calculated using the same procedure as the steady-state gain matrix. Equation (40) shows the steady-state exergy gain matrix.

푏11 푏12 … 푏1푛 (40) 푏 푏 … 푏 퐵 = 21 22 2푛 ⋮ ⋮ ⋱ ⋮ 푏푛1 푏푛2 … 푏푛푛

Using Equation (40) the REA can be determined as shown in Equation (41).

ℬ = 퐵 ⨂ 퐵 −1 T (41)

This calculation procedure has the advantage that a number of the properties of the RGA are being inherited by the REA. Such as the summation of the rows and columns are equal to one. It is independent of scaling and the interpretation of the results is analogous to that of the RGA.

66

4.3.2 Interpreting the exergy-based RGA

The properties and results of the REA provide a quantitative analysis of the effect that the control loop interactions have on the thermodynamic process efficiency. That is, the exergy gain [bij] as defined by Equation (38) quantifies the amount of exergy change produced in the stream of the controlled variable when a certain (exergy) change is introduced in the stream of the manipulated variable. This translates to an alternative measure of the exergetic efficiency for the pair [mj-yi]. Note, in Chapter 3 it was shown that the exergetic efficiency is a measure of eco-efficiency.

This exergy gain indicates the type of change that occurs in the process variable

[yi] when the manipulated variable [mj] undergoes a step change. If the [bij] is negative it means that one of the streams decreases in exergy while the other increases its exergy value. Recall that, it is the net exergy change of the process that is equal or less than zero, individual process streams can increase or decrease in exergy content.

From [bij] it is also possible to obtain the relative change in the exergy of the streams. Looking at the absolute value of [bij], if the value is greater than one then the actual change in the exergy of the controlled variable’s stream is larger than the actual change in the exergy of the manipulated variable’s stream.

The REA also provides information about the efficiency of the [yi-mj] pairing by relating the exergy gain of the control loop when all the other control loops are also open to the gain of the same control loop performance when all the other loops are closed.

Thus, it is a measure of how other loops affect the thermodynamic efficiency by interacting with the control loop under consideration [yi-mj]. Consequently, the relative

67 exergy gain, Equation (36), implies the exergetic efficiency of operating all the control loops simultaneously.

If an element in the REA is equal to one then the thermodynamic efficiency of the control loop is not affected by other loops. This would be a good pairing candidate because the maximum change in exergy is not increased nor decreased by the loop interaction.

If an element in the REA is less than one then the changes in exergy derived from the control loop interactions are greater than the changes when all loops are open. In this case the interaction in the variables of the process is increasing the changes in exergy.

For this case, if the sign of both exergy gains [bij] for the REA element [βij] is negative, closing the control loops would improve the thermodynamic efficiency for the loop. If, on the other hand, the sign of both exergy gains [bij] for the REA element [βij] is positive then the open loop would decrease its thermodynamic efficiency.

If an element in the REA is greater than one then the effect of the open loop is dominant in the exergy change for the control loop. In this case the interaction of the variables in the process is decreasing the changes in exergy. If the sign of both exergy gains [bij] for the REA element [βij] is negative then a larger value of [βij] would increase the thermodynamic efficiency. If, on the other hand, the sign of both exergy gains [bij] for the REA element [βij] is positive then the thermodynamic efficiency would decrease for the [yi-mj] loop.

4.4 Summary

A review of the derivation and interpretation of the original RGA was provided and a new controllability index (Relative Exergy Array, REA) based on the RGA has

68 been presented. The exergy gain ratio has been presented as a measure for the exergetic efficiency of a [mj-yi] variable pairing. When used together, the RGA and the REA provide a broader view of the process by quantifying the interaction in the decentralised control structure while providing a sense of the thermodynamic (exergetic) efficiency of the proposed control structure.

Guidelines for interpreting the REA were also presented and when used with the results of the RGA the engineer can quantitatively determine the effects of both control loop interaction and control pairing thermodynamic efficiency.

69

Chapter Five: Sample Applications and Results

In this chapter, a sample exergy analysis for a natural gas dehydration plant is presented as a proof of concept and application for the Exergy Calculator developed in

Chapter 3. This case study is followed by an analysis of a multi-component distillation column using the original RGA and the proposed exergy-based RGA (REA) developed in

Chapter 4. A combined exergy analysis, REA and RGA calculations for a mono-chloro- benzene separation plant are also presented in this Chapter. These sample applications show the main advantages of using the newly developed tools.

5.1 Exergy analysis case study

A typical natural gas Tri Ethylene Glycol (TEG) Dehydration process has been selected as a case study for the purposes of demonstrating the exergy calculator tool.

Glycol dehydration is used to lower the water content of natural gas in order to prevent hydrate formation in the pipelines and downstream processes. Note, TEG Dehydration is not the only process available for this purpose but it is very common when the specifications to be met are just for transportation of the natural gas. For instance, the

Gas Processors Suppliers Association allows no more than 4 lbs of water per MMSCF of gas for pipeline transmission (GPSA 1998).

5.1.1 TEG dehydration process and model description

The process consists of an absorber operated at high pressure in which the water- saturated natural gas is contacted with recycled lean TEG, from this absorber the dry gas stream from the top is sent to a gas/lean heat exchanger in which some energy is transferred from the hot recycled TEG stream, before entering the absorber, to the dry gas. The rich TEG stream from the bottom of the absorber is passed through a valve to

70 decrease its pressure and then in a flash drum separator in which some of the water vapour and acid gas content (if any) are removed and sent to a separate processing unit.

The liquid stream exiting the flash drum separator is preheated and fed to the TEG regenerator, where the water and the remainder of the acid gas are removed. The regenerated lean TEG is then recycled. This regenerated TEG stream from the regenerator is passed through a feed-bottoms heat exchanger where it preheats the regenerator rich amine feed. Make up TEG is added to the lean recycled TEG to mitigate any TEG losses and then the recycled TEG stream is pumped to high pressure, cooled in the gas/lean heat exchanger and fed to the top of the absorber.

Figure 8 shows a simplified, typical configuration. Table 5 presents the feed composition while Table 6 presents the operating conditions for the TEG Dehydration plant selected for this case study.

71 s a G

r u o S r o t a r e n e g e R

G E T G d E e T e

F n

a r

e o t L a r e n e g e R R / L

m o r F G E T

p X U E e k H a

M h c i R / n p a m e u L P

o T G E T

h c i R

p P m L u s a P G n a e L / s a G

e o v l T a V

r e t f . Natural Gas TEGSchematic . Natural Dehydration Plant A 8 s a G e s v l e s l a a a Figure Figure V S G

y r D G E X T

E h c i H

R

n P a H e L / s a r G o t c a t n d o e e C F

G G E E T T s a G

t e l n I

72

Table 5. Inlet Gas Composition for a Saturated Lean Natural Gas

Component Mole fraction

N2 0.00100

H2S 0.01544

CO2 0.02835

CH4 0.89820

C2H6 0.03098

C3H8 0.01479

iC4H10 0.00590

nC4H10 0.00300

iC5H12 0.00100

nC5H12 0.00050

H2O 0.00086

The required specifications for the computer simulation of the TEG dehydration plant are shown in Table 6.

73

Table 6. Specifications for the Simulation Model

Parameter Value

Inlet gas pressure 6200 kPa

Inlet gas temperature 303.15 K

Inlet gas flow 500 kmol/h

TEG contactor pressure drop 10 kPa

TEG contactor theoretical stages 3

TEG contactor feed pressure 6205 kPa

TEG contactor feed temperature 318.15 K

TEG contactor feed flow 4.02 kmol/h

Dry gas temperature 304 K

Sales gas temperature 309.8 K

Low pressure rich TEG 180 kPa

TEG regen. feed temperature 378.15 K

TEG regen. feed pressure 110 kPa

TEG regen. theoretical stages 2

TEG regen. reboiler temperature 477.15 K

TEG regen. overhead temperature 375.15 K

Pump feed pressure 102.3 kPa

Pump outlet pressure 6275 kPa

74

The Peng-Robinson equation of state was used in the simulation as the thermodynamic property package. Note, the simulation case study was set up with no heat losses from any equipment to the environment, hence is a rather idealized simulation. However, as will be shown even an idealized process has exergy losses and it is possible to identify the equipments in which these losses are significant.

5.1.2 Exergy analysis sample results and discussion

For this particular research project it was decided to use the reference state as given by Szargut and collaborators (Szargut et al. 1988), because it has a valid fundamental thermodynamic basis and practical meaning, especially for the chemical exergy of the elements. Hence the reference pressure is 101.325 kPa and the reference temperature is 298.15 K. Table 7 presents the exergy values for the chemical elements present in the case study.

Table 7. Reference Chemical Exergy for Selected Elements

Element or Exergy, kJ/mol

Compound

C 410.25

H2 236.08

N2 0.72

O2 3.97

S 632.50

75

After applying the Exergy Calculator, detailed in Chapter 3, to the simulation case study the values obtained are summarized in Table 8.

Table 8. Material Streams Exergy

Stream Exergy, kJ/kmol Exergy flow, kW

Inlet gas 8.784x105 1.219x105

TEG feed 3.365x106 3.757x103

Dry Gas 8.784x105 1.219x105

Sales Gas 8.784x105 1.219x105

HP rich TEG 2.941x106 3.807x103

After Valve 2.939x106 3.804x103

Gas 7.810x105 3.667x101

LP Rich TEG 3.020x106 3.767x103

Regen. Feed 3.023x106 3.771x103

Sour Gas 1.161x105 1.519x101

Lean TEG 3.377x106 3.770x103

From L/R 3.369x106 3.761x103

Make Up TEG 3.601x106 2.986x10-1

To Pump 3.369x106 3.762x103

To Gas/Lean 3.371x106 3.764x103

76

Note, there are energy streams in the simulation that are not taken into account by the exergy calculator because they were modeled as direct energy inputs to the system

(i.e. no exergy loss in them).

Table 9 shows the inlet and outlet exergy flows for each of the main pieces of equipment in the process simulation.

Table 9. Equipment Exergy Flows

Equipment Exergy in, kW Exergy out, kW Exergetic

efficiency

TEG contactor 1.257x105 1.257x105 0.999

Gas/Lean HEX 1.257x105 1.256x105 0.999

Valve 3.807x103 3.804x103 0.999

Flash drum 3.804x103 3.804x103 1.000

Lean/Rich HEX 7.334x103 7.329x103 0.999

TEG Regen. 6.090x103 5.343x103 0.991

Pump 3.661x103 3.662x103 1.000

The results shown in Table 8 along with the exergy of the utilities are the values needed to carry out a simple exergy analysis. Table 9 shows where the exergy losses are more significant, thus providing a basis for alternative improvements.

For this case study it can be seen that the exergetic efficiencies are high for all equipment. This is due to the assumptions used to set up the simulation model.

77

However, the equipment where the most exergy is lost is the TEG regenerator. This has to do with the multiple separation stages inside this equipment. This cannot be changed in the actual process since a predefined degree of separation is required, however, a more detailed analysis within the TEG regenerator could lead to locations inside the column where the exergy is being lost (besides the separation stages). One possibility could be the heating medium for the reboiler. If the temperature difference is too large the exergy loss will be large. In this particular simulation the reboiler and condenser were modeled with direct energy input, this causes the exergy to be conserved (as if all the work were done by electricity).

The pump offers an excellent example of how the prediction of thermodynamic properties could affect the exergy calculation. The strange values obtained for the lean

TEG pump can be attributed to the fact that an equation of state (Peng-Robinson) has been used for essentially pure TEG. In process simulators it is common to use generic equations of state for a wide range of compounds and process conditions. In the case of

TEG, the standard implementation of this equation of state is not the best choice for those conditions. The unexpected high efficiency can also be attributed in part to the modeling of the pump duty with a direct energy input.

The flash drum presents a constant exergy flow because the actual exergy loss

(less than 0.1%) takes place in the inlet feed valve.

The heat exchangers are the best example to show that even when an ideal model

(e.g. an adiabatic heat exchanger) is used there is an exergy loss which is due to the irreversibility of the process. In the heat exchanger example this occurs because of the over a finite temperature difference.

78

From a design point of view the analysis of a heat exchanger could be used to find the best combination of temperature difference and heat transfer area (capital cost) that minimizes the exergy loss, i.e. maximizes efficiency.

It has been shown that the exergy can be easily calculated with the aid of a chemical process simulator. The results provided from this simple exergy analysis show the processing areas where the exergy consumption is the greatest, thus pointing to potential improvement locations within the process.

5.2 Exergy Relative Gain Array case study

It is well known that two-point composition control of a distillation column is a highly interactive process (Svrcek et al. 2006). Two-point composition control means that the compositions at the top and bottom of the distillation column are to be controlled.

Although techniques to minimize the loop interaction have been proposed (Ryskamp

1980) this case study will use basic distillation control configurations to illustrate the use of the RGA and the new REA.

5.2.1 Multi-component distillation column process and model definition

For this case study a multi-component distillation column designed to meet purity specifications for both the distillate and the bottom draws was selected. The distillation column is detailed in the book of Svrcek and co-workers (Svrcek et al. 2006) and Table

10 summarizes the feed conditions of the column. This case is a good example of a non- linear process in which several options for control exist and careful analysis is needed to determine the best control candidate.

79

Table 10. Distillation Column Feed Flow Rate and Composition

Feed

Flow 40000 bbl/day

C3H6 5 wt%

iC4H10 40 wt%

nC4H10 40 wt%

iC5H12 15 wt%

The distillation column specifications are 0.01wt% of propane in the bottoms stream and a 0.1wt% of iso-pentane in the distillate stream. The operating pressure of the distillation column and levels in the condenser and in the reboiler are also controlled.

Figure 9 shows a schematic of this distillation system.

80

Condenser

Accumulator

Reflux (L)

Distillate (D)

Feed Distillation Column

Boil-up (V)

Reboiler

Bottoms (B)

Figure 9. Distillation Column Schematic

The column was simulated in Aspen HYSYS™ using a property package based on the Peng-Robinson equation of state. For simplicity purposes energy streams were used instead of utility streams for the condenser and the reboiler. From an exergy point of view, this means that no exergy is destroyed due to heat transfer in the column’s condenser and reboiler.

81

5.2.2 Controllability index calculation (RGA)

Three basic control configurations can be defined for the two-point composition control of the distillation column (DV, LB and LV). The naming of each control configuration corresponds to the two variables that are used to control each of the compositions (D for the Distillate rate, V for the Boil-up rate, L for the Reflux rate and B for the Bottoms rate). Details for the selection of control configurations for this distillation column can be found elsewhere (Svrcek et al. 2006). Table 11 summarizes the manipulated and controlled variables for each of the proposed control configurations.

Table 11. Variable Pairing for the Proposed Control Configurations

Configuration m1 y1 m2 y2

LV Reflux flow xD Boil-up flow xB

DV Distillate flow xD Boil-up flow xB

LB Reflux flow xD Bottoms flow xB

Following the procedure summarized in Chapter 4 for obtaining the open-loop gain matrix from a simulation, tests for determining the elements of this matrix were performed using the specifications noted in Table 12.

82

Table 12. Configuration for the Step Change Experiments

Pair Mode m1 y1 m2 y2

1 1 Open Spec Step Record Spec Base

1 2 Open Spec Base Record Spec Step

2 1 Open Spec Step Spec Base Record

2 2 Open Spec Base Spec Step Record

1 1 Closed Spec Step Record Spec Set Point

2 2 Closed Spec Set Point Spec Step Record

Using Equations (24), (25) and (27) the RGA for each of the proposed control configurations was determined and are presented below.

1.484 −0.484 0.373 0.627 0.697 0.303 퐿푉 = 퐷푉 = 퐿퐵 = −0.484 1.484 0.627 0.373 0.303 0.697

These results indicate that the system will have loop interactions for all three control configurations. Following the guidelines presented in Chapter 4, the LB configuration is the best candidate because each element in the main diagonal approaches the value of 1.0 without exceeding it. The next best candidate would be the LV configuration because its elements in the main diagonal are still close to the desired value of 1.0. The least desirable configuration would be the DV because it indicates that the manipulated variables have little effect over the controlled variables.

83

It is important to mention that in this case we are only interested in the main diagonal pairings because using the other pairing would introduce significant dead time in the control system as it would mean that one is trying to control a variable at the bottom of the column by manipulating a rate at the top and vice versa.

5.2.3 Relative exergy gain array (REA)

With the use of the developed Exergy Calculator the exergy values necessary to calculate the REA were obtained from the same experiments used in the previous section.

Table 11 and Table 12 present the setup for these experiments.

Exergy flows were recorded and used as described in Equations (36), (37) and

(38) to obtain the REA for each proposed process control configuration. The results for the REA are presented below.

3.188 −2.188 1.0 0.0 0.007 0.993 퐿푉 = 퐷푉 = 퐿퐵 = −2.188 3.188 0.0 1.0 0.993 0.007

Following the guidelines presented in Chapter 4, the REA would indicate that the

DV configuration would be a good candidate as the exergetic efficiency is not affected by loop interactions. For the LB configuration the REA shows that the exergy changes due to loop interactions are much larger than the exergy changes due to the open loop operation. The LV configuration acts in the opposite way, the REA indicates that the exergy changes of the open loop are larger than the changes caused by the closed loop operation.

84

Once again, only the main diagonal pairings are looked at because using the other pairing would introduce a significant amount of dead time in the process.

Using the results from the RGA and the REA it is possible to quickly determine the effect of the loop interactions for each of the proposed control configurations. For this example, although the REA suggests that the DV configuration would be preferred from an energy efficiency point of view, the RGA indicates that loop interactions would affect operation of the column.

In order to make a final decision between the LV and LB configurations more information and a more detailed analysis would be necessary. From the process control point of view a dynamic simulation would be the next step in order to properly assess the performance of each configuration. For eco-efficiency purposes the actual energy usage of each of these configurations would have to be determined.

5.3 Combined Exergy and Relative Exergy Array case study

The process of separating the effluent of a reactor to produce mono-chloro- benzene (MCB) by the chlorination of benzene is used as a case study for a combined exergy and controllability analysis.

5.3.1 Separation of MCB process and model description

This separation process takes the effluent of a benzene chlorination reactor and partially vaporizes it. This effluent consists of a mixture of mono-chloro-benzene

(MCB), the desired product, hydrogen chloride (HCl), a by-product and unreacted benzene. The partially vaporized stream enters a flash tank. The vapour stream coming out of the flash tank is fed into an absorber where it is contacted with recycled MCB.

85

Most of the HCl goes out the absorber through the vapour outlet while the liquid outlet of the absorber is most of the benzene absorbed in MCB. This stream is mixed with the liquid stream from the flash tank and this combined liquid stream is then sent as the feed to a distillation tower.

In the distillation tower, a fixed amount (1% of the inlet feed to the plant) is purged from the system as vapour out of the condenser to avoid HCl build-up, the distillate (liquid) stream is the benzene-rich product stream while the bottoms of the tower is the MCB-rich stream that will be cooled down and then split into the recycle stream and the MCB product. Figure 10 shows a schematic of the MCB separation process.

The inlet composition for the MCB separation process modeled here is presented in Table 13.

Table 13. Inlet Composition for the MCB Separation Process

Component Mole fraction

HCl 0.100

C6H6 0.400

C6H5Cl 0.500

The required specifications for the computer simulation of the MCB separation plant are shown in Table 14.

86 e t a l l i t s i D e g r u P n m u l x o u c l f

e n R o i t a l l i t s i D

r B e C l o M o C

o T n o i t a l l i t s i D

o T r e x i M

o t

r r e e l b r o o o s b C A r l e C b r r H e t t o i l s p b S

A o T r e x i M

o t

h s a l p . MCB Separation Process Schematic Separation. MCB Process F m u P

o 10 T e l c p y c m e u R Figure Figure P k n a T

r h e s b r a l o s F b A

o T h s a l F

o T 1 H d e e F

87

Table 14. Specifications for the MCB Simulation Model

Parameter Value

Feed pressure 37 psia

Feed temperature 80 F

Feed flow 100 kmol/h

H1 pressure drop 2 psi

H1 out temperature 270 F

Absorber pressure drop 1 psi

Absorber theoretical stages 4

Absorber top pressure 32 psia

Distillation tower pressure drop 2 psi

Distillation tower theoretical stages 13

Distillation tower feed stage 7

Distillation tower top pressure 23 psia

Distillate benzene purity 0.99

Bottoms MCB purity 0.98

Purge flow 1 kmol/h

Cooler pressure drop 2 psi

Cooler out temperature 120 F

Flow fraction to recycle 0.67

Pump efficiency 30 %

Pump outlet pressure 50 psia

88

The NRTL activity model was used in the simulation as the thermodynamic property package. Note, the simulation case study was set up with no heat losses from any equipment to the environment, hence is a rather idealized simulation. However, as will be shown even an idealized process has exergy losses and it is possible to identify the equipments in which these losses are significant.

5.3.2 Exergy analysis results and discussion

As noted in section 5.1.2 the reference state used in this research project is that given by Szargut and collaborators (Szargut et al. 1988). Hence, the reference pressure is

101.325 kPa and the reference temperature is 298.15 K. Table 15 presents the exergy values for the chemical elements present in the case study.

Table 15. Reference Chemical Exergy for Selected Elements

Element or Exergy, kJ/mol

Compound

C 410.25

H2 236.08

Cl2 123.70

After applying the Exergy Calculator, detailed in Chapter 3, to the simulation case study the values obtained are summarized in Table 16.

89

Table 16. Material Streams Exergy

Stream Exergy, kJ/kmol Exergy flow, kW

Feed 2.930x106 81392.02

To flash tank 2.929x106 81380.68

Flash to absorber 2.659x106 38407.09

Flash to mixer 3.221x106 19492.69

HCl from absorber 1.881x105 520.51

Absorber to mixer 3.212x106 128877.78

To distillation 3.215x106 171855.47

Benzene 3.284x106 35205.87

To cooler 3.204x106 136057.44

To splitter 3.209x106 136280.97

MCB 3.209x106 44972.72

To Pump 3.209x106 91308.25

Recycle 3.208x106 91252.25

Note, there are energy streams in the simulation that are not taken into account by the exergy calculator because they were modeled as direct energy inputs to the system

(i.e. no exergy loss in them).

Table 17 shows the inlet and outlet exergy flows for each of the main pieces of equipment in the process simulation.

90

Table 17. Equipment Exergy Flows

Equipment Exergy in, kW Exergy out, kW Exergetic

efficiency

H1 82192.26 81380.68 0.990

Flash tank 81380.68 81380.68 1.000

Absorber 129659.34 129398.29 0.997

Mixer 171851.38 171855.47 1.000

Distillation tower 173961.63 172173.58 0.989

Cooler 136789.55 136280.96 0.996

Pump 91310.10 91252.24 0.999

The results shown in Table 16 along with the exergy of the utilities are the values needed to do a simple exergy analysis. Table 17 shows where the exergy losses are more significant, thus providing a starting point for energy alternatives.

From this case study it can be seen that the exergetic efficiencies are high for all equipment. This is due to the assumptions used to set up the simulation model.

However, the equipment where the most exergy is lost is the distillation tower. This has to do with the multiple separation stages inside this equipment. This cannot be changed in the actual process since a predefined degree of separation is required, however, a more detailed analysis within the distillation tower could lead to locations inside the column where the exergy is being lost (besides the separation stages). One possibility could be the heating medium for the reboiler. If the temperature difference is too large the exergy

91 loss will be large. In this particular simulation the reboiler and condenser were modeled with direct energy input, this causes the exergy to be conserved (as if all the work were done by electricity).

The flash tank presents a constant exergy flow because the actual exergy loss

(around 1%) takes place in the heating of the feed stream in the (H1) heater. Since no pressure drop is modeled in the flash tank there is no further change in exergy.

In the heater and cooler, H1 and Cooler, the losses can be attributed in large part to the pressure drop. One can conclude this because the duty for these pieces of equipment is modeled as a direct energy input.

The results provided from this simple exergy analysis show the processing areas where the exergy consumption is the greatest, thus pointing to potential improvement locations within the process. Even in this case where the model is rather idealized it was possible to find exergy losses. In practice, when the model is further enhanced to take into account energy losses to the environment and actual utility modeling the exergy analysis should reveal other potential improvement locations.

5.3.3 Controllability index calculation (RGA)

Seider and coworkers (2009) demonstrate that the plant-wide controllability analysis for the MCB separation plant used in this case study can be reduced to a 3x3 system. This conclusion is reached by realizing that the control of inventories will not interact with the control loops dedicated to maintain the quality of the products and the recycle flow. Table 18 summarizes the manipulated and controlled variables for the proposed control configuration.

92

Table 18. Variable Pairing for the Proposed Control Configuration

Control loop Manipulated Controlled

1 Reflux flow xB

2 Reboiler duty xMCB

3 Cooler duty xHCl

In the proposed configuration the Reflux flow and the Reboiler duty refer to the distillation column while the Cooler duty refers to the cooler at the bottom of the distillation column. The compositions being controlled are the benzene composition [xB] at the distillation tower distillate, the MCB composition [xMCB] in the product at the bottom of the distillation tower and the HCl composition [xHCL] at the top of the absorber.

It has been demonstrated that the proposed control configuration, shown in Table

18, has the best performance when operating the plant under normal conditions and expected disturbances (Seider et al. 2009). The RGA analysis for this configuration is replicated in this work by using a different step size (2% of each variable range) to determine the open-loop gain matrix for this model.

Following the procedure summarized in Chapter 4 for obtaining the open-loop gain matrix from a simulation, tests for determining the elements of this matrix were performed using the specifications shown in Table 19.

93

Table 19. Specifications for Step Change Experiments

Pair Mode m1 y1 m2 y2 m3 y3

1 1 Open Step Record Base Base

1 2 Open Base Record Step Base

1 3 Open Base Record Base Step

2 1 Open Step Base Record Base

2 2 Open Base Step Record Base

2 3 Open Base Base Record Step

3 1 Open Step Base Base Record

3 2 Open Base Step Base Record

3 3 Open Base Base Step Record

The resulting open-loop gain matrix for the proposed configuration control is shown below.

0.539405 −0.5777 0.456949 퐺 = −2.63277 5.227194 −2.46038 −0.01208 0.06817 0.632539

Using Equation (30) it is possible to obtain the RGA directly from this open-loop gain matrix. The resulting RGA for this control configuration is shown below.

94

2.226721 −1.16357 −0.06315 Λ = −1.24061 2.153515 0.087093 0.013887 0.010052 0.976061

The results indicate that there will be some interaction in the control configuration. Loop 3 shows a very good situation where the interaction is minimal, while loops 1 and 2 show a higher degree of interaction. These results confirm that the selection of this control structure should be satisfactory. Seider and coworkers (2009) have demonstrated through dynamic simulation that this control configuration is stable and shows very good response when subjected to disturbances.

5.3.4 Relative exergy gain array calculation (REA)

With the use of the developed Exergy Calculator the exergy values necessary to calculate the REA were obtained from the same experiments used in the previous section.

The open-loop exergy gain matrix, as defined by Equation (40), is shown below.

−1.12427 1.921844 −0.96034 퐵 = −32.6163 32.74664 −32.837 0.082512 −0.35312 −2.89634

Using Equation (41) it is possible to obtain the REA directly from this open-loop exergy gain matrix. The resulting REA for this control configuration is shown below.

−1.58382 2.471776 0.112045 ℬ = 2.549247 −1.44563 −0.10362 0.034574 −0.02615 0.991575

95

Analyzing the exergy gain matrix and the relative exergy array it is possible to determine that loop 3 has a very small effect in the thermodynamic efficiency of the plant. Since the diagonal element in the REA for loop 3 is close to 1.0 the thermodynamic efficiency of this loop pairing is not affected by interactions from other loops. The diagonal element for loop 3 in the exergy gain matrix shows that the change in the exergy of the controlled variable is greater that the exergy change in the manipulated variable. That is, an increase or decrease in the Cooler duty exergy will cause a decrease or increase of almost three times in the exergy of the HCl vapour stream at the top of the absorber.

From the REA results, loops 1 and 2 show a similar behaviour in that they will both be affected by loop interaction. The changes in exergy for the open loop behaviour are roughly 1.5 times those for the closed loop. They also indicate that for an increase in exergetic efficiency in the open loop a decrease in exergetic efficiency should be expected in the closed loop.

The diagonal element for loop 2 in the exergy gain matrix shows that an increase or decrease in the Reboiler duty exergy will cause an increase or decrease of more than

32 times in the exergy of the distillation column Bottoms stream. In contrast, for loop 1, a change in the Reflux flow exergy will result in a change in the opposite direction for the

Distillate stream exergy of about 12%.

5.4 Summary

Sample applications of the tools developed in this thesis have been presented in this chapter. A natural gas TEG dehydration plant was analyzed with the Exergy

Calculator developed in Chapter 3. The analysis showed where the exergy is being lost

96 in every part of the plant and it allows for easy identification of problematic units. This would allow the process engineer to direct the improvement effort to key areas of the plant.

A sample multi-component distillation column to separate a feed into two streams with specific purities has been used to demonstrate the application of the REA developed in Chapter 4. In conjunction with the RGA, the REA was used to determine the potential loop interactions for the three proposed control structures. The RGA identified the control structure that would result in less loop interactions than the other two while the

REA determined the effects of each of the proposed control structures on the exergetic efficiency of the distillation column.

The final example involving a plant to separate the effluent from a reactor was used to demonstrate the use of the Exergy Calculator to determine the thermodynamic efficiency of the plant. The use of the RGA and REA showed the performance of the plant’s control structure with respect to operating performance and thermodynamic efficiency.

97

Chapter Six: Discussion, Conclusions and Recommendations

In this chapter general discussions of the Exergy Calculator and of the Relative

Exergy Array (REA) are presented. The application of these proposed tools in the integration of process design and process control is also discussed. Furthermore, conclusions and recommendations for future research work are also presented in this chapter.

6.1 Benefits of the Exergy Calculator

It was shown and explained in Chapters 1 and 2 of this thesis that Exergy is a thermodynamic property that can aid in identifying inefficiencies in processes. These inefficiencies are normally related to energy and, consequently, to process economics.

The Exergy Calculator allows for the rapid thermodynamic efficiency evaluation of a process provided that a process simulation exists. It quickly identifies the key areas where exergy is being destroyed in greater quantities than other areas. This feature of

Exergy directs the potential process improvement efforts to areas and equipments where a small modification could mean significant savings.

The developed software was implemented in a widely available commercial process simulator (Aspen HYSYS®) and in an open source process simulator (Sim42®), thus making it easy to use and readily accessible to many process simulation users.

6.1.1 Limitations of the current Exergy Calculator

Although the design and implementation of the Exergy Calculator as developed and presented in this research project is very flexible and robust, there are some limitations in its design and applicability. By design, the Exergy Calculator deals with material streams and neglects all pure energy streams. The current implementation

98 assumes that any energy stream in the simulation/model under study will transfer all its exergy without any losses. This is a drawback whose effect can be minimized by modeling utility streams as material streams (steam, cooling water, heating oil, etc.).

6.2 A New Controllability Index

Arguably, the new controllability index defined by the REA is a breakthrough in attempting to unify the application of thermodynamic efficiency and process control.

With this new tool the process engineer obtains information about the effect the loop interactions of a control structure will have on the thermodynamic efficiency of the process. The thermodynamic efficiency can be related to economic efficiency and it is definitively valuable to know, at the early stages of designing the control structure, what impact a control structure will have on the economics of the process in its operating stage.

The results obtained from the REA do provide the process engineer with a tool to quickly evaluate several control structures and rank them according to their relative thermodynamic efficiency. This information can then be used in deciding a final control structure for the unit operation or process.

6.2.1 Limitations of the REA

The REA definition proposed in Chapter 4 is analogous to the RGA, thus it implies that the control structure under consideration applies to a linear system. In other words, the application of the REA to highly non-linear system is limited to the range in which the model is evaluated. For instance, the distillation column shown in Chapter 5 is a highly non-linear system. However, the results are valid for the range in which the distillation column RGA and REA were evaluated.

99

The REA is, as is the RGA, strictly applicable to steady control scheme evaluation. This drawback is due to the definition of the REA which indicates that only values from steady state (open and closed loop) are used in the calculation of the interaction matrix. In other words, the interactions reflect the final new steady state but not necessarily the path to it.

6.3 Conclusions

The objectives set for this research project and described in Chapter 1 (section

1.5) have been achieved. The development and implementation of the Exergy Calculator tool allows for the rapid analysis of the thermodynamic efficiency of a plant when a process simulation is available. The Exergy Calculator was successfully implemented in two different process simulators (Aspen HYSYS® and Sim42®).

A new controllability index, the Relative Exergy Array (REA), which integrates concepts of process control and thermodynamic efficiency, was developed. This new index provides a means to analyze the thermodynamic efficiency of a control structure as it is affected by control structure loop interactions. Thus, the economic effects of a candidate control structure can be implied by realizing that the thermodynamic efficiency translates directly to process economics and thus, eco-efficiency. For instance, the higher the thermodynamic efficiency of a process the smaller the utility expenses are.

The Exergy Calculator tool was demonstrated in a case study of a natural gas

TEG dehydration plant. The results showed that even a simplified, idealized process has identifiable exergy losses. The results also pointed to the areas of the process where the losses are greatest, thus identifying the key areas where the improvement efforts should be directed.

100

The Relative Exergy Array (REA) was used in the evaluation of three proposed control structures for a two-point composition control of the distillation process. In conjunction with the RGA it helped in identifying the best candidate control structure with respect to control performance and thermodynamic efficiency.

A combined exergy analysis and RGA and REA calculation for an MCB separation plant was also presented. The results obtained helped explaining how the control structure affects the thermodynamic efficiency for each of the variable pairings.

6.4 Recommendations for future research

As noted, the development of the REA is a new contribution to the research aimed at integrating process design and process control. It opens a new perspective for evaluating the loop interactions of a control structure in terms of thermodynamic efficiency and, thus, economic impact.

Future research should focus on the limitations identified for each of the developed tools as presented in sections 6.1.1 and 6.2.1. Following is a list of proposed topics for further research based on these limitations.

1. Development of a methodology to define an efficiency factor for energy streams

in process simulations. This efficiency factor could be used when the simulation

of the utility systems is not important but there is a need to perform an exergy

analysis of the process. For instance, a fixed efficiency factor for a cooler’s

energy stream can be used instead of simulating a heat exchanger with cooling

water on the utility side.

2. Extend the Relative Exergy Array to non-linear systems. A full non-linear

version of the REA could provide a means of evaluating a control structure over

101

the full range of operating conditions. This could be approached from the

“classical” process control point of view using frequency domain concepts.

3. Extend the Relative Exergy Array for non-square control structures. This could

allow the full analysis of loop interactions for control structures where the number

of controlled variables and available manipulated variables are different.

4. Development of a “Dynamic REA” based on the developed REA. Analogous to

the “Dynamic RGA” which could provide information on the behaviour of the

control structure with respect to time as opposed to the loop interactions of only

the final steady state.

102

References

Alhammadi, H. Y. and J. A. Romagnoli (2004). Process design and operation:

Incorporating environmental, profitability, heat integration and controllability

considerations. The Integration of Process Design and Control. P. Seferlis and M.

C. Georgiadis. Amsterdam, Elsevier B.V. 17: 264-305.

Alonso, A. A., B. E. Ydstie and J. R. Banga (2002). "From irreversible thermodynamics

to a robust control theory for distributed process systems." Journal of Process

Control 12: 507-517.

Antelo, L. T., O. Exler, J. R. Banga and A. A. Alonso (2008). "Optimal Tuning of

Thermodynamic-Based Decentralized PI Control Loops: Application to the

Tennessee Eastman Process." AIChE Journal 54(11): 2904-2924.

Antelo, L. T., I. Otero-Muras, J. R. Banga and A. A. Alonso (2007). "A systematic

approach to plant-wide control based on thermodynamics." Computers &

Chemical Engineering 31(5-6): 677-691.

Arkun, Y. and J. Downs (1990). "A general method to calculate input-output gains and

the relative gain array for integrating processes." Computers & Chemical

Engineering 14(10): 1101-1110.

Aspen Technology (2005). HYSYS 2004.1 Customization Guide. Cambridge, Aspen

Technology, Inc.

Bahri, P. A., J. A. Bandoni and J. A. Romagnoli (1997). "Integrated Flexibility and

Controllability Analysis in Design of Chemical Processes." AIChE Journal 43(4):

997-1015.

103

Biegler, L. T., I. E. Grossmann and A. W. Westerberg (1997). Systematic Methods of

Chemical Process Design. Upper Saddle River, NJ, Prentice Hall PTR.

Bristol, E. H. (1966). "On a New Measure of Interaction for Multivariable Process

Control." IEEE Transactions on Automatic Control 11(1): 133-134.

Cao, Y. and D. Rossiter (1997). "An input pre-screening technique for control structure

selection." Computers & Chemical Engineering 21(6): 563-569.

Chang, H. and J.-w. Li (2005). "A new exergy method for process analysis and

optimization." Chemical Engineering Science 60(10): 2771-2784.

Cota Elizondo, R. C. (2003). Development of an open source chemical process simulator.

Dept. of Chemical and Petroleum Engineering. Calgary, AB, University of

Calgary. M.Sc.: xxiii, 276

Cota Elizondo, R. C. (2005). Personal communication with J. M. Montelongo-Luna.

Coughanowr, D. R. (1991). Process Systems Analysis and Control. New York, McGraw-

Hill, Inc.

Denbigh, K. G. (1956). "The second-law efficiency of chemical processes." Chemical

Engineering Science 6(1): 1-9.

Dincer, I. (2002). "The role of exergy in energy policy making." Energy Policy 30(2):

137-149.

Dincer, I. and M. A. Rosen (2007). Exergy: Energy, Environment and Sustainable

Development. Amsterdam, Elsevier.

Douglas, J. M. (1985). "A hierarchical decision procedure for process synthesis." AIChE

Journal 31(3): 353-362.

104

Douglas, J. M. (1988). Conceptual Design of Chemical Processes. New York, McGraw-

Hill, Inc.

Douglas, J. M. and D. C. Woodcock (1985). "Cost Diagrams and the Quick Screening of

Process Alternatives." Industrial & Engineering Chemistry, Process Design and

Development 24(4): 970-976.

Downs, J. J. and E. F. Vogel (1993). "A plant-wide industrial process control problem."

Computers & Chemical Engineering 17(3): 245-255.

El-Sayed, Y. M. (2002). "Application of exergy to design." Energy Conversion and

Management 43(9-12): 1165-1185.

Engell, S., J. O. Trierweiler, M. Volker and S. Pegel (2004). Tools and indices for

dynamic I/O-controllability assessment and control structure selection. The

Integration of Process Design and Control. P. Seferlis and M. C. Georgiadis.

Amsterdam, Elsevier B.V. 17: 430-463.

Fan, L. T. and J. H. Shieh (1980). "Thermodynamically based analysis and synthesis of

chemical process systems." Energy 5(8-9): 955-966.

Farschman, C. A., K. P. Viswanath and B. E. Ydstie (1998). "Process Systems and

Inventory Control." AIChE Journal 44(8): 1841-1857.

Fisher, W. R., M. F. Doherty and J. M. Douglas (1988a). "The Interface between Design

and Control. 1. Process Controllability." Industrial and Engineering Chemistry

Research 27: 597-605.

Fisher, W. R., M. F. Doherty and J. M. Douglas (1988b). "The Interface between Design

and Control. 2. Process Operability." Industrial and Engineering Chemistry

Research 27: 606-611.

105

Georgakis, C., D. Uzturk, S. Subramanian and D. R. Vinson (2003). "On the operability

of continuous processes." Control Engineering Practice 11(8): 859-869.

GPSA (1998). Engineering Data Book - FPS. Tulsa, OK, USA, Gas Processors Suppliers

Association.

Grosdidier, P. and M. Morari (1986). "Interaction Measures for Systems Under

Decentralized Control." Automatica 22(3): 309-319.

Grosdidier, P., M. Morari and B. R. Holt (1985). "Closed-Loop Properties from Steady-

State Gain Information." Industrial & Engineering Chemistry Fundamentals

24(2): 221-235.

Henley, E. J. and J. D. Seader (1981). Equilibrium-Stage Separation Operations in

Chemical Engineering. New York, John Wiley & Sons, Inc.

Himmelblau, D. M. and J. B. Riggs (2004). Basic Principles and Calculations in

Chemical Engineering. Upper Saddle River, New Jersey, Prentice Hall.

Hinderink, A. P., F. J. P. M. Kerkhof, A. B. K. Lie, J. De Swaan Arons and H. J. Van Der

Kooi (1996). "Exergy analysis with a flowsheeting simulator - I. Theory;

calculating exergies of material streams." Chemical Engineering Science 51(20):

4693-4700.

Kemp, I. C. (2007). Pinch Analysis and Process Integration: A User Guide on Process

Integration for the Efficient Use of Energy. London, Butterworth-Heinemann.

Kookos, I. K. and A. I. Lygeros (1998). "An Algorithmic Method for Control Structure

Selection Based on the RGA and RIA Interaction Measures." Chemical

Engineering Research and Design 76(4): 458-464.

106

Kookos, I. K. and J. D. Perkins (2001). "An Algorithm for Simultaneous Process Design

and Control " Industrial & Engineering Chemistry Research 40(19): 4079-4088.

Koolen, J. L. A. (2001). Design of Simple and Robust Process Plants. Weinheim,

Germany, WILEY-VCH.

Kotas, T. J. (1985). The Exergy Method of Thermal Plant Analysis. London,

Butterworths.

Luyben, M. L. and C. A. Floudas (1994a). "Analyzing the Interaction of Design and

Control - 1. A Multiobjective Framework and Application to Binary Distillation

Synthesis." Computers & Chemical Engineering 18(10): 933-969.

Luyben, M. L. and C. A. Floudas (1994b). "Analyzing the Interaction of Design and

Control - 2. Reactor-Separator-Recycle System." Computers & Chemical

Engineering 18(10): 971-994,.

Luyben, M. L., B. D. Tyreus and W. L. Luyben (1997). "Plantwide Control Design

Procedure." AIChE Journal 43(12): 3161-3174.

Luyben, W. L. (2004). The need for simultaneous design education. The Integration of

Process Design and Control. P. Seferlis and M. C. Georgiadis. Amsterdam,

Elsevier, B.V. 17: 10-41.

Luyben, W. L., B. D. Tyréus and M. L. Luyben (1998). Plantwide Process Control. New

York, McGraw-Hill.

McAvoy, T. J. (1981). "Connection between Relative Gain and Control Loop Stability

and Design." AIChE Journal 27(4): 613-619.

McAvoy, T. J. (1983). Interaction Analysis: Principles and Applications. Research

Triangle Park, NC, Instrument Society of America.

107

Meeuse, F. M. and J. Grievink (2004). Thermodynamic controllability assessment in

process synthesis. The Integration of Process Design and Control. P. Seferlis and

M. C. Georgiadis. Amsterdam, Elsevier B.V. 17: 146-167.

Montelongo-Luna, J. M., W. Y. Svrcek and B. R. Young (2007). "An exergy calculator

tool for process simulation." Asia-Pacific Journal of Chemical Engineering 2(5):

431-437.

Montelongo-Luna, J. M., B. R. Young and W. Y. Svrcek (2005). An Open Source Exergy

Calculator Tool. 2nd CDEN International Conference on Design Education,

Innovation, and Practice, Kananaskis, Alberta, Canada.

Niederlinski, A. (1971). "A Heuristic Approach to the Design of Linear Multivariable

Interacting Control Systems." Automatica 7(6): 691-701.

Palazoglu, A. N. and Y. Arkun (1986). "A Multiobjective Approach to Design Chemical

Plants With Robust Dynamic Operability Characteristics." Computers &

Chemical Engineering 10(6): 567-575.

Papadourakis, A., M. F. Doherty and J. M. Douglas (1987). "Relative Gain Array for

Units in Plants with Recycle." Industrial and Engineering Chemistry Research 26:

1259-1262.

Peters, M. S. and K. D. Timmerhaus (1991). Plant design and economics for chemical

engineers. New York, McGraw-Hill.

Rivero, R. and M. Garfias (2006). "Standard Chemical Exergy of Elements Updated."

Energy 31: 3310-3326.

Ruszkowski, M., V. Garcia-Osorio and B. E. Ydstie (2005). "Passivity based control of

transport reaction systems." AIChE Journal 51(12): 3147-3166.

108

Ryskamp, C., J. (1980). "New strategy improves dual composition column control."

Hydrocarbon Processing 60(6): 51-59.

Santoso, H., J. Bao and P. Lee (2007). "Passivity Based Dynamic Controllability

Analysis for Multi-Unit Processes." Chemical Product and Process Modeling

2(2): Article 7.

Seborg, D. E., T. F. Edgar and D. A. Mellichamp (1989). Process Dynamics and Control.

New York, John Wiley & Sons.

Seferlis, P. and M. C. Georgiadis, Eds. (2004). The Integration of Process Design and

Control. Computer-Aided Chemical Engineering. Amsterdam, Elsevier B. V.

Seferlis, P. and J. Grievink (2004). Process desig and control structure evaluation and

screening using nonlinear sensitivity analysis. The Integration of Process Design

and Control. P. Seferlis and M. C. Georgiadis. Amsterdam, Elsevier B.V. 17: 326-

351.

Seider, W. D., J. D. Seader and D. R. Lewin (2003). Product and Process Design

Drinciples: Synthesis, Analysis, and Evaluation. New York, Wiley.

Seider, W. D., J. D. Seader, D. R. Lewin and S. Widagdo (2009). Product and Process

Design Principles: Synthesis, Analysis, and Evaluation. Hoboken, NJ, John Wiley

& Sons, Inc.

Sinnott, R. K. (2005). Chemical Engineering Design. New York, Elsevier Butterworth-

Heinemann.

Skogestad, S. (2004). "Control structure design for complete chemical plants."

Computers & Chemical Engineering 28: 219-234.

109

Skogestad, S., P. Lundström and E. W. Jacobsen (1990). "Selecting the Best Distillation

Control Configuration." AIChE Journal 36(5): 753-764.

Skogestad, S. and I. Postlethwaite (2005). Multivariable Feedback Control: Analysis and

Design. Chichester, John Wiley & Sons, Ltd.

Smith, J. M., H. C. Van Ness and M. M. Abbot (2005). Introduction to Chemical

Engineering Thermodynamics. New York, McGraw-Hill.

Smith, R. (2005). Chemical Process Design and Integration. Chichester, England, John

Wiley & Sons, Ltd.

Sorin, M., A. Hammache and O. Diallo (2000). "Exergy based approach for process

synthesis." Energy 25(2): 105-129.

Svrcek, W. Y., D. P. Mahoney and B. R. Young (2006). A Real-Time Approach to

Process Control. Chichester, John Wiley & Sons Ltd.

Szargut, J., D. R. Morris and F. R. Steward (1988). Exergy analysis of thermal, chemical,

and metallurgical processes. New York, Hemisphere.

Turton, R., R. C. Bailie, W. B. Whiting and J. A. Shaeiwitz (2003). Analysis, Synthesis,

and Design of Chemical Processes. Upper Saddle River, NJ, Prentice Hall PTR.

Tyréus, B. D. (1999). "Dominant Variables for Partial Control. 1. A Thermodynamic

Method for Their Identification." Industrial and Engineering Chemistry Research

38(4): 1432-443.

Ulrich, G. D. and P. T. Vasudevan (2004). Chemical Engineering Process Design and

Economics: A Practical Guide. Durham, New Hampshire, Process Publishing.

Walas, S. M. (1985). Phase Equilibria in Chemical Engineering. Boston, Butterworth

Publishers.

110

Wall, G. (2003). "Exergy tools." Proceedings of the Institution of Mechanical Engineers,

Part A: Power and Energy 217: 125-136.

WBCSD (2006). Eco-Efficiency - Learning Module, World Business Council for

Sustainable Development.

Weitz, O. and D. R. Lewin (1996). "Dynamic controllability and resiliency diagnosis

using steady state process flowsheet data." Computers & Chemical Engineering

20(4): 325-335.

Ydstie, B. E. (2002). "Passivity based control via the second law." Computers and

Chemical Engineering 26: 1037-1048.

Ydstie, B. E. and A. A. Alonso (1997). "Process systems and passivity via the Clausius-

Planck inequality." Systems & Control Letters 30: 253-264.

Young, B. R., R. Tellez and W. Y. Svrcek (2006). "Towards integrated process and

control system synthesis for heat-integrated plants." Canadian Journal of

Chemical Engineering 84(2): 219-229.

Zeghal, S. and A. N. Palazoglu (1993). "Interaction measures and decentralized control of

chemical plants." Computers & Chemical Engineering 17(Supplement 1): 335-

341.

111

APPENDIX A: CALCULATION OF THE STANDARD CHEMICAL EXERGY

The standard chemical exergy for the reference state is necessary to calculate the chemical exergy component for the calculation of a stream of matter’s exergy.

The reference state presented by Szargut and collaborators (Szargut et al. 1988) is adequate for chemical and petrochemical process or processes involving interaction with the environment. Recently, an update to this reference state has been presented (Rivero and Garfias 2006). However, no significant differences were reported for the compounds of interest.

The reference substances applicable to the chemical compounds dealt with in this research project are encountered in the standard composition for air (Szargut et al. 1988),

Table 20.

Table 20. Reference environment composition

Compound Partial pressure [kPa]

H2O 2.2

N2 75.78

CO2 0.0335

O2 20.39

Ar 0.906

The standard chemical exergy for gaseous reference species is given by Equation

(42).

112

푃 (42) 퐵0 = 푅푇 푙푛 0 푐푕푒푚 푅퐸퐹 −푖 0 푃푅퐸퐹−푖

For chemical species not part of the standard reference state it is possible to obtain their standard chemical exergy by relating them to standard species through reactions of formation as shown by Equation (43).

퐵0 = ∆퐺0 − 휈 퐵0 (43) 푐푕푒푚 푖 푓푖 푗 푐푕푒푚 푗 푗

For cases when the standard chemical exergy needed for a compound is not in the appropriate phase as given by the reference environment, Equations (44) and (45) are used to obtain the standard chemical exergy of the correct phase.

퐵0훼 = 퐵0훽 + ∆퐺0 (44) 푐푕푒푚푖 푐푕푒푚 푖 푖 훽→훼

Equation (45) describes the calculation of the Gibbs Free Energy for the phase change.

∆퐺0 = ∆퐺0훼 − ∆퐺0훽 (45) 푖 훽→훼 푓푖 푓푖

Table 21 shows the standard chemical exergy for the reference species.

Table 21. Standard Chemical Exergy for Reference Species

Compound Standard Chemical Exergy [J/mol]

(v) H2O 9493.57

N2 720.09

CO2 19866.60

O2 3974.26

Ar 11692.71

113

Standard chemical exergy and for selected non-reference compounds is shown in

Table 22.

Table 22. Standard Chemical Exergy for Selected Compounds

Compound Standard Chemical Exergy [J/mol]

(l) H2O 936.60

C 410251.34

H2 236078.44

S 632500.00

Cl2 123700.00

CH4 815527.31

C2H6 1462762.18

C3H8 2102324.23

iC4H10 2734859.86

nC4H10 2738604.84

iC5H12 3370957.28

nC5H12 3377406.05

H2S 831900.04

C6H14O4 (TEG) 3537900.03

HCl 84574.98

C6H6 3299175.97

C6H5Cl (MCB) 3212517.63

114

APPENDIX B: COMPUTER CODE DEVELOPED FOR THE EXERGY

CALCULATOR

As mentioned in Chapter 3 the Exergy Calculator was implemented in two different computer languages targeting two different process simulators. In the case of the Aspen HYSYS implementation the computer language chosen was Visual Basic for

Applications (VBA) and the code was written and executed from Microsoft Excel 2003 and Microsoft Excel 2007. This Appendix lists all the computer code developed for this implementation.

B.1. VBA code developed for the Aspen HYSYS implementation of the Exergy

Calculator

The Aspen HYSYS Type Library must be added to the VBA project references in order to access the Aspen HYSYS COM functionality.

B.1.1. Main module

'************************************************************************** 'This Module contains the Main Routines for the Program 'Developed by: Juan M. Montelongo Luna 'e-mail: [email protected], [email protected] 'Last Modified: Dec 8th, 2009 '**************************************************************************

'************************************************************************** Option Explicit 'Force the declaration of all variables Option Base 0 'Default index for Arrays starts at 0 '**************************************************************************

'************************************************************************** Public Sub Initialize()

115

'This Subroutine Initializes HYSYS and the Simulation

Dim CasePath As String 'Path for the HYSYS Case

Dim myMaterialStreams As Streams 'Stream Collection Dim myStream As ProcessStream 'Stream Object Dim myMolarFractions As Variant 'Array to store the Comp. Mol Fractions Dim myCompounds As Components 'Component Collection Dim myCompound As Component 'Component Object Dim Tstd As Double 'Standard Temperature [K] Dim Pstd As Double 'Standard Pressure [kPa] Dim Row As Integer, Col As Integer 'Variables for Rows and Columns in Excel Dim i As Integer, Counter As Integer 'Counters Dim mySFS As Long '... Number of SubFlowSheets in the Case Dim myNoCmps As Long '... Number of Compounds

Dim myMassFractions As Variant 'Array to store the Comp Mass Fractions

'Catch any errors that may occur On Error GoTo Initialize_Error

'Start HYSYS 'Create the HYSYS Object. Not necessary if Retrieving information only Set myHysysApp = CreateObject("HYSYS.Application")

'Set HYSYS visible/hidden to the user 'myHysysApp.Visible = True

'Open the Simulation by fixing the Pah or using the dialog box 'CasePath = "C:\Documents and Settings\Juan Montelongo\" 'CasePath = CasePath + "My Documents\Research\GlycolDehydrationTest.hsc" CasePath = UseFileDialogOpen()

Set mySimCase = GetObject(CasePath, "HYSYS.SimulationCase")

'Clear the previous simulation

116

Call CleanMainWS Call CleanSubFlowsheetWS Call CleanExergyDBWS

'Print the Full Path and Name of the Simulation in use ActiveSheet.Range("B3").Value = mySimCase.FullName ActiveSheet.Range("B4").Value = mySimCase.Flowsheet.FluidPackage. _ PropertyPackageName mySFS = mySimCase.Flowsheet.Flowsheets.Count

'... Print some information about Subflowsheets ActiveSheet.Range("B8").Value = mySFS

'Account just for the FIRST SubFlowsheet for now... If mySFS > 0 Then ActiveSheet.Range("B9").Value = _ mySimCase.Flowsheet.Flowsheets(0).MaterialStreams.Count End If

'... Initialize counters Counter = 0 Row = 10 Col = 2 'Columnn "B"

'... Grab the necessary objects to start handling compounds and streams Set myMaterialStreams = mySimCase.Flowsheet.MaterialStreams Set myCompounds = mySimCase.Flowsheet.FluidPackage.Components myNoCmps = myCompounds.Count

With Worksheets("Main") '... Headings .Cells(Row + Counter + 13, Col - 1).Value = "Mol Fraction" .Cells(Row + Counter + 15 + myNoCmps, Col - 1).Value = _ "Mass Fraction" For Each myCompound In myCompounds .Cells(Row + Counter + 14, Col - 1).Value = myCompound.Name

117

.Cells(Row + Counter + 16 + myNoCmps, Col - 1).Value = _ myCompound.Name Counter = Counter + 1 Next myCompound

Counter = 0 'Re-initialize the counter

'... Printing simulation values For Each myStream In myMaterialStreams myMolarFractions = myStream.ComponentMolarFractionValue myMassFractions = myStream.ComponentMassFractionValue .Cells(Row, Col + Counter).Value = myStream.Name .Cells(Row + 1, Col + Counter).Value = myStream.TemperatureValue .Cells(Row + 2, Col + Counter).Value = myStream.PressureValue .Cells(Row + 3, Col + Counter).Value = _ myStream.MolarFlowValue * 3600 'kmol/h .Cells(Row + 4, Col + Counter).Value = _ myStream.MolarEnthalpyValue .Cells(Row + 5, Col + Counter).Value = _ myStream.MolarEntropyValue For i = 0 To UBound(myMolarFractions) .Cells(Row + 14 + i, Col + Counter).Value = _ myMolarFractions(i) .Cells(Row + 16 + myNoCmps + i, Col + Counter).Value = _ myMassFractions(i) Next i Counter = Counter + 1 Next myStream

End With

Call GetGibbsOfFormation

'... Set the Tstd and Pstd Tstd = 25# 'in [C] for HYSYS' SI units Pstd = 101.325 'in [kPa] for HYSYS' SI units

118

'... Perform the Exergy Calculation Call CalculateExergy(Tstd, Pstd) If mySFS > 0 Then Call CalculateExergySubFlowsheet(Tstd, Pstd) End If

'... Free global objects and close the case and HYSYS Call CleanUp

Initialize_Next: Exit Sub

Initialize_Error: Call RenderError("Initialize", Err.Description) Call CleanUp Resume Initialize_Next

End Sub '**************************************************************************

'************************************************************************** Public Sub CalculateExergy(ByRef Tstd As Double, ByRef Pstd As Double) 'This Subroutine Calculates the three Exergy components (Chemical, Physical 'and Change of Mixing) for each of the Process Streams in the working 'simulation. 'It relies in the PUBLIC Variables myHysysApp and mySimCase

Dim myPureComponents As Components 'Component Collection for Pure Chemicals Dim myPureComponent As Component 'Component Object for a Pure Chemical Dim mySimStreams As Streams 'Streams Collection Dim myStream As ProcessStream 'Process Stream Dim myDummyStream As ProcessStream 'Process Stream Dim myFluid As Fluid 'Fluid to Duplicate a Stream Dim myComponentMatrix As Variant 'Matrix to hold the Compositions Dim myCompositions As Variant 'Array to hold the compositions of a stream

119

Dim myPureCompsHSStd As Variant 'Matrix to hold Enthalpy and Entropy of 'the Pure components at Standard 'Reference State Dim myPureCompsHSActual As Variant 'Matrix to hold Enthalpy and Entropy of 'the Pure components at Actual Conditions Dim myStreamEntropy As Variant 'Array to hold Entropy of the Streams Dim myStreamEnthalpy As Variant 'Array to hold Enthalpy of the Streams Dim myStreamEntropyStd As Variant 'Array to hold Entropy of the Streams 'at Standard Conditions Dim myStreamEnthalpyStd As Variant 'Array to hold Enthalpy of the Streams 'at Standard Conditions Dim PureChemExergy As Variant 'Array to hold the Standard Chemical 'Exergy of the Pure Components Dim myChemicalExergy As Double 'Chemical Exergy for a stream [kJ/mol] Dim SumHStd As Double 'Summation of Standard Enthalpies. x(i)*H(i) Dim SumSStd As Double 'Summation of Standard Entropies. x(i)*S(i) Dim SumHActual As Double 'Summation of Actual Enthalpies. x(i)*H(i) Dim SumSActual As Double 'Summation of Actual Entropies. x(i)*S(i) Dim StreamIdx As Integer, Counter As Integer 'Counters Dim i As Integer, j As Integer 'Counters

'Catch any errors that may occur On Error GoTo CalculateExergy_Error

With mySimCase.Flowsheet Set myPureComponents = .FluidPackage.Components Set myDummyStream = .MaterialStreams.Item(0) 'Just to Duplicate Fluid Set mySimStreams = .MaterialStreams End With

'Prepare the vectors for the Compositions Counter = myPureComponents.Count StreamIdx = mySimStreams.Count ReDim myComponentMatrix(Counter - 1, Counter - 1) ReDim myCompositions(Counter - 1) ReDim myPureCompsHSStd(Counter - 1, 1)

120

ReDim myPureCompsHSActual(Counter - 1, StreamIdx - 1, 1) ReDim myStreamEntropy(StreamIdx) ReDim myStreamEnthalpy(StreamIdx) ReDim myStreamEntropyStd(StreamIdx) ReDim myStreamEnthalpyStd(StreamIdx) ReDim PureChemExergy(Counter - 1)

'Send number of Streams and Compounds to the "Main" Spreadsheet ActiveSheet.Range("B6").Value = Counter ActiveSheet.Range("B7").Value = StreamIdx

'Set the diagonal elements to One, the rest to Zero. (Double type vars) For i = 0 To Counter - 1 For j = 0 To Counter - 1 If i = j Then myComponentMatrix(i, j) = 1# Else myComponentMatrix(i, j) = 0# End If Next j 'Load the Standard Chemical Exergy of the Pure Components (does not 'change throughout the solving process) PureChemExergy(i) = Worksheets("Exergy DB").Cells(22 + i, 5).Value Next i

'... Reset the counter Counter = 0

'... Grab a working object to perform necessary flash calculations Set myFluid = myDummyStream.DuplicateFluid

'Get the Properties for the Pure Compounds With myFluid For Each myPureComponent In myPureComponents 'Hold the Solver so information can be transferred faster mySimCase.Solver.CanSolve = False

121

For i = 0 To UBound(myCompositions) myCompositions(i) = myComponentMatrix(i, Counter) Next i .MolarFractionsValue = myCompositions 'Calculate the properties at the Standard Reference State .TemperatureValue = Tstd .PressureValue = Pstd .TPFlash 'Turn on the Solver so the calculations can be done mySimCase.Solver.CanSolve = True

'Save the Enthalpy and Entropy values for the pure component 'at the Standard Reference State myPureCompsHSStd(Counter, 0) = .MolarEnthalpyValue myPureCompsHSStd(Counter, 1) = .MolarEntropyValue

'... Reset the counter StreamIdx = 0 For Each myStream In mySimStreams

'Hold the Solver so the information is transferred faster 'mySimCase.Solver.CanSolve = False

'Calculate the properties at the Actual Conditions of each 'Stream in The Flowsheet .TemperatureValue = myStream.TemperatureValue .PressureValue = myStream.PressureValue .TPFlash 'Turn on the Solver so the calculations can be done 'mySimCase.Solver.CanSolve = True

'Save the Enthalpy and Entropy values for the pure 'component at the Actual Conditions for each Stream in 'the Flowsheet myPureCompsHSActual(Counter, StreamIdx, 0) = _

122

.MolarEnthalpyValue myPureCompsHSActual(Counter, StreamIdx, 1) = _ .MolarEntropyValue

'Increase the counter for the next Stream StreamIdx = StreamIdx + 1 Next myStream

'Increase the counter for the next Compound Counter = Counter + 1 Next myPureComponent

End With

'... Reset the counter StreamIdx = 0

'Calculate the Chemical Exergy, Physical Exergy & Exergy Change of Mixing 'for each Stream For Each myStream In mySimStreams 'Reinitialize counter for Compounds Counter = 0 'Reinitialize the summations myChemicalExergy = 0# SumHStd = 0# SumSStd = 0# SumHActual = 0# SumSActual = 0#

'Duplicate the stream properties Set myFluid = myStream.DuplicateFluid

'Get the Enthalpy and the Entropy of the Actual Stream myStreamEnthalpy(StreamIdx) = myStream.MolarEnthalpyValue myStreamEntropy(StreamIdx) = myStream.MolarEntropyValue

123

'Get the Enthalpy and the Entropy of the Actual Stream at 'Standard Conditions myFluid.TemperatureValue = Tstd myFluid.PressureValue = Pstd myFluid.TPFlash myStreamEnthalpyStd(StreamIdx) = myFluid.MolarEnthalpyValue myStreamEntropyStd(StreamIdx) = myFluid.MolarEntropyValue

Dim myPhase As FluidPhase Dim myLiqStd As FluidPhase Dim ChemExergyVap As Double, ChemExergyLiq As Double Dim IsTwoPhase As Boolean

IsTwoPhase = myFluid.VapourFractionValue < 1# And myFluid.VapourFractionValue > 0#

For Each myPureComponent In myPureComponents 'Perform the Summations

'Take care of Liq/Vap phases at Std Conditions ' If myFluid.VapourFractionValue < 1# And myFluid.VapourFractionValue > 0# Then If IsTwoPhase Then ChemExergyLiq = 0# ChemExergyVap = 0# 'We have two phases at Standard Conditions For Each myPhase In myFluid.FluidPhases If myPhase.VapourFractionValue = 0 Then 'Liquid 'The value in the HYSYS database is for vapor Water 'so we need to provide the value for liquid Water If myPureComponent.Name = "H2O" Then PureChemExergy(Counter) = 0.9366 'kJ/mol for Liquid Water End If ChemExergyLiq = _ myPhase.MolarFractionsValue(Counter) * _

124

PureChemExergy(Counter) Else 'This value for CO2 is only used to match the value from the paper of 'Hinderink et al. (Chem Eng Sci, v 51, n 20, pp 4693-4700, 1996) 'If myPureComponent.Name = "CO2" Then ' PureChemExergy(Counter) = 19.86 'kJ/mol for CO2 'End If ChemExergyVap = _ myPhase.MolarFractionsValue(Counter) * _ PureChemExergy(Counter) End If Next myPhase myChemicalExergy = myChemicalExergy + ChemExergyVap * myFluid.VapourFractionValue _ + (1 - myFluid.VapourFractionValue) * ChemExergyLiq Else myChemicalExergy = myChemicalExergy + _ myFluid.MolarFractionsValue(Counter) * _ PureChemExergy(Counter) End If

'Perform the rest of the Summations SumHStd = SumHStd + myFluid.MolarFractionsValue(Counter) * _ myPureCompsHSStd(Counter, 0) SumSStd = SumSStd + myFluid.MolarFractionsValue(Counter) * _ myPureCompsHSStd(Counter, 1) SumHActual = SumHActual + myFluid.MolarFractionsValue(Counter) _ * myPureCompsHSActual(Counter, StreamIdx, 0) SumSActual = SumSActual + myFluid.MolarFractionsValue(Counter) _ * myPureCompsHSActual(Counter, StreamIdx, 1) 'Increase the counter for the next Compound Counter = Counter + 1 Next myPureComponent

125

'Perform the Calculation and print the Result for the current Stream With ActiveSheet .Cells(16, 2 + StreamIdx).Value = _ (myStreamEnthalpy(StreamIdx) - _ myStreamEnthalpyStd(StreamIdx)) - _ (Tstd + 273.15) * _ (myStreamEntropy(StreamIdx) - _ myStreamEntropyStd(StreamIdx)) .Cells(17, 2 + StreamIdx).Value = myChemicalExergy * 1000 .Cells(18, 2 + StreamIdx).Value = _ ((SumHActual - (Tstd + 273.15) * SumSActual) - _ (SumHStd - (Tstd + 273.15) * SumSStd)) .Cells(19, 2 + StreamIdx).Value = _ (myStreamEnthalpy(StreamIdx) - SumHActual) - _ (Tstd + 273.15) * _ (myStreamEntropy(StreamIdx) - SumSActual) .Cells(20, 2 + StreamIdx).Value = _ .Cells(13, 2 + StreamIdx).Value * _ (.Cells(17, 2 + StreamIdx).Value + _ .Cells(18, 2 + StreamIdx).Value + _ .Cells(19, 2 + StreamIdx).Value) / 3600 .Cells(21, 2 + StreamIdx).Value = _ .Cells(17, 2 + StreamIdx).Value + _ .Cells(18, 2 + StreamIdx).Value + _ .Cells(19, 2 + StreamIdx).Value End With

'Increase the counter for the next Stream StreamIdx = StreamIdx + 1 Next myStream

CalculateExergy_Next: Exit Sub

CalculateExergy_Error: Call RenderError("CalculateExergy", Err.Description)

126

'Call CleanUp Routine 'Call CleanUp Resume CalculateExergy_Next

End Sub '**************************************************************************

'************************************************************************** Public Sub CalculateExergySubFlowsheet(ByRef Tstd As Double, ByRef Pstd _ As Double) 'This Subroutine Calculates the three Exergy components (Chemical, Physical 'and Change of Mixing) for each of the Process Streams in the working 'simulation. It performs the same calculations as the CalculateExergy 'subroutine but with the First Subflowsheet. 'It relies in the PUBLIC Variables myHysysApp and mySimCase

Dim myPureComponents As Components 'Component Collection for Pure Chemicals Dim myPureComponent As Component 'Component Object fo a Pure Chemical Dim mySimStreams As Streams 'Streams Collection Dim myStream As ProcessStream 'Process Stream Dim myDummyStream As ProcessStream 'Process Stream Dim myFluid As Fluid 'Fluid to Duplicate a Stream Dim myComponentMatrix As Variant 'Matrix to hold the Compositions Dim myCompositions As Variant 'Array to hold the compositions of a stream Dim myPureCompsHSStd As Variant 'Matrix to hold Enthalpy and Entropy of 'the Pure components at Standard 'Reference State Dim myPureCompsHSActual As Variant 'Matrix to hold Enthalpy and Entropy of 'the Pure components at Actual Conditions Dim myStreamEntropy As Variant 'Array to hold Entropy of the Streams Dim myStreamEnthalpy As Variant 'Array to hold Enthalpy of the Streams Dim myStreamEntropyStd As Variant 'Array to hold Entropy of the Streams 'at Standard Conditions Dim myStreamEnthalpyStd As Variant 'Array to hold Enthalpy of the Streams 'at Standard Conditions Dim PureChemExergy As Variant 'Array to hold the Standard Chemical

127

'Exergy of the Pure Components Dim myChemicalExergy As Double 'Chemical Exergy for a stream [kJ/mol] Dim SumHStd As Double 'Summation of Standard Enthalpies. x(i)*H(i) Dim SumSStd As Double 'Summation of Standard Entropies. x(i)*S(i) Dim SumHActual As Double 'Summation of Actual Enthalpies. x(i)*H(i) Dim SumSActual As Double 'Summation of Actual Entropies. x(i)*S(i) Dim StreamIdx As Integer, Counter As Integer 'Counters Dim i As Integer, j As Integer 'Counters

Dim Row As Integer, Col As Integer 'Variables for Rows and Columns in Excel Dim myCompounds As Components 'Component Collection Dim myCompound As Component 'Component Object Dim myMaterialStreams As Streams 'Stream Collection Dim myMolarFractions As Variant 'Array to store the Comp. Molar Fractions Dim StreamCounter As Integer 'Counter for the number of Material Streams Dim myNoCmps As Long '... Number of Compounds

Dim myMassFractions As Variant 'Array to store the Comp Mass Fractions

'Catch any errors that may occur On Error GoTo CalculateExergySubFlowsheet_Error

With mySimCase.Flowsheet.Flowsheets(0) Set myPureComponents = .FluidPackage.Components Set myDummyStream = .MaterialStreams.Item(0) 'Just to Duplicate Fluid Set mySimStreams = .MaterialStreams

Set myCompounds = .FluidPackage.Components Set myMaterialStreams = .MaterialStreams End With

myNoCmps = myCompounds.Count

'Prepare the vectors for the Compositions Counter = myPureComponents.Count StreamIdx = mySimStreams.Count

128

ReDim myComponentMatrix(Counter - 1, Counter - 1) ReDim myCompositions(Counter - 1) ReDim myPureCompsHSStd(Counter - 1, 1) ReDim myPureCompsHSActual(Counter - 1, StreamIdx - 1, 1) ReDim myStreamEntropy(StreamIdx) ReDim myStreamEnthalpy(StreamIdx) ReDim myStreamEntropyStd(StreamIdx) ReDim myStreamEnthalpyStd(StreamIdx) ReDim PureChemExergy(Counter - 1)

'Send number of Streams and Compounds to the "SubFlowsheet" Spreadsheet Worksheets("SubFlowsheet").Range("B6").Value = Counter Worksheets("SubFlowsheet").Range("B7").Value = StreamIdx Worksheets("SubFlowsheet").Range("B8").Value = _ mySimCase.Flowsheet.Flowsheets.Count

'... Initialize counters StreamCounter = 0 Row = 10 Col = 2 'Columnn "B"

With Worksheets("SubFlowsheet") '... Headings .Cells(Row + StreamCounter + 13, Col - 1).Value = "Mol Fraction" .Cells(Row + StreamCounter + 15 + myNoCmps, Col - 1).Value = _ "Mass Fraction" For Each myCompound In myCompounds .Cells(Row + StreamCounter + 14, Col - 1).Value = _ myCompound.Name .Cells(Row + StreamCounter + 16 + myNoCmps, Col - 1).Value = _ myCompound.Name StreamCounter = StreamCounter + 1 Next myCompound

StreamCounter = 0 'Re-initialize the counter

129

'... Printing simulation values For Each myStream In myMaterialStreams myMolarFractions = myStream.ComponentMolarFractionValue myMassFractions = myStream.ComponentMassFractionValue .Cells(Row, Col + StreamCounter).Value = myStream.Name .Cells(Row + 1, Col + StreamCounter).Value = _ myStream.TemperatureValue .Cells(Row + 2, Col + StreamCounter).Value = _ myStream.PressureValue .Cells(Row + 3, Col + StreamCounter).Value = _ myStream.MolarFlowValue * 3600 'kmol/h .Cells(Row + 4, Col + StreamCounter).Value = _ myStream.MolarEnthalpyValue .Cells(Row + 5, Col + StreamCounter).Value = _ myStream.MolarEntropyValue For i = 0 To UBound(myMolarFractions) .Cells(Row + 14 + i, Col + StreamCounter).Value = _ myMolarFractions(i) .Cells(Row + 16 + myNoCmps + i, Col + StreamCounter).Value _ = myMassFractions(i) Next i StreamCounter = StreamCounter + 1 Next myStream

End With

'Set the diagonal elements to One, the rest to Zero. (Double type vars) For i = 0 To Counter - 1 For j = 0 To Counter - 1 If i = j Then myComponentMatrix(i, j) = 1# Else myComponentMatrix(i, j) = 0# End If Next j 'Load the Standard Chemical Exergy of the Pure Components (does not

130

'change throughout the solving process) PureChemExergy(i) = Worksheets("Exergy DB").Cells(22 + i, 5).Value Next i

'... Reset the counter Counter = 0

'... Grab a working object to perform necessary flash calculations Set myFluid = myDummyStream.DuplicateFluid

'Get the Properties for the Pure Compounds With myFluid For Each myPureComponent In myPureComponents 'Hold the Solver so information can be transferred faster mySimCase.Solver.CanSolve = False

For i = 0 To UBound(myCompositions) myCompositions(i) = myComponentMatrix(i, Counter) Next i .MolarFractionsValue = myCompositions 'Calculate the properties at the Standard Reference State .TemperatureValue = Tstd .PressureValue = Pstd .TPFlash 'Turn on the Solver so the calculations can be done mySimCase.Solver.CanSolve = True

'Save the Enthalpy and Entropy values for the pure component 'at the Standard Reference State myPureCompsHSStd(Counter, 0) = .MolarEnthalpyValue myPureCompsHSStd(Counter, 1) = .MolarEntropyValue

'... Reset the counter StreamIdx = 0 For Each myStream In mySimStreams

131

'Hold the Solver so the information is transferred faster 'mySimCase.Solver.CanSolve = False

'Calculate the properties at the Actual Conditions of each 'Stream in The Flowsheet .TemperatureValue = myStream.TemperatureValue .PressureValue = myStream.PressureValue .TPFlash 'Turn on the Solver so the calculations can be done 'mySimCase.Solver.CanSolve = True

'Save the Enthalpy and Entropy values for the pure 'component atthe Actual Conditions for each Stream in 'the Flowsheet myPureCompsHSActual(Counter, StreamIdx, 0) = _ .MolarEnthalpyValue myPureCompsHSActual(Counter, StreamIdx, 1) = _ .MolarEntropyValue

'Increase the counter for the next Stream StreamIdx = StreamIdx + 1 Next myStream

'Increase the counter for the next Compound Counter = Counter + 1 Next myPureComponent

End With

'... Reset the counter StreamIdx = 0

'Calculate the Chemical Exergy, Physical Exergy & Exergy Change of Mixing 'for each Stream For Each myStream In mySimStreams 'Reinitialize counter for Compounds

132

Counter = 0 'Reinitialize the summations myChemicalExergy = 0# SumHStd = 0# SumSStd = 0# SumHActual = 0# SumSActual = 0#

'Duplicate the stream properties Set myFluid = myStream.DuplicateFluid

'Get the Enthalpy and the Entropy of the Actual Stream myStreamEnthalpy(StreamIdx) = myStream.MolarEnthalpyValue myStreamEntropy(StreamIdx) = myStream.MolarEntropyValue

'Get the Enthalpy and the Entropy of the Actual Stream at 'Standard Conditions myFluid.TemperatureValue = Tstd myFluid.PressureValue = Pstd myFluid.TPFlash myStreamEnthalpyStd(StreamIdx) = myFluid.MolarEnthalpyValue myStreamEntropyStd(StreamIdx) = myFluid.MolarEntropyValue

Dim myPhase As FluidPhase Dim myLiqStd As FluidPhase Dim ChemExergyVap As Double, ChemExergyLiq As Double Dim IsTwoPhase As Boolean

IsTwoPhase = myFluid.VapourFractionValue < 1# And myFluid.VapourFractionValue > 0#

For Each myPureComponent In myPureComponents 'Perform the Summations

'Take care of Liq/Vap phases at Std Conditions

133

' If myFluid.VapourFractionValue < 1# And myFluid.VapourFractionValue > 0# Then If IsTwoPhase Then ChemExergyLiq = 0# ChemExergyVap = 0# 'We have two phases at Standard Conditions For Each myPhase In myFluid.FluidPhases If myPhase.VapourFractionValue = 0 Then 'Liquid 'The value in the HYSYS database is for vapor Water 'so we need to provide the value for liquid Water If myPureComponent.Name = "H2O" Then PureChemExergy(Counter) = 0.9366 'kJ/mol for Liquid Water End If ChemExergyLiq = _ myPhase.MolarFractionsValue(Counter) * _ PureChemExergy(Counter) Else 'This value for CO2 is only used to match the value from the paper of 'Hinderink et al. (Chem Eng Sci, v 51, n 20, pp 4693-4700, 1996) 'If myPureComponent.Name = "CO2" Then ' PureChemExergy(Counter) = 19.86 'kJ/mol for CO2 'End If ChemExergyVap = _ myPhase.MolarFractionsValue(Counter) * _ PureChemExergy(Counter) End If Next myPhase myChemicalExergy = myChemicalExergy + ChemExergyVap * myFluid.VapourFractionValue _ + (1 - myFluid.VapourFractionValue) * ChemExergyLiq Else myChemicalExergy = myChemicalExergy + _ myFluid.MolarFractionsValue(Counter) * _

134

PureChemExergy(Counter) End If

'Perform the rest of the Summations SumHStd = SumHStd + myFluid.MolarFractionsValue(Counter) * _ myPureCompsHSStd(Counter, 0) SumSStd = SumSStd + myFluid.MolarFractionsValue(Counter) * _ myPureCompsHSStd(Counter, 1) SumHActual = SumHActual + myFluid.MolarFractionsValue(Counter) _ * myPureCompsHSActual(Counter, StreamIdx, 0) SumSActual = SumSActual + myFluid.MolarFractionsValue(Counter) _ * myPureCompsHSActual(Counter, StreamIdx, 1) 'Increase the counter for the next Compound Counter = Counter + 1 Next myPureComponent

'Perform the Calculation and print the Result for the current Stream With Worksheets("SubFlowsheet") .Cells(16, 2 + StreamIdx).Value = _ (myStreamEnthalpy(StreamIdx) - _ myStreamEnthalpyStd(StreamIdx)) - _ (Tstd + 273.15) * _ (myStreamEntropy(StreamIdx) - _ myStreamEntropyStd(StreamIdx)) .Cells(17, 2 + StreamIdx).Value = myChemicalExergy * 1000 .Cells(18, 2 + StreamIdx).Value = _ ((SumHActual - (Tstd + 273.15) * SumSActual) - _ (SumHStd - (Tstd + 273.15) * SumSStd)) .Cells(19, 2 + StreamIdx).Value = _ (myStreamEnthalpy(StreamIdx) - SumHActual) - _ (Tstd + 273.15) * _ (myStreamEntropy(StreamIdx) - SumSActual) .Cells(20, 2 + StreamIdx).Value = _ .Cells(13, 2 + StreamIdx).Value * _ (.Cells(17, 2 + StreamIdx).Value + _ .Cells(18, 2 + StreamIdx).Value + _

135

.Cells(19, 2 + StreamIdx).Value) / 3600 .Cells(21, 2 + StreamIdx).Value = _ .Cells(17, 2 + StreamIdx).Value + _ .Cells(18, 2 + StreamIdx).Value + _ .Cells(19, 2 + StreamIdx).Value End With

'Increase the counter for the next Stream StreamIdx = StreamIdx + 1 Next myStream

CalculateExergySubFlowsheet_Next: Exit Sub

CalculateExergySubFlowsheet_Error: Call RenderError("CalculateExergySubFlowsheet", Err.Description) 'Call CleanUp Routine 'Call CleanUp Resume CalculateExergySubFlowsheet_Next

End Sub '**************************************************************************

'************************************************************************** Public Sub CleanUp() 'This Subroutine Closes the Current Simulation Case and the HYSYS Engine

'Catch any errors that may occur On Error GoTo CleanUp_Error

'Close the HYSYS Simulation Case mySimCase.Close 'Terminate the HYSYS Engine myHysysApp.Quit

CleanUp_Next:

136

Exit Sub

CleanUp_Error: Call RenderError("CleanUp", Err.Description) Resume CleanUp_Next

End Sub '**************************************************************************

'************************************************************************** Private Sub CleanMainWS() 'This Subroutine Clears the previous data on the Main Worksheet leaving the 'headers on the first 9 Rows

'Catch any errors that may occur On Error GoTo CleanMainWS_Error

Worksheets("Main").Range("B1:IV65536").Clear Worksheets("Main").Range("A22:A65536").Clear

CleanMainWS_Next: Exit Sub

CleanMainWS_Error: Call RenderError("CleanMainWS", Err.Description) Resume CleanMainWS_Next

End Sub '**************************************************************************

'************************************************************************** Private Sub CleanSubFlowsheetWS() 'This Subroutine Clears the previous data on the SubFlowsheet Worksheet 'leaving the headers on the first 9 Rows

'Catch any errors that may occur

137

On Error GoTo CleanSubFlowsheetWS_Error

Worksheets("SubFlowsheet").Range("B1:IV65536").Clear Worksheets("SubFlowsheet").Range("A22:A65536").Clear

CleanSubFlowsheetWS_Next: Exit Sub

CleanSubFlowsheetWS_Error: Call RenderError("CleanSubFlowsheetWS", Err.Description) Resume CleanSubFlowsheetWS_Next

End Sub '**************************************************************************

B.1.2. PublicVars module

'************************************************************************** 'This Module contains the Data Structures Definitions and some Global 'Constants used throughout the code. 'Developed by: Juan M. Montelongo Luna 'e-mail: [email protected], [email protected] 'Last Modified: Dec 7th, 2009 '**************************************************************************

'************************************************************************** Option Explicit 'Force the declaration of all variables Option Base 1 'Default index for Arrays starts at 1 '**************************************************************************

'************************************************************************** 'Objects required to Bind HYSYS to Excel 'Public myHysysApp As HYSYS.Application '... For early binding '

138

Public myHysysApp As Object 'Object to handle HYSYS. For late binding Public mySimCase As HYSYS.SimulationCase 'Object to handle the Simulation Public mySimStream As HYSYS.ProcessStream 'Object to handle the Streams

'Objects to Receive/Send the Information from HYSYS/Excel Public myStreams As Variant '**************************************************************************

B.1.3. Auxiliary module

'************************************************************************** 'This Module contains the Ancillary Routines for the Exergy Calculator 'Program 'Developed by: Juan M. Montelongo Luna 'e-mail: [email protected], [email protected] 'Last Modified: Dec 7th, 2009 '**************************************************************************

'************************************************************************** Option Explicit 'Force the declaration of all variables Option Base 1 'Default index for Arrays starts at 1 '**************************************************************************

'************************************************************************** Public Sub GetGibbsOfFormation() 'This Subroutine gets the Names and Gibbs Free Energy of Formation of the 'compounds in the working Simulation Case. 'It relies in the PUBLIC Variables myHysysApp and mySimCase

Dim myCompounds As Components 'HYSYS Component Collection Dim myCompound As Component 'HYSYS Component Object Dim Tstd As Double 'Standard Temperature [K] Dim ChemExergy As Double 'Standard Chemical Exergy [kJ/mol] Dim Row As Integer, Col As Integer 'Variables for Rows and Columns in Excel

139

Dim RowParsed As Integer 'Offset variable for the Atoms Worksheet Dim Counter As Integer 'Counter Dim i As Integer, j As Integer '... Short-name counters

'Catch any errors that may occur On Error GoTo GetGibbsOfFormation_Error

If Not mySimCase Is Nothing Then Set myCompounds = mySimCase.Flowsheet.FluidPackage.Components End If

Counter = 0 Row = 22 Col = 1 'Column "A" RowParsed = Row - 2

With Worksheets("Exergy DB") Tstd = .Cells(3, Col + 1).Value + 273.15 'Convert from C to K For Each myCompound In myCompounds j = Row + Counter '... Use shorter name

.Cells(j, Col).Value = myCompound.Name .Cells(j, Col + 1).Value = myCompound.Formula .Cells(j, Col + 2).Value = myCompound.EvaluateGibbs(Tstd) .Cells(j, Col + 3).Value = myCompound.HeatOfFormationValue

'Call the routine to parse the formulae now that we know 'the compounds Call ParseFormula

i = Row + Counter - RowParsed '... Use shorter name

'Calculate the Standard Chemical Exergy for each compund

'Only compounds with C, H, N, O, S and Cl are being taken into

140

'account for now ChemExergy = .Cells(Row + Counter, Col + 2).Value / 1000 - _ ((-1) * Worksheets("Atoms").Cells(i, 8) * .Range("C7") + _ (-Worksheets("Atoms").Cells(i, 3) / 2) * .Range("C8") + _ (-Worksheets("Atoms").Cells(i, 9) / 2) * .Range("C9") + _ (-Worksheets("Atoms").Cells(i, 10) / 2) * .Range("C10") + _ (-Worksheets("Atoms").Cells(i, 18)) * .Range("C11") + _ (-Worksheets("Atoms").Cells(i, 19) / 2) * .Range("C12"))

.Cells(Row + Counter, Col + 4).Value = ChemExergy

'Increase counter for next row Counter = Counter + 1 Next myCompound End With

GetGibbsOfFormation_Next: Exit Sub

GetGibbsOfFormation_Error: Call RenderError("GetGibbsOfFormation", Err.Description) 'Call CleanUp Resume GetGibbsOfFormation_Next

End Sub '**************************************************************************

'************************************************************************** Public Sub ParseFormula() 'This Subroutine Parses the Compound Formula to get the number of different 'atoms in each compound. 'It should be called after the Compounds for the case are known and have 'been printed to the "Exergy DB" worksheet

Dim Formula As String 'Variable to hold the alphanumeric formula Dim PrevChar As Variant 'Variabel to store the Previous Character

141

Dim CurrChar As Variant 'Variable to store the Current Character Dim NextChar As Variant 'Variable to store the Next Character Dim FormulaLength As Integer 'Character length Dim Row As Integer, Col As Integer 'Variables for Rows and Columns in Excel Dim RowParsed As Integer 'Variable for Rowns in the Atoms Worksheet Dim Index As Integer 'Index for character position Dim Counter As Integer 'Counter Dim i As Integer, j As Integer '... Short-name counters

On Error GoTo ParseFormula_Error

'Clean the worksheet from any previous operations Call CleanAtomsWS

Counter = 0 Row = 22 Col = 2 'Column "B" RowParsed = Row - 2

With Worksheets("Exergy DB") Do While .Cells(Row + Counter, Col).Value <> "" 'Read the formula Formula = .Cells(Row + Counter, Col).Value 'Remove all leading and trailing spaces Formula = Trim(Formula)

i = Row - RowParsed + Counter '... Use shorter name

'Copy the Compound Names and Formulas from the DataBase to the '"Atoms" worksheet. Worksheets("Atoms").Cells(i, 1).Value = _ .Cells(Row + Counter, 1).Value Worksheets("Atoms").Cells(i, 2).Value = Formula

'Parsing FormulaLength = Len(Formula)

142

Index = 1 'First Character in the String 'Add a space at the end of the String so it can calculate the 'NextNextChar Formula = Formula + " "

Do While Index <= FormulaLength 'Get the Characters to work with CurrChar = Mid(Formula, Index, 1) NextChar = Mid(Formula, Index + 1, 1)

'Check first the most common elemnts Select Case CurrChar 'Column Number is the Atomic Number PLUS TWO Case "C" If Asc(NextChar) >= 48 And Asc(NextChar) <= 57 Then 'There is more than One Carbon Atom (C#). '... Assume no more than 99 If Asc(Mid(Formula, Index + 2, 1)) >= 48 And _ Asc(Mid(Formula, Index + 2, 1)) <= 57 Then Worksheets("Atoms").Cells(i, 8).Value = _ Worksheets("Atoms").Cells(i, 8).Value _ + NextChar + Mid(Formula, Index + 2, 1) Else Worksheets("Atoms").Cells(i, 8).Value = _ Worksheets("Atoms").Cells(i, 8).Value _ + NextChar End If 'Increase counter for next Character Index = Index + 1 'Check for other combinations of One Carbon Atom. 'There will be at least ONE atom... write it for now ElseIf Asc(NextChar) = 108 Then 'It is a Chlorine Atom (Cl) Worksheets("Atoms").Cells(i, 19).Value = 1 'Increase counter for next Character Index = Index + 1

143

ElseIf Asc(NextChar) = 97 Then 'It is a Calcium Atom (Ca) Worksheets("Atoms").Cells(i, 22).Value = 1 'Increase counter for next Character Index = Index + 1 ElseIf Asc(NextChar) = 114 Then 'It is a Chromium Atom (Cr) Worksheets("Atoms").Cells(i, 26).Value = 1 'Increase counter for next Character Index = Index + 1 ElseIf Asc(NextChar) = 111 Then 'It is a Cobalt Atom (Co) Worksheets("Atoms").Cells(i, 29).Value = 1 'Increase counter for next Character Index = Index + 1 ElseIf Asc(NextChar) = 117 Then 'It is a Copper Atom (Cu) Worksheets("Atoms").Cells(i, 31).Value = 1 'Increase counter for next Character Index = Index + 1 ElseIf Asc(NextChar) = 100 Then 'It is a Cadmium Atom (Cd) Worksheets("Atoms").Cells(i, 50).Value = 1 'Increase counter for next Character Index = Index + 1 ElseIf Asc(NextChar) = 115 Then 'It is a Cesium Atom (Cs) Worksheets("Atoms").Cells(i, 57).Value = 1 'Increase counter for next Character Index = Index + 1 ElseIf Asc(NextChar) = 101 Then 'It is a Cerium Atom (Ce) Worksheets("Atoms").Cells(i, 60).Value = 1 'Increase counter for next Character Index = Index + 1 ElseIf Asc(NextChar) = 109 Then

144

'It is a Curium Atom (Cm) Worksheets("Atoms").Cells(i, 98).Value = 1 'Increase counter for next Character Index = Index + 1 ElseIf Asc(NextChar) = 102 Then 'It is a Californium Atom (Cf) Worksheets("Atoms").Cells(i, 100).Value = 1 'Increase counter for next Character Index = Index + 1 Else 'It is a SINGLE Carbon Atom (C) Worksheets("Atoms").Cells(i, 8).Value = _ Worksheets("Atoms").Cells(i, 8).Value + 1 'Increase counter for next Character Index = Index + 1 End If Case "H" If Asc(NextChar) >= 48 And Asc(NextChar) <= 57 Then 'There is more than One Hydrogen Atom (H#) If Asc(Mid(Formula, Index + 2, 1)) >= 48 And _ Asc(Mid(Formula, Index + 2, 1)) <= 57 Then Worksheets("Atoms").Cells(i, 3).Value = _ NextChar + Mid(Formula, Index + 2, 1) Else Worksheets("Atoms").Cells(i, 3).Value = _ NextChar End If 'Increase counter for next Character Index = Index + 1 'Check for other combinations of One Hydrogen Atom.

'There will be at least ONE atom... write it for now Else 'It is a SINGLE Hydrogen Atom (H)

145

Worksheets("Atoms").Cells(i, 3).Value = 1 'Increase counter for next Character Index = Index + 1 End If Case "O" If Asc(NextChar) >= 48 And Asc(NextChar) <= 57 Then 'There is more than One Oxygen Atom (O#) If Asc(Mid(Formula, Index + 2, 1)) >= 48 And _ Asc(Mid(Formula, Index + 2, 1)) <= 57 Then Worksheets("Atoms").Cells(i, 10).Value = _ NextChar + Mid(Formula, Index + 2, 1) Else Worksheets("Atoms").Cells(i, 10).Value = _ NextChar End If 'Increase counter for next Character Index = Index + 1 'Check for other combinations of One Oxygen Atom.

'There will be at least ONE atom... write it for now Else 'It is a SINGLE Oxygen Atom (O) Worksheets("Atoms").Cells(i, 10).Value = 1 'Increase counter for next Character Index = Index + 1 End If Case "N" If Asc(NextChar) >= 48 And Asc(NextChar) <= 57 Then 'There is more than One Nitrogen Atom (N#) If Asc(Mid(Formula, Index + 2, 1)) >= 48 And _ Asc(Mid(Formula, Index + 2, 1)) <= 57 Then Worksheets("Atoms").Cells(i, 9).Value = _ NextChar + Mid(Formula, Index + 2, 1) Else

146

Worksheets("Atoms").Cells(i, 9).Value = _ NextChar End If 'Increase counter for next Character Index = Index + 1 'Check for other combinations of One Nitrogen Atom.

'There will be at least ONE atom... write it for now Else 'It is a SINGLE Nitrogen Atom (N) Worksheets("Atoms").Cells(i, 9).Value = 1 'Increase counter for next Character Index = Index + 1 End If Case "S" If Asc(NextChar) >= 48 And Asc(NextChar) <= 57 Then 'There is more than One Sulphur Atom (S#) If Asc(Mid(Formula, Index + 2, 1)) >= 48 And _ Asc(Mid(Formula, Index + 2, 1)) <= 57 Then Worksheets("Atoms").Cells(i, 18).Value = _ NextChar + Mid(Formula, Index + 2, 1) Else Worksheets("Atoms").Cells(i, 18).Value = _ NextChar End If 'Increase counter for next Character Index = Index + 1 'Check for other combinations of One Sulphur Atom.

'There will be at least ONE atom... write it for now Else 'It is a SINGLE Sulphur Atom (S)

147

Worksheets("Atoms").Cells(i, 18).Value = 1 'Increase counter for next Character Index = Index + 1 End If Case Else 'Increase counter for next Character Index = Index + 1

End Select Loop 'Increase counter for next Row Counter = Counter + 1 Loop End With

ParseFormula_Next: Exit Sub

ParseFormula_Error: Call RenderError("ParseFormula", Err.Description) Resume ParseFormula_Next

End Sub '**************************************************************************

'************************************************************************** Private Sub CleanAtomsWS() 'This Method clears all the cells in the "Atoms" Worksheet leaving only 'the headers at Row 1

On Error GoTo localErr

'... The range assumes Excel 97-2003 Worksheets("Atoms").Range("A2:IV65536").Clear

CleanAtomsWS_Next:

148

Exit Sub localErr: Call RenderError("CleanAtomsWS", Err.Description) Resume CleanAtomsWS_Next

End Sub '**************************************************************************

'************************************************************************** Public Sub CleanExergyDBWS() 'This Method clears all the cells in the "Exergy DB" Worksheet leaving 'headers and DataBase information only

On Error GoTo localErr

'... The range assumes Excel 97-2003 Worksheets("Exergy DB").Range("A22:E65536").Clear

CleanExergyDBWS_Next: Exit Sub localErr: Call RenderError("CleanExergyDBWS", Err.Description) Resume CleanExergyDBWS_Next

End Sub '**************************************************************************

'************************************************************************** Public Function UseFileDialogOpen() As String '... Uses the Microsoft Office Common Dialog to retrieve the case's path

Dim lngCount As Long

' Open the file dialog

149

With Application.FileDialog(msoFileDialogOpen) .AllowMultiSelect = True .Filters.Add "HYSYS Case", "*.hsc", 1 ShowDialog: .Show

'Make sure ONE file is selected If .SelectedItems.Count = 0 Then MsgBox ("Please select a file") GoTo ShowDialog End If

' Display paths of each file selected For lngCount = 1 To .SelectedItems.Count MsgBox .SelectedItems(lngCount) Next lngCount

' Return the Function value (File Path) UseFileDialogOpen = .SelectedItems(lngCount - 1) End With

End Function '**************************************************************************

'************************************************************************** Public Sub RenderError(ByVal strCalledBy As String, ByVal strError As String) '... Renders the Error Message in a Popup Window ' strCalledBy - String containing the Name of the Method or Function ' reporting the error ' strError - String with the Error Description ' MsgBox ("An Error occurred in " & strCalledBy & vbCrLf & strError)

End Sub '**************************************************************************