2006 - Modeling and Optimization of An Ammonia Reactor Using Multiple-Shooting Method
2006 - Modeling and Optimization of An Ammonia Reactor Using Multiple-Shooting Method
Multiple-Shooting Method
By
JANUARY 2006
31750 Tronoh
b
Perak Darul Ridzuan PUSAT SUMSER MAKLUMAT
UNIVERSiTI TEKNOLOGI PETRONAS
W ,9 J
1'NlVERSITI TEKNOLOGI PETRONAS
.nuiion Resource Center ^
'100^
By
(PClMslindaZabiri)
CERTIFICATION OF ORIGINALITY
This is to certify that I am responsible for the work submitted in this project, that the
original work is my own except as specified in the references and acknowledgements,
and that the original work contained herein have not been undertaken or done by
unspecified sources or persons.
n
ABSTRACT
Optimization is concerned with selecting the best among the entire set by efficient
quantitative methods. It is much very often required to solve dynamic optimization
problems in the design and operation of complex chemical processes. The objective of
this final year project is to model and find anoptimal design for an ammonia reactor. For
the past few years, ammonia has been widely used in the manufacturing of fertilizers,
explosives and other chemical products. Hence modeling and optimizing ammonia
synthesis has received a lot of attention among process industries. Apart from
determining the optimal reactor length, the comparison ofresults obtained from different
methods is presented.
The production of ammonia depends on temperature of feed gas at the top of the reactor
(top temperature), the partial pressures of the reactants and the reactor length. The
optimal design problem requires obtaining the optimal reactor length with maximum
economic returns corresponding to various top temperatures.
This paper presents an alternative approach in solving the boundary value problem and at
the same time determines the optimal solution. This method is called multiple-shooting.
The software used for this modeling is MATLAB version 6.1. The ODE integration
routine technique used is 'ode45' and the optimization routine of 'FMINCON' is
selected. Apart from determining the optimal length ofreactor, the comparison of results
reported in earlier literature is analyzed and presented.
In this project, the values profiles of top temperature (Tf), reacting gas temperature (Tg)
and mole flow rate of nitrogen per area catalyst (Nn2> at a top temperature of 694K were
generated. From the results obtained, a top temperature of 694K yields an objective
function value of $5.0155 x 106 at an optimum reactor length of 6.6953m. These values
agree with the latest literature work onthe same case study that uses different method. By
analyzing the results, multiple shooting method is found to be a robust, simple and fast
computation technique for optimization problems in chemical processes.
in
ACKNOWLEGDEMENT
In order to complete the Final Year Research Project, many steps and procedures need to
be taken and followed thoroughly. It would have been an intricate task to complete
within the given time frame. It is the support and patience of the following individuals
that made my project successful.
My foremost gratitude goes to Pn. Haslinda Zabiri, my supervising lecturer who has
helped tremendously by giving me precious insights and advices. Her supervision and
guidance in accomplishing the scheduled tasks has indeed useful and a remarkable one
towards fulfilling thisFinal Year Research Project's requirements.
I also extend my appreciation to Dr. Suzana Yusup, my co-supervisor for providing detail
explanations on the topic. Her elaboration on methodology has assisted me very much.
Being under hersupervision has been anirreplaceable experience.
Special thanks go to Pn. Yuliana Yuhana and Mr. Bawadi Abdullah, coordinators ofFinal
Year Research Project for providing the basic needs to complete this project successfully.
I would also like to acknowledge my family, course mates and seniors for all the
motivation and help extended to me throughout the project duration. Last but not least, I
would like to acknowledge others not named here for their input, guidance, assistance
and suggestions.
IV
TABLE OF CONTENTS
CERTIFICATE OF APPROVAL i
CERTIFICATE OF ORIGINALITY ii
ABSTRACT i"
ACKNOWLEDGEMENT iv
LIST OF FIGURES vii
LIST OF TABLES viii
NOMECLATURE ix
CHAPTER 1: INTRODUCTION
VI
LIST OF FIGURES
vn
LIST OF TABLES
Table 4.1 Summary of number of intervals, time taken, profit and optimal reactor
length for initial guess of 7m.
Table 4.2 Summary of initial guess of reactor length, intervals, timetaken for
optimization terminated successfully and number of iterations
Table 4.3 Summary ofinitial guess of reactor length, objective function and optimal
reactor length for two intervals
Table 4.4 Summary of initial guess ofreactor length, objective function and optimal
reactor length for four intervals
Table 4.5 Summary of initial guess ofreactor length, objective function and optimal
reactor length for eight intervals
Table 4.6 Results obtained from optimization for two intervals
Table 4.7 Results obtainedfrom optimization for four intervals
Table 4.8 Results obtainedfrom optimization for eight intervals
Table 4.9 Reactor length at which variables NN2 and Tf intersect
Table 4.10 Optimum reactor length &Objective function using various Numerical
Methods
vm
NOMENCLATURE
Nn2 Mole flow rate of nitrogen per area catalyst (kgmol/m .h)
f Catalyst activity
IX
CHAPTER 1
INTRODUCTION
o
r*
o
o
-w
to
•H
pa
O
>
C/3
Cocttng
***" Cwb«n OtoKM*
mmmmt
COjRemoval j
Ammonia
AMMONIA SYNTHESIS METHANATOR
j^j K^03*Hp +C02—^ 2KHCOi^ IGWTEMPSHIT
{Ammonia Formation) COJCGjPolbhinii (COConvers'MHiJ
2KHC03*""* KtfOs+H^*C02|
Ammonia synthesis using the Haber process is restricted by unfavourable position of the
chemical equilibrium and by the relatively low activity of the promoted iron catalysts.
Even at high pressure such as 30 MPa, not more than 20-25% of the synthesis gas is
converted to ammonia per pass. The unreacted gas mixture is returned to the reactor.
Since its development in 1913, industrial ammonia synthesis has always implemented a
recycle process. Thus to produce 1 kg ammonia, 4-6 kg synthesis gas must be recycled
through the reactor. To improve this, many studies were completed to find the optimal
design of an ammonia reactor. According to Babu, Angira and Nilekar (2004), the yield
of ammonia depends on the temperature of the feed gas at the top of the reactor i.e. top
temperature, the partial pressures of the reactants (nitrogen and hydrogen) and the reactor
length. Thousands of combinations of feed gas temperature, nitrogen mass flow rate,
reacting gas temperature and reactor length are possible. The optimal design problem
requires obtaining the optimal reactor length with maximum economic returns
corresponding to the various top temperatures.
At the end of the 19th century, Chilean nitrates, were the major source of nitrates at the
time for the Germans. It was clear, that this source would not be able to meet future
demands. It was also realised that in the event of a war, any nation cut off from the
Chilean supply, would not be able to make adequate amounts of munitions (military
weapons). Germany (Haber's native country) was in particular dependent on this source
of nitrogen compounds, to manufacture explosives. Following the allied block of the
South American ports, this supply was well and truly cut off An alternative method of
producing nitrates was needed. Fritz Haber and Carl Bosch promptly developed this
process in 1909 and had it patented in 1910. In World War 1, had Haber not invented the
process, Germany would have been forced to surrender years earlier than it did. As a
result the Haber-Bosch process indirectly, cost thousands of people their lives. Soon, the
Germans adopted this process and started producing ammonia at industrial scale.
The process is highly exothermic with a AH value of 92.2 kj per mole. As a result a
compromise has to be made withregards to what temperature is used. A high temperature
favours a higher rate of reaction and so equilibrium is reached more quickly; a high
temperature however favours the backward reaction since the process is exothermic (Le-
Chateliers principal states that any changes made to a reaction mixture will be
compensated for by the reaction). Therefore, since the process is exothermic, increasing
the temperature promotes the backward reaction since this takes in heat from the
surroundings, hence lowering the temperature. As a result, a compromise is made
between the two. This compromised temperature is between 673 ~ 923 Kelvin.
The catalyst provides an alternative pathway for the reaction to occur, which has lower
activation energy. This means that a lower temperature can be used without
compensating the rate too much. Carl Bosch found that a mixture of Fe203 and Fe304
catalyses the reaction best over the temperature range 650 ~ 950 Kelvin.
Also due to Le-Chateliers principle a highpressure is used. The mol ratio of gases is 4:2,
therefore if a high pressure is used the forward reaction is promoted, since at a higher
pressure the products hold a smaller volume, hence decreasing thepressure. The pressure
used is 200 - 400 atmospheres, which is quite high.
In this process, the inlet synthesis gas flows through an annular space and into an
internally located heat exchanger that preheats the gas to synthesis temperatures.
Quenching thebed effluents with cold synthesis gas controls inlet bed temperature. Most
of conversion occurs in the first bed which has the highest driving force to the
equilibrium. A bypass is provided around theintercooler for temperature control.
The ammonia converter (reactor) operates at high pressure ranges 100 - 300 bars. Its
catalyst bed is divided into 3 layers. Quench gas is supplied in between beds and internal
heat exchanger is provided to maintain the temperature at optimum level. The Synthesis
Gas is fed to Converter at 150°C. The monitoring parameters are temperature profile and
flow rate in ammonia converter.
Quench Gas
Syn Gas
Reactor
Compressor
HEX
150°C/300 bars
800°C To coolers/chillers
In 1970, Murase et al. applied the Pontryagin's maximum principle to compute the
optimum temperature trajectory along the reactor length. Although their formulation was
correct, the stated objective function was wrong. This error was identified by Edgar and
Himmelblau (2001) and used Lasdon's generalized reduced-gradient method to arrive at
an optimal reactor length corresponding to a particular reactor top temperature of694K.
However a term mentioned in Murase's formulation was ignored, pertaining to te cost of
ammonia already present inthe feed gas, inthe objective function. Also the expression of
the partial pressure ofnitrogen, hydrogen and ammonia used to simulate the temperature
and flow rate profiles across the length of the reactor-were not correct. In 1990,
Vasantharajan et al. obtained the optimal combination ofthe feed gas temperature at the
top ofthe reactor and reactor length using a non-linear programming technique. Only a
few internal points along the length ofthe reactor were selected for the simulation ofthe
7
reactor profiles. This does not appear to do justice to the not-so smooth reactor profiles
and leaves behind an uncertainty of the globality of the obtained optimal solution.
A study done by Upreti and Deb (1996) used genetic algorithms (GA) to determine an
optimal design for an ammonia reactor. This method is a search and optimization
technique based on principles of natural genetics. Although there exist at least a couple of
other studies on the optimal design of ammonia synthesis reactor, they have ignore some
terms in the formulation of the objective function, for which the reported optimal solution
does not match with the solution obtained using an enumerative search technique (Upreti
and Deb, 1996). Using GA, the optimal reactor length was found to be at 5.33m and the
typical economic return from the reactor operation with a top temperature of 694K comes
out to be$4.23 xlO6/year.
On another latter study, Babu, Angira & Nilekar (2004) published a paper which presents
the application of two methods; i.e. Runge-Kutta variable step size and Gear's method in
combination with Differential Evolution and verify the contradictory results reported
using simple GA in the earlier literature. The results obtained indicate that the profiles of
temperature and flow rate are smooth. At the top temperature of 694K, the reactor length
was found to be 6.79m and gave the optimum objective function value of $4.84 x 106/
year.
Cooling zone
Catalyst zone
Tube Wall
Heat flow
(AQ)
Figure 2.2: Ammonia synthesis reactor. The shaded blue coloured area contains the
catalyst [Adapted from Murase et al., "Optimal Thermal Design of an Auto-thermal
Ammonia Synthesis Reactor," Ind Eng Chem. Process Des Dev 9:504 (1970). Copyright,
American Chemical Society.]
The yield of ammonia depends on the temperature of feed gas at the top of the reactor
(top temperature), the partial pressure of the reactants and the reactor length. The optimal
design problem is to obtain the optimal reactor length which yields the maximum
economic returns from the reactor operation corresponding to various top temperatures.
Objective Function
F =/(z,iVA,2,rg,r/) =1.33563xl07~1.70843xl04^2+704.09(rg-r0)-
(Eq. 2)
699.27(7} -TQ)-[3.45663xlO7 +1.98365xl09z]( ]0.5
The objective function, F depends on four variables: the reactor length (z), mole flow rate
of nitrogen per area catalyst (N^), the top temperature (Tg) and the feed gas temperature
(Tf). From the system model, there are three differential equations and four variables,
making the degree of freedom equal to one. By specifying the length of reactor, the
remaining variable can be calculated using the system model and the pass these variables
to the optimization routine as shown below;
(Ode45)
Not optimized
(Tf,Tg,NN2andz)
Initial guess of
i r:\ i i \ v v " \ v i
\L' 1V1J.1 N\^W LNJ
(Tf,Tg,NN2andz)
Optimized Value
Mass Balance, N2
.1-5
dNN2 k PxiPm fc VNH (Eq. 5)
= ~f
dz NM, 2 P'i2 /
10
where
f- 20800^
*,= 1.78954 xl04exp
-47400
k2 = 2.5714 xl016exp
7?r.
* j
286(2.23NN-2NN)
Pnh, =
2.598tf„+2tf„
Boundary conditions
Inequality constraints
The upper and lower bounds of the design variables are:
0<NNz <3220; 400 <7} < 3220; z>0
The reacting gas temperature (Tg) depends on the nitrogen mass flow rate (Nn2), feed gas
temperature (Tf) and reactor length (z). Hence no implication on any boundaries of Tg
required. All the initial guesses for all variables will be specified in the model and
optimal solution is produced.
11
CHAPTER 3
METHODOLOGY
3.2 Tool-MATLAB
MATLAB is an interactive system whose basic data element is an array that does not
require dimensioning. Many technical computing problems can be solved using
MATLAB, especially those with matrix and vector formulations in a fraction of thetime.
It would take a lot of time to write a program in a scalar non-interactive language such as
C or FOTRAN compared to the simple language of MATLAB.
MATLAB which stands for matrix laboratory was originally written to provide easy
access to matrix software developed by the LINPACK and EISPACK projects.
12
MATLAB has evolved over a period of years with input from many users. It has become
a standard tool for students to use in introduction and advanced courses in mathematics,
engineering and science. It is also the tool of choice for high-productivity research,
development and analysis in many industries.
Ode45 is a function to solve initial value problems for ordinary differential equations
(ODEs). This function is more suitable for non-stifftype of problem. It also has medium
level of accuracy.
Syntax
[L, Y] = ode45 ( odefun, tspan, yO, options)
where L is dependent variable and T is independent variable.
Arguments
i) odefun A function that evaluates the right-hand side of the differential equations.
It solves systems of equations in the form y' = f(t,y) or problems that
involve a mass matrix, M(t,y) y' = f(t,y).
ii) tspan A vector specifying the interval of integration, [to,tf].
iii) yO Initial value of y.
iii) options Optional integration argument created using the odeset function.
13
c{x) < 0
ceq(x) - 0
min
f(x) subjected to Ax < b
x
Aeq.x = beq
lb<x<ub
Where x, b, beq, lb and ub are vectors, A and Aeq are matrices, c(x) and ceq(x)
are functions that return vectors, and f(x) is a function that returns a scalar. f(x),
c(x) and ceq(x) can be nonlinear functions.
Syntax
x = fmincon (fun, xO, A, b, Aeq, beq, lb, ub, cons, options)
Arguments
i) fun The function to be minimized. It accepts a vector x and returns a scalar f,
the objective function evaluated at x.
ii) cons The function that computes the nonlinearinequalityconstraints c(x) <0
and the nonlinearequalityconstraints ceq(x) - 0. This function accepts
a vector x and returns two vectors c and ceq. The vector c contains the
nonlinear inequalities evaluated at x, and ceq contains the nonlinear
equalities evaluated at x.
iii) options Provide parameters which are onlyrelevant when using large-scale
algorithm or medium-scale algorithm.
14
solver at each iteration. The control variables are represented as piecewise polynomials
and optimization is performedwith respect to the polynomial coefficients. The sequential
approach is a feasible path method; in every iteration the DAE system is solved.
However, this procedure is only robust when the system contains stable modes.
Otherwise, finding a feasible solution for a given set of control parameters maybe
difficult.
The simultaneous approach is based on complete discretization of the state and control
variables leading to a large-scale non-linear programming (NLP) problem. This method
directly couples the solution of the DAE system with the optimization problem; the DAE
system is solved only once, at the optimal point, and therefore can avoid intermediate
solutions that may not exist or may require excessive computational effort. They have
advantages for problems with path constraints and with instabilities that occur for a range
of inputs. On the other hand, disadvantages include the question of where to place the
finite elements in order to maintain accuracy of the discretized DAE model and to
determine the optimal breakpoint location in the optimal control profile, as well as the
need to solve large NLP.
15
Figure 3.1: Illustration of Single Shooting Method
y 1
•••: r«...r- '""""-] fi.0
1 I j j }•• •i 1 r
| ]"7j"""| [" / / -sU
> I / !
'7 5$2iy
* Hfcynp
I /
Direct single shooting method represents a pure sequential approach whereas multiple
shooting is considered as a hybrid approach because the model equations are solved
"exactly" only on intervals during the solution iterations. Therefore direct single shooting
method only requires two boundary initial value guesses (i.e. a and b) whereas multiple
shooting approach requires initial guesses for all the node values (i.e. xu x2, ...). The
disadvantage of single shooting method is there can be serious problems with the
16
accuracy. The problems occur when making the correction to the calculated vector. This
vector is usually corrected using a modified Newton's Method and in practice, the system
must be linearized to use this method. If error is large, then convergence can be quite
slow. This drawback can be fixed by implementing multiple shooting method.
For multiple-shooting, the length of the reactor is partitioned into smaller length elements
and the DAE models are integrated separately in each element. Equality constraints are
added to the nonlinear program in order to link the elements and ensure that the states are
continuous across each element. Inequality constraints for states and controls can be
imposed directly at the grid points.
17
a) ode3.m - To declare the variables, parameters and problems formulated in the
optimization programs. This m-file need to be created first so that the
subsequent m-files can run.
function dy = odel(L,z)
% Equality constraints
pl=286*z(l)/deno;
p2 = 3*pl;
p3 = 286*(2.23*yl0 - 2*z (l))/deno;
dy(l) = -f*sub;
dy(2) = -U*Sl/(W*Cpf)*(z(3)-z(2));
dy(3) = -U*Sl/(W*Cpg)*(z(3)-z(2)) + (-dH)*S2/(W*Cpg)*(-dy(l));
b) Objfun.m - To define the objective function which is a function of Tf, Tg ,Nn2 and
length of reactor, z. The objective function value is equals to the
profit margin.
function obj = objfunfy)
TO = 694; % initial T
18
c) Constraints.m - To define all the equalities and inequalities constraints for the
reactor. By running this program, profiles of Tf, Tg and Nn2 at a
specific length of reactor can be generated.
function [c,ceq] = mycon(y);
c~[]; % no inequalities
19
3.5 Project Process Flow
20
CHAPTER 4
From the results obtained, it is clear that irrespective of the number of interval, the same
optimized values for objective function ($5.0155 x 106/year) and reactor length
(6.6953m). This consistency authenticates the robustness of the multiple shooting method
regardless the number of intervals.
From Table 4-1, an initial reactor length of 7m is the nearest to the optimal value which is
6.6953m. The least time taken is 2.172s for two intervals, followed by four intervals
which give a reading of 5.828s and finally 19s for eight intervals. This proves that as the
number of intervals increases, the more iteration is required to optimize the objective
function and as a result of that, the time taken increases. Also the closer the initial
guesses to the optimal value, the lesser the time taken for the convergence.
21
iInitial guess of 2m Initial guess of4m
(a) Initial reactor length guess of 2m (b) Initial reactor length guess of 4m
2011
15-Mi
"• 10 JK
5-BB
0-jHI
2 4 8
(c) Initial reactor length guess of 5m (d) Initial reactor length guess of 7m
(e) Initial reactor length guess of 10m (f) Initial reactor length guess of 15m
Figure 4.1: Convergence time comparison for 2,4 and 8-intervals for varying initial
guessed values of the reactor length
22
Initial guess of Objective function, F Optimal reactor length,
reactor length (m) (Profit Margin, $/yr) (m)
2 4.45973x10° 3.5667
4 4.45973x10° 3.5667
5 5.0155 x 10° 6.6953
7 5.0155 x 10° 6.6953
10 5.0155x10° 6.6953
15 5.0155x10° 6.6953
Table 4.3: Summary of initial guess of reactor length, objective function and optimal
reactor length for two intervals
Based on Table 4-3, Table 4-4 and Table 4-5, the objective function and optimal length
reactor show consistent values of $5.0155 x 106 per year and 6.6953m respectively.
However, as shown in Table-2, two intervals failed to converge to the correct values
when subjected to poor initial guesses of 2m and 4m. When these two values were used,
the objective function was only $ 4.45973 x 106 per year with corresponding reactor
23
length of 3.5667m only. This is because for multiple-shooting, one of the requirements is
that the need to supply the initial guesses for all the nodes values. The more intervals
used in the system, the more node values can be initialized and clearly if the state
trajectory is known, this can dampen the effect of bad initial guesses for the inputs. The 4
and 8-intervals system has more node and input values that can be specified compared to
2-intervals systems. These node values for the states and the intermediate reactor initial
guesses dampen the effect of the initial reactor length guesses of 2m and 4m, and the
solution converges. Overall, these results show that the higher the number of intervals
used, the more robust the multiple-shooting method to bad imtial guesses.
•NN2
Tf
•Tg
2 4 6
24
Profiles at a top temperature of 694K for 4 intervals
NN2
Tf
Tg
2 4 6
25
Profiles at a top temperature of 694K for 8 intervals
NN2
Tf
Tg
2 4 6
26
4.3 Comparison with previous studies
From the Table 4-9, the difference in prediction of intersections is less than 5.0%
between multiple-shooting method and RKVS & GEAR method. Hence this indicates
that multiple-shooting method gives accurate results and suitable to be used as an
alternative method for solving the three coupled differential algebraic equation.
The table above shows the results obtained from different methods and its comparison
with those obtained in [1, 2, 3, 4, 5] using Pontryagin's Maximum Principle (PMP),
Lasdon's Generalized Reduced-Gradient method (LGRG), Genetic Algorithm (GA),
27
Runge-Kutta Variable Size (RKVS) with Differential Evolution (DE), Gear's Method
(GEAR) with DE and Single Shooting Method respectively. From Table 4-10, the
optimum reactor length of 2.58m is reported in [2] and 5.18m in [1], both of which are
wrong due to the errors in their problem formulations as pointed out in [3]. An optimum
reactor length of 5.33m and the corresponding objective function value is $4.23 x 10°7
year, reported in [3] are also not correct as found [4]. Among other methods, GEAR and
RKVS have the same objective function value though the optimum reactor length is
slightly different in each case. The correct optimum reactor length can be considered as
6.79m with an objective function value of $4.84 x 106/ year as reported in [4], The result
given by multiple-shooting strategy as found in this study agrees considerably well with
these values as reported by [4].
28
CHAPTER 5
For future projects, the ammonia reactor in the modeling can be changed from a packed
bed reactor to a different type of reactor. The optimization process could be different and
could be more profitable. This can be studied in detailed in the future.
29
CHAPTER 6
REFERENCES
[7] Fletcher, R. and MJ.D. Powell, "A Rapidly Convergent Descent Method for
Minimization," Computer Journal, Vol. 6, pp. 163-168,1963.
[8] Goldfarb, D., "A Family of Variable Metric Updates Derived by Variational Means,"
Mathematics of Computing, Vol. 24, pp. 23-26,1970.
[9] Eymery J., Dynamic behavior of an ammonia synthesis reactor. (D.Sc. thesis). MIT
(1964).
[10] http://www.cheresources.com/ammonia.shtml
[II] http://www.imcatalvsts.com/pct/marketshome.asp?marketid=2&id=45
30