You are on page 1of 6

Process Simulation Exercise Numerical methods for process simulation part 1

Algebraic Solvers Problem 1: CSTR A continuous stirred tank reactor, CSTR, is cooled by a jacket. A first order exothermic reaction occurs in the reactor and the reaction rate is temperature dependent and is assumed to follow Arrenius law, kr=k0 e(-Ea/RT). Assume the heat transfer to be described by a constant heat transfer coefficient. d (Vc) = qin cin qc Vr dt d ( VC p T ) = C p (qin Tin qT ) H reacVr k ht A(T T j ) dt
r = kr c = koe c The jacket temperature can be calculated using the jacket heat balance if we assume it to at steady-state. d ( jV j C p , j T j ) = j C p , j (qin , j Tin , j qT j ) + k ht A(T T j ) = 0 dt j C p , j qin , j Tin , j + k ht AT Tj = j C p , j qin , j + k ht A Data: q=1.1 m3/h, qj = 1.4 m3/h, c0=9000 mol/m3, k0=6.99E10 h-1, V=1.3 m3, rho=800 kg/m3, Cp=3.142 kJ/(kg K), T0=273+21 K, Vj=0.11 m3, rhoj=1000 kg/m3, Cp,j=4.19 kJ/(kg K), Tj,0=273+21 K, kht=3070 kJ/(h m2K), A=23 m2 Ea=69.418 kJ/mol, R=0.00833 kJ/(mol K), Hreac=-69.9 kJ/mol
Ea RT

The model above is implemented in cstr.m. a) Find the solutions to the model using a Gauss-Newton-method in fsolve. Study how the method performs during iteration. Set the option NonlEqnAlgorithm to 'gn' for Gauss-Newton. Set the option Display option to 'on'. b) Study how a trust-region method performs during iteration in fsolve. Set the option NonlEqnAlgorithm to 'dogleg' for trust-region. (this is the default method in fsolve) Set the option Display option to 'on'.

Ordinary Differential Solvers Problem 2: Tank-series Simulate the concentration dynamics in two well stirred tanks with constant flow rate and volumes. The total volume of the tank series is 1 and the flow rate is 1. The inlet concentation is 1 and the initial concentrations in the tanks are 0. a) Assume the the tank volumes are the same. Simulate the system with ode23, ode23s and ode23t. Compare the results and the required computational time. Use tic and toc or cputime. b) Assume that the volume of the first tank is 0.1 % of the second one. Simulate the system with ode23, ode23s and ode23t. Compare the results and the required computational time. Explain! Problem 3: Nonstiff tank-series Simulate the tank-sseries from Problem 2a). Assume the the tank volumes are the same. Simulate the system with ode23, ode45 and ode113. Increase the accuracy by decreasing RelTol and AbsTol. Compare the results and the required computational time. Problem 4: Stiff tank-series Simulate the tank-sseries from Problem 2b). Assume that the volume of the first tank is 0.1 % of the second one. Simulate the system with ode23s, odes3tb and ode15s. Increase the accuracy by decreasing RelTol and AbsTol. Compare the results and the required computational time.

Exercise Numerical methods Suggestions on solutions


Problem 1: CSTR a) Display of the cstr.m M-file.
type cstr function [res]=cstr(x) % CSTR is a steady-state lumped model of an % exothermic continuous stirred tank reactor. % Call: % [sol]=fsolve(@((x) cstr(x),[8000;300]); % unknown variables C=x(1); T=x(2); % parameters q=1.1; % m^3/h C0=9000; % mol/m^3 T0=273+21; % K V=1.3; % m^3 k0=6.99E10; % h^-1 Ea=69.418; % kJ/mol R=0.00833; % kJ/(mol K) rho=800; % kg/m^3 Cp=3.142; % kJ/(kg K) dH=-69.9; % kJ/mol U=3070; % kJ/(h m^2 K) A=23; % m^2 Tj0=273+21; % K qj=1.4; % m^3 rhoj=1000; % kg/m^3 Cpj=4.19; % kJ/(kg K) % equations k=k0.*exp(-Ea./(R.*T)); ra=k.*C; Tj=(rhoj*qj*Cpj*Tj0+U*A.*T)./(rhoj*qj*Cpj+U*A); % balances resCB=q.*(C0-C)-V.*ra; resEB=rho*Cp*q.*(T0-T)-dH*V.*ra-U*A.*(T-Tj); res=[resCB; resEB]; type cstrplot function cstrplot opt=optimset; opt=optimset(opt,'TolX',0.1,'NonlEqnAlgorithm','gn'); opt=optimset(opt,'Display','iter'); %Guess points %conc 1000 4000 8000

%temp 320 380 % hot point guesses guess=[1000;320] [sol]=fsolve(@(x) cstr(x),guess,opt) plot(sol(1),sol(2),'x',guess(1),guess(2),'o') hold on guess=[1000;380] [sol]=fsolve(@(x) cstr(x),guess,opt) plot(sol(1),sol(2),'x',guess(1),guess(2),'o') guess=[4000;320] [sol]=fsolve(@(x) cstr(x),guess,opt) plot(sol(1),sol(2),'x',guess(1),guess(2),'o') guess=[4000;380] [sol]=fsolve(@(x) cstr(x),guess,opt) plot(sol(1),sol(2),'x',guess(1),guess(2),'o') guess=[8000;320] [sol]=fsolve(@(x) cstr(x),guess,opt) plot(sol(1),sol(2),'x',guess(1),guess(2),'o') guess=[8000;380] [sol]=fsolve(@(x) cstr(x),guess,opt) plot(sol(1),sol(2),'x',guess(1),guess(2),'o') hold off xlabel('concentration') ylabel('temperature') end cstrplot guess = 1000 320

sol = 1.0e+003 * 5.8670 0.3234 guess = 1000 380 sol = 490.2224 373.9797 guess = 4000 320 sol = 1.0e+003 * 8.4366 0.2993 guess = 4000 380 sol = 490.1287 373.9838 guess = 8000 320

sol = 1.0e+003 * 5.8670 0.3234 guess = 8000 380 sol = 490.2188 373.9799
380

360

t e m p e ra t u re

340

320

300

280

1000

2000

3000

4000 5000 concentration

6000

7000

8000

9000

Note which guess value that converge to which solution! Note also the number of iterations needed to solve the problems.

You might also like