PROPT Batch Reactor Problem

From TomWiki
Jump to navigationJump to search

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

BatchReactor 01.png