PROPT Batch Reactor Problem: Difference between revisions
From TomWiki
Jump to navigationJump to search
(Created page with " Example 6: DYNOPT User's Guide version 4.1.0 Batch reactor with reactions: A -> B -> C. M. Cizniar, M. Fikar, M. A. Latifi, MATLAB Dynamic Optimisation Code DYNOPT. User's Gui...") |
No edit summary |
||
(4 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{Part Of Manual|title=the PROPT Manual|link=[[PROPT|PROPT Manual]]}} | |||
Example 6: DYNOPT User's Guide version 4.1.0 | Example 6: DYNOPT User's Guide version 4.1.0 | ||
Line 11: | Line 12: | ||
<math> J = x_2(t_f) </math> | <math> J = x_2(t_f) </math> | ||
subject to: | subject to: | ||
<math> \frac{dx_1}{dt} = -k_1*x_1^2 </math> | <math> \frac{dx_1}{dt} = -k_1*x_1^2 </math> | ||
<math> \frac{dx_2}{dt} = k_1*x_1^2-k_2*x_2 </math> | <math> \frac{dx_2}{dt} = k_1*x_1^2-k_2*x_2 </math> | ||
<math> k_1 = 4000*exp^{-\frac{2500}{T}} </math> | <math> k_1 = 4000*exp^{-\frac{2500}{T}} </math> | ||
<math> k_2 = 620000*exp^{-\frac{5000}{T}} </math> | <math> k_2 = 620000*exp^{-\frac{5000}{T}} </math> | ||
where | where | ||
<math> x(0) = [1 \ 0] </math> | <math> x(0) = [1 \ 0] </math> | ||
<math> 298 <= T <= 398 </math> | <math> 298 <= T <= 398 </math> | ||
< | |||
<source lang="matlab"> | |||
% Copyright (c) 2007-2008 by Tomlab Optimization Inc. | % Copyright (c) 2007-2008 by Tomlab Optimization Inc. | ||
</ | </source> | ||
==Problem setup== | ==Problem setup== | ||
< | <source lang="matlab"> | ||
toms t | toms t | ||
p = tomPhase('p', t, 0, 1, 30); | p = tomPhase('p', t, 0, 1, 30); | ||
Line 59: | Line 67: | ||
% Objective | % Objective | ||
objective = -final(x2); | objective = -final(x2); | ||
</ | </source> | ||
==Solve the problem== | ==Solve the problem== | ||
< | <source lang="matlab"> | ||
options = struct; | options = struct; | ||
options.name = 'Batch Reactor'; | options.name = 'Batch Reactor'; | ||
Line 73: | Line 81: | ||
x2 = subs(collocate(x2),solution); | x2 = subs(collocate(x2),solution); | ||
T = subs(collocate(T),solution); | T = subs(collocate(T),solution); | ||
</ | </source> | ||
<pre> | <pre> | ||
Problem type appears to be: lpcon | Problem type appears to be: lpcon | ||
Time for symbolic processing: 0. | Time for symbolic processing: 0.14292 seconds | ||
Starting numeric solver | Starting numeric solver | ||
===== * * * =================================================================== * * * | ===== * * * =================================================================== * * * | ||
Line 92: | Line 100: | ||
FuncEv 1 ConstrEv 26 ConJacEv 26 Iter 23 MinorIter 84 | FuncEv 1 ConstrEv 26 ConJacEv 26 Iter 23 MinorIter 84 | ||
CPU time: 0.031200 sec. Elapsed time: 0. | CPU time: 0.031200 sec. Elapsed time: 0.033000 sec. | ||
</pre> | </pre> | ||
Line 98: | Line 106: | ||
==Plot result== | ==Plot result== | ||
< | <source lang="matlab"> | ||
subplot(2,1,1) | subplot(2,1,1) | ||
plot(t,x1,'*-',t,x2,'*-'); | plot(t,x1,'*-',t,x2,'*-'); | ||
Line 108: | Line 116: | ||
legend('T'); | legend('T'); | ||
title('Batch Reactor control'); | title('Batch Reactor control'); | ||
</ | </source> | ||
[[File:batchReactor_01.png]] | |||
[[Category:PROPT Examples]] |
Latest revision as of 04:42, 14 February 2012
This page is part of the PROPT Manual. See PROPT Manual. |
Example 6: DYNOPT User's Guide version 4.1.0
Batch reactor with reactions: A -> B -> C.
M. Cizniar, M. Fikar, M. A. Latifi, MATLAB Dynamic Optimisation Code DYNOPT. User's Guide, Technical Report, KIRP FCHPT STU Bratislava, Slovak Republic, 2006.
Problem description
Find T over t in [0; 1 ] to maximize
subject to:
where
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
Problem setup
toms t
p = tomPhase('p', t, 0, 1, 30);
setPhase(p);
tomStates x1 x2
tomControls T
% Initial guess
% Note: The guess for t_f must appear in the list before expression involving t.
x0 = {icollocate({x1 == 1; x2 == 0})
collocate(T==398-t*100)};
% Box constraints
cbox = {298 <= collocate(T) <= 398};
% Boundary constraints
cbnd = initial({x1 == 1; x2 == 0});
% Various constants and expressions
k1 = 4000*exp(-2500./T);
k2 = 620000*exp(-5000./T);
% ODEs and path constraints
ceq = collocate({dot(x1) == -k1.*x1.^2
dot(x2) == k1.*x1.^2-k2.*x2});
% Objective
objective = -final(x2);
Solve the problem
options = struct;
options.name = 'Batch Reactor';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
% Extract optimal states and controls from solution
t = subs(collocate(t),solution);
x1 = subs(collocate(x1),solution);
x2 = subs(collocate(x2),solution);
T = subs(collocate(T),solution);
Problem type appears to be: lpcon Time for symbolic processing: 0.14292 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: --- 1: Batch Reactor f_k -0.610799380695554950 sum(|constr|) 0.000006007956394549 f(x_k) + sum(|constr|) -0.610793372739160350 f(x_0) 0.000000000000000000 Solver: snopt. EXIT=0. INFORM=1. SNOPT 7.2-5 NLP code Optimality conditions satisfied FuncEv 1 ConstrEv 26 ConJacEv 26 Iter 23 MinorIter 84 CPU time: 0.031200 sec. Elapsed time: 0.033000 sec.
Plot result
subplot(2,1,1)
plot(t,x1,'*-',t,x2,'*-');
legend('x1','x2');
title('Batch Reactor state variables');
subplot(2,1,2)
plot(t,T,'+-');
legend('T');
title('Batch Reactor control');