Modeling, Simulation and Control of A Drum Boiler
Modeling, Simulation and Control of A Drum Boiler
Introduction
There are dramatic changes in the power industry because of deregulation. One consequence
of this is that the demands for rapid changes in power generation is increasing. This leads to
more stringent requirements on the control systems for the processes. It is required to keep
the processes operating well for large changes in the operating conditions. One way to
achieve this is to incorporate more process knowledge into the systems. The goal is to
develop moderately complex nonlinear models that capture the key dynamical properties over
a wide operating range. The models are based on physical principles and have a small number
of parameters; most of which are determined from construction data. Particular attention has
been devoted to model drum level dynamics well. Drum level control is an important
problem for nuclear as well as conventional plants. In Parry, Petetrot and Vivien (1995) it is
stated that about 30% of the emergency shutdowns in French PWR plants are caused by poor
level control of the steam water level. One reason is that the control problem is difficult
because of the complicated shrink and swell dynamics. This creates a nonminimum phase
behaviour which changes significantly with the operating conditions. Since boilers are so
common there are many modelling efforts. There are complicated models in the form of large
simulation codes which are based on finite element approximations to partial differential
equations. Although such models are important for plant design, simulators, and
commissioning, they are of little interest for control design because of their complexity. The
model presented here is adapted from K.J Astrom and R.D. Bell (1998). A nonlinear dynamic
model for natural circulation drum-boilers is adapted. The model describes the complicated
dynamics of the drum, downcomer, and riser components. It is derived from first principles,
and is characterized by a few physical parameters. A strong effort has been made to strike a
balance between fidelity and simplicity. Since the model is derived from first principles it can
describe the system for a wide operating range.
Simulation of the model is done using MATLAB R2010a and results have been verified with
plant data presented in K.J Astrom and R.D. Bell (1998). The conventional PID controller is
applied when the boiler is operating at medium load for both servo and regulatory problems.
Advanced controllers such as Fuzzy logic controllers(FLC) and Neural Network(NN)
predictive controllers have been also tried with satisfactory results. The details of these
controllers are discussed in the report within.
The drum boiler is a simple boiler which consist of a drum, downcomer and riser
components. A simple schematic of the drum boiler have been shown in Figure 1. The heat
Q, supplied to the risers causes boiling. Gravity forces the saturated steam to rise causing a
circulation in the riser-drum-downcomer loop. Feedwater qf , is supplied to the drum and
saturated steam, qs, is taken from the drum to the superheaters and turbine. The presence of
steam below the liquid level in the drum causes the shrink-and-swell phenomenon which
makes level control difficult. In reality the system is much more complicated than shown in
the figure. The system has a complicated geometry and there are many downcomer and riser
tubes. The outflow from the risers passes through a separator to separate the steam from the
water. In spite of the complexity of the system it turns out that its gross behaviour is well
captured by global mass and energy balances.
The shrink and swell phenomena in a drum boiler makes the level control very
difficult. Under boiling conditions, steam supporting field products such as bubbles
exist below the water/steam level interface. These bubbles have volume and therefore
displace water to create a misrepresentation of the true water level in the drum.
Another effect upon drum level is pressure in the drum. Because steam bubbles
compress under pressure the steam bubbles expand or contract respective to these
pressure changes. A higher steam demand will cause the drum pressure to drop, and
the steam bubbles to expand to give the appearance of a water level higher than it
truly is.This fictitious higher water level causes the feedwater input to be shut down at
a time when more water is really required. A surge in water level as a result of the
drum pressure decreasing is called 'swell'. A water level decrease due to drum
pressure increase is called 'shrink'.
Chapter - 2
Modeling and Simulation
2.1 Global mass and energy balance equations
The global mass balance equation is
Rate of accumulation of mass in the system = Rate input of mass Rate output of mass.
[
.(1)
where
S= density of saturated steam (kg/m3)
Vst= total volume of steam in the boiler system (m3)
W= density of saturated water (kg/m3)
Vwt= total volume of water in the boiler system (m3)
qf= feed flowrate (kg/s)
qs=steam flowrate(kg/s)
The global energy balance is
Rate of accumulation of energy in the system = Rate input of energy Rate output of energy.
[
..(2)
.(3)
]
[
.
[
.
.
.
.
.
4
.
.
So
[
(5)
.
Where
.
=
(6)
.
.
.
)
.
.
.
.
.
.
and
. The
The condensation flow rate is given by a simple energy balance done within the system
(
where
.
.
pressure energy change within the system. The negative sign appears before
since
)..(8)
The energy balance can be derived as follows. Let us consider a infinitesimally small block of
cube through which the fluid is flowing. The cube is a control volume. We will do the energy
balance around this cube. The cube has three coordinates x, y and z. So
Energy flow into the cube- Energy flow out of the cube= Rate of change of energy
Energy flow into the cube=
Energy flow out of the cube=
.
.
Dividing both sides by dxdydz we get.
.
.
.
.
(10)
The specific internal energy of mixture of steam and water is
.(11)
Where
denotes the mass fraction of steam in the flow i.e. the quality of the mixture.
) (
where
. .(13)
To model drum level it is essential to describe the total amount of steam in the risers. This is
governed by the average volume fraction in the risers.
) ..(14)
(15)
.
.
.
.
(
.(16)
Circulation flow
The momentum balance for the downcomer riser loop is
8
Where Lr and Ldc are the length of riser and downcomer respectively, k is a dimensionless
friction coefficient and Adc is the area of the downcomer.
This is a first order system with time constant
.
With typical numerical values we find that the time constant is about a second. This is short
in comparison with the sampling period of the experimental data and we will therefore use
steady state relation.
.
.(17)
..(19)
Flow qsd is driven by the density differences of water and steam, and momentum of flow
entering the drum.
Good fit to the experimental data have been obtained with the following empirical model.
.(20)
Here Vsd0 denotes volume of steam in the drum in the hypothetical situation where there is no
condensation of steam in the drum and Td is the residence time of steam in the drum.
Drum level
9
.(21)
10
*(
*(
.
.(23)
Where
*(
+.
If the state variables p and r are known the riser flow rate qr can be computed from eq(13).
..(24)
Drum Dynamics
The dynamics for the steam in the drum is obtained from the mass balance (18). Introducing
(24) for qr , (19) for qcd and (20) for qsd we get
(
.
(
)
11
.
(25)
Where
*
(
)
+.
+.
.
2.6 Summary
The model can be written as
[
.
.
.
.
where
.
=
.
.
12
*(
+.
+.
+.
.
2.7 Steady state solution of the model
.
.
.
.
Where qdc is given by equation (15) i.e.
A convenient way to find the initial values is to first specify steam flow rate q s and steam
pressure p. The feedwater flowrate qf and input power Q are given by the first two equations
and the steam volume in the drum is given by the last equation. The steam quality is
obtained by solving the nonlinear equations.
.
) .
Where
This is an ordinary differential equation which can be solved by MATLAB using the ODE
function. Basically we use ODE 45 since it is nonstiff differential equations. The ODE 45
implements the fourth or fifth order Runge-Kutta method.
2.9 Step Responses
Fuel Flow changes at medium load
A step change increase of 10 MW is given to the fuel flow rate and the results are discussed
below
As the steam flow out from the drum is constant ,this in turn keeps the pressure of the drum
constantly increasing at the same rate.The constantly increasing pressure in the drum causes
condensation to take place inside the drum which is the reason for an increase in the water
volume, Vwt within the drum.Initially the steam quality at riser outlet shows a rapid increase
and then as time value increases,the quality of steam tends to become more stable with
gradual increase. The volume of steam inside the drum initially shows an increases by a small
volume and eventually decreases as time value increases. As seen from Figure 2 we note a
sharp initial increase in the steam volume and then a steep fall in the curve, the sharp
increases could be atrributed with the increasing steam flowrate in the riser whereas the steep
fall occurs due to the increase in pressure within the drum causing condensation to take place.
At the onset of the step there is a rapid increase in the outlet flow rate of the steam from the
risers as the flowrate of steam from the outlet of the riser needs to match the downcomer
14
flowrate we observe a decrease in the outlet steam flow rate .These flow rates equalize
almost after 30 seconds. The condensation flow changes in an almost step like manner. A
combination of water and steam dynamics are responsible for the response in drum level
indication and is somewhat complicated .The initial increase in the water level is due to the
rapid initial response of steam. The response in level is a combination of two competing
mechanisms. The water volume in the drum increases due to increased condensation caused
by increasing pressure. The volume of steam in the drum first increases a little and then it
decreases because of the increasing pressure.
A step increase of 10 kg/s in steam flow at medium load is given and the results are
discussed below.
As observed in figure 3 there is a linear decrease in the pressure of the steam because
of an increased steam flow rate. As we note a decrease in the pressure of steam , this
causes an increase in the evaporation rate of the water within the drum, in turn
causing an overall decrease in the water volume within the drum boiler system. As
mentioned above the steam quality at the riser outlet first increases rapidly due to
pressure decrease and it then decreases due to an increase in the water circulation flow
rate. The drop in steam pressure within the boiler system causes an increase in the
steam volume .There is very rapid increase of flow out of steam from the riser as a
reason of high pressure drop within the system. After this initial transient response of
the riser flow rate it decreases to match the downcomer flow rate.The decreased steam
pressure causes both the downcomer as well as riser flow rates to increase. The
constant decrease in the pressure happens to create an almost step like decrease in the
condensation flow rate response.
The shrink and swell effect is clearly visible. The contributions from the volumes of
steam and water have initially the same sign. There would however be a decrease in
the water volume because of steam flow rate alterations.
16
Fig 2: Response due to step change in steam flow rate at medium load.
17
Chapter 3
Control Schemes
The feedback control scheme will be implemented to control the water level with the
conventional PID controller and advanced controller fuzzy logic controller(FLC).
However we will try only feedwater flow rate as the manipulated variable and both
servo and regulatory testing will be done.
The feedback control scheme
3.1 PID controllers
The control implemented by the PID controller can be given as
(27)
Advantages
Disadvantages
Manual Tuning
Requires
personnel.
Zeigler-Nichols
Software tools
Cohen-Coon
experienced
starts to oscillate. For a quarter amplitude decay type response the KP value should
be set as half of the value at which the response starts to oscillate. Next we have to
increase KI until the offset is eliminated in sufficient time of the process and at last
increase KD, if required until loop is quick to reach its reference after a load
disturbance. But, too much increase in KD can cause excessive response and
overshoot. A fast PID loop usually overshoots a little bit to reach its response
reference point more quickly; however in some system overshoot is not acceptable, in
which case we require an overdamped response.
Parameter
Rise time
Overshoot
Settling
time
Steadystate error
Stability
Kp
Decrease
Increase
Small
change
Decrease
Degrade
KI
Decrease
Increase
Increase
Eliminate
Degrade
KD
Minor
change
Decrease
Decrease
No effect in Improve in
theory
Kd small
Fig 5: Simulink model to control the level in feedback control scheme using the PID
controller.
20
21
22
NB
NS
ZO
PS
NB
PB
PB
PM
PS
ZO
NS
PB
PB
PS
ZO
NS
ZO
PB
PS
ZO
NS
NB
PS
PM
ZO
NS
NB
NB
PB
ZO
NS
NB
NB
NB
PB
23
Traditional optimization
Genetic Algorithm
Region I
Converges to 1
Converges to 2
Region II
Converges to 2
Converges to 2
Region III
Converges to 3
Converges to 2
The differences between GA and traditional methods of optimization can be stated as:
24
GA use the objective function information and not the derivative or second
derivative.
GA use stochastic transition rates , not deterministic rates.
In our case the objective function is to minimize the integral of square error(ISE) and
the variables are k1, k2 and k3. k1 , k2 , k3 are the values which need to be multiplied
with the ranges of the functions E, E and W. The optimum values of k1,k2 and k3
are obtained by using GA inthe optimization toolbox in MATLAB.
25
Neuron Model
The scalar input p is multiplied by the scalar weight w to form wp , one of the
terms that is sent to the summer. The other input,1 , is multiplied by a bias b and then passed
to the summer. The summer input often referred to as net input , goes into a transfer function,
f which produces the scalar neuron output a.
26
Typically a neuron has more than one input . A multiple input neuron is shown in figure 12.
The neuron has a bias b, which is summed with the weighted inputs to form the net input n.
.
which can be written in matrix form as
..(30)
Where the matrix W from the single neuron case has only one row.
27
28
]..(31)
where u(k) is the system input , y(k) is the system output and d is the system delay (we will
use a delay of 1 for the predictive controller).
29
].(32)
..(33)
where N1 , N2 and Nu define the horizons over which the tracking error and the control
increments are evaluated. The u variable is the tentative control signal , yr is the desired
response and ym is the network model response. The value determines the contribution that
the sum of the squares of the control increments has on the performance index..
The following block diagram illustrates the model predictive control process. The controller
consists of the neural network plant model and the optimization block. The optimization
block determines the values of u that minimize J and then the optimal u is the output to the
plant.
30
Fig 20: The Simulink model for neural network predictive control.
31
Chapter 4
Results and Discussions
4.1 PID controller
4.1.1 Regulatory Problem
In the first regulatory problem we are giving a step change in fuel flow as 10 MW.
The PID parameters obtained by manual tuning are
KC = 500
I = 1 , D = 1.
The response of the system can be seen as follows
32
Time period, T= 30 s
Response time , ts = 100 s
Decay ratio = 0.33.
Overshoot = 0.58
The manipulated variable i.e. feedwater flow rate changes are given by
33
34
35
36
Fig 25 : Changes in feed water flow rate to control the level.(servo problem)
The changes in the feed water flow rate at the beginning rises to almost 180 kg/s and
then drops to almost 15 kg/s and after about 150 s it settles to a constant value of 50
kg/s.
4.2 Fuzzy Logic Controller
4.2.1 Regulatory Problem
Step Change in fuel flow rate by 10 MW
The membership function of the fuzzy logic controller before optimization are shown
below
37
Fig 27: membership function for input variable E. Range [-0.1 0.1]
Fig 28: membership function for output variable W . Range [-20 20]
The responses before and after optimization of the membership functions are
compared below. As can be seen from the figure that the integral of square error (ISE)
before and after optimization have a difference of almost 26. The three values k1,k2
and k3 which are multiplied with the membership functions of E,E and W
respectively to minimize ISE are 0.109,0.814 and 0.302 respectively.
38
Fig 27: response before optimization of membership functions (change in fuel flow)
ISE=148.1217
Fig 28: results after optimization of membership functions (change in fuel flow)
ISE=122.0842
39
Fig 29: response of FLC due to step change in fuel flow rate.
Fig 30: changes in feedwater flow rate to control the level for FLC for a step in fuel
flow.
40
As we can see from figure 20 that the changes in feedwater flow rate can be limited
within a range ,in or case it is +- 20 kg/s but in PID controller it is not possible if the
disturbance by somehow increases to a great extent.
4.2.2 Servo Problem
The membership function of the fuzzy logic controller before optimization are shown
below
Fig 32: membership function for input variable E. Range [-0.1 0.1]
Fig 33: membership function for output variable W . Range [-20 20]
41
The responses before and after optimization of the membership functions are
compared below. As can be seen from the figure that the integral of square error (ISE)
before and after optimization have a difference of almost 0.3 which is low but the
response time decreases by an extent of almost 5 s. The three values k1,k2 and k3
which are multiplied with the membership functions of E,E and W respectively to
minimize ISE are 1.981,1.593 and 1.34 respectively.
Fig 34: response before optimization of membership functions (change in set point )
ISE=156.6541
Fig 35: response after optimization of membership functions (change in set point )
ISE=156.333
42
43
PID
ISE
FLC
ISE
PID
Response
time
FLC
Response
time
PID
Type of
response
Fuel flow
Steam
Flow
Set Point
147.57
147.55
122.08
--------
100 s
110 s
90 s
--------
Oscillatory Smooth
Oscillatory Smooth
160.95
156.33
90 s
105 s
Oscillatory Smooth
44
FLC
Type of
response
Chapter 5
Conclusion
After analyzing the results we can conclude as:
The model obtained clearly takes the shrink and swell effect in the drum
The water level contribution(lw) to the water level(l) actually is the water in
the drum and hence we can distinguish it from the model.
Both servo and regulatory problems are taken into account to control the water
level.
The feed water flow rate is very efficient in controlling the level of water.
PID gives an oscillatory response whereas FLC gives a smooth response.
We can restrict the manipulated variable, in our case the feed water flow rate
to a certain range in FLC but it is not possible in PID controllers.
45
References:
1) K.J.Astrom, R.D.Bell, Drum-boiler dynamics, Automatica,2000,vol 36,pg 363-378.
2) A.Parry, J.F. Petotrot and W.J.Vivier. Recent progress in sg level control in French
pwr plants. In Proc. Int. Conf on Boiler Dynamics and Control in Nuclear
Powerstations, pg 81-88. British Nuclear Energy Society ,1995
3) H.H. Hacene Habbi, M.Zelmat, B.O. Bouamama,A dynamic fuzzy model for drum
boiler turbine system,Automatica,2002,vol 39,pg 1213-1219.
4) E.J.Adam, J.L.Maarchetti (1997) ,Dynamic Simulation of large boilers with natural
circulation, Computers and Chemical Engineering,1999,vol 23,pg 1031-1040.
5) M.E. Flynn, M.J.O.Malley(1999), A drum boiler model for long term power system
dynamic simulation, IEEE transactions on Power Systems,1999, Vol. 14, pg .
6) H.Kim, S.Choi(2005), A model on water level dynamics in natural circulation drumtype boilers, International Communications in Heat and Mass Transfer,2005,vol
32,pg 786-796.
7) M.T.Hagan,H.B.Demuth,O.D.Jesus, An introduction to use of neural networks in
control system, International journal of robust and non linear control,2002, Vol 12
,pg 959-985.
8) M. Hudson Beale, M. T. Hagan, H. B. Demuth,Neural Network Toolbox 7,
Users Guide MATLAB.
9) D.M. Himmelblau,Applications of Artificial Neural Networks in Chemical
Engineering, Korean Journal. Chemical Engineering.2000,vol 17,pg 373-392.
10) Toshinori Munakata, Fundamentals of the New Artificial Intelligence, SpringerVerlag London Limited, 2008, ISBN- 978-1-84628-839-5.
11) Fuzzy Logic Toolbox, Users Guide, MATLAB ,R2014a.
12) Basics of S-functions retrieved march 5, 2014 from the world wide web
http://www.mathworks.in/help/simulink/s-function-basics.html
13) Fuzzy Logic toolbox retrieved april 5, 2014 from the world wide web
http://www.mathworks.in/products/fuzzy-logic/
14) PID Controller retrieved may 9, 2014
http://en.wikipedia.org/wiki/PID_controller.
46
from
the
world
wide
web
15) Neural Network toolbox retrieved may 5, 2014 from the world wide web
http://www.mathworks.in/products/neural-network/
47
Appendix A
MATLAB CODE
function[sys,x0,str,ts]=sfd302_sfcn(t,x,u,flag,x_init)
%sfd302 S-function version of the four state model
%compatible with simulink block diagrams.
global qr qdc qct;
%plant parameters------------------------------mt=300000;mr=100000;md=20000;Cp=650;
Cfw=4.18;Ad=23;Vd=37;Vr=37;Vdc=11;
Vt=Vd+Vr+Vdc;
ke=200;Vsd0=8;beta=0.3;
%properties of steam and water in saturated table
a01=2.7254E6;a11=-1.8992E4;a21=-1160.0;
a02=53.1402;a12=7.673;a22=0.36;
a03=1.4035E6;a13=4.9339E4;a23=-880.0;
a04=691.35;a14=-18.672;a24=-0.0603;
a05=310.6;a15=8.523;a25=-0.33;
%------------------------------------------------if abs(flag) ==1, %compute state derivatives
%state initial conditions
Vwt=x(1);
p=x(2);
ar=x(3);
Vsd=x(4);
%controls or inputs
Q=u(1)*1e6; %conversion to watts
qf=u(2);
tf=u(3);
qs=u(4)+4.8*(p-8.5); %correction for steam transducer
% properties of steam and water in saturated state
hs=a01+(a11+a21*(p-10))*(p-10);
dhsdp=a11+2*a21*(p-10);
rs=a02+(a12+a22*(p-10))*(p-10);
drsdp=a12+2*a22*(p-10);
hw=a03+(a13+a23*(p-10))*(p-10);
dhwdp=a13+2*a23*(p-10);
rw=a04+(a14+a24*(p-10))*(p-10);
drwdp=a14+2*a24*(p-10);
ts=a05+(a15+a25*(p-10))*(p-10);
dtsdp=a15+2*a25*(p-10);
%properties of water in subcritical state
hf=(Cfw*tf+p*1e3/rw)*1e3;
%the model equations-------------------hc=hs-hw;
hr=ar*hs+(1-ar)*hw;
%average steam quality volume rati and partial derivatives
z=ar*(rw-rs)/rs;
48
av=rw/(rw-rs)*(1-(1/z)*log(1+z));
davdar=rw/rs*((1/z)*log(1+z)-1/(z+1))/z;
zp=(rs*drwdp-rw*drsdp)*ar/rs/rs;
z1=(rw*drsdp-rs*drwdp)/(rw-rs)/(rw-rs);
z2=rw/(rw-rs)*((1/z)*log(1+z)-1/(1+z))/z*zp;
davdp=z1*(1-(1/z)*log(1+z))+z2;
%circulation flow
s1=ke*(rw-rs)*Vr*av;
qdc=sqrt(s1);
%equations for coefficents of derivatives of state variables
Td=600/qs;
Vst=Vt-Vwt;
Vwd=Vwt-Vdc-(1-av)*Vr;
e11=rw-rs;
e12=Vst*drsdp+Vwt*drwdp;
e21=hw*rw-hs*rs;
e22x=-Vt*1e6+mt*Cp*dtsdp;
e22=Vst*(hs*drsdp+rs*dhsdp)+Vwt*(hw*drwdp+rw*dhwdp)+e22x;
e3w=(rw*dhwdp-ar*hc*drwdp)*(1-av)*Vr;
e3x=(rs+(rw-rs)*ar)*hc*Vr*davdp-Vr*1e6+mr*Cp*dtsdp;
e32=((1-ar)*hc*drsdp+rs*dhsdp)*av*Vr+e3w+e3x;
e33=(rs+(rw-rs)*ar)*hc*Vr*davdar;
e42y=(1+beta)*ar*Vr;
e42x=e42y*((1-av)*drwdp+av*drsdp+(rs-rw)*davdp)+Vsd*drsdp;
e42=(rs*Vsd*dhsdp+rw*Vwd*dhwdp-Vsd*1e6+md*Cp*dtsdp)/hc+e42x;
e43=(1+beta)*(ar*Vr*(rs-rw)*davdar);
e44=rs;
e=[e11,e12,0,0
e21,e22,0,0
0,e32,e33,0
0,e42,e43,e44];
%the right hand side of state equations
b4=(hf-hw)*qf/hc+rs*(Vsd0-Vsd)/Td;
b=[qf-qs; Q+qf*hf-qs*hs; Q-qdc*ar*hc; b4];
%solve linear equation for derivatives
dx=e\b;
qx=(rw-rs)*Vr*davdp*dx(2)+(rw-rs)*Vr*davdar*dx(3);
%two important flows for understanding behaviour
qr=qdc-(av*drsdp+(1-av)*drwdp)*Vr*dx(2)+qx;
qctx=rs*Vst*dhsdp+rw*Vwt*dhwdp-Vt*1e6+mt*Cp*dtsdp;
qct=((hw-hf)*qf+qctx*dx(2))/hc;
%step the derivatives, dx is a 4X1 vector
sys = [dx];
%------------------------------------------------------------elseif flag==3, %Compute outputs
%extract state variables
Vwt=x(1);
p=x(2);
ar=x(3);
Vsd=x(4);
49
%drum level
rs=a02+(a12+a22*(p-10))*(p-10);
rw=a04+(a14+a24*(p-10))*(p-10);
z=ar*(rw-rs)/rs;
av=rw/(rw-rs)*(1-(1/z)*log(1+z));
Vwd=Vwt-Vdc-(1-av)*Vr;
ls=Vsd/Ad;
lw=Vwd/Ad;
l=lw+ls;
sys=[l,p,lw,ls,qr,av,qdc,ar,Vwt,Vsd,qct];
%-------------------------------------------------------------elseif flag==0, %INITIALIZATIONS
str=[];
sizes(1)=4; %4 continious states
sizes(2)=0; %0 discrete states
sizes(3)=11; % 11 outputs
sizes(4)=4; %4 inputs
sizes(5)=0; % no discontinious roots
sizes(6)=0; % no direct term
sizes(7)=1; ts=[0,0]; %efficency fix(see[1])
sys=sizes';
x0(1)=x_init(1);
x0(2)=x_init(2);
x0(3)=x_init(3);
x0(4)=x_init(4);
else
sys=[]; %flags 2 or 4 , not considered since we have no discrete states.
end;
% Also flag 5 is of no interest.
50
Appendix B
Optimization Code
The code for the fuzzy logic file is:
d=newfis('boiler','mamdani');
d=addvar(d,'input','err',[-0.1 0.1]*k1);
d=addmf(d,'input',1,'nb','trimf',[-0.19 -0.1 -0.01]*k1);
d=addmf(d,'input',1,'ns','trimf',[-0.03 -0.015 0]*k1);
d=addmf(d,'input',1,'z0','trimf',[-0.0004 0 0.0004]*k1);
d=addmf(d,'input',1,'ps','trimf',[0 0.015 0.03]*k1);
d=addmf(d,'input',1,'pb','trimf',[0.01 0.1 0.19]*k1);
d=addvar(d,'input','dele',[-0.1 0.1]*k2);
d=addmf(d,'input',2,'nb','trimf',[-0.15 -0.1 -0.05]*k2);
d=addmf(d,'input',2,'ns','trimf',[-0.1 -0.05 0]*k2);
d=addmf(d,'input',2,'z0','trimf',[-0.0004 0 0.0004]*k2);
d=addmf(d,'input',2,'ps','trimf',[0 0.05 0.1]*k2);
d=addmf(d,'input',2,'pb','trimf',[0.05 0.1 0.15]*k2);
d=addvar(d,'output','w',[-20 20]*k3);
d=addmf(d,'output',1,'nb','trimf',[-27.5 -20 -12.5]*k3);
d=addmf(d,'output',1,'nm','trimf',[-15 -10 -5]*k3);
d=addmf(d,'output',1,'ns','trimf',[-10 -5 0]*k3);
d=addmf(d,'output',1,'z0','trimf',[-2.5 0 2.5]*k3);
d=addmf(d,'output',1,'ps','trimf',[0 5 10]*k3);
d=addmf(d,'output',1,'pm','trimf',[5 10 15]*k3);
d=addmf(d,'output',1,'pb','trimf',[12.5 20 27.5]*k3);
ruleList=[ ...
11711
12711
13611
14511
15411
21711
22711
23511
24411
25311
31711
32511
33411
34311
35111
41611
42411
43311
44111
45111
51411
51
52311
53111
54111
5 5 1 1 1];
d=addrule(d,ruleList);
hw=a03+(a13+a23*(p(i)-10))*(p(i)-10);
dhwdp=a13+2*a23*(p(i)-10);
rw=a04+(a14+a24*(p(i)-10))*(p(i)-10);
drwdp=a14+2*a24*(p(i)-10);
ts=a05+(a15+a25*(p(i)-10))*(p(i)-10);
dtsdp=a15+2*a25*(p(i)-10);
%properties of water in subcritical state
hf=(Cfw*tf+p(i)*1e3/rw)*1e3;
%the model equations-------------------hc=hs-hw;
hr=ar(i)*hs+(1-ar(i))*hw;
%average steam quality volume rati and partial derivatives
z=ar(i)*(rw-rs)/rs;
av=rw/(rw-rs)*(1-(1/z)*log(1+z));
davdar=rw/rs*((1/z)*log(1+z)-1/(z+1))/z;
zp=(rs*drwdp-rw*drsdp)*ar(i)/rs/rs;
z1=(rw*drsdp-rs*drwdp)/(rw-rs)/(rw-rs);
z2=rw/(rw-rs)*((1/z)*log(1+z)-1/(1+z))/z*zp;
davdp=z1*(1-(1/z)*log(1+z))+z2;
%circulation flow
s1=ke*(rw-rs)*Vr*av;
qdc=sqrt(s1);
%equations for coefficents of derivatives of state variables
Td=600/qs(i);
Vst=Vt-Vwt(i);
Vwd=Vwt(i)-Vdc-(1-av)*Vr;
e11=rw-rs;
e12=Vst*drsdp+Vwt(i)*drwdp;
e21=hw*rw-hs*rs;
e22x=-Vt*1e6+mt*Cp*dtsdp;
e22=Vst*(hs*drsdp+rs*dhsdp)+Vwt(i)*(hw*drwdp+rw*dhwdp)+e22x;
e3w=(rw*dhwdp-ar(i)*hc*drwdp)*(1-av)*Vr;
e3x=(rs+(rw-rs)*ar(i))*hc*Vr*davdp-Vr*1e6+mr*Cp*dtsdp;
e32=((1-ar(i))*hc*drsdp+rs*dhsdp)*av*Vr+e3w+e3x;
e33=(rs+(rw-rs)*ar(i))*hc*Vr*davdar;
e42y=(1+beta)*ar(i)*Vr;
e42x=e42y*((1-av)*drwdp+av*drsdp+(rs-rw)*davdp)+Vsd(i)*drsdp;
e42=(rs*Vsd(i)*dhsdp+rw*Vwd*dhwdp-Vsd(i)*1e6+md*Cp*dtsdp)/hc+e42x;
e43=(1+beta)*(ar(i)*Vr*(rs-rw)*davdar);
e44=rs;
e=[e11,e12,0,0
e21,e22,0,0
0,e32,e33,0
0,e42,e43,e44];
%the right hand side of state equations
b4=(hf-hw)*qf(i)/hc+rs*(Vsd0-Vsd(i))/Td;
b=[qf(i)-qs(i); Q(i)+qf(i)*hf-qs(i)*hs; Q(i)-qdc*ar(i)*hc; b4];
%solve linear equation for derivatives
dx=e\b;
qx=(rw-rs)*Vr*davdp*dx(2)+(rw-rs)*Vr*davdar*dx(3);
53
if i==1
dele=0;
else
dele=err(i)-err(i-1);
end
w=evalfis([err(i) dele], d);
qf(i+1)=50+w;
end
iseplot=ise(200);
54
55