-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex10.m
116 lines (99 loc) · 2.02 KB
/
ex10.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
% Exercise 10: Tune steam battery P-controllers
param
% Set parameters
delta_fkul = 2; % step disturbance in steam consumption
omega_1 = 0.005; % low frequency
B = 0; % amplitude of low frequency disturbance
omega_2 = 0.2; % high frequency
C = 0; % amplitude of high frequency disturbance
slope = 0; % ramp disturbance
z1_0 = 1; % equilibrium setting of valve z1
% PID parameters for u
K_p = 2;
K_i = 0.02;
K_d = 20;
% PID parameters for z1
K_pz = 0.3;
K_iz = 0.02;
K_dz = 0;
% steam battery controller parameters
k_out=210;
k_in=25.5;
% Simulate
Simulation_Time = 1000;
SimOut = sim('ex11_model.slx', Simulation_Time);
% Plot the controls and pressures
figure(1)
subplot(221)
plot(SimOut.time, SimOut.z1)
xlabel("time")
ylabel("z_1")
subplot(223)
plot(SimOut.time, SimOut.pvp)
xlabel("time")
ylabel("p_{vp} (bar)")
subplot(222)
plot(SimOut.time, SimOut.u)
xlabel("time")
ylabel("u")
subplot(224)
plot(SimOut.time, SimOut.pkp)
xlabel("time")
ylabel("p_{kp} (bar)")
% plot steam consumption and steam battery pressure
figure(2)
subplot(221)
plot(SimOut.time, SimOut.f_kul)
xlabel("time")
ylabel("f_{kul} (kg/s)")
subplot(222)
plot(SimOut.time, SimOut.pa)
xlabel("time")
ylabel("p_a (bar)")
subplot(223)
plot(SimOut.time,SimOut.z2)
xlabel("time")
ylabel("z_2")
subplot(224)
plot(SimOut.time,SimOut.z3)
xlabel("time")
ylabel("z_3")
% sine wave disturbances
delta_fkul = 0;
C = 1;
B=1;
SimOut = sim('ex11_model.slx', Simulation_Time);
figure(3)
subplot(221)
plot(SimOut.time, SimOut.z1)
xlabel("time")
ylabel("z_1")
subplot(223)
plot(SimOut.time, SimOut.pvp)
xlabel("time")
ylabel("p_{vp} (bar)")
subplot(222)
plot(SimOut.time, SimOut.u)
xlabel("time")
ylabel("u")
subplot(224)
plot(SimOut.time, SimOut.pkp)
xlabel("time")
ylabel("p_{kp} (bar)")
figure(4)
subplot(221)
plot(SimOut.time, SimOut.f_kul)
xlabel("time")
ylabel("f_{kul} (kg/s)")
subplot(222)
plot(SimOut.time, SimOut.pa)
xlabel("time")
ylabel("p_a (bar)")
subplot(223)
plot(SimOut.time,SimOut.z2)
xlabel("time")
ylabel("z_2")
subplot(224)
plot(SimOut.time,SimOut.z3)
xlabel("time")
ylabel("z_3")