forked from stelmo/LoopRanking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
octavedriver.m
143 lines (133 loc) · 5.52 KB
/
octavedriver.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
function [outvec,outu] = octavedriver(inputchangeid,numberofhours)
% Call with flag=0 to initialise
flag.initialise = 0;
flag.derivatives = 1;
flag.outputs = 3;
[sizes,x0,str,ts] = TESFUNCo(0, 0, 0, 0);
x = x0;
dt = 1/3600;
N = 60*60*numberofhours; %takes from method parameters
% Inputs. These should be real values - check the Fortran source or
% the document
% u = ones(sizes.NumInputs, 1);
u = [0;% IDV(1,1) A/C Feed Ratio, B Composition Constant (Stream 4) Step
0;% IDV(1,2) B Composition, A/C Ratio Constant (Stream 4) Step
0;% IDV(1,3) D Feed Temperature (Stream 2) Step
0;% IDV(1,4) Reactor Cooling Water Inlet Temperature Step
0;% IDV(1,5) Condenser Cooling Water Inlet Temperature Step
0;% IDV(1,6) A Feed Loss (Stream 1) Step
0;% IDV(1,7) C Header Pressure Loss - Reduced Availability (Stream 4) Step
0;% IDV(1,8) A, B, C Feed Composition (Stream 4) Random Variation
0;% IDV(1,9) D Feed Temperature (Stream 2) Random Variation
0;% IDV(1,10) C Feed Temperature (Stream 4) Random Variation
0;% IDV(1,11) Reactor Cooling Water Inlet Temperature Random Variation
0;% IDV(1,12) Condenser Cooling Water Inlet Temperature Random Variation
0;% IDV(1,13) Reaction Kinetics Slow Drift
0;% IDV(1,14) Reactor Cooling Water Valve Sticking
0;% IDV(1,15) Condenser Cooling Water Valve Sticking
0;% IDV(1,16) Unknown
0;% IDV(1,17) Unknown
0;% IDV(1,18) Unknown
0;% IDV(1,19) Unknown
0;% IDV(1,20) Unknown
63.053; % XMV(1,1) D Feed Flow (stream 2) (Corrected Order)
53.98; % XMV(1,2) E Feed Flow (stream 3) (Corrected Order)
24.644; % XMV(1,3) A Feed Flow (stream 1) (Corrected Order)
61.302; % XMV(1,4) A and C Feed Flow (stream 4)
22.21; % XMV(1,5) Compressor Recycle Valve
40.046; % XMV(1,6) Purge Valve (stream 9)
38.1; % XMV(1,7) Separator Pot Liquid Flow (stream 10)
46.534; % XMV(1,8) Stripper Liquid Product Flow (stream 11)
47.446; % XMV(1,9) Stripper Steam Valve
41.106; % XMV(1,10) Reactor Cooling Water Flow
18.114; % XMV(1,11) Condenser Cooling Water Flow
50]; % XMV(1,12) Agitator Speed
%now change u according to method parameters
%in retrospect your method is much better...
if (inputchangeid < 13)
u(20+inputchangeid) = 5;
end
outu = u;
%
% u +---------------------+ y
% ---->| x (internal states) |------>
% +---------------------+
% Euler integration
t = 0;
yplot = [];
for i = 1:N
% Calculate derivatives
dx = TESFUNCo(t, x, u, flag.derivatives);
% Calculate outputs
y = TESFUNCo(t, x, u, flag.outputs);
yplot = [yplot y]; % store outputs
% Integrate
x = x + dt*dx;
t = t + dt;
end
% plot(0:dt:(t-dt), yplot')
% plot(yplot')
% pause(10)
arr = yplot';
outvec = arr(end,:)';
% Continuous Process Measurements
%
% XMEAS(1,1) A Feed (stream 1) kscmh
% XMEAS(1,2) D Feed (stream 2) kg/hr
% XMEAS(1,3) E Feed (stream 3) kg/hr
% XMEAS(1,4) A and C Feed (stream 4) kscmh
% XMEAS(1,5) Recycle Flow (stream 8) kscmh
% XMEAS(1,6) Reactor Feed Rate (stream 6) kscmh
% XMEAS(1,7) Reactor Pressure kPa gauge
% XMEAS(1,8) Reactor Level %
% XMEAS(1,9) Reactor Temperature Deg C
% XMEAS(1,10) Purge Rate (stream 9) kscmh
% XMEAS(1,11) Product Sep Temp Deg C
% XMEAS(1,12) Product Sep Level %
% XMEAS(1,13) Prod Sep Pressure kPa gauge
% XMEAS(1,14) Prod Sep Underflow (stream 10) m3/hr
% XMEAS(1,15) Stripper Level %
% XMEAS(1,16) Stripper Pressure kPa gauge
% XMEAS(1,17) Stripper Underflow (stream 11) m3/hr
% XMEAS(1,18) Stripper Temperature Deg C
% XMEAS(1,19) Stripper Steam Flow kg/hr
% XMEAS(1,20) Compressor Work kW
% XMEAS(1,21) Reactor Cooling Water Outlet Temp Deg C
% XMEAS(1,22) Separator Cooling Water Outlet Temp Deg C
%
% Sampled Process Measurements
%
% Reactor Feed Analysis (Stream 6)
% Sampling Frequency = 0.1 hr
% Dead Time = 0.1 hr
% Mole %
% XMEAS(1,23) Component A
% XMEAS(1,24) Component B
% XMEAS(1,25) Component C
% XMEAS(1,26) Component D
% XMEAS(1,27) Component E
% XMEAS(1,28) Component F
%
% Purge Gas Analysis (Stream 9)
% Sampling Frequency = 0.1 hr
% Dead Time = 0.1 hr
% Mole %
% XMEAS(1,29) Component A
% XMEAS(1,30) Component B
% XMEAS(1,31) Component C
% XMEAS(1,32) Component D
% XMEAS(1,33) Component E
% XMEAS(1,34) Component F
% XMEAS(1,35) Component G
% XMEAS(1,36) Component H
%
% Product Analysis (Stream 11)
% Sampling Frequency = 0.25 hr
% Dead Time = 0.25 hr
% Mole %
% XMEAS(1,37) Component D
% XMEAS(1,38) Component E
% XMEAS(1,39) Component F
% XMEAS(1,40) Component G
% XMEAS(1,41) Component H
endfunction