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
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 24: Line 25:
<math> 298 <= T <= 398 </math>
<math> 298 <= T <= 398 </math>


<syntaxhighlight lang="matlab">
<source lang="matlab">
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
</syntaxhighlight>
</source>


==Problem setup==
==Problem setup==


<syntaxhighlight lang="matlab">
<source lang="matlab">
toms t
toms t
p = tomPhase('p', t, 0, 1, 30);
p = tomPhase('p', t, 0, 1, 30);
Line 59: Line 60:
% Objective
% Objective
objective = -final(x2);
objective = -final(x2);
</syntaxhighlight>
</source>


==Solve the problem==
==Solve the problem==


<syntaxhighlight lang="matlab">
<source lang="matlab">
options = struct;
options = struct;
options.name = 'Batch Reactor';
options.name = 'Batch Reactor';
Line 73: Line 74:
x2 = subs(collocate(x2),solution);
x2 = subs(collocate(x2),solution);
T  = subs(collocate(T),solution);
T  = subs(collocate(T),solution);
</syntaxhighlight>
</source>


<pre>
<pre>
Line 98: Line 99:
==Plot result==
==Plot result==


<syntaxhighlight lang="matlab">
<source lang="matlab">
subplot(2,1,1)
subplot(2,1,1)
plot(t,x1,'*-',t,x2,'*-');
plot(t,x1,'*-',t,x2,'*-');
Line 108: Line 109:
legend('T');
legend('T');
title('Batch Reactor control');
title('Batch Reactor control');
</syntaxhighlight>
</source>

Revision as of 10:54, 2 November 2011

Notice.png

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.16316 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.048000 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');