Skip to content

Commit a17c622

Browse files
committed
Fixed some typos
1 parent 2f91015 commit a17c622

8 files changed

+37
-23
lines changed

AuxFunctions/figured.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function save2pdfemb(ho,~)
3939
end
4040

4141
function save2pdflocal(pdfFileName,dpi,handle)
42-
% Addapted from (c) Gabe Hoffmann, gabe.hoffmann@gmail.com
42+
% Adapted from (c) Gabe Hoffmann, gabe.hoffmann@gmail.com
4343

4444
% Backup previous settings
4545
prePaperType = get(handle,'PaperType');

AuxFunctions/lagrange.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
% Allocation
3030
P = zeros(np,1);
3131

32-
% Calculate the lagrange polinomial in x -> P(x)
32+
% Calculate the lagrange polynomial in x -> P(x)
3333
for j = 1:ng
3434
l = ones(np,1);
3535
for i = 1:ng

Extractors.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
% N: Number of Stages
2323
% R: Raffinate flow rate
2424
% E: Extract flow rate
25-
% Xf: Molar fration feeding stage 1 at raffinate
26-
% Yf: Molar fration feeding stage N at extract
25+
% Xf: Molar fraction feeding stage 1 at raffinate
26+
% Yf: Molar fraction feeding stage N at extract
2727
% Ki: Equilibrium constants
2828
%
2929
% Mass balance:
@@ -46,7 +46,7 @@
4646
%% Problem setup
4747
addpath('AuxFunctions')
4848

49-
% Numer of stages
49+
% Number of stages
5050
N = 10;
5151
K = 0.25*ones(N,1);
5252
R = 1;

MPC_tank_reactor.m

+17-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
%
44
% You'll learn:
55
% +: how to solve optimization problems
6-
% +: How to apply a model predictice control with non linear models
6+
% +: How to apply a model predictive control with nonlinear models
77
%
88
%% The problem
99
%
@@ -12,6 +12,12 @@
1212
% lb < u < ub
1313
% 0 < |du| < du_max
1414
%
15+
% About the process:
16+
% CSTR with van de vusse reaction system
17+
% A -> B
18+
% B -> C
19+
% 2A -> D
20+
%
1521
% ============================================================
1622
% Author: ataide@peq.coppe.ufrj.br
1723
% homepage: github.com/asanet
@@ -33,7 +39,7 @@
3339
% The objective function parameters
3440
Hp = 1000; % Prediction horizon
3541
nt = 50; % Time sampling points
36-
P_sp = 1; % Set point violetion penalty
42+
P_sp = 1; % Set point violation penalty
3743
P_u = 1e6; % Saturation penalty
3844
P_du = 1e6; % Delta u penalty
3945
lb = 273.15; % lower bound to u
@@ -60,7 +66,7 @@
6066
% Simulation span
6167
tspan = 1:3*Hp;
6268

63-
% The intial u profile (must have Hc values)
69+
% The initial u profile (must have Hc values)
6470
u = [373.15 0 0 0]';
6571
umi = u(1);
6672

@@ -109,13 +115,13 @@
109115
um(i+1) = u(1);
110116
umi = u(1);
111117

112-
% Disturbance in tal
118+
% Disturbance in tau
113119
if i == fix(nsamples/2)
114120
Tf = 420;
115121
end
116122
end
117123

118-
%% plot the data
124+
% Plot the data
119125
figure;
120126
subplot(211)
121127
h = plot(tm,ym(:,3),tm,spval*ones(nsamples,1),'LineWidth',1.5);
@@ -136,7 +142,7 @@
136142

137143
function f = mpc_cost_function(u,ynow)
138144

139-
% Solve the model until the preditction horizon
145+
% Solve the model until the prediction horizon
140146
ts1 = linspace(0,Hp,nt);
141147
[t,y] = ode15s(@model,ts1,ynow,simulationOpt,u);
142148

@@ -151,26 +157,26 @@
151157
% Delta u penalty
152158
f3 = -min(0, du_max - max(abs([umi- u(1); u(2:end)])));
153159

