7/26/2019 Development of a process simulator using object oriented programm.pdf
1/148
Iowa State University
Digital Repository @ Iowa State University
R!-+!c%! !! a* D%!-a%+*
1992
Development of a process simulator using objectoriented programming: Numerical procedures and
convergence studiesKheng Hock LauIowa State University
F++ $% a* a%%+*a +-' a: $6://%b.-.%aa!.!/-
Pa- + $! C$!%ca E*#%*!!-%*# C++*
% D%!-a%+* % b-+#$ + + +- -!! a* +!* acc! b D%#%a R!+%+- @ I+a Sa! U*%!-%. I $a b!!* acc!! +- %*c%+* %*
R!-+!c%! !! a* D%!- a%+* b a* a$+-%4! a%*%-a+- + D%#%a R!+%+- @ I+a Sa! U*%!-%. F+- +-! %*+-a%+*, !a!
c+*ac $%*!'@%aa!.!.
R!c+!*! C%a%+*La, K$!*# H+c', "D!!+!* + a -+c! %a+- %*# +b&!c +-%!*! -+#-a%*#: N!-%ca -+c!-! a* c+*!-#!*c!%! " (1992). Retrospective Teses and Dissertations. Pa!- 10325.
http://lib.dr.iastate.edu/?utm_source=lib.dr.iastate.edu%2Frtd%2F10325&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://lib.dr.iastate.edu/rtd?utm_source=lib.dr.iastate.edu%2Frtd%2F10325&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://lib.dr.iastate.edu/rtd?utm_source=lib.dr.iastate.edu%2Frtd%2F10325&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://network.bepress.com/hgg/discipline/240?utm_source=lib.dr.iastate.edu%2Frtd%2F10325&utm_medium=PDF&utm_campaign=PDFCoverPagesmailto:[email protected]:[email protected]://network.bepress.com/hgg/discipline/240?utm_source=lib.dr.iastate.edu%2Frtd%2F10325&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://lib.dr.iastate.edu/rtd?utm_source=lib.dr.iastate.edu%2Frtd%2F10325&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://lib.dr.iastate.edu/rtd?utm_source=lib.dr.iastate.edu%2Frtd%2F10325&utm_medium=PDF&utm_campaign=PDFCoverPageshttp://lib.dr.iastate.edu/?utm_source=lib.dr.iastate.edu%2Frtd%2F10325&utm_medium=PDF&utm_campaign=PDFCoverPages7/26/2019 Development of a process simulator using object oriented programm.pdf
2/148
INFORMATION TO
USERS
This manuscript has been reproduced from
the
microfihn 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.
The quality of this reproduction is dependent upon the quality of the
copy
submitted. Broken or indistinct
print, colored
or poor
quality
illustrations
and photographs,
print bleedthrough, substandard margins,
and improper alignment can adversely affect reproduction.
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.
Oversize materials (e.g., maps, drawings, charts)
are
reproduced
by
sectioning the
original,
beginning
at the upper left-hand
corner
and
continuing
from left
to right
in equal sections
with small
overlaps.
Each
original
is
also photographed in one exposure
and
is
included
in
reduced form at the back of the book.
Photographs included in the original manuscript have been reproduced
xerographically
in this copy.
Higher
quality 6
x
9 black
and white
photographic prints are available for any photographs or illustrations
appearing in this copy for an additional charge. Contact UMI directly
to order.
University
Microfilms International
A Bell Howell
Information
Company
300North Zeeb Road. Ann Arbor.
Ml 48106-1346 USA
313/761-4700 800/521-0600
7/26/2019 Development of a process simulator using object oriented programm.pdf
3/148
7/26/2019 Development of a process simulator using object oriented programm.pdf
4/148
Order
Number 9234828
Development of a process simulator using object-oriented
programming: Numerical procedures and convergence studies
Lau, Kheng Hock, Ph.D.
Iowa State
University,
1992
U M I
300
N.
Zecb
Rd.
Ann
Arbor, MI
48106
7/26/2019 Development of a process simulator using object oriented programm.pdf
5/148
7/26/2019 Development of a process simulator using object oriented programm.pdf
6/148
Development
of
a
process simulator using
object
oriented
programming:
Numerical procedures and convergence studies
b y
Kheng Ho ck Lau
A Dissertation Submitted to
the
Graduate
Faculty
in Partial
Fulf i l lment
of the
Requirements
for
the
Degree
of
DOCTOR
OF
PHILOSOPHY
Major: Chemical Engineering
App^ed:
In
Charge of Maior
W or k
For the Major
Dt^artment
F or the
Graduate
Col lege
I owa
State
U nive r s i t y
A m e s ,
Iowa
1 9 9 2
7/26/2019 Development of a process simulator using object oriented programm.pdf
7/148
i i
TABLE OF
CONTENTS
ACKNOWLEDGMENTS viii
CHAPTER
1.
INTRODUCTION 1
CHAPTER
2.
LITERATURE
REVIEW 5
Process
Simulation
5
Sequential
modular simulators 5
Equation-based simulators 8
Numerical Methods 9
Tearing Algor i t hms il
Densities f rom
Equations
of
State
14
Object
Oriented
Programming 16
CHAPTER
3. NUMERICAL
PROCEDURES
19
Numerical
Methods 19
Newton's method 19
M o d i f i e d
Powell ' s
dog leg
method
2 1
Tearing
Algorithms
40
Partitioning
algorithm 42
Physical
Property
System 59
Top l i s s ' s
algorithm
61
7/26/2019 Development of a process simulator using object oriented programm.pdf
8/148
Mathias's algorithm 6 2
Property
method system 71
CHAPTER 4. CONVERGENCE STUDIES 8 1
Sequential Modular Simulators
82
Processes simulated 83
Results 87
Equation-Based Simulators 9 3
CHAPTER
5. CONCLUSIONS
1 0 1
CHAPTER 6. RECOMMENDATIONS 1 0 4
BIBLIOGRAPHY 1 0 6
APPENDIX A. TEST FLOWSHEETS
1 1 2
APPENDIX B. FULL-MATRIX TEST PROBLEMS 1 1 8
APPENDIX C.
SAMPLE
C++
PROGRAMS
1 2 6
7/26/2019 Development of a process simulator using object oriented programm.pdf
9/148
iv
LIST OF TABLES
Table
3.1: Test
problems
for ful l matrix
modi f i ed Powel l ' s
method
... 24
Table 3.2: Number of iterations for full matrix modi f i ed P owel l ' s method
in test
runs
27
Table
3.3:
Test problems for sparse matrix
modif ied Powel l ' s method .
. 33
Table
3.4:
Number of
iterations for sparse matrix modi f i ed
Powel l ' s
method
in
test
runs 3 4
Table
3.-5:
Class ical flowsheets
55
Table 3 .6 : Legend for tearing algorithms 55
Table 3.7:
Number of
tear streams selected
56
Table 3 .8 : Averaged execution time (ms) 57
Table
4.1:
Tear sets u sed in simulations 8 6
Table B.l: Parameter set 123
7/26/2019 Development of a process simulator using object oriented programm.pdf
10/148
V
LIST
OF FIGURES
Figure
1.1 : Elements of an Object Oriented Process
Simulation
Environ
ment
4
Figure
2.1:
Sample
flowsheet
with
a r ecycle l oop 7
Figure 3.1: A sample occurence matrix
2 8
Figure 3.2 : A C++
program demonstrating
the
use
of nonlinear equation
so lver
37
Figure 3.3 : C++ code for Broyden's
update
3 8
Figure
3.4:
Simpl i f i ed
Barkley-Motard graph
44
Figure 3.5 :
Simpl i f i ed
Christensen-Rudd graph
II
48
Figure 3.6 :
Adjacency Matrix
for graph
in Fig. 3.5
48
Figure 3.7 :
Tie
reso lu t ion scheme 50
Figure 3.8 : Adjacency
Matrix
for Figure 3.4 51
Figure 3.9 : Three typical curves for
P( /9 )
versus
density
63
Figure 3.10:
Three typical c u r ve s for P p [ p ) ve r sus
density
6 4
Figure
3.11: L iqu id
densities
for
an
equal-molar
mixture
of
ethane
and
n -
heptane with
SRK equation
of state
6 9
7/26/2019 Development of a process simulator using object oriented programm.pdf
11/148
vi
Figure 3 .12 : Vap o r densities for an equal-molar mixture
of
ethane and n -
heptane with SRK equation of state
70
Figure 3.13: Fugacity
coeff icients of an equal-molar mixture
of
ethane and
n-heptane with SRK equation
of
state 72
Figure 3.14: Fugacity coeff icients of an equal-molar mixture
of ethane and
n-heptane
with SRK
equation of state 73
Figure 3.1.5:
Enthalpies
of an
equal-molar mixture
of ethane
and n-heptane
with SRK equation of state
74
Figure
3 .16 :
Enthalpies
of
an
equal-molar
mixture
of
ethane and n-heptane
with
SRK
equation of state 75
Figure 3.17: A C-f-f sample program
us ing
phys ica l property system ... 80
Figure
4.1 : Insertion of
inner loop
84
Figure 4.2 : Cavett problem
86
Figure
4.3 : Recompression f lowshee t 8 7
Figure
4.4: A
s ing le - loop flowsheet 88
Figure
4.5 : Iterations vs tear set for
Cavett
problem
(Broyden's
Method) 89
Figure
4.6 :
Iterations vs
tear
sets for Cavett problem
(direct substitution) 9 0
Figure
4.7:
Iterations v s
tear
sets
for
Cavett
problem (SQP) 9 1
Figure 4.8 : Iterations v s
tear sets
fo r r e c omp r e s s ion f l owshe e t (Broyden's
Method) 92
Figure
4.9 :
Iterations
v s
tear
sets
for
r e c omp r e s s ion f l owshe e t
(direct sub
stitution)
9 3
Figure
4.10: Iterations vs
tear
sets for r e c omp r e s s ion flowsheet
(SQP)
. .
9 4
7/26/2019 Development of a process simulator using object oriented programm.pdf
12/148
v
Figure 4.11; Iterations v s tear sets for s ing le - loop
flowsheet
(Broyden's
method) 9 . 5
Figure A.l:
Rubin
graph
112
Figure A.2:
Rubin and
Hutchison
graph 112
Figure A.3: Christensen and Rudd graph 112
Figure A.4 : Upadhye and Grens graph 113
Figure
A.5 : Christensen
and Rudd
graph I 113
Figure A.6 :
Christensen
and
Rudd graph
II 113
Figure
A.7 : Sargent and
Westerberg
graph 114
Figure A.8:
Shannon graph (Su lfu r ic
ac id ) 114
Figure
A.9; Gundersen graph
(Heavy
water) 115
Figure
A.10:
Pho and Lapidus
graph
115
Figure
A.11:
Barkley
and Motard graph 1 1 6
Figure
A.12: Jain
and Eakman
graph
(HF-alkylation) 1 1 6
Figure A.13: Jain and Eakman graph
(Vegetable
oi l ) 117
Figure C.l:
A
s ing le - loop flowsheet
127
7/26/2019 Development of a process simulator using object oriented programm.pdf
13/148
viii
ACKNOWLEDGMENTS
I would l ike to express my sincere gratitude to Pro fe s so r Dean L. Ulr ichson
for
his
guidance and
advice throughout the course of this research. Many
thanks to
Professor
Les
L. Mil le r for sharing h i s ve ry
interesting
perspective on databases with
our research group and attending many of our group meetings. Many important ideas
were
ident i f ied
in
the
discuss ions .
The financial assistance I
received
from the
Department of
Chemical Enginee r
ing at
Iowa
State
whi l e work ing on this research is deeply appreciated. Thanks to
Pro fe s so r Richard S. Seagrave
for
kindly lending me
one
of his group's workstations.
Special
thanks
to my fel low co -worke r
Mr. Gadiraju
Varma from
w h o m I
learned
so many
programming
t r icks .
Thanks for bringing
me into
the wor ld
of object
oriented
programming.
My parents shall be complimented fo r a l l owing
me
to explore further education
adventures in America.
The initial
opportunity that I was g iven has made
a subtle
impact
in my
l ife
and
brought me into the
boundary of science and engineer ing .
Finally, I am grateful
to my f iancee ,
Masami
lida
for
her patience,
understanding
and support.
7/26/2019 Development of a process simulator using object oriented programm.pdf
14/148
1
CHAPTER 1.
INTRODUCTION
Applications of
computers
in
chemical
engineering
began approximately thirty-
f iv e yea r s
ago [26 ,
2 7 , 48 ,
49] .
Initial work
was
mainly concentrated
on
dev e lop ing
application
specif ic
computer programs.
There
was
little
thought
giv en
to the
concept
of a
proces s
simulator. Howev er , the initial
efi 'ort
produced many
re l iab le
algorithms
s pec ia l ly
developed
for
s o lv ing
process
simulation problems. For example,
several
al
gorithms w e r e d e v e l o p e d to s o lv e the
resulting energy and
material
balance
equations
and the
gov ern ing
equations that arise
from
phase equilibrium thermodynamics for
multi-stage operations.
B y
the
end
of
1960 s ,
it was evident that if al l the prev iou s ly
dev e loped
programs
were
incorporated
into
a
single system
that
cou ld
perform
al l
the
neces s a ry
calculations for an
entire or a
section of a
f lows h ee t , then proces s eng i
nee r s
would have a powerfu l tool
that
could
expand
the
boundary
of the simulation
problems that
cou ld
be solved
[69] .
Consequently,
proces s
simulators
were
developed.
With today's
computing t ech no log ies , p roces s
simulation
is
performed routinely
in the des ign of new proces s es and studies
of
current processes related to
p lan t
oper
ations,
optimization, proces s
control, and operability. Such a
wide
array
of tasks cer
tainly requires a
systematic approach
to organize
al l information generated
through
out
the
course of a
project. In addition, the
project
work
may
involve d i f fe ren t
application software
pack ages that
perform a
range
of
computations f r o m
simple
unit
7/26/2019 Development of a process simulator using object oriented programm.pdf
15/148
2
simulation
to
rigorous
p r oc es s
simulation. O f course,
these
sof tware packages
may
exchange data
during the
process calculations. Hence,
the
creation of a common
framework for these application software packages will certainly
improve
engineering
productivity and
enhance the
tools
available
for process
studies.
This concept has
been ca l led process
integration. Initial
work in this
area
i nv o lv ed
the
extension of
current p r oc es s f lowsheet ing pac kages
and
the development of eng i nee r i ng database
management systems. Many obstacles were encountered in integrating these appli
cation
programs
because
most
of them
w er e de s i gned with no
intention of
being
embedded into another
system. R ec ogn i z i ng
the
need
for establishing data trans
fer
standards, AIChE has
already
formed
the
Process
Data
Exchange Institute
to
develop such standards for process integration [69] .
Object oriented programming
(OOP) has
been recognized by severa l r esearchers
as
having
the potential
for
achieving process integration in deve l op i ng engineering
softwares [61] . In
OOP,
data types
are
modeled in a natural fashion for
the
application
of interest. Fina l ly , programs
are
composed from
the
ident i f i ed data types obtained
from
data modeling o r data abstraction. It is
c lear
that OOP gives more importance
to
data as opposed
to operations
that
u se the
data
to
perform
the
des i red
function.
An object is a
data
type
with
its respective def ined operations. Si nc e OOP is
still
in
its
infancy in c hem i c a l engineering
application,
work in
exploring
h ow
w e
can use
OOP
in engineering software development
is
ve r y much
under
active research.
The current work involved the development
of
a
process
simulation
environment
us i ng object oriented programming.
Our
view of an integrated chemica l p rocess sim
ulation environment is shown in Figure 1.1. The pac kage c ons i s t s of a sequential
modular
simulator,
an
equation-based simulator,
a phys i c a l
property system,
a phys
7/26/2019 Development of a process simulator using object oriented programm.pdf
16/148
7/26/2019 Development of a process simulator using object oriented programm.pdf
17/148
4
Physical
P r op e r ty
Sys tem
Physical
Quant i ty
S ys t e m
Equa t ion
Based
Simulator
Databank
Sequent ia l
Mo du l a r
S imula to r
C
+ +
Figure
1.1: Elements
of
an Object
Oriented
Process Simulation Environment
7/26/2019 Development of a process simulator using object oriented programm.pdf
18/148
5
CHAPTER 2.
LITERATURE
REVIEW
Process
Simulation
Simulation
of
c he mic a l
plants
is very common with
today's
advanced computing
t echnologies .
For
steady
state material
and energy
balance
computations, a c he mic a l
plant
can be described
b y
a
set
of nonlinear algebraic equations.
Since
the advent
of the f i rs t
simulator
in c he mic a l engineering, there have been numerous simulators
developed in both
academic
and industrial environments. For example, CHESS [68],
FLOWTRAN [48],
ASPEN [1],
PROCESS [68] , FLOWSIM
[55]
and SPEEDUP [43].
G ive n a
f lowshee t ,
all these
simulators can
so lve the resulting set of nonlinear a lge b r a i c
equations. There are three primary achitectures
fo r c he mic a l p r oc e s s
simulators
in
use today. They are sequential modular simulators, equation-based simulators and
simultaneous
modular
simulators.
This work concerns only sequential
modular
and
equation-based simulators.
Sequential
modular
simulators
This type
of
simulator
is ve r y
common in
the
industry.
Biegler
[4]
recent ly
performed a survey of
current
commercial simulators and found that se ve n ty p e r c e n t
of
the
simulators are sequential modular simulators. A s the name implies,
a
sequential
modular simulator performs calculations
sequentially
in
the
direction of material
7/26/2019 Development of a process simulator using object oriented programm.pdf
19/148
6
flow.
This
imp l i e s
that
b efore
the
computations
for one particular process unit
in
a
f lows h ee t are
performed, all
input streams
to
that
unit must
be known. With
the
presence of recyc le streams,
the
output of
one
downstream proces s
unit is the
input
of o n e upstream proces s unit.
Consequently,
the calculations are iterative because
some stream's state and component
flowrates
must
be gu es s ed and
corrected
till
they conv erge
within a
prespeci f ied tolerance.
The
gu es s ed streams are
commonly
r e fe r r ed to
as
tear streams. It is
obvious
that gu es s ed streams
h a v e
to be
selected
b efore
simulation
computations can
begin if the f lowshee t
of
interest
contains r ecyc le
streams. A
sample flowsheet
is shown in Figure
2.1 .
The
se lec ted tear stream is
Recyp. The
resulting set of
equations can
be arranged as
X
=
Y (2.1)
or
X - Y
= 0 ( 2 . 2 )
X is the
gu es s ed
stream vector containing component
flowrates,
enthalpy and
pres
sure. Y is the computed stream
vector consisting
of
elements
s imi lar
to
X. Equa
tion 2.1 is usually
s o lv ed
using Wegstein's
method
[2] or direct substitution. In
order
to use Newton's method or Broyden's
method [6 ] ,
the set
of
equations is expressed
in
the form
of
equation 2.2 .
One
obvious characteristic
of this
set
of
equations is that
the
equations can
not
be written
explicitly
in terms of the
unknowns. Consequently,
in order to evaluate equation 2.1 or
2.2,
the
f lows h ee t
has
to be evaluated. This can
be expensive for methods
that
require
derivative
information.
S ev era l
algorithms
h av e
been
developed
to
identify
the optimal tear streams
b as ed on the t opo logy of flowsheets.
All these algorithms ignore
the
existence
of c o n -
7/26/2019 Development of a process simulator using object oriented programm.pdf
20/148
I
Feedf Vap
Liq
ecy
Recyp
Prod
Y
=
Spit
Flash
Pump
Mixer
Figure 2.1: Sample f l owshee t with a recycle
loop
straints when gues sed streams are selected
as
l ong
as
the f inal
computation sequence
is consistent.
A
constraint is
a des ign spec i f i ca t ion thru
which
w e w i sh to
control
some
output
of a p roces s unit. When constrain ts are imposed, extra inner l oops have to be
converged in addition
to
the
outer
iterative
computation
described above. Because of
the architecture of sequential modular
simulators,
constraints nearly a lways
compl i
cate
the
conve rgence
of
iterated variables. In
general, f l owshee t s almost
a lways
have
recycle
streams and
constraints.
This
kind of
simulation
is termed des ign simulation.
On
the
contrary,
if
there
is no
constraint,
the simulation is cal led performance simu
lation. Since
the convergence behavior
of sequential modular simulators
is generally
more complicated when des ign simulation is performed,
there
is a
need to
investigate
the
effect
of
constraints on the
performance of
sequential modular simulators.
7/26/2019 Development of a process simulator using object oriented programm.pdf
21/148
7/26/2019 Development of a process simulator using object oriented programm.pdf
22/148
9
that
is robust
enough to
satisfy the
needs
of proces s simulation. One famous
com
mercial equation-based simulator is SPEEDUP
[43] ,
deve l oped at
Imperial Col lege ,
London. Prototype equation-based
simulators
have
a l s o b een
developed
at
several
institutions. For instance, FLOWSIM
(University
of Connecticut) [-55], ASCEND
(Carnegie M e l l o n )
[40] ,
and
SEQUEL (University
of I l l inois) [60] .
We developed a
prototype
ec ju a t ion -b as ed
simulator
to
illustrate the applicability
of object oriented
programming i n p roces s
simulation.
Then
the performance
of
this
equation-based simulator
was
evaluated.
Numerical Methods
For both sequential modular and equation-based simulators,
a
nonlinear ecpia t ion
solver i s needed. There have been
two
competitive nonlinear equation
solvers
in
the literature. One is the
class ic
quasi-Newton method which is mostly k n o w n as
Broyden's method.
There are t w o
variations
of this
method:
One
updates
the
inverse
of
the
. J acobian matrix; the other approach updates the . Jacobian matrix. A . Jacobian
matrix contains
all
the derivatives of the equations with respect
to
unknowns.
Since a
set of
linear
equations
is
solved
repeatedly
in
the
proces s of s o lv ing
a
set of
nonlinear
equations,
updating
the
inverse
of
the
Jacobian matrix
results into
an
easier task
i n s o lv ing
the linear equations. Only a straight
forward
matrix multiplication is
required.
Otherwise,
either an iterative
approach or
a
direct method is
needed. The
variation
wh ich
updates
the
Jacobian
matrix
performs
better
in
practice.
This
is
due
to the instability
of
the update
equation
for
the
inverse of the
Jacobian matrix.
In
trying
to improve the reliability of this method,
Pa los ch i
and Perkins [39]
developed
several
update procedures for the Jacobian matrix. Their
modifications
have b een
7/26/2019 Development of a process simulator using object oriented programm.pdf
23/148
10
used successfu l ly
to
solve many chemical engineering
and mathematical
problems.
One other attractive
numerical
method
is
the
we l l - known Powell's
d og le g method.
This approach takes a hybrid of Newton's method and the steepest descent method.
The motivation for this concept is to
take
advantage of the global convergence b e
havior
of
the steepest descent method and the loca l
quadratic
convergence behavior
of
Newton's
method. In Hiebert's
evaluation
of mathematical software fo r so lv ing
systems of
nonlinear
equations,
he
concluded
that this
approach did not perform
better
than
the
quasi-Newton method
[2.3].
Chen
and
Stadtherr [8] mod i f i e d P owe l l ' s
method b y adding an
automatic
scaling step for both functions and variables, a n e w
test
for
nearby loca l minima, and a p r ov i s ion to force unknowns to be
nonnegative.
The last addition
is
logical since most of the var iables involved
in
chemical engineer
ing problems are
nonnegative.
With these modifications, they reported
a
remarkably
improved performance
of
Powell's
d og le g method.
In
this
approach, Broyden's u p
date
for
the
Jacobian matrix
is
used. The n e w update introduced b y Paloschi and
Perkins
[39]
can
also
be
used.
In sequential modular simulators, the
nonlinear
equations are dense, implying
that the elements of the Jacobian
matrix
are
mostly
nonzero. On the contrary, the
nonlinear equations that arise
from
equation-based simulators produce
a
very sparse
. J acobian
matrix.
A s reported b y Stadtherr and W o o d [58] , the percent o f nonzero
elements in
the Jacobian matrix
is mostly below
ten.
Maintaining the sparsity
of
this
matrix
is
important
since only nonzero
elements
are stored. In addition, if
the
sparsity
degenerates,
w e
may run
out of computer
memory
in the p r oc e s s of
solving
the set
of nonlinear equations since
the cardinality
of the set
is
always ve r y
large.
In order to
maintain the
sparsity of
the
Jacobian
matrix,
a ne w
update formula
7/26/2019 Development of a process simulator using object oriented programm.pdf
24/148
11
was developed
b y Schubert
[53]. With inclus ion of this update formula, Chen and
Stadtherr [9] successfu l ly
so lved
many f l owshee t ing problems. In contrast,
other
researchers reported a very poor performance of Schubert's update. More recent ly ,
Bogle and
Perkins [ - 5 ] der ived
a
n e w update formula for
use with
the
sparse
Jacobian
matrix. Sun
and
Stadtherr [64] incorporated this n e w update formula and reported
promising results for their vers ion of Pow el l 's dog leg
method.
Since most of the successes of the modi f i ed Powel l ' s dog leg method were re
ported by the original authors, w e investigated this numerical method extensively
for
further
clar i f ica t ion of its
performance
in so lv ing
both sparse
and
dense sets
of
nonlinear equations. W e a l s o tested two
approaches for
keep ing the u n k n o w n s within
prespec i f i ed bounds.
Tearing Algorithms
Flowshee t
partitioning
and
tearing
is
an
integral
part
of
sequential
modular
sim
ulation. In the process
of
f lowshee t partitioning and tearing, a computation sequence
and
the associated set of tear
streams are
generated. The subject of
partitioning and
tear stream se lect ion has emphasized the identification of the optimal
tear
set for a
given flowsheet. The objective in identifying
an
optimal
tear set
is
to minimize
the
required
computation
time in the
actual simulation. There
have been seve ra l criteria
u sed
to
characterize
an optimal
tear
set.
The main
criteria are
1. Minimize
the number
of iterated variables
2 . Minimize the sum of
stream
weigh t s in the tear set
3. Minimize
the number
of
times
loops are torn
7/26/2019 Development of a process simulator using object oriented programm.pdf
25/148
12
A tear stream se lec t ion
algorithm
that
sat isf ies the above three
criteria
may not
minimize the computation time espec ia l ly when des ign constraints are p r e se n t i n
the
flowsheet.
This is because the
criteria listed
above are
sometimes mutually exc lus ive
and constraints have va r y ing effects on
the
c onve r ge nc e behavior. Gros et al.
[21]
showe d
that
the numerical method used to converge the
tear
variables d oe s not
affect
the c onve r ge nc e behavior of an unconstrained flowsheet. It wil l be s h o w n later, in
Chapter
4 of this
thesis,
that the
c onve r ge nc e behavior
of
a constrained f l owshe e t
i s
sensitive
to the c onve r ge nc e method
use d
in
converg ing
the tear streams and it is
a lso
a f fec ted
b y
the
type
of
constraints.
H e nc e ,
formulating
a
reliable
tearing algorithm
is not
as easy
as it
first appears. Since most commercial simulators use sequential
modular computation, p r ov id ing an efficient partitioning
and
tearing algorithm
is
essential in helping c he mic a l engineers
simulate
practical flowsheets.
A t
the
f l owshe e t partitioning
step,
each strong component in a f lowshee t
is
iden
t i f ied.
Within
a
strong component, there must be a zero
or
nonzero length path
from
any one node (A)
to
al l
other
nodes including
node
A
itself.
Unless
the
strong
component consists
of
only one s ing le node,
w e
a lway s have
a cycl i ca l ly
connected
graph in a strong component
s ince
w e
can a lway s
revis i t the node
where
w e
began
b y traversing the graph thru a wel l -def ined path.
In order
to
make
the graph acyc l ic ,
some streams must be
se l e c t e d a s
tear streams.
This
is
the
tearing
step or
simply
the tear
stream
se lec t ion
step.
M o s t tear stream se lec t ion algorithms
w o r k
with
the
cyc le
matrix
where
al l l oop s and streams participating
in
the loops are
stored
in a
matrix.
For
f lowshee ts
with
just a few cycles , identifying all loops
is
trivial. A s noted
b y Gundersen
and
Hertzberg
[22],
this
step
can
be
very
expensive
when a ve r y huge
number of cyc les exist in
the
flowsheet. In addition, the required storage for such
a
7/26/2019 Development of a process simulator using object oriented programm.pdf
26/148
13
cyc le
matrix may be
v ery
large. For the heavy water plant presented b y Gundersen
and
Hertzberg
[22] , the storage requirement for the
fu l l
cycle matrix
amounts
to ap
proximately
4.5
MB assuming a 2-byte
integer
space for
each
element of the matrix.
We we r e
not able
to
find
a tear
set for this
problem using
ASPEN PLUS
[1]
on
a
DEC 3100 due to the lack
of memory.
W e
conclude that
tearing algorithms ut i l iz ing
the
cyc le matrix
are impractical w h e n a large number of cycles and units are present.
John and Mii l le r [22] deve l oped an algorithm that can produce an
optimal tear
set as the tear set
that
minimiz es the sum
of
tear
stream weights . In
their
algorithm,
a
branch and bound method was u s ed to
reduce the dimension
of the
combinato
r ial problem. This approach
requ ires
bounds on tear sets of
v ar iou s
subproblems.
An
eff icient algorithm must be
av a i l ab le
to
produce such bounds for the success of
the branch
and
bound method. An
exce l l en t r ev iew on this
subject
was written b y
Gundersen
and Hertzberg [22]. A s
discussed above, w e
can not
guarantee
that this
minimum tear set
requires
the minimum computation time. Furthermore, if the flow
sheet has many
cyc les l ike
the
heavy water plant,
a
simpler approach
that
produces
a close-to-minimal
tear
set without requiring large storage
space is
acceptable.
Gundersen
and
Hertzberg
[22]
introduced
a tearing
algorithm that
does not
use
the cycle
matrix. Since
it is based on a simple heuristic rule
that
se lec ts the
input
streams
to
a unit that produce the most output information as tear
streams,
it
does
not consistently produce an optimum tear set. They described it as a c los e - to -
optimal"
tearing algorithm. More
recent ly ,
Li
et al.
[31]
developed
a
n e w
algorithm
that
also
does not
use the cycle
matrix. We implemented their algorithm
and fou nd
that
it also fa i led to
consistently
giv e an optimum tear set. Its
re l iab i l i ty
in finding
an optimum tear set was found to be
similar to that
of Gundersen's algorithm. Lien
7/26/2019 Development of a process simulator using object oriented programm.pdf
27/148
14
and Hertzberg [30] modi f ied
the
original Gundersen algorithm
b y
introducing a new
tearing
criterion
that
uses the
cyc le
matrix.
Their
reported results s h o w e d that the
n e w
algorithm produced the optimal
tear
set
for cases where
the
original algorithm
had fa i led . As d i scu ssed by
Lien
and
Hertzberg
[.30], this
is caused
b y the l ack of
a tie r e so lu t i on scheme in the
algorithm
itself. The improvement w as
obtained
by
sacr i f ic ing data storage
space
and
speed
since
the cyc le
matrix has to be updated
repeatedly. Since
w e
are interested in tearing algorithms that do not u se the cycle
matrix, the i m p r o v e d Gundersen algorithm was not cons ide red here .
In
this work ,
w e
propose
a new
tearing algorithm
based on
the
concepts of Li 's
algorithm.
Densities
from Equations of State
In
process
simulation,
obtaining the liquid and
v a p o r
densities
of
a mixture
constitutes
the
fundamental
step
in obtaining
other
properties required
for
phase
equilibrium and material and energy
balance
computations. O f
course,
there are
in
stances
where
other
correlations are u sed
to compute
des i r ed properties. Generally,
the speci f ica t ions of the state of a
mixture
with
a
spec i f i ed composition
are
temper
ature and pressu re
for the
simple reason that
these
two intensive var iab les can
be
measured read i ly . For a pressure explicit equation of state, so lv ing for
the
densities
of
vapor
and
l iqu id
is
then an iterative
process.
Most
equations
of
state are
a
third
order
polynomial
in
density.
This implies that the equations of
state
are not
mono-
tonic throughout the range
of
interest.
Depending on the specif ied
state, w e
may
have one density root or
three density roots
where the maximum and minimum roots
correspond
to
l iqu id and
vapor
densities, r e spec t i ve ly . The
other
density root
is
in
a
7/26/2019 Development of a process simulator using object oriented programm.pdf
28/148
15
phys ica l ly unapproachable r e g ion . Mos t iterative numerical methods have been d e
ve lop e d
by
assuming
the
existence
of
monotonie be hav io r
of
functions. This certainly
imposes a constraint to
the
applicability
of
these methods in so lv ing
for the
densities
of an
equation
of
state. Another
w a y of so lv ing for the densities is to
use algorithms
spec ia l ly tailored for
obtaining
al l
roots
of a polynomial. Ho w e v e r , w e don't need
both l iquid and vapor densities at
the
same time. Consequently, iterative methods
are still
the
prefe r red route for
determining
the
density from
an
equation of state.
Mathias et al. [ . 3 5 ] developed
an
alogorithm for obtaining the desired density
from
an equation
of
state.
This particular algorithm
was
use d
in the
phys ica l
proper
ties
system
of
ASPEN. More recent ly ,
Topl i ss
[65] published a new algorithm that he
contended
was more eff icient . Sinc e pressure,
temperature
and composition
of
a m i x
ture
are common iterative var iables in
the
solution
of
f lowshee t ing problems,
w e
may
encounter cases where no rea l density
root exists for
both
vapor and liquid. Topliss's
algorithm
stops
at
this point if such a situation is determined. In contrast, Mathias
et al.
[35]
produced
a
pseudo-root
for
this
c ase
and let the simulation
calculations
continue.
This is
desirable because such a phenomenon normally
occurs
in the midst
of
so lv ing
the
f lowshee t ing
problem; the temperature,
pressure
and composition of
a mixture
can
be ve r y
unreasonable for
properties calculations.
If
a pseudo-root
is
used, w e may get to a val id spec i f ica t ion in
the
next iteration of
the
computations.
Care must be exerc ised to check
the
val id i ty of
the
f inal
simulation
solutions.
W e
implemented
Topl i ss ' s
algorithm
and
extended
it so
that
pseudo-roots are
generated
when inva l id spec i f ica t ions
occur.
Our present phys ica l
property system
uses
this extended algorithm
as the underlying
method
for
determining densities
from
an
equation
of state.
7/26/2019 Development of a process simulator using object oriented programm.pdf
29/148
16
Object Oriented Programming
Modern software engineering fundamentals stress
the
notion
of
data
m o d e l i n g
in
the
development
of ne w
software
instead of functional
analysis
[36] .
Modular
ity
of
software is a lways
emphasized. Unfortunately, no
one
clear
def ini t ion
for
the
meaning
of
modularity is suff ic ient .
M e y e r
[ . 3 6 ] suggested
that
a comprehensive
def
inition of
modularity
should address
var ious aspects of
good software qualities l ike
extendibility,
reusab i l i ty ,
etc. In
l igh t
of dev e lop ing modular
software,
object ori
ented programming has arisen as one
of
the
prominent routes towards modularity.
S ince most
proces s
simulators have complex requirements
and intricate
relationships
among the constituent elements,
w e
need
a systematic approach
towards
the des ign
of proces s
simulators. Object oriented programming concepts facilitate
such
a sys
tematic
approach
in the proces s of
software
construction. M o s t importantly, they
emphasize
data
modeling and
system des ign whic h promote software
extendibility
and
reusab i l i ty .
These qualities are crucial
in
a
proces s
simulator.
D e v e l o p m e n t of
a
versatile
proces s
simulator is inherently an
o n - g o i n g
task. N e w
capabilities must
be incorporated into the simulator as
they
arise
without
causing
any drastic
change
in
the
simulation
system.
Also , modifications
of
old algorithms implemented previ
ous ly
should not affect
the
continuing user.
Current
modules should
be ut i l ized in
future development.
All
these requirements
point towards
the use
of
object oriented
programming notions in the development
of
a
proces s
simulation environment.
An object consists
of
data and operations that
manipulate
or act
o n
the data.
S of tware construction thru object-oriented
programming is
es s en t i a lly iden t i fy ing var
ious objects
required in a
spec i f ic application
and
def ining
relationships
among the
objects.
Hence, the notion
of
data modeling
is
just the
proces s of i den t i fy ing
objects
7/26/2019 Development of a process simulator using object oriented programm.pdf
30/148
17
and
def in ing their
respective
relationships.
The operations def ined
must
be
ade
quate to
support
sof tware
requirements. Encapsulation is
the
creation of a
boundary
around
an
object.
In other words, only
operations def ined
for an object can
act on
the
object. This
gives
us the ability
to
limit
the
use of objects
so
that they will not
be m i sused
unintentionally
like the COMMON
block in
Fortran.
Information hiding
is a direct
benef i t
that comes from encapsulation.
Si nc e an
object's data is available
to
the
outside wor ld
only thru its operations,
programmers c an
hide implementation
details from the user. For example, when w e h a v e a set of numbers in an
object,
the
operation
to
produce
an ordered list
can
be implemented in severa l ways .
The
user
k nows
only that the
operation returns an ordered l i s t and nothing else. In
fact,
this
notion is not new , w e
can
also obtain
information
hiding from conventional program
ming languages l ike Pascal, Fortran, C, etc. How eve r ,
encapsulation
does
more
than
just information hiding b y imposing constraints on operations permitted
to
ac c e s s
the
data
of an object.
Mes s age sending
is the
w a y objects communicate
with the
outside wor ld
thru
def ined
operations. We
send
a message
to
an object and it
will
then decide what
to
do with
that m essage . This is parallel
with
the
conventional
procedure ca l l s .
The
procedure is the operation associated with an object; the procedure's argument
l i s t
is the data
of
an
object.
Clearly,
w e
have a reverse ownership
of
argument
l i s t
and
procedures
in
object oriented programming.
Her e ,
the data ow n the
operations.
Importance
of
data
in object
oriented
programming
is
an
aspect
which should
not be
over looked .
Inheritance is the
ability
to
create new objects (derived objects) b y inheriting
data and
operations of
previously def ined
objects
(base objects).
Conceptually, w e
7/26/2019 Development of a process simulator using object oriented programm.pdf
31/148
18
can v iew the b a s e object as a gene r a l i zed object and the
der ived object
as a s pec ia l i z ed
object.
For
example, a complex number has a rea l part and a complex part.
The
rea l
part i s
a
gene r a l i zed object since
every
rea l
number
has
this
part.
The
complex
part
is
a spec ia l i zed object because only a complex
number
has this
part. The
rea l v a lu e
of
inheritance is in software development and espec ia l ly
in
data abstraction. To the
user of an
object
oriented application so f tw a r e ,
inheritance is
almost invi s ib le .
From a
programming perspective,
inheritance p r ov i de s
for the reduction of code duplication
s i nc e a spec ia l i zed object inherits
attributes
from fu l ly deve l oped
and tested
objects
and
their
operations.
The
program
structure and information
m o d e l i n g
of
this work are
described
b y
Varma [67] . Examples manifesting the benef i ts of object oriented programming wil l
be shown in the d i sc us s i ons of numerical procedures.
7/26/2019 Development of a process simulator using object oriented programm.pdf
32/148
19
CHAPTER
3. NUMERICAL
PROCEDURES
Numerical
Methods
The
problem of f inding a
so lu t i on
to
a
set of
nonlinear equations
can
be
def ined
as: g iven
f(x)
= 0,
w e
would l ike to find a vector x* such
that
f(x*) ^ 0 or
f(x*)
~ tolerance. M o s t methods ava i lable
for solving
this problem are iterative.
They
generate
a sequence of
vec tors
{x^} and
if
the method
succeeds, then
{x^}
wil l co n v e r g e to {x*}.
Newton s method
Fo r
the
class ic Newton's method, the iterative
wor k ing
equations
for
so lv ing such
a set of nonlinear equations a re:
= H-+Pk (3 II
H^k'lPk
=
-f(x&l ( 3 - 2 )
To
so lve fo r pj^, w e h a v e to
solve a se t
of
linear equations
def ined in equation 3.2.
Standard
Gaussian
elimination with
p ivo t i ng
is
usually
used
to
ac c omp l i sh
this
task.
Hence, for
an initial {xo}, w e ne e d
to
compute
the
Jacobian
matrix.
J(xo), and then
calculate pj^. Subsequently,
a
n e w {x} i s generated. This p r oc e s s
continues
unt i l l
{x^} co n v e r g e s to the
solution within
a speci f i ed
tolerance.
Note that the Jacobian
7/26/2019 Development of a process simulator using object oriented programm.pdf
33/148
7/26/2019 Development of a process simulator using object oriented programm.pdf
34/148
21
There h a v e
been
t w o
approaches to this initialization problem.
One
is to
use finite
difference
as
for
the
cas e of
Newton's
method.
Since
the initial guesses , {xo}, can
be ve r y far
a w a y
from the solution,
it may
not
be neces s a ry
to
p r o v i d e
an accurate
approximation
of
the
Jacobian
matrix. With this
argument, an
identity matrix is
u se d as the initial . J acob ian matrix. In
practice,
both approaches
h a v e
b een u s ed
successful ly.
But, u s ing an identity matrix to in i t i a l i ze
the
Jacobian matrix
can
cau s e
the
method
to perform
poorly in
some
cases .
Modified
Powell's dogleg
method
This method is
a
hybrid of
Newton's
method and the
steepest
des cen t
method.
The
der iv a t ion of
this
method
can be found in a paper
b y
Chen
and Stadtherr [8].
The
work ing equations can
be summarized as fo l lows:
(3 . 1 0 )
(3 . 1 1 )
( 3 . 8 )
( 3 . 9 )
p" =
Dip
(.3.12)
Dy
and
are function
s ca l ing and
variable
s ca l ing
matrices,
g is the s ca led steepest
des cen t
direction.
Afte r
computing
p ^ ^ and
p ,
then
Powel l ' s
search d i rec t ion
is
determined according to
the
fo l lowing equations:
P = P^^
if
^
> I I P ^ ^ I I
p
=
ap^
+
(l-a)p^
if llp^^ll
> A > l | p - | |
(3 . 1 3 )
( 3 . 1 4 )
7/26/2019 Development of a process simulator using object oriented programm.pdf
35/148
22
P = yr^g if I 1 P ' 1 1 >^ ( 3 .15 )
llgll
w h e r e a is def ined in the fo l lowing equation.
" (piv_pi')V
+
r
r =
{1(p ^) P -A2|2
+ [||P V||2_a2][A2-||P||2]}1/2
, 3 . 1 7 ,
A is the radius of the reg ion
within whic h
the
linearization can
be trusted.
For initial
guesses
X q
and
f(xo), an algorithm
of this method
can be def ined
as
fo l lows:
1. Calculate the Jacobian matrix
by
f in i t e
di f fe rence .
2.
Calculate Dy
and Dx and
s ca le the
Jacobian matrix.
Dy
is c hose n
s u ch
that
the largest
absolute va lue
in
each
row of the
matrix DyB
is equal
to uni ty .
S imi la r ly , ch oos e Dj; s u ch
that
the l a rges t absolute v a lu e in each co lu mn of
Ds
qual to
u ni ty .
3. Calculate initial step bound, A = r * maa;{ | | Da ;X o | |, 10 .0 } . r is a number
provided
by the
user. A s the def in ing equation
shows,
it affects the va lue
of
the
initial step
bound.
4.
Calculate the s ea rch
direction p},
accord ing
to above d e f ine d equations.
5. Evaluate
+
pj^.)
6.
Check
for s low c onve r ge nc e or nonconv ergence . In this step,
a
n e w
test
for loca l
minima w a s p r o p o s e d b y Chen and Stadtherr [8] .
7. Check
if Jacobian matrix needs
to be re-evaluated.
7/26/2019 Development of a process simulator using object oriented programm.pdf
36/148
7/26/2019 Development of a process simulator using object oriented programm.pdf
37/148
24
In
testing our implementation,
w e u sed ten chemica l eng inee r ing problems
p r o
p o s e d b y Shacham
[56].
These
problems
were a l so used by Sun and Stadtherr
[64].
The problem description is shown in Table
3.1
and
the
details of the problems are
included in
Appendix
B.
Table 3.1: Test
problems
for
fu l l
matrix
modi f i ed
Powel l ' s
method
Problem
D i m e n s i o n Description
1
2
Material balance of
a
reactor
2 7
Chemical equilibrium
of
o x y g e n
and methane
3
2
Thermodynamics
of
a
2-component l i qu id mixture
4 2
Equilibrium
c onve r s i on
of a reactor
5 2
Material and e n e r g y balances of
a
reactor
6
2
Chemical equilibrium problem
7 13
F r e e
energy minimization
of a reacting
system
8
6
Steady
state
kine t i c s
9 6
Chemical
equilibrium
problem
10
10
Combustion of
propane
and air
In
these problems,
there are
var i ab l es
that are
nonnegative.
For
example,
the
composition
and flowrates h a v e
to
be
positive. H o w e v e r ,
there are var i ab l es that can
be
positive and
negative
in chemical eng inee r ing problems. Enthalpy and heat duty
are
two
o b v i o u s examples. W e implemented
two
w ays of ensuring var i ab l es to be
positive. The first approach i s
to
take the absolute
va lu e
of
the negative va lu e
and
adjust
pf,
accord ing ly . The
result
of this
step is abandoning the
direction of
current
iteration and
starting
at a n e w g u e s s
point. One
other
w ay i s
to
keep
the
direction
of
by imposing a step bound
factor
just l ike the
case
of damped Newton's method.
Instead of minimiz ing the norm of
the
functions, this factor is u sed to keep va r i ab l es
7/26/2019 Development of a process simulator using object oriented programm.pdf
38/148
25
in the def ined
bounds. The
equation for
computing
the factor i s
given
b e low.
A
=
Vimin
*
(3 .22)
P f
where a i s a small number
close
to one
and
xp
is
the lower bound of var i ab l e Xj .
Note that the computation of A i s only done for
all
p^''s that are l ess than ze ro .
Q is used
to
ensure that the constrained variable will not
reach
exactly
the
lower
bound but very c lose to
it. This is
because w e
may have
terms in the equations that
are
undefined
if some var iab les are ze ro exactly. F o r example, the logarithm of a
composition var i ab l e with a value of z e r o
w oul d
cause an error.
We
used 0 .99 for a
in our code.
In Sun and Stadtherr's
evaluation of numerical
methods, they
c o n c l u d e d
that
the modi f i ed Powel l ' s
method is more reliable
than
the quasi-Newton method
that
uses
Broyden's
update [64]. The
results of our investigation are s h o w n in Table 3.2.
All of the
problem
numbers with
alphabetical
endings represent runs with different
initial gu esses
for
the same problem. A n /in the
table
indicates a fa i lu re in obtaining
the f inal solution. Some of the
problems
are numerically singular at the given initial
guesses.
These problems w er e so l ved with two scaling options, function scal ing (FS)
and both function and var i ab l e sca l i ngs (FVS).
The t w o b o u n d - c h e c k i n g
strategies
w e r e a l s o tested. There is
a
use r g i ven
parameter,
r, in the algorithm but Sun and
Stadtherr
did
not
report
any values of
r
u s e d in their
runs. For
our results, al l
the
problems w e r e
so l ved
with the fo l lowing
set
of va lu es and the best
performance is
reported.
r
= {0.1,0.2,0.3,...,1,5,10}
The results
obtained
c lear ly
support
the re l iab i l i ty of this
method
as reported
b y
7/26/2019 Development of a process simulator using object oriented programm.pdf
39/148
26
Sun and Stadtherr [64]. Both of
the
approaches
for
keep ing u n k n o w n s in
the
feas ib le
r eg ion work ve ry well .
They do not
impede the progress of
the
numerical
method.
The
method
that abandons
pjr.
with
only function sca l ing fa i ls
5
times.
Only 4
cases
fa i led
fo r
the
other
va r i a t i ons in this test. This gives a success
rate
of more than 80 %
for
al l
of the
different
va r i a t i ons of the modi f ied Powel l ' s dog leg method
tested.
The
results
a l so indicate that the performance of the
method is not ve r y much af fec ted
b y
variable sca l ing . For th i s set
of
test problems, there i s no one clea r optimum va lue
of
r. Ho w e v e r ,
one
was found
to
be a good number
for
mos t
of the
p r o b l e m s studied.
The
algorithm
for
so lv ing
a
set
of
sparse
non l ine a r
equations
is
essent ia l ly
the
same as
the ful l
matrix c ase except for
the fo l lowing
steps:
1.
Evaluating
the Jacobian matrix.
2. Solv ing
the
l inear se t of equations.
3. Updating the Jacobian matrix.
In evaluating the Jacobian matrix for
the
ful l non l ine a r equations, every s ing le
unknown
is
perturbed i nd iv id ua l l y . Obv ious ly , there are
many unknowns
in most
sparse systems of equations.
U s i n g the ful l
matrix approach
is
too
cos t ly .
Further
more, there are equations that may
not
be af fec ted b y the perturbed variable. Sun
and Stadtherr [63]
studied
two
algorithms
for simultaneous perturbation
of
unknowns
and co n c l u de d that both are effect ive . These t w o algorithms w e r e d e ve lop e d b y Cur
tis
et
al.
[12]
and
C o l e m a n
and
More
[11].
The
main
thrust
of
these
two
algorithms
is
to
group
var iab le s
which invo lve
di f fe ren t
functions
as a cluster. Then these variables
can be perturbed
simultaneously
when computing
the
Jacobian matrix. Considering
the
oc c u r e nc e matrix in Figure 3.1, w e can group
{21,22} ^^d
{23,2^,25} as two
7/26/2019 Development of a process simulator using object oriented programm.pdf
40/148
27
Table 3.2 : Number
of
iterations for ful l matrix modi f ied
P owe l l ' s method in test
runs
Preserve
P A .
Abandon
Pk
Problem
FVS
FS
FVS
FS
1
13 17
1 2
15
2 a
47
46
3 2
38
2 b 2 0
20
18
22
3
10 10 1 0
1 0
4a f
f
f
f
4b 12 15
1 2
15
4c
1 0 11 10 11
4d 21
25
2 1
25
5a
7 8 8
7
5b 5 5
5
5
5 6
6 6 6
5 d 19
1 4
19
1 4
6a 16 1 6 1 6 1 6
6b 2 5 3 2 2 5
32
7
40
5 6 3 3
28
8a
7 7 7 7
8b
f f
f
f
8c
8
8
8 8
8 d f
f
f
f
8 e 4 9
17
36
18
120 88
1 6 3 f
9a
f
f
f
f
9b 3 6 36
40
42
9 c
4 0 4 0
2 6
26
9 d 4 9
49
3 7
37
1 0 a 2 4 2 4
22
22
1 0 b
2 0 2 0
15
15
10c
38
36
3 5
36
lOd 44 39 41
40
7/26/2019 Development of a process simulator using object oriented programm.pdf
41/148
7/26/2019 Development of a process simulator using object oriented programm.pdf
42/148
29
(b)
Perturb each var i ab l e in the variable set separately and evaluate the func
tion.
2. Repeat step
1
until al l
equations are p r o c e s s e d .
It
i s
clear
that
this strategy computes the Jacobian matrix one
r ow
at a time.
This
approach is
desirable only if al l the
equations
are simple equations. For
instance,
they don't need
to
cal l some other subroutine that accepts parameters that may
or may not i nvo lve the
unknowns
in order to compute the function va lu e . The
majority of the equations in process simulation fal l
into
this
category.
There is
another
category
of equations
that need
to
make subroutine
cal ls before thay
can
compute
the respective
function values . In phase
equilibrium
calculation, the A'j
va l ue s
are good examples
of
this type
of equations.
Before
computing
A'j , the fu gac i t y
coeff ic ient
of component
i
fo r the l iqu id
phase
and v a p o r
phase must
be computed.
These calculations
n e e d
l iqu id and v a p o r
c o m p o s i t i o n s
that are normally
u n k n o w n s
in the set
of
equations. Mathematically, the equations are as
fol lows :
K i - g ( T , P , X , Y )
= 0
: :
( 3 . :% )
K n
- g
T , P
, X , Y )
= 0
With just a
function
cal l to the procedure g ,
w e
obtain al l
values .
Hence ,
w e
can
group
al l
these
equations
into
a
procedural equation
which
ca l l s
the
procedure
g
and produces a sequence of
function
values . This procedural equation a l so
has an
associated set of
var i ab l es for Jacobian matrix
calculation.
F o r
this example, this
se t is {A'j,..., A'n,
T,
P,
X,
Y}. In
this manner, the Jacobian
matrix is evaluated
column wise instead of row w i se as in the case of simple equations. With
the
addition
7/26/2019 Development of a process simulator using object oriented programm.pdf
43/148
30
of procedural equations, the Jacobian matrix is f i l led up column wise
and
row wise
interspersely depending
on
the equation type.
Fo r
the
solution of a set of sparse linear equations,
the
main
concern i s to pre
se r ve the
sparsity
of the matrix. Ideal ly,
if a
matrix i s triangular, no
f i l l - in
i s poss ib le .
A fi l l - in i s a
generated nonze r o e l e me n t in
the
p r oc e s s
of
so lv ing
the equations. C o n
sequently,
f i l l - in ' s
occur only
thru
deviation
from
a triangular
matrix.
Sinc e a set
of
sparse
linear
equations has
to
be
so lved repeatedly, efficient algorithms which exp lo i t
the
sparsity of
the matrix must
be used .
Standard Gaussian
elimination
causes the
sparsity
to
degenerate.
Stadtherr and Wood [.58, 59] developed severa l
algorithms
that
can
so lve a set of sparse l inear equations efficiently . Their algorithms cons i s t of
t w o major
steps:
1.
Reordering phase
2 . Numerical phase
An algorithm
that
solves
a
se t
of
linear equations in
t w o
phases
i s ca l l ed
a
tw o -
p ass approach.
There
i s another method c a l l e d a priori approach
which s w i t ch e s
between reordering
and
nume r i c a l steps as
the
linear
equations
are be ing so lved.
Stadtherr and W o o d
[59] co n c l u de d that
the t w o - p a s s approach i s
superior
to the a
priori method. In
the
reorder ing phase,
the matrix
is permuted to
block
triangular
form. A s
its
name impUes , the nume r i c a l phase
is
the
task
of so lv ing
the
equations. A t
this stage,
if
the
d iagona l e l e me n t
i s
not
a
suitable
pivot, column or
row
interchange
wil l take place. This o b v i o u s l y
defea ts
the
purpose
of the reordering phase
be c ause
the matrix is ordered
such
that
min ima l f i l l - in ' s
are
generated in
the
nume r i c a l
step.
H e nc e , maintaining
the sparsity of
a
matrix and establishing the stability of the
7/26/2019 Development of a process simulator using object oriented programm.pdf
44/148
31
s o lu t ion
p r oc e s s
are
mutually exclus ive . To reso lve this dilemma, a threshold
p iv o t ing
strategy
is used. Here,
p iv o t s
are
considered
acceptable
if
they
are l a rge r than
some
k X max, where&isa constant less
than
1
and
max is the
largest
e lement
in a column
or
r ow.
The v a lu e for
k
i s n o r m a l l y v e r y
small.
A
commonly use d v a lue is 0 .1 . If k
approaches 1,
then
this method reduces
to
the normal
p iv o t ing
strategy.
W e implemented Stadtherr and Wood's algorithm for so lv ing a
set
of sparse
linear
equations. The
details
of the
algorithm
are described by M ah [33]. S ince three
algorithms we r e
p r e s e n t e d
b y Stadtherr
and
Wood
[58 , 59] , we opted
to
use SPKl
for
the
reordering
phase
and
RANKI for the
numerical
phase. This combination is
among
the
better
per fo rmers in
their tests. Before applying these two algorithms, the
matrix should
be
partitioned
o r
reordered
into
a block-triangular form.
Partitioning
cons is ts of
two
steps. Ini t ia l ly ,
the matrix must
satisfy
the
cond i t ion
of maximal
transversal. That is ,
the matrix
must
have
a
set
of
z e ro
f ree
diagonal elements.
An
efficient algorithm to obtain this property
for a
giv en matrix was
presented
by
Duff [15] .
This algorithm
was u s ed
in
our implementation.
The
next step,
a
simple
symmetric
permutation of
the matrix
wil l
produce a block-triangular
f o r m
matrix.
The permutation
can
be
done
eff icient ly
with
the
we l l - known
Tarjan's
algorithm.
Duff and
Reid [14]
prov ided
a ve r y good implementation
of
this algorithm.
W e
coded
this algorithm
b as ed
on the wor k of Duff and Reid
[14] .
Note
that this algorithm
a l s o
s e rv es as a strong component
finder
in our studies
of
tearing algorithms
to be
pres en ted
in
the
next section.
Fina l ly ,
for
the update of the sparse
Jacobian
matrix, w e
studied
two update
equations presented
b y
Schubert
[53] , and
Bog le
and
Perkins
[5] .
Schubert's
update
7/26/2019 Development of a process simulator using object oriented programm.pdf
45/148
32
is
def ined
as:
B&+1
=
Bi.
+ Z{D(yj-Bi.pfc)p[.}
( 3 . 24 )
Z
is an operator
def ined fo r
any matrix
M
by:
Z{M}
=
0
i f Y i j =
0
= M i j i f Y i j =
1
( 3 .2 5 )
w her e
Y
i s the occurence
matrix of
the set of sparse nonlinear equations to be so l ved ,
Yij
is
the
element in
row
i
and
column
j
of
Y.
If
w e
let be
the
vec to r
formed
from by
setting the
component to
zero
if
Yij
i s
zero, then
D
=
(3.26)
I 1 ^ 7 7
Each element in
D i s de f ined
to
be
1/a^
if a *
is
not zero ;
otherwise
the element is
as s i gned to be zero, a is
the
dot
product of the
v ec to r p^ w i th i tself .
The
update
i s
des i gned to operate
b y rows
in order to p r e se r ve
sparsity
of the
Jacobian
matrix.
When
the
diagonal e l em en t
Djj
is too small or zero , then row i
is
lef t unchanged.
For
Bogle ' s update,
the equation
is as
fo l lows:
yf
= )-%(%&)
This equation a l s o pe r f o r m s update b y rows . Si m i l a r action
is
taken if the d e n o m i
nator is too small. N o
update
is done to
that
particular r ow . Note
that
if any B^-
e l em en t
is
zero , the sec ond term
will
a l so become ze r o due to (B^ )^ . Therefore, the
sparsity
is
p r e se r ved .
7/26/2019 Development of a process simulator using object oriented programm.pdf
46/148
33
In
testing
our sparse nonlinear equation
so lver ,
ten problems w e r e so l ved .
The
description of
these
problems is
g i ven
in Table
3.3 . The
results obtained
are
presented
in Table 3.4.
The
problem numbers with alphabetical endings represent
either
s imi la r
problems
with
dif ferent initial guesses o r with dif ferent input
parameters
for
the
equations.
For
instance, the
split f r ac t i on of
a simple splitter
is
changed. The
bound
checking strategies
used for the fu l l matrix
are a l so included
in this
test
s i nc e m os t
of the
var i ab l es are
nonnegative. Similar ly ,
the
symbol
FVS stands
for
both
function
and variable sca l i ng , and FS indicates only function sca l i ng . For the
v a lu es
of r,
w e used {0.1,0.2, ...,1,5,10}. The r e su l t show n
is
the best from these 12 dif ferent
v a lu es
of r.
Table 3.3; Test problems for sparse matrix modi f ied
Powel l ' s
method
Problem
D i m ens i on
Descr ip t i on
1
12
Isothermal f l ash
us ing composition
2
12
Isothermal f l ash
us ing flowrates
3
30
Si ng l e l oop f l ow shee t
material
balance
us ing
compositions
4
30 Si ng l e l oop
f lowshee t material
balance us i ng flowrates
5 10 0
Schubert's test problem with
dif l 'erent
dimensions [53]
6
17 0
Cavett p r o b l e m
7 19
D e w point ca lcula t ion
8 19
Bubble point c a l c u l a t i on
9
19
Adiabatic
f l a sh c a l c u l a t i on
10
4 3
Ammonia f lowshee t material balance
The
results
s h o w ve r y
good
pe r f o r m anc e
of
modi f ied
Powel l ' s
dog l eg
method
with both Schubert's update and
Bogle ' s
update.
In
the case of Schubert's update,
a f ew r e sea r c he r s reported
ve r y
p o o r performance of this
formula
when
they
u s ed
it in place
of
Broyden's formula in solv ing a sparse set
of
nonlinear equations. N o t
surpr i s ingly ,
Chen and Stadtherr
reported p r om i s i ng performance
of
Schubert's up -
7/26/2019 Development of a process simulator using object oriented programm.pdf
47/148
7/26/2019 Development of a process simulator using object oriented programm.pdf
48/148
35
date. This
may indicate that
the p o o r performance is caused
b y
the w ay
the sea rch
direction (p^) is
computed.
Bogle ' s update a l so g i ve s v e r y encouraging results. This
is
also
in
agreement with the r e su l t s of Sun
and
Stadtherr. Again,
the
results s h o w
not much degradation in
p e r f o r m a n c e if
variable
scaling i s
omitted. Neither bound
check ing strategy impedes the progress
of
the so lve r .
The best
r va lu e
var ies
drasti
ca l l y for this set of
problems.
Some problems w e r e c o n v e r g e d requiring the minimum
iterations
with a r
va lu e
less than one.
There
w er e
a
f ew
cases
ach i ev ing
convergence
with
minimum
number of
iterations with a r va lu e
of
larger than one. N o
apparent
optimum
va lu e for fis found. Although
the
va lu e of r is not reported here, it should
be noted that the number of iterations
i s
quite sensitive to the va lu e of r. This
is
p o s s i b l e because r determines the initial trust
region. This
may l ead to taking
the
wrong direction
in i t ia l ly
b y
not interpolating
between the
directions of Newton's
method and
the
steepest-descent
method. Then the trust r eg ion
can
not recover to
guide the direction of interpolation step.
We
observed that for seve ra l fai led cases ,
the trust
reg ion
w as very
small implying that
only the
steepest descent
d i r ec t i on
w as
used in the solution process . The algorithm detected that c o n v e r g e n c e
was
too
s low
and the iterative
calculation
stopped.
We
attempted to
overcome
this p r o b l e m b y
switching
to
Newton's method after
seve ra l
consecutive steepest-descent
iterations.
For
some problems, this
appeared
to
be he lp fu l . Unfortunately,
this
quick
fix a l so
fai led
for some cases .
C onsequ en t ly , there
is
still no
easy w a y
of avo id ing taking
too
many
steepest-descent steps.
In
summary,
w e
f o u n d
that the modi f i ed Powel l ' s dog leg method
i s r e l i able
in
so lv ing the ful l and sparse systems of
nonlinear
equations. The fu l l matrix vers ion of
this so lve r
is
u s e d
to so lve
nonl inea r equations that arise from our
sequential
modular
7/26/2019 Development of a process simulator using object oriented programm.pdf
49/148
36
simulator. For the sparse
set
of
nonlinear equations in equation-based simulation, the
sparse
vers ion of the modi f ied P owe l l ' s d og l e g method with either
Schubert's update
or
Bogle ' s update is
suitable for solving these equations. Both
vers ions
of
the update
are
implemented.
An
example illustrating the use of our equation so lve r i s
shown
be low.
The
text that appears after
'//'
s a comment statement in C++ M o r e exam
p les are
g i ve n
b y Varma [67] . In i t ia l ly , an array of 1 2 e l e me n t s of Equation-variable
i s
de f ined. These
are the unknowns
in
our equations. Simi la r ly ,
an
array of Equation
is d e c l a r e d so that equations can
be
d e f ine d . F ina l l y , an Equation.set i s n e e d e d
to
store al l
def ined equations.
After
setting
initial
guesses to
the unknowns , the set
of
equations can
be
so lved
eas i ly with
the
'solve()' operation.
In the d e ve lop me n t of both the
full
matrix
and
sparse matrix solvers , w e found
that objects l ike
Matrix, Sparse-matrix, Permutation-vector
and DiagonaLvector are
v e r y helpfu l . A s
an
example, for the Broyden's update, a se c t i on of the code that
performs this
update is
shown in Figure 3.3 .
The
statement
m i m i cs
exactly
the
mathematical
form of
Broyden's
update,
equation
3.2 ,
except
the
last
'()'
in
the
se c ond
statement. In
contrast, one
has to ca l l a
subroutine
o r
inser t
'DO'
l oop s in
a Fortran program to ac c omp l i sh the same
task. Then,
one
l oses
the mathematical
form of
the
or ig ina l equation.
In an
object oriented programming language,
one def ines new data types and
al l
operations that
are deemed log ica l
and
necessary in
manipulating
these ne wly
def ined types. In other wor d s ,
one
can extend the language i t se l f to ac c omp l i sh one's
task.
In most c onve n t iona l programming languages l ike Fortran, data types
of rea l
and
integer
come with the
language.
In addition,
al l
me an ing fu l and
fundamental
mathematical operations l ike '+', '/'?
others
that
one
can perform
on
7/26/2019 Development of a process simulator using object oriented programm.pdf
50/148
37
#include Equation_set.h
#include
bool.h
mainO
c
int
n
= 12; // Order of equation
set
Vector x( eqn2.dat ); // Load initial guesses vector
Equation.variable X[12]; //
Declare number
of unknowns
Equation
e[l2];
// Declare number
of
unknowns
II Define equations using unknown variables defined above
e[0] = 100.0*0.220
-
X[10]*X[0]
-
XCll]*X[5];
eCl]
=
100.0*0.660
-
X[l0]*X[l]
-
X[11]*X[6];
eC2] = 100.0*0.114
-
X[10]*X[2]
-
X[ll]*X[7]
e[3] =
100.0*0.002
-
X[10]*X[3]
- X[ll]*X[8];
e[4] =
100.0*0.004
-
X[10]*X[4]
-
X[ll]*X[9]:
e[5]
=
X[0]
+
XCl]
+
X[2] +
XC3] +
X[4]
- 1.0;
e[6] = X[5] + X[6] +
X[7]
+ X[8] +
X[9]
- 1.0;
e[7] = X[0]
-
66.67*XC5]
e[8] = X[l] -
50.0*X[6]
e[9] = X[2] -
0.015*XC7]
e[10] =
X[3]
-
100.0*X[8]
eCll] = X[4]
-
33.33*X[9]
// Set initial guesses of unknowns
for
(i
= 0; i < n; i++)
X[i]
7/26/2019 Development of a process simulator using object
Top Related