Development of A Process Simulator Using Object Oriented Programm
Development of A Process Simulator Using Object Oriented Programm
1992
Recommended Citation
Varma, Gadiraju V., "Development of a process simulator using object oriented programming: Information modeling and program
structure " (1992). Retrospective Theses and Dissertations. 10355.
https://lib.dr.iastate.edu/rtd/10355
This Dissertation is brought to you for free and open access by the Iowa State University Capstones, Theses and Dissertations at Iowa State University
Digital Repository. It has been accepted for inclusion in Retrospective Theses and Dissertations by an authorized administrator of Iowa State University
Digital Repository. For more information, please contact [email protected].
MlCROnLMfiD 1992
INFORMATION TO USERS
This manuscript has been reproduced from the microfilm master. UMI
films the text directly from the original or copy submitted. Thus, some
thesis and dissertation copies are in typewriter face, while others may
be from any type of computer printer.
In the unlikely event that the author did not send UMI a complete
manuscript and there are missing pages, these will be noted. Also, if
unauthorized copyright material had to be removed, a note will indicate
the deletion.
UMI
300N.ZeebRd.
Ann Arbor, MI 48106
Development of a process simulator using object oriented programming:
Information modeling and program structure
by
Gadiraju V. Varma
DOCTOR OF PHILOSOPHY
Approved:
Signature was redacted for privacy.
In Charge of Major Work
Signature was redacted for privacy.
For the MajoKBepartment
Signature was redacted for privacy.
For the Graduate College
TABLE OF CONTENTS
ACKNOWLEDGEMENTS viii
CHAPTER 1. INTRODUCTION 1
Process Simulation 5
Object Orientation 7
Process Integration 18
Units of measurement 41
Physical quantities 46
Dimensional expressions 47
Chemical components 51
iii
Physical properties 59
Flowsheet System 68
Balance equations 69
Process flowsheeting 76
CHAPTER 5. CONCLUSIONS 85
CHAPTER 6. RECOMMENDATIONS 87
BIBLIOGRAPHY 89
LIST OF TABLES
LIST OF FIGURES
ACKNOWLEDGEMENTS
giving me an opportunity to come to USA and work under him. His invaluable
My sincere thanks to Professor Les L. Miller for his kind and active involvement
in this work.
I would like to acknowledge the financial support from the department of chem
ical engineering.
I am very much thankful to my colleague Mr. Kheng H. Lau for his great help
I am grateful to my family and my wife's family for their support and encour
agement.
Finally, I appreciate very much the patience and understanding of my wife during
CHAPTER 1. INTRODUCTION
in the late eighties generated a rush of activity in the software arena. OOPL provide
a new approach for the design, development, and maintenance of software projects
resulting in improved software productivity and reduced software costs. Object mod
eling and overloading are two features of OOPL that distinguish them from their
are logical entities that exhibit the behavior of the real world entities in the prob
lem's domain. They also provide the tight coupling necessary between the data and
Overloading assigns an operation more than one meaning; it resolves the ambiguity
by analyzing the objects involved and performs the right action. An important con
sequence of the combination of these two features in OOPL is the language extension.
operations with respect to these new objects, the language is considered to be ex
tended to that application. It is this fact that makes OOPL attractive as software
platforms for a number of application areas. The application area of interest in this
through process design, plant startup and process control. It involves a number of
engineering disciplines and requires specialized software to carry out each task. Be
cause of the close inter-relationship among various tasks and the iterative nature of
the engineering process, the automation of the whole process requires either a com
mon platform around which all the applications can be developed or a one-to-many
interface approach that integrates all the applications involved in process engineering.
cess simulation is a well established design activity. Process simulation can be per
sign firm often may end up dealing with more than one process simulator requiring
specialized training for the personnel and forcing increased software costs.
simulation. Plant-wide energy integration using pinch technology and detailed heat
exchanger design can be performed with ADVENT. Since a typical design task in
volves more than one of these packages, and each package has its own data format,
the problem of data transfer among these packages arises. Manual transfer of data is
packages, the coordination among software vendors is difficult to realize and the
interface development itself is often not cost effective. With the realization of object
a viable alternative. There have been some efforts in the literature to use object
orientation to achieve process integration. They either use an existing object oriented
that integrates various related applications. The integration is achieved at the object
level rather than at the module level. The language extension feature of OOPL,
with the help of object standardization, can be effectively used to achieve process
integration.
Since the integration is at the object level, for each application to be integrated,
the design of objects present in that application must follow some standard design cri
teria. Efforts are under way to establish standards for process engineering data [25].
But there is neither an established criteria nor one being worked out for the design
of objects. The objective of this work is to develop an object oriented steady state
state process simulator that uses both sequential and simultaneous approaches is
developed and demonstrated here using the object oriented programming language
other graduate student. This thesis develops the information modeling and program
structure aspects of the simulator. The reader is refered to the thesis of Lau [8] for
4
the details of numerical procedures used and the results of convergence studies based
of developing the object oriented process simulator, an analysis of the object model
It is found that the object model has to be extended with operational behavior
greatly reduced by using the object oriented approach for the process simulator, ob
ject standardization including object design criteria is essential for achieving process
integration, OOPL can act as common platforms for integrating process engineer
ing activities, and C++ can be used effectively as an implementation language for
object oriented process simulation. The ease with which the sequential and simulta
neous approaches are incorporated into the process simulator reflects the potential
that the developed process simulator can be easily extended with dynamic simulation
Chapter 2 provides a review of the literature related to this work. Object model
system and flowsheet system. Chapter 4 gives a detailed description of the objects
Process Simulation
The existence of many commercial process simulators reveals that process sim
ulation is a well established design activity. Process simulators may follow different
approaches in handling material and energy balance calculations, but they all require
substantial effort for their development. Numerical computations and data manage
ment are the two features characteristic of process simulators. Here, we concentrate
designers who use the system. This requires that the process simulator deal with nat
ural objects. Some of the tools used by commercial process simulators are graphic
input interfaces, high level input languages for problem specification and graphic
report presentation systems. All these tasks require tremendous effort in software
development.
simulators evolve and hence they should be extensible with the addition of new unit
operations and modification of existing unit operation and physical property models.
This also indicates the importance of software maintenance. Also, designers of differ
ing expertise use the simulators. Thus a graphic interface may be an effective tool for
6
a novice user but not for an expert user who wants to explore the advanced capabili
ties of the process simulator. So, the process simulator should support differing levels
of abstraction and detail. This puts additional constraints on the development of ef
ficient process simulator. Process simulators are supplied by many vendors and the
lack of industry standards for process simulators leads to simulators with a variety of
interfaces. This puts more burden on the users who wish to learn and use various sim
ulators. This also makes process integration more difficult as will be discussed later
in this chapter. The peculiarity arising from the simulator support of two disparate
features: data management and numerical computations, leads more often than not,
to either the use of more than one implementation language (e.g. SPEEDUP) or the
development of additional software just to handle the data structures (e.g. ASPEN).
different approach. The development of the simulator starts with either the selection
with a process simulator (Figure 2.1). This reduces the process simulator develop
ment effort considerably and also permits us to focus on the application area (process
simulation in our case) rather than the software development necessary for the data
management support. Also, the selection and design of standardized objects has an
sible, limited only by the capability of the underlying OOPL. Also, the division of
the application space into objects and incorporation of objects into the programming
7
Process
Simulation
Object
Library
Object
Oriented
Programming
Language
as an OOPS
language provides the designers with a clear insight into the software structure. Since
a novice user will also be a programmer at a later stage, and since objects can be
used both by users and programmers, object orientation provides a natural solution
Object Orientation
We see more and more CAD applications relying on object orientation. Object
It is said to be at the center of the triangle with these three fields forming the ver
tices (Figure 2.2). Our interest in object orientation initially arose from an interest
8
Data Bases
Art£lcial Programming
Intelligence Languages
in databases. It has long been established that classical data models are inadequate
for CAD databases. The pursuit of new data models led to semantic, special purpose
and finally, object data models. When it comes to data modeling, the gap between
databases and programming languages becomes narrow, and the object model pro
vides the common interface. With our choice of process simulation as the application
sages and inheritance (generalization) constituting the object model. Any entity can
be treated as an object. An object consists of data and operations that act upon that
equipment unit, chemical component, equation, reaction and even numerical values
object such as flowsheet, we should identify the data associated with the flowsheet
9
Objaob Flowsheet
Simulate Display
and the operations required to analyze it. A typical flowsheet consists of a set of
equipment units. So equipment units are the data part of the object flowsheet.
the flowsheet, or display and draw the flowsheet. So, simulate, design, display and
There is a concept worth emphasizing here. In our view flowsheet is tlie object
and simulate is an operation around it. The output of the simulate operation is the
same flowsheet with more information (Figure 2.4). It is equally possible to view the
a simulator like ASPEN, does this (Figure 2.5). It emphasizes the simulator rather
than the flowsheet. The flowsheet information is buried into the input speciflcation
language. The output from the simulator does not signify the flowsheet either. In
fact there is no apparent relationship between the input and output of the simulator.
So, there is a choice among the views, and the choice of flowsheet as an object, is
preferable because it is natural to the designers. It is the flowsheet that we are sinni-
10
Object Object
Operation
Incomplete Completed
Simulate
Flowsheet Flowsheet
Object Data
Data
lating, not the simulators that we are flowsheeting. A single simulate operation may
be applied to many flowsheets, but a flowsheet does not operate on many simulators.
In fact a flowsheet operating on simulator itself is rather imaginative. The same sce
nario is supported in OOPL by differentiating between what is called class object and
instance object (Figure 2.6). An instance object contains the actual values (data)
and the class object contains the structure of the instance object. There can be only
one class object and many instance objects derived from that class object. Also, the
operations that can act on the instance objects are only a part of the class object,
not the instance objects. So, we can have many instance objects (differing in data
values) that use the same set of operations with similar structure. From Figure 2.6,
note that the data of an object consists of two parts: class data and instance data.
Class data is the data (both values and structure) common to all instances of a class
object. Instance data (only values not structure!) varies from instance to instance.
Viewing this subject from a different perspective, objects are nothing new to
piece of data and associated operations acting on that data. A function or procedure
takes arguments as input, and returns arguments as output. So, the function or
procedure is the operation, and the input and output parameters are the data. So,
here too we have data and operations. But one difference between OOPL and CPL
is the kind of importance we attribute to data. In OOPL, it is the data that has
operations; in CPL, it is the operations that have input/output data. The other
that data in an object can only be modified by the operations belonging to that
12
[ Class data ]
Simulate Display
Operations
if
F1 Instance object
(HX1,DST1,HX2)
Simulate
Object's operations
Object
X Bncapsulatli
Object
Creators
object. This statement has more implications than are apparent at the outset.
First, since a user cannot modify an object's data directly, there should be
somebody who will provide the user with the set of operations that act upon the
object's data. So, there should be at least two parties - a creator (programmer)
who creates the object (its structure and operations) and a user (group of users)
who works with the object. In Cox's terms [4], the users and creators correspond to
consumers and suppliers, respectively. A consumer can buy products (objects) from
different suppliers and store them in his storehouse (object library) and build his own
Second, since the operations act as a wall between the outside world and the
14
object's data, the way the user views the data may be completely different from
the representation of the object. The representation can be changed as long as the
previous operations are supported in the object's new representation. In essence, en
capsulation provides the logical data independence between the object and the users.
their capability. Encapsulation also supports the view concept of database models.
Many users can look at the same object from different perspectives. The differences
in the perspectives will be taken care of by the creator through the operations. So,
the users feel as though they are working with different objects tailored to their own
Third, encapsulation ensures that the object is consistent with respect to other
objects. Since the only way one can modify an object is through its operations, the
object's consistency is ensured as long as the operations are valid. It is the creator's
responsibility to provide a complete and valid set of operations, and to see that
various views co-exist. The user cannot perform a desired function on the object
unless the function is in the set of operations. This requires that the creator has a
Finally, encapsulation forces the user to identify the object first before he can
invoke an operation. One cannot invoke an operation without referencing the object
to which that operation belongs. (Remember that there will be more than one object
with a similar set of operations. In fact, all instance objects of a particular structure
15
object have the same set of operations.) This operation invoking is made possible by
the procedure should have at least two arguments: one, the message receiver (an
object); two, the message selector (an operation of that object). The reply from a
message varies from operation to operation. Some messages may have no replies; in
that case it is customary to return the receiver as the reply. A typical syntax for
messaging is shown in Figure 2.8. Languages like Smalltalk follow a clever approach of
making the arguments semantic rather than syntactic. They precede each argument
with the role of the argument (a colon separates the argument and its role), and
the concatenation of the roles form the operation to act on the object. The sender
of the message has to wait for the reply (may be a null reply) from the message
of control is still sequential but the way one looks at the execution mechanism is
different. Figure 2.9 shows the flow of control for creating the flowsheet object F1
and simulating it. Assuming that the flowsheet F1 contains a heat-exchanger HXl,
the flow of control goes to the Construct operation of the class object Flowsheet,
comes back, goes to the Simulate operation of the instance object Fl, goes to the
Simulate operation of the instance object HXl, returns from HXl, and flnally back
to the program. Messaging is the only way one can talk to the objects (through the
operations).
fields [12]. Inheritance is a kind of abstraction in which objects are viewed as hier
archies with specialized objects being at the bottom and generalized objects at the
16
/
Message
N Message
Receiver Selector
top (Figure 2.10). A specialized object possesses all the attributes of its generalized
object, besides having its own additional attributes. Also, since operations are part
of an object, they also adhere to inheritance and generalized operations may work
as an implementation tool rather than a programming tool. As far as the users are
concerned, inheritance is absent from OOPL. But the object creators use inheritance
OOPL may not be even realizable [4]. Also, inheritance removes the restriction of ob
ject development from base level. Object developers can use the existing hierarchical
objects at the base level to start with and can achieve higher productivity.
17
Instance object:
Class object: F1
Flowsheet
Data
Data
Program:
Simulate
Flowsheet F1
Fl.Simulate
HXl.Simulate
Simulate
Data
Analyze
Instance object:
HXl
Process Integration
A process design task consists of many phases and encompasses many disciplines.
Frequently, the output of one phase becomes the input to the next phase. Design
tools exist to carry out various design phases, but they are all independent and a
transition from one ])hase to another is not smooth. Process integration is the (ask
of combining these independent design tools to form a single design support system.
'J'he independent development of design tools means the current approach to process
integration is to create a one-to-many interface. That is, with each design tool, we
require additional interfaces to integrate that tool with its preceding and succeeding
difficult and sometimes impractical. This is because the software packages, around
which the interface is needed, will be supplied by different vendors and, quite of
ten, the design of these packages does not take into account the existence of other
packages that have to be interfaced later. For example, when the implementors of
ASPEN-PLUS realized the need for the management of flowsheeting data gener-
19
atecl by their simulator, they turned to the relational database management system
PR0DA13AS [25]. But, since PRODABAS was not their own product, and PROD-
between those two was necessary, and they had considerable difficulty in realizing the
interface.
Object oriented process integration assumes that all the design tools are devel
oped around a single object oriented programming system (Figure 2.12). Also, the
that conventional and object oriented approaches do not differ in their need for ob
ject standardization. But the objects in the object oriented approach make object
j)ropose a one-to-one interface approach, la this approach, a design tool needs a sin
gle interface with the semi-standard object with which it is interacting. This reduces
20
Process
Oriflae Simulation
Sizing
OOPS
OL OL
as an
Executive
Piping
Layout
Equipment
OL Design
OL
the number of interfaces considerably, and at tlie same time provides for software
design tools.
Early efforts at adapting object orientation to chemical CAD can be attributed
and combined it with an object oriented CAD DBMS to form a complete object
The importance of object orientation for process integration was pointed out by
Yamashita and Motard [24]. Their interactive programming environment VSM (writ
software. They acknowledged the importance of object modeling and expressed con
cern over the lack of proper object design methodology [9, 6, 10]. They used their
in-house design tools: spreadsheet, sequential modular simulator (CHESS) and re
lational DBMS (CADRE) to show how they could achieve process integration using
VSM. In essence, their VSM acts as an object oriented interface between the users
and existing software and other design tools. They also showed the application of
VSM to object oriented dynamic simulation, again using existing software as far as
possible. Since VSM is not a true object oriented programming language and the enti
ties involved in integration were never re-designed using object model, the suitability
work, follows homogeneous integration, with the development of all design tools from
mon Lisp (and its derivative, KEE). They also stressed the need for more work on
In a more recent work, Stephanopoulos et al. [13, 14] developed a new modeling
found in process engineering. The knowledge is collected using some basic modeling
elements and relating them through fundamental semantic relationships. Their work
22
closely resembles the one in this thesis. It tries to cover the entire process engineering
cycle without particular emphasis on any one activity. In comparison, the present
work concentrates on process simulation activity alone. Also, the emphasis of the
present work is not on developing a new modeling or programming language but to use
an existing object oriented programming language and its accompanying object model
languages for process integration limits the integration only to process engineering.
Another modeling language that has been developed using object oriented mod
eling concepts is that of Piela ei al. [11]. The language allows the definition of a
the solution of it. It treats even the solution schemes for the equations as models,
thus allowing the user to specify new solution methods for solving equations. But it
appears that the modeling elements present in the language allow only a restricted
set of methods to solve ordinary differential equations, thus limiting its versatility.
The present work also supports equations as modeling elements to define a physical
Objects are central to the theme of object orientation. OOPL allow objects to
be created and manipulated. But they don't carry the methodology to identify and
entities and intricate relationships among them. The division of an application space
into various objects capturing all the intricate relationships, within the constraints of
As discussed in the previous chapter, the object model of OOPL supports concepts
sulation. The following questions arise as one tries to identify the objects using these
concepts;
This arises from the fundamental definition of the object itself. For example,
and simulator.flowsheet. Since the relation between data and operation is many
to one and also since it is clear that we can use a single simulate operation
to simulate many flowsheets, in this case, flowsheet becomes the object and
This arises from the concept of aggregation, which allows related entities to
consider a broader view as shown in Figure 3.2, we may ask ourselves whether
different? The first approach [6] organizes time and temperature into their
respective units. Note that there is one-to-one correspondence among these
units (e.g. 1 hr = 60 min = 3600 sec). The second approach identifies unit as a
separate object and places time and temperature under yet another new object
physical quantity. Contrary to the first, the second approach does not treat the
specific units (s, min, C) as separate objects but as instances of the object unit.
At first sight, it appears that approach 1 is simpler and easier to use, but the
Component flowrate
Component
Name
Component PC
To
— Name
Flowrate
— PC
— To
Variation 1 Variation 2
Stream Stream
Temperature Temperature
Pressure Pressure
Sequence of component
Set of Component flowrate
Sequence of flowrate
Component flowrate
Component
Flowrate
all velocity units and put them under velocity. The decision of whether to treat,
without going through the object's ojîerations. How many operations are we
going to provide for an object? How do we know that the provided operations
are sufficient? What is the guarantee that an object does not have interac
tions with the new objects, or new interactions with the existing objects? A
antee that the object design is perfect and complete in view of the emerging
27
s min hr b Symbol
Dimension
— M
L
— T
t
Temperature Physical quantity
Magnitude
C F R Unit
Time Temperature
Approach 1 Approach 2
Approach 1 Approach 2
software maintenance.
Object selection and design is critical for the success of OOPL. Also, process
designed following a well established object design criteria. Without a proper object
design criteria, the independent efforts in selection and design of objects provide not
much more benefit than that of conventional programming. In spite of the obvious
need for an object design criteria, as yet, there does not exist any object design
way to build the object oriented process simulator. Based on our experience gained
in developing the process simulator, we provide below a list of guidelines for object
design:
1. The relation between data and operations is many to one. Also, operations
characterize data.
a generalized object.
objects.
29
5. Provide a minimal and convenient set of operations that satisfy all the require
7. Prefer top-down design. A top-down design identifies all the top-level objects
10. Achieve modular design. Divide the application space into categories of closely
related objects (object modules). Object modules provide greater flexibility for
objects usage.
are user extensible if the extension is at the instance object level. Programmer
13. Make object modules includable. An object module should be usable in another
entities of process simulation. We argue that, with the present modeling constructs
30
for the operations of an object, it is difficult to represent all the entities of process
simulation, so the modeling power of operations around the data of an object need to
be explored further. For example, take the physical property system. If we consider
the component as an object, physical properties like enthalpy and density become
its operations. We know that there is more than one method for calculating en-
halpies. So, a term like component .enthalpy will be incomplete unless we specify a
method that estimates enthalpy. We can identify all the enthalpy estimation proce
dures, name them differently and call a particular procedure to calculate enthalpy
But each of these procedures do not know the existence of the other and we are
essentially losing the fact that the operation enthalpy is a generic name for various
enthalpy calculation routines. Also, a user does not want to specify his choice of
enthalpy estimation method every time he wants to calculate the enthalpy of a com
ponent. Instead, he specifies once and intends to use the same procedure until he
overrides it. To support this scenario, we need to enhance the existing object model
We can see that if we assume data and operation of an object as separate entities,
there is a binary relationship between the two. Also, the binary relationship is one
sided, since we distinguish between data and operation and only data, operation is
meaningful, not the operation, data. If we go one step further and make a one-sided
binary relationship (a.b), a two-sided one, then (a.b) and (b.a) should be identical
and both data and operation should be objects. This eliminates the dilemma of data
31
Operation
Sub opl
Sub op2
Altl Alt 2 Alts
Sub op3
Sub opl
Sub op2
Sub op3
and operation distinction. At first glance, this two-sided binary relationship appears
to have solved the problem of operational behavior, since the earlier operation can
now be treated as an object and can be described with the original concepts of the
object model to reflect its behavior. But, it generates a whole new set of problems
as to which the entity (a.b) belongs - to a? to b? or to both? Also what about the
concept of encapsulation?
The disadvantage of the binary relationship is that we cannot relate more than
two entities directly. If we go even one step further and make a binary relationshi]),
also reduces the number of arguments to be passed to the operations. For example,
of state (vapor, liquid, solid) we can get the enthalpies of a chemical component for
diflerent states. Of course, as we can see, the higher the order of the relationship.
32
the more complex it is to interpret and maintain the operations involving the related
objects.
tion, more or less similar to that of objects, provides a reasonable and simple modeling
ponent is an object (data) and enthalpy is an operation for the component, but now,
works fine with individual objects, but fails with groups of objects. For example, in
physical property system, we can see the object component and the object component
set. Component set is a collection of component objects. The object component can
be specialized into molecular component, coal component, ionic component etc. But
the same thing cannot be done with the component set, molecular component set,
coal component set etc. because when we say component set it means collection of
components - in fact, all types of components. So, this makes the specialization of
uralness and storage space, even though both are important. An example illustrating
this fact can be taken from the physical quantity system. There the object physical
quantity is specialized into length, area, dimensional etc. To save space, physi
cal quantity does not have dimensional information, because not all objects under
it require the dimensional information stored within them. Only the instances of
the object dimensional contain specific dimensional information. So, it is not clear
whether the object physical quantity or the object dimensional is the generic object
33
quantity and calling it the root of the hierarchy is more natural but wasteful of space.
A problem involving both the object model and the programming language is
the definition of a complex object. A complex object is one that is either big enough
all the information pertaining to it when it is constructed. In that case, how can it
have to be initialized (flashed, in this case) before they can be used. The objects are
called semi-automatic because the user may not give the full data of the object but
expects the program to fill in the remaining data. To address this problem, a new
concept called state of an object may have to be defined in the object model. The
user can start with an empty object, add the necessary data and fix its state. Once
Object model does not enforce every object to have an external identity. But
objects for comparing the objects is a good choice, but is implementation dependent
and not advisable. Objects may have their own identity based on some key, but
unless it is required by the object model, the uniformity is lost. The current work
gramming language should support the following programming features to make the
34
programming simple. Note that our comments apply mainly to C + + , since that is
our implementation language. Languages like CLOS support some of these features.
1. Ability to know the names of the instance objects. This reduces the user input
data.
2. Facility for dynamic expression evaluation. Without this feature, we lose the
programmer convenience.
4. Ability to access the object's meta data besides the object's data. Meta data
is the data about data. An object's meta data includes its type, name and its
at will and may remain without being used by anyone. The unused objects
7. Move some of the run-time error checking to the compilation step by allowing
8. Ability to define objects as restricted that makes some of the operations more
efficient.
Automatic freeing of unused space is very important and worth some discussion.
Process simulation involves complex objects and when it is necessary to copy objects
35
from one to another, the copying operation becomes very expensive and sometimes
infeasible. Also, a simple object may be shared by more than one complex object.
So, when the complex object is deleted, the simple object within it should not be
deleted unless it is not pointed to by any other object. Since C++ does not support
our own. This increases the programming effort and also makes the programming
difficult.
There are many schemes to restore unused space. The technique used in this work
is based on reference counting. Every object contains a count that tells the number of
references to that object. The object will be deleted when its reference count goes to
zero. To support reference counting, an object has to be divided into two parts: data
part and pointer part. The pointer points to the data part. When an object is copied
from one to another, the data are not copied but its count is increased by one and
the new object points to the old. Because of the use of reference counting, an object
can stay out of its scope. (A scope, in programming language sense, determines the
life of an object.) This in turn requires the object's data to be stored not on the
stack but on the heap. (Again, a stack is a part of the computer memory that will
be used by compiler as a storage space. Heap is also a part of the computer memory
but will be used by the programmer as a storage space.) Since storing objects on the
heap is much slower than on the stack, the price paid in supporting complex objects
is obvious.
One of the main advantages of using reference counting is that it makes the users
feel they are working with objects rather than pointers to objects. The disadvantage
of using reference counting for complex objects is that if an object points to itself
36
either directly or indirectly, it is never deleted. The division of an object into two
parts makes it unnatural to the users. Use of a pointer to access an object's data
makes the operations slower. Since, quite often, not all objects are complex and
storing of simple objects on stack is much faster, we will end up with two type of
objects thereby losing the uniformity. In spite of these disadvantages, the technique
of reference counting has widespread use and consequently it is used for storing and
The approach used in this work to develop the process simulator is to choose
tation language and extend it with objects specific to process simulation. Other
approaches either develop new object oriented programming languages tailored for
ulators. The premise behind the present work is to use an existing object oriented
programming language that is easily available to all and explore its suitability for
process simulation. The well known C++ is used as the implementation language
One important point to note here is that the use of object oriented programming
to develop process simulators does not change in any way the conventional process
simulation calculation methods or unit operation models. The same physical property
are used, except that the way they are incorporated into the computer program (the
that is procedural (i.e. that allows a sequence of instructions) recognizes two enti
ties: data and procedures. In a conventional programming language, the data and
guage the data and procedures are clubbed together to form what is called object. It
is the identification of these objects and defining them into the programming language
This chapter describes the objects that have been identified and defined to per
form process simulation using C+ + . The complexity of the process simulator made
it necessary to divide the information content in the process simulator into easily
manageable components. Three major components were identified. They are Physi
cal Quantity System (PQS), Physical Property System (PPS) and Flowsheet System
the process simulator. PPS makes possible the calculation of physical properties for
picture of the objects that were defined and their inter-relationships. Note the close
interaction between the FS and the PPS. Also the hierarchy is obvious. The FS
includes both the PPS and the PQS. The PPS includes only the PQS. The PQS can
Since C++ does not support garbage collection and the inherent nature of simu
lation requires objects to be created at random and destroyed if unused, the technique
of reference counting, as discussed in the previous chapter, is used to monitor the life
of an object. The object dynamic and its associated object dynamic record facilitates
the implementation of the reference counting technique. Eventually all complex ob
jects (i.e. objects that are either big enough or contain references to other objects)
are divided into two parts: object and object record, and inherit the properties of the
39
Flowsheet
t Equipment units
Constraints
L Streams
FLOWSHEET SYSTEM
Phase mixture
J
Phases J
Component mixture J
Components J—J PHYSICAL PROPERTY SYSTEM
Physical quantity
L Unit
L Dimension
Dynamic
^— Count
11
Flowsheet •" Flowsheet record
dynamic and dynamic record objects. Figure 4.2 illustrates the concept of treating
flowsheet as a dynamic object. Almost all objects of the FS and the PPS are treated
as dynamic objects. To make the understanding easier, the rest of the discussion does
not divide objects into its constituent parts: object and object record, even though
they are implemented in that fashion. Appendix A contains a list of all the objects
defined in the process simulator. Also, the user is allowed to manipulate only the
objects, not their record parts. This makes it clear the the division of an object into
I,wo parts is just to facilitate implementation and the user need not know anything
The rest of this chapter discusses the three major components of the developed
in C!++, since it is the implementation language. The reader is referred to [16] for a
detailed description of the C++ programming language. The examples given here do
not assume any proficiency of the reader in C++. Appendix B gives an outline of the
exam])les.
41
quantities), real (for real precision numbers) or double (for double precision numbers),
while physical quantities like length, velocity and density are of primary interest to
the process designer. In contrast, conventional process simulators carry the notion
of units and physical quantities, but they bury the concept into their input language
thereby reducing its functionality. PQS fills this gap being an independent and
major component of the developed process simulator. There have been efforts to
support dimensional quantities in OOPL [5], but they tend to be incomplete for the
chemical process design environment. The approach used in this work emphasizes
object modeling, eliminates most of the constraints of the previous approaches and
is far more extensive. Figure 4.3 shows the relationship of the objects defined in the
PQS.
Units of measurement
Physical quantities such as length and density have units. Units in turn have di
mensions. Dimension is defined in terms of the primary dimensions like mass, length,
time and temperature. Table 4.1 shows the operations defined around dimension.
These operations allow the generation of derived dimensions from the primary di
mensions. Examples of derived dimensions are the dimensions of force and energy.
A dimension can be raised to any power, real or integer. As shown in Figure 4.4,
this allows the definition of physical quantities like dipole moment which involves
Operations similar to those around dimension are defined around unit. Each
42
Physical quantity
L .
'— Dimension
Unit
Difference
L Dimension
Prefix
// Primary dimensions
// Derived dimensions
II Input/Output
Dimension P; // Power
cin » P; // ML[2]t[-3]
cout << P; // ML[2]t[-3]
cout << E; // ML[2]t[-2]
cout << V; // L[3]
cout << D; // M[0.5]L[2.5]t[-l]
unit is uniquely identified by a symbol. Two units are said to be equivalent if they
both have the same dimension. To convert a physical quantity from one unit {x) into
where a is the conversion factor. This simple form fails to convert some of the physical
quantities like temperature from one unit into another. A conversion function of the
form y = ax + b where a and b are the conversion constants works for all engineering
units [19]. Consequently this is the form adopted in the PQS. For example, to convert
carries with it two conversion constants; conversion factor (a) and conversion offset
(6). SI is chosen as the reference unit system to store the conversion constants of all
units. This implies that the conversion factor and conversion offset of all SI units
are 1 and 0, respectively. A unit's conversion constants are the constants when it is
converted to its equivalent SI unit. For example, the conversion constants for C are
1.0 and 273.15. Figure 4.5 shows how complex units can be built from simple units.
Prefixes are short-hand notation for powers of. ten. They considerably improve
unit with null dimension. Only the multiply operation of unit is needed for prefix.
Unit set is a collection of units. All miscellaneous units which do not belong to
any unit system can be grouped together using unit set. Unit system is a unit set with
the restriction that no two units are equivalent. Unit system can be used to support
measurement unit systems like SI, ENGLISH and METRIC. Note that, contrary to
unit system, unit set can contain more than one unit with the same dimension. The
operations around the unit system allow the user to switch from one unit system
45
Il SI units
// ENGLISH units
// Miscellaneous units
// Input/Output
// prefixes
II use of prefixes
to another for input/output of physical quantities, to create new unit systems that
contain units of user's preference, to copy one unit system to another and to display
a unit system. Similar operations are also present around unit set.
Physical quantities
sity. Quantification of a physical quantity requires two items: numerical value and
unit. But by sticking to a single unit system (SI in this work) for storing physical
quantities, we can eliminate the need for the second item, unit. This is reflected in
Figure 4.3, which shows the object physical quantity and some of its derived objects.
The input and output unit systems facilitate the input/output of physical quantities.
Physical quantities like length and velocity are dimensional quantities. The
specialized object dimensional, under the physical quantity, represents all the dimen
sional quantities that are not explicitly present under physical quantity (Figure 4.3).
47
An example of dimensional is the ideal gas constant (Figure 4.7). Note that, contrary
to physical quantities like length, dimensional objects can have different dimensions.
Also, a particular dimensional object can have different dimensions at different times
(Figure 4.8).
Dimensional expressions
Directly following from the dimensional quantities are the dimensional expres
mensional quantities (Figure 4.8). A dimensional expression is valid only if the di
mensions of its Ihs and rhs are equal. Also it is meaningful to add/subtract only
dimensional expressions.
Sometimes we find dimensional expressions whose Ihs and rhs are not dimen-
design fall into this category. We call these expressions empirical expressions. Em
// normal expression
// r = 1.987 cal/gmol/K
double r = 8320.0; // = 8320 J/kmol/K
double p = 101325.0; // p = 1 atm = 101325 Pa
double t = 298.15; // t = 25 C = 298.15 K
double v; // V = ?
V = r * t / p; // normal expression
cout << v; // 24.48 cum/kmol
Il dimensional expression
Length 1(3,cm); // 1 = 3 cm
Dimensional s(20,kg/cm); // s = 20 kg/cm
s = 1 * s; // s is now mass (s = 60 kg)
For example, to calculate the volumetric flowrate through a valve in a liquid storage
tank, an equation of the following form is used: q{cxtft/s) = 0.27^dh{ ft). Figure 4.9
normal and difference quantities. A difference quantity, as the name implies, is the
difference between two values of a physical quantity. Change in pressure {DP) and
physical quantity. Physical quantities like temperature difference are defined as dif
into difference dimensional to account for difference quantities that are not specifi
cally categorized under physical quantity. Figure 4.10 shows a programming example
The fact that all the objects in PQS have input/output operations defined around
them makes the PQS very powerful for entering/displaying physical quantities in user
preferred units/unit systems and for writing interactive programs such as unit con-
50
Temperature T(25,C); // T = 25 C
Temperature.difference DT(25,C); // DT = 25 C
cout << T; // 298.15 K
cout << DT; // 25 K
T = T + DT; // dimensional expression
cout << T; // 323.15 K
verter, that converts physical quantities from one unit to another. An interactive unit
converter was written using PQS that was less than thirty lines of source code. This
productivity. The stand alone nature of the PQS makes it useful not only for process
simulation but for any application that deals with units of measurement. This kind of
reusability is another attractive feature of object orientation that makes the software
Physical property calculations play a major role in any process simulator. The
material and energy balance calculations of the Flowsheet System, FS, make use of
the property estimation procedures of the PPS. The design of the PPS affects the
bank and physical properties are the major constituents of PPS. Even though the
PPS and the FS are two separate components of the process simulator, the interaction
between the two does not allow an independent design of these two systems. Since
PPS involves physical quantities like enthalpy and density, its development requires
51
the PQS. Figure 4.11 shows the relationship among the objects defined in the PPS.
Chemical components
Chemical components or simply components form the basis for PPS. Compo
nents are defined as objects and the physical properties as the operations around
mineral solids, petroleum and coal liquid fractions. The diversity arises from the
establishes the data required to identify that component and deduce the physical
properties of that component from the component data using various physical prop
terization and their characterization stems from theoretical principles and empirical
correlations [18]. Non-conventional coal and other mineral solids are characterized in
a variety of ways and none of the schemes provide a complete identification for these
components with the result that all or some of them are used to estimate their phys
ical properties. For example, coal characterization schemes include ultimate analy
scheme for petroleum and coal liquid fractions and the subject is still under active
research [17, 23]. Assay data analysis in terms of boiling point and specific grav
ity curves and pseudo-component methods provides one way of characterizing these
used to convert assay data analysis from one type of boiling point curve to another
52
Phase mixture
L Phases
Component mixture
Reaction
L L Components
Participants
L
H— Component
L Formula
i
' State A
Physloal
Properbles
Methane
Denalty
Enthalpy
and also the empirical correlations used to generate the pseudo-components from
these boiling point curves and to establish the identity of these pseudo-components.
uous mixture is gaining acceptance in the literature [22]. There are some components
like charcoal which can be treated as both conventional components (carbon) and as
ponent hierarchy. Note that the same compound (say coal) depending on its phase
Figure 4.13 shows the component hierarchy as defined in the PQS. Compo
petroleum components can be further specialized from the molecular component but
they haven't been implemented in the present work. Ionic components are required to
Note that pseudo-components are useful only if the petroleum fraction is treated as
continuous mixture, a new type of component has to be defined with physical prop
erty calculation methods radically different from those used for pseudo-components.
methods for process equipment, arriving at a fixed software design of the process
simulation application will never be realizable. But the challenge for the process
using techniques such as object orientation, coming up with a software design that
Properties such as enthalpy, density, Gibbs free energy and fugacity coefficient
can be calculated for a component using its operations. The details of these physical
property calculations can be found in the work of Lau [8]. We rarely work with just
another object defined in PPS. Similar to component, component mixture also has
mixture make use of the physical property operations of the pure components. Since
various types, component mixture also needs to be divided into various types. Fig
ure 4,13 shows that component mixture is divided into molecular component mixture
and mixed component mixture, A mixed component mixture, as the name implies, is
I I
Molecular Coal Component set
Component pairs
I— First component
only molecular components. In the present work, again, component mixtures such as
electiolytes and jietroleum fractions are not implemented, but they can be included
without too much effort because they eventually make use of the operations defined
Component pair can be used to store the binary parameters. Also, some of the
binary interaction parameters may not be symmetric and this requires the component
pair to be ordered. That's the reason why the components in a component pair are
named first component and second component. The user has no control of specifying
the names of the two components. This makes it much easier for the user to simply
specify the interaction parameters for a pair of components without worrying about
their order in the component pair. Let us say we have 10 components and we would
like to store a binary interaction parameter for those components. That requires 45
is clear that for components in the range of hundreds (which is not uncommon in
industrial processes), a huge amount of data space is required to store the components
and their associated binary parameters. This requires only the components required
others must be stored in the secondary storage such as disk. Note that some of
the physical property models (e.g. liquid phase equilibrium calculations) require
ternary interaction parameters, besides binary parameters. This increases the storage
space requirements tremendously. A data bank that stores all the components and
Components and component pairs used in the component mixture are placed
in the object component set. By doing so all the material streams present in the
flowsheet can share a single set of components, which reduces duplication to a great
extent. It is often the case that the same components are used throughout the
flowsheet and if the data of a component is changed the changes need to be reflected
everywhere. As shown in Figure 4.13, component set is further specialized into molec
ular component set. Molecular component set contains only molecular components
and molecular component pairs. It can be used to store components and component
ing atoms and their atomic weights facilitate the calculation of molecular weight for
the formula object. Chemical components participate in reactions. The state of the
component participating in the reaction can be solid, liquid or vapor. Also, compo
of component, state and stoichiometric number yields the object participant. The
object reaction contains reactants and products. Reactants and products are a set of
participants. Figure 4.14 shows an example involving reaction. It can be seen that
starting from simple objects, using object modeling concepts such as aggregation and
phases. There can be any number of phases in a phase mixture. Also, the phase
molecular phase mixture allows only equilibrium phases. When physical properties
are requested, a molecular phase mixture uses flash calculations to establish the
phases from the total component mixture present in it. In the present work, only
two phase (vapor-liquid) flash calculations are performed, but three phase (vapor-
liquid-liquid) calculations are also quite common in process simulation and they can
be incorporated without much effort. Phase mixture can eventually be used as part
// Atoms
// Formulas
II Components
// Reaction
Physical properties
we have to specify the state of the system such as the temperature and pressure.
together rather than independently, for example, enthalpy and temperature derivative
of enthalpy. In general, a physical property procedure takes the state of the system as
input and returns as output one of simple property or aggregate property. To support
this kind of scenario, the object property value is defined. .4n example of a simple
In the approach used in this work, physical properties form the operations around
different physical properties depending on its state (solid, liquid or vapor). The
object property method contains the information necessary to calculate the physical
a component mixture. Property can be any physical property like enthalpy or density.
Property function is the name of the procedure that implements the physical property
Invariably, there will be more than one method of calculation for any physical
property. These methods vary in their accuracy and applicability. The object prop
erty method set implements this fact. It is a collection of property method objects.
equations of state exist which differ in applicability. So, to calculate the vapor en
thalpy of a component, we may have three property methods: one using ideal gas,
one using SRK equation of state and one using PR equation of state. All these may
be put in the property method set to tell the programming system that there are
erty operation may have many alternatives. Each alternative may have one or more
sub-operations. The sub-operations in turn may have alternatives and so on. This
sort of tree structure is evident among the physical property procedures of process
simulators.
Also, in a simulation run or property run, the user wants to specify the physical
commercial process simulators using an option set for physical properties [18].
Unfortunately, the object model of OOPL does not support any modeling fea
tures for the operations. For example, an operation cannot know its sub-operations
that constitute it. As discussed in chapter 3, this is one of the drawbacks of the
object model of OOPL and further work needs to be done to enhance the object
modeling features. Since object modeling is being used in this work, and the object
model does not support operational description, the object property method system
is defined, the primary purpose of which is to support the user in controlling the
physical property calculation procedures. We also note that, the physical property
tree shown in Figure 4.15 is too general and our object property method system rep
resents a simplified version of it (Figure 4.16). The major difference between these
61
„/ \ O - Operation
A1) f A2 ) A - Alternative
'—^ ^^ S - Sub-operation
two choices is that in the first case, an operation present in more than one place may
use (lifTerent procedures for its calculation. This is not allowed in the second case
and hence all the operations are at the same level. The simplified physical property
tree will be sufficient for a realistic physical property system and consequently that
The object property method set contains a set of property methods. Two prop
erty methods are said to be equivalent if they specify for a substance, in a particular
state, two different property functions for the same property. The object property
to a unit system where there won't be more than one unit with the same dimension
in a unit system. Propei'ty method systems such as IDEAL, SllK, PR can be either
pre-defined or the user can define new property method systems based on existing
(5 © © © ©
O - Operation
A - Alternative
Enthalpy
Density
SRK enthalpy
SB PB PR enthalpy
SRK density
PR density
property methods. Similar to the unit system, there will be a default property method
system defining the properties calculated for a substance. When the property of a
find out which property method is present for that substance and for that property,
and once it is found, it is used to calculate that property. Note that a property may
When a major property is requested for a substance, the major property gets the
specific property method from the default property method system. The specific
property method will in turn go to the default property method system to get the
exceptions to this are in situations where the major property of a substance requires
its sub-ordinate property to be calculated using the the same calculation method as
the one used in the major property calculation. For example, to calculate the vapor
enthalpy of a pure component, if the default property method system contains the
which is required in the calculation of enthalpy using the same SRK equation of
state, even though the default property method system contains the PR method to
all the component data. During a particular simulation or property run, only those
components of interest should be retrieved from the data bank for program use, saving
the core memory. Component and component pair are the objects that will be stored
64
— Modify — Modify
. Traverse
~~ Allooate_spaae
— Deallooatespaoe
— Pill_spaoe
Read spaoe
Persistent
Retrieve
Modify
Remove
in the object data bank. Component contains the universal constants and model
The object data bank stores information about the objects component anil com
ponent pair. How will it know how to store an object? Obviously, the dala bank will
have no idea of tlie structure of the object. So, it simply asks the respective object
to get itself stored in the data bank. Now, the stored object takes control and taking
66
the help ol'storage management operations of the data bank, gets itself stored in the
data bank. Hence, the data bank merely acts as a mediator between the object and
the user (Figure 4.19) and provides permanent storage facilities for the objects. 'J'he
only intelligence the data bank has is that it knows what objects it contains, but does
not know how it is stored. However, with this little knowledge, it can, il" necessary,
approach the respective objects and can manage the information contained within it.
All objects that have to be stored in the data bank have to be put under the object
persistent (Figure 4.18). Data bank and persistent talk to each other through the
The object data index allows the data in the data bank to be stored as a tree-like
structure. This tree-like structure allows fast access to individual objects from the
disk. Data index is implemented as a B-tiee. B-tree [7] is a data structure that
provides fast access to external information (information that is stored on disk in the
form of files). It is a multi-way search tree, with some restrictions on its growth I hat
will minimize file accesses. Data index contains a set of keys with their respective
data values. So, given a key, it searches the tree to get the data belonging to that
key. The length of the key and data fields can be specified when the clala index is
67
Cl 02
02 03 04
C - Component
BP BP - Binary parameters
constructed. Objects use data index to their advantage to store data, in the object
data bank. Figure d.lS shows the operatioJis around data index. When a new data
bank is created, it starts with a top level empty data index. This tree contains as
key, the object type (component, component pair etc.) and as data, a pointer to
some space in the data bank. Objects store their data using whatever approach they
i'eel is best, and pass the top pointer back to the data bank. Data bank stores the
pointers under the key belonging to that object's type. To store the data belonging
to it, component creates a new data index, the key being the name of the component,
and the data being a pointer to the storage space in the data bank that contains
the component data. On the other hand, component pair creates two levels of data
index, one for storing the second component and the otiier for storing the binary
interaction parameters as shown in Figure 4.20.
A default data bank called public data bank is created and loaded with a number
methane.acentric_factor(0.012);
methane_ethane.srk_kij(-0.003);
nent or component pair is defined in a program, the public data bank is automatically
searched and retrieved if it is present in the data bank. The user may specify a par
ticular data bank to be searched for a component instead of the public data bank.
Since a data bank can be copied from one to another, the user can make a private
copy of the public data bank and make modifications to the personal copy by adding
Flowsheet System
simultaneous equation based approach. In the sequential approach, each process unit
69
present in the flowsheet is represented by a module and the modules are solved in
sequence. Each module takes the inlet streams of the process unit as input and
performs the material and energy balance calculations using the modeling equations
specific to the unit operation being carried out in the process unit. The output of
the module is the outlet streams of the process unit. In the simultaneous approach,
all the modeling equations of all the process units present in the flowsheet are solved
simultaneously without the need for any sequence. Some of the variables are known
and the rest are unknown, and the number of equations must be equal to the number
of unknown variables in order to solve the resulting consistent set of equations. Both
approaches have advantages and disadvantages. The objects in the Flowsheet System,
FS, are designed in such a way that both sequential and simultaneous approaches to
flowsheet calculations can be supported. Figure 4.22 shows the relationship among
Balance equations
Process simulation involves solving the material and energy balance equations
for all the process units present in the flowsheet. Figure 4.23 shows the hierarchy of
objects created for supporting equations. The object equation variable is different
value won't be evaluated immediately, but stored as an equation expression. The ob
ject equation represents the mathematical relationship among the equation variables
present in it. Not just one equation, but hundreds of them are required to model
any sizable process flowsheet. The object equation set is a collection of one or more
equation objects. Equation solution procedures are built around the equation set.
70
Flowsheet
b Equipment units
a4> v>B 4
Constraints a I
Flowsheet
b Streams
Constraints
Ordered Unordered
Equipment unit
Constraint
Stream
Material Energy
Molecular
Equation set
— Equations
Matrix
— Sparse matrix Equation expression
Static Dynamic
x\
Double Dimensional Independent Dependent Derivative
Equation
Static Dynamic
Procedural object
Equation set
— Equation variables
Number of equations
Function values
Static Mixed
~ Evaluate
— Evaluate approximate
the equations and hence, equation variables and equation sets are divided into various
that are not functions of time or any other independent variable. Dynamic equations
model equations that are functions of time or any other independent variable. Static
and Dynamic equations are divided again into algebraic and procedural equations. In
process simulation, the majority of balance equations involve physical property calcu
to include the equations and variables involving physical property calculations into
the general set of equations and variables. Instead, the equations involving physical
properties are solved separately from the main set of equations. The commonly used
technique is that at the beginning of each iteration, the equation solver calculates all
the physical properties necessary for the main set of equations. The technique used in
the present work is not to perform physical property calculations at the beginning of
each iteration, but to integrate them into the main set of equations using procedural
equations. This provides the uniformity necessary for good object design. Using this
new technique, the physical property calculations are still solved separately from the
main set of equations but they are not visible to the equation solver. Procedural
it has as its data: equation variables, number of equations and function values, and
as its operations: evaluate and evaluate approximate. To get the function values of
a procedural equation (Note that a procedural equation may in fact represent more
73
Equation.variable X;
Equation.variable Y;
X « 0.5; // X = 0.5
Y « 0.3; // Y = 0.3
Equation.set s (e,f);
s.solve 0 ;
cout « X; // X = 0.7574
cout « Y; // Y = 0.0426
than one equation), the evaluate operation of the procedural object is executed. The
operation evaluate approximate may be used to get approximate function values when
the rigorous evaluation of the equations is too expensive and approximate function
values are sufficient. An example where approximate function values are sufficient is
when the equations are perturbed to get the interaction of the variables present in
the equations. Figure 4.24 shows an example involving equations.
approaches, an equation variable is allowed to have direct link with a normal pro
gramming variable. Since the simultaneous approach needs good initial guesses to
arrive at a fast converged solution, and the sequential approach with its robust in
dividual equipment models can provide good guesses, the switch over between these
like double (in C+-I-, double is a data type for representing double precision num-
74
double d = 2; // d = 2
Temperature t (300,K); // t = 300
cout << D; // 2
cout << T; // 300
d = 4; // d = 4
o
o
T « 400;
II
cout << D; // 4
cout << t; // 400 K
bers) which will be used for the sequential approach and equation variables which
will be used in the simultaneous approach. The static equation variable is in turn
divided into double and dimensional equation variables. Since in process simulation,
dimensional variables (physical quantities) are used even more frequently than dou
able and a derivative variable. A variable like time can be defined as an independent
variables.
An equation expression provides the link between equation variables and equa
which every node points to two more nodes. Since most of the arithmetic operators
involved in an equation expression are binary (binary operators take two operands)
binary tree is a natural data structure for storing the equation expression. When
an equation has to be evaluated, the binary tree of the equation expression will be
traversed.
Numerical solution of the equations requires the object matrix and its associ
Vector, diagonal vector and permutation vector are derived from matrix to facilitate
sparse. Sparse techniques are essential to solve flowsheeting problems, otherwise the
storage requirements are excessive and speed deteriorates rapidly with the size of the
problem. Sparse techniques are implemented around the object sparse matrix.
In this work, the operations around the object equation set allows only the
solution of the algebraic equations. This is because only sequential and simultaneous
approaches to process simulation are supported in this work. The equation set has to
be augmented with operations for the solution of the differential equations if dynamic
simulation has to be performed. The non-linear algebraic equations are solved using
the modified Powell's dogleg method developed by Chen and Stadtherr [2, 3] for full
and sparse matrices. The details of the solution procedures are discussed by Lau [8].
76
Process flowsheeting
Material and energy is invariably recycled back in any typical industrial chemical
process. This creates recycle loops in the flowsheet representing that physical process.
Also, to achieve the desired product quality and yield, industrial processes use process
controllers to maintain some of the process parameters at preset values. This creates
control loops in the flowsheet. A control loop can be feed forward or feedback. In
feed forward control, the value of a downstream process parameter is set based on
the values of upstream parameters. In feedback control, the upstream parameters are
loops may also be artificially created by the process designers to make what-if studies
(in the form of design specifications) on the process flowsheet. Figure 4.26 shows a
are performed in sequence, module by module, the presence of recycle and feedback
control loops makes it necessary to tear these loops, sequence the modules and per
form iterative calculations until the guessed and calculated values of the tear streams
match within a desired tolerance. For the flowsheet in Figure 4.26, tearing the recycle
stream results in the calculation sequence shown in the figure. In the simultaneous
approach, recycle and control loops either augment the equations of the flowsheet by
a certain number or make known variables unknown and unknown variables known
so that the final set of equations representing the flowsheet is consistent. The equa
tions resulting from the presence of recycle and control loops may be called constraint
(equality constraint) equations. So, constraints in the simultaneous approach are sim
ilar to the design specifications and tear streams found in the sequential approach.
7T
- - Tear stream
Vapor
Liquid
equipment module assumes that some parameters are known and others unknown. To
make a known parameter, unknown, a module (design specification block or fort ran
block) has to be created. Also, the module has to be identified as feed forward,
feedback or recycle, even though the user may not know in advance whether a module
is feed forward or feedback. Note that in feedback control the upstream parameters
when the sequence of the flowsheet is known, but the user has no way of knowing
in advance the sequence generated by the simulator. In this work, it is felt that the
the simulation calculations. Once a flowsheet is deflned, the user must be able to
perform simulation using any one of the approaches without giving additional data
for the flowsheet's definition. To support this idea, the flowsheet is defined in terms
of equipment units and constraints, and the constraints need not be identified as feed
forward or feed back, instead they must be specified whether implicit or explicit. The
Material or energy flows from one process unit to another in a physical process.
The object stream models these flows. Streams convey the inter-relationship among
the process units. Streams are divided into material and energy streams. Material
79
stream models the flow of material in a process. Energy streams convey the transfer
of energy flow from one process unit to another. Material stream contains the object
phase mixture defined in the PQS. So, it forms the connection between the PQS and
The object constraint models both the behavior of design specifications and
tear stream specifications encountered in the sequential approach and the equality
constraints found in the simultaneous approach. It is divided into four types: recycle
constraint, as the name implies, is used to specify tear streams. In the sequential
modular approach, since the calculation flow is sequential, any flow of material or
energy that is in the opposite direction has to be iterated until the convergence is
achieved between the guessed and calculated values. In the simultaneous approach
recycle constraint has no significance because equations from all the process units are
all are equations, it should not matter at least from the user's point of view, if known
and unknown variables are interchanged. But for the sequential approach, changing
a variable from known to unknown creates an additional convergence loop that has to
be torn and iterated. Implicit constraint, as the name implies, provides an additional
implicit equation, for example y = f{x,y), and reduces the number of known variables
feedback control specification. The variable which has been made unknown has to
be iterated until the implicit equation is satisfied. Note that inverse constraint is
An explicit constraint again, as the name implies, gives an explicit expression for
a variable (of the form y = f{x)) and reduces the known variables by one. In the
simultaneous approach this is not much different from an implicit constraint, but in
the sequential approach time can be saved if, instead of iterating on the unknown
variable, the variable is simply set by the value of the explicit expression. Of course,
this is possible only if the calculation sequence is such that the variables involved
to a feed forward control specification. Figure 4.22 shows the object hierarchy for
constraints.
operations around this object allow the analysis of the process unit to be performed.
unit corresponding to that process unit. In the sequential approach, the mathematical
some variables to be known and others unknown. Note that the calculation procedure
works only under this assumption. That is the reason why if a known variable
is made unknown one must resort to iterative calculations because the procedure
always treats that variable as known. The advantage of the sequential approach is
that the calculation procedure is robust and rarely fails. The disadvantage is that if
too many variables that the procedure assumed to be known are, in fact, unknown,
In this case a robust equation solver, which seems not to be available yet, is required
to solve the equations. Equipment unit is divided into flasher, mixer, splitter etc.
81
Each of these models a unit operation. Equipment unit contains streams, as inlets
and outlets. In the sequential approach, the outlets are calculated based on the
values of inlets and parameters of that equipment unit. Figure 4.22 shows the object
tion of equipment unit objects. Equipment unit objects in turn have references to
the stream objects. Stream object in turn to phase mixture and so on. So, flowsheet
is the top-most object in the process simulator. Flowsheet may have constraints. Be
divided into ordered and unordered flowsheet. Figure 4.22 shows the object hierarchy
for the flowsheet. In an ordered flowsheet the sequence of equipment units is already
unordered flowsheet is used for simultaneous calculations and ordered for sequen
ous calculations can be performed. Figure 4.27 shows the programming example for
tions representing all the equipment units present in the flowsheet are gathered into
an equation set, the equation set can be solved using the operations around the
equation set. As discussed before, one of the operations around the equation set is
to solve a set of non-linear algebraic equations. This is the same whether constraints
82
Explicit.constraint ec (flash.TEMPERATUREO,
mix.TEMPERATUREO .flash,mix);
Implicit_constraint ic (flash.PRESSURE(),
product.MOLAR_FLOWRATE() = 0.5,flash,product);
Unordered.flowsheet f ("flowsheet",mix,flash,split);
f.constraints(ec,ic);
f. simulate 0 ;
Ordered.flowsheet of = f.sequenceO ;
of.simulate0 ;
are present in the flowsheet or not. But for an ordered flowsheet, the presence of
constraints makes the calculations iterative. The definition of the flowsheet is re
cursive. That is, an ordered flowsheet is a sequence of equipment units and ordered
included in a larger flowsheet and also to divide a large flowsheet into sections which
an ordered flowsheet needs some discussion. The first step in arriving at the ordered
flowsheet is to build the digraph from the equipment units and streams present in
in the form of vertices and directed edges. Then the digraph is updated to reflect
the presence of constraints in the unordered flowsheet. That is, for every constraint,
additional edges are added into the digraph if the edges involving that constraint
are not already present in the digraph. Then the edges of the digraph are given
weights. When the decomposition step is performed on the digraph, weights deter
mine whether an edge has to be torn or not. The given weight depends on whether the
edge represents a material stream, energy stream or if a constraint, what type of con
straint etc. The lower the weight the more chance that it may be torn in the tearing
step of the decomposition algorithm. In general, constraints and energy streams are
given lower weights, and material streams are given higher weights because tearing
an energy stream gives much faster convergence than tearing a material stream. An
energy stream typically contains only one variable that has to be iterated, whereas a
material stream with its component flowrates, temperature, pressure and enthalpy is
84
more difficult to converge in iterative calculations. Once the weights are assigned, the
the largest part of the digraph that cannot be further subdivided without tearing
an edge. The reader is referred to any text book on graph theory for the rigorous
mathematical definition of a strong component. In the tearing step, all the loops are
torn and the sequence is generated. Once the strong components are identified and
the sequence is generated, the equipment units present in each strong component are
placed in an ordered flowsheet unless the strong component contains only a single
equipment unit. These ordered flowsheets and equipment units in turn are placed in
an ordered flowsheet that will eventually be simulated. All the constraints and tear
no constraints, each equipment unit in the ordered flowsheet is simulated one after
which in turn executes the constraints and simulates the equipment units when the
equation is evaluated. Hence, the solution of the equation set results in the simulation
CHAPTER 5. CONCLUSIONS
Our main research interest lies in applying the concept of object orientation to
more functional and flexible than its conventional counterpart. Our approach to the
ject oriented programming system for the process simulation. The process simulation
is the key to successful object oriented process simulator development, primarily be
cause objects provide the vehicle for process integration. Even though object design
is an important aspect of object orientation there has never been an established ob
ject design criteria. We provide a set of guidelines for object selection and design. We
also explore the suitability of object modeling in the process simulation environment.
It is found that the object model has to be extended with operational behavior
greatly reduced by using the object oriented approach for the process simulator, ob
ject standardization including object design criteria is essential for achieving process
integration, OOPL can act as common platforms for integrating process engineering
activities, and C + + can be effectively used for implementing object oriented simula
tion applications. The ease with which the sequential and simultaneous approaches
86
are incorporated into the process simulator reflects the potential of object oriented
programming for process engineering applications. It can be seen that the developed
The major impact of this work is on the development and maintenance of process
design software. The use of commercial OOPL for process simulation and design
shortens the software development cycle. Process simulation using object orientation
eases software maintainance. The reduced cost in the development and maintenance
of design software has direct effect on the investment of a process design organization.
87
CHAPTER 6. RECOMMENDATIONS
main ingredients of dynamic simulation. They were modeled but not implemented
in the present work. So, without too much effort dynamic simulation can be incor
the object oriented approach will greatly assist in developing the graphic interface by
In the existing simulator, not many unit operation models were implemented.
Only a flasher, mixer, splitter and separator are present in the simulator. However,
since the structure of the program need not be extended to support additional unit
Only two phase calculations are allowed in the current system. Support for
three phase calculations requires a more extensive set of physical property methods
to be added into the simulator. Physical property methods in the current simulator
are based on SRK and PR equations of state. Using these methods, vapor phase
calculations can be performed fairly accurately, but not liquid phase calculations
88
(especially at high pressures). More accurate liquid phase property methods such as
implemented in the present work. Even though the majority of chemical processes use
to extend the scope of the simulator to processes involving solids. The complex
characterization schemes used for non-conventional components will test the power of
the object model in effectively representing the information contained in real chemical
processes.
89
BIBLIOGRAPHY
[1] Buchmann Alejandro P., An architecture and data model for CAD databases.
11th International Conference on Very Large Data Bases, Stockholm (1985).
[4] Cox Brad J., Object oriented programming: An evolutionary approach. Addison-
Wesley, Reading, Massachusetts (1987).
[5] Cmelik Robert F., and Narain H. Gehani, Dimensional Analysis with C++.
IEEE Software 5, 21 (1988).
[7] Kruse Robert L., Data structures & program design. Prentice-Hall, Englewood
Cliffs, New Jersey (1984).
[8] Lau Kheng H., Development of a process simulator using object oriented pro
gramming: Numerical procedures and convergence studies. Ph.D. dissertation,
Iowa State University, Ames, Iowa (1992).
[10] Motard R. L., Integrated computer aided process engineering. Computers and
Chemical Engineering, 13, 1199 (1989).
90
[11] Piela P. C. et. al., Ascend: An object oriented computer environment for model
ing and analysis: The modeling language. Computers and Chemical Engineering
15, 53 (1991).
[13] Stephanopoulos G. et. al., Model.LA. A modeling language for process engineer
ing - I. The formal framework. Computers and Chemical Engineering 14, 813
(1990).
[14] Stephanopoulos G. et. al., Model.LA. A modeling language for process engineer
ing - II. Multifaceted modeling of processing systems. Computers and Chemical
Engineering 14, 847 (1990).
[15] Stephanopoulos G. et. al.. Design-kit: An object oriented environment for pro
cess engineering. Computers and Chemical Engineering 11, 655 (1987).
[21] Wandmacher Cornelius, Metric units in engineering - Going SI. Industrial Press,
New York (1978).
[24] Yamashita Y., and R. L. Motard, Object oriented integration in process engi
neering computation. AIChE Spring Meeting, New Orleans (1986).
[25] Winter P., Computer-aided process engineering: The evolution continues. Chem
ical Engineering Progress 88, 76 (1992).
92
are of primary interest to the users. A number of other objects are required to support
those primary objects. Table A.l Contains a list of all the objects that are defined to
As any other programming language C++ has its own syntax. But since C+ +
language can be extended with application specific objects, programs written in C++
won't be difficult to understand from the syntax point of view. Table B.l gives an