154-
% THe objective function
160+
% The objective function
155161
f = P_sp*f1 + P_u*f2 + P_du*f3;
156162
end
157163

158164
function dy = model(t,y,u)
159165
% Van de vusse reaction in a CSTR
160166
Ca = y(1); Cb = y(2); T = y(3);
161167

162-
% the regularization function
168+
% The regularization function
163169
reg = 1/2 + tanh(p*(t - td))/2;
164170

165-
% control variable
171+
% Control variable
166172
Tc = sum(u.*reg);
167173

168-
% reaction rates
174+
% Reaction rates
169175
r1 = k1*exp(-E1/R/T)*Ca;
170176
r2 = k2*exp(-E2/R/T)*Cb;
171177
r3 = k3*exp(-E3/R/T)*Ca^2;
172178

173-
% mass balances
179+
% Mass balances
174180
dCa = (Caf - Ca)/tau -r1 -2*r3;
175181
dCb = -Cb/tau + r1 - r2;
176182
dT = (Tf - T)/tau -1/rho/cp*( UA/V*(T - Tc) + H1*r1 + H2*r2 +H3*r3 );

Parameter_estimation.m

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@
99
%% The problem
1010
%
1111
% Given a data set (xe,ye), find the parameters of a dynamical
12-
% non linear model. By least squares hte problem is:
12+
% non linear model. By least squares the problem is:
1313
%
1414
% minimize the sum of (ye_i - ycalc_i)^2
1515
%
16+
% About the process:
17+
% CSTR with van de vusse reaction system
18+
% A -> B
19+
% B -> C
20+
% 2A -> D
21+
%
22+
% Estimate the Arrhenius pre-exponential factor and activation energies
23+
%
1624
% ============================================================
1725
% Author: ataide@peq.coppe.ufrj.br
1826
% homepage: github.com/asanet
@@ -57,7 +65,7 @@
5765
% Calculate ycalc with the estimated parameters for comparison
5866
tspan = linspace(0,te(end),100)';
5967
[tc,yc] = ode15s(@model,tspan,y0,odeopt,parEst);
60-
[tc2,yc2] = ode15s(@model,te,y0,odeopt,parEst);
68+
[~,yc2] = ode15s(@model,te,y0,odeopt,parEst);
6169

6270
% Plot data
6371
close all

Reaction_diffusion.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
opt = optimoptions(@fsolve,'TolFun',1e-10,'TolX',1e-10,'Display','iter-detailed',...
6060
'Algorithm','trust-region-reflective');
6161

62-
% Passing the Sparty Pattern (Compare solution time with and without it)
62+
% Passing the Sparsity Pattern (Compare solution time with and without it)
6363
opt.JacobPattern = Jp;
6464

6565
% Solver call

Steady_state_PFR.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
% C_i = P/(R*T)*F_i/Ft
1919
% u*sum(C_i) = Ft
2020
%
21-
% Auxiliar equations
21+
% Auxiliary equations
2222
% cp*Ft = sum(F_i*cp_i)
2323
%
2424
% ============================================================

Tubular_reactor_2D.m

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
% Operational parameters (play around)
4949
vmax = 1;
5050
vz = vmax*(1 - (r/R).^2); % Velocity profile
51-
Dz = 0.5*0; % Diffusion coeficients
51+
Dz = 0.5*0; % Diffusion coefficients
5252
Dr = 0.01*0;
5353
k = 0.1*0; % Kinetic constant
54-
Cf = ones(Nr,1); % Feed concetration
54+
Cf = ones(Nr,1); % Feed concentration
5555

5656
% The initial condition
5757
y0 = zeros(Nr*Nz,1);
@@ -100,7 +100,7 @@
100100
xlabel('Length')
101101
ylabel('Diameter')
102102
hcb = colorbar;
103-
hcb.Label.String = 'Concetration';
103+
hcb.Label.String = 'Concentration';
104104
colormap jet
105105
for ii = 1:Nt
106106
imagesc(z,[2*r;2*r],[flip(Csol(:,:,ii));Csol(:,:,ii)])

0 commit comments

Comments
 (0)