You are on page 1of 10

Runge-Kutta Method

What is the Runge-Kutta 4th order method?


Runge-Kutta 4th order method is a numerical technique
used to solve ordinary differential equation of the form
dy = f (x, y), y(0)= y0
dx
So only first order ordinary differential equations can be
solved by using the Runge-Kutta 4 order method.

Formulation
Explicit Runge-Kutta methods are popular as each stage
can be calculated with one function evaluation. In
contrast, implicit Runge-Kutta methods usually involves
solving a non-linear system of equations in order to
evaluate the stages. As a result, explicit schemes are
much less expensive to implement than implicit schemes.
However, there are cases in which implicit schemes are
necessary and that is in the case of stiff sets of equations.
The higher-order Runge-Kutta methods can be derived by
in manner similar to the midpoint formula. An s-stage
method is compared to a Taylor method and the terms are
matched up to the desired order.
Methods of order M > 4 require M + 1 or M + 2 function
evaluations or stages, in the case of explicit Runge-Kutta
methods. As a result, fourth-order Runge-Kutta methods
have achieved great popularity over the years as they
require only four function evaluations per step. In
particular, there is the classic fourth-order Runge-Kutta
formula:
k1 =hf(yn,tn)
k2 = hf (yn + k1 , tn + h )
k3 = hf (yn + k2 , tn + h ) 22
k4 =hf(yn +k3,tn +h)
yn+1 =yn+k1 +k2 +k3 +k4

CSTR Continous Stirred Tank


Reactor
What is Continuous stirred tank reactor (CSTR) ?
A Continuous Stirred-Tank Reactor (CSTR) is a common
ideal reactor in chemical engineering. A CSTR is a model
used to estimate the key unit operation variables when
using a continuous agitated-tank reactor to reach a
specified output.
Working of CSTR
In a CSTR, one or more fluid reagents are introduced into a
tank reactor. The tank reactor is typically equipped with an
impeller. As the fluid reagents are introduced the reactor
effluent is removed. To ensure proper mixing, the impeller
stirs the reagents. The residence time or the average
amount of time a discrete quantity of reagent spends in
side the tank is giving by simply dividing the volume of
the tank by the average volumetric flow rate. The
reaction's expected percent completion can be calculated
by using chemical kinetics. The following are some
important aspects of CSTR :
The mass flow rate in must equal the mass flow rate
out at steady-state, otherwise the tank will overflow
or go empty (transient state). The model equation
must be derived from the differential mass and
energy balances while the reactor is in a transient
state.
The rate of the reaction is governed by reaction rate
associated with the final (output) concentration as
the concentration is assumed to be homogenous
throughout the reactor.
Operating several CSTRs in series is often
economically beneficial. This allows the first CSTR to
operate at a higher reagent concentration and
therefore a higher reaction rate. In such cases, the
sizes of the reactors may be varied in order to

minimize the total capital investment required to


implement the process.
Characterstics Of CSTR
It runs at steady state with continuous flow of
reactants and products.
The feed takes a uniform composition throughout the
reactor.
The exit stream has the same composition as in the
tank.

Advantages of CSTR
Continuous operation
Good temperature control
Easily adapts to two phase runs
Good control
Simplicity of construction
Low operating (labor) cost
Easy to clean
Disadvantages of CSTR
Lowest conversion per unit volume
By-passing and channeling possible with poor
agitation

Writing the material balance for this reactor gives


-1
CSTR Constant Density
If the reactor volume is constant and the volume of the
inflow and the outflow streams are the same, then the
above equation reduces to
The below parameter is called the mean residence time of
the CSTR.
We refer to this balance as the constant-density case. It is
often a good approximation for liquid-phase reactions.

CSTR Steady State


The steady state of the CSTR is described by setting the
time derivative in the above equation to zero,
- 2

Conversion of reactant j is defined for a steady-state CSTR


as follows

The equation 2 can be divided by VR to obtain for the


constant-density case

CODE :
clear
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
% global Parameter
global
global
global
global

cA0 cP0 T0
VR Aw Uw rho cp TC
dh E stoss T_B
cA_zu cP_zu T_zu Vpunkt_zu

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
% Temperature
TC = 55 % [C] Cooler temp
T0 = TC % [C] Initial temp of reactor
T_zu = 10 % [C] Inlet temp
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
% Material constants
VR = 4
% [m3]
Volume of reactor
Aw = 15;
% [m2]
Heat transfer surface area
Uw = 1000;
% [W/m2/K] Heat transfer coefficient
rho = 1000;
% [kg/m3] Density
cp = 4000;
% [J/kgK] Heat capacity
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
% Reaction parameter
dh = -7.0e5;
% [J/mol] Enthalpy of reaction
E
= 21000;
% [K] Activation energy
T_B = 350;
% [K] Base temp
stoss = 0.15;
% [1/s] Shock factor
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
% Inflow values
cA_zu = 300;
% [mol/m3] Inlet conc of A
cP_zu = 0;
% [mol/m3] Inlet conc of Product
Vpunkt_zu= 2.22222e-3; % [m3/s] Feed flow
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
% Strating values
cA0 = 300 % [mol/m3]
cP0 = 0
% [mol/m3]
y0(1) = cA0;
y0(2) = cP0;

y0(3) = T0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
% ODE45 call
[t,y] = ode23s('cstr_func',[0 36000],y0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
% Graph output
time = t/3600.0; % seconds to hours
subplot(2,2,1);
plot(time,y(:,1),'-k','LineWidth',2,...
'MarkerFaceColor','k');
grid on;
axis([0 10 0 400]);
xlabel('t [h]');
ylabel('c_A [mol/m^3]');
subplot(2,2,3);
plot(time,y(:,2),'-k','LineWidth',2,...
'MarkerFaceColor','k');
grid on;
axis([0 10 0 400]);
xlabel('t [h]');
ylabel('c_P [mol/m^3]');
subplot(2,2,2);
plot(y(:,3),y(:,1),'-k','LineWidth',2,...
'MarkerFaceColor','k');
grid on;
axis([0 120 0 400]);
xlabel('T [^oC]');
ylabel('c_A [mol/m^3]');
subplot(2,2,4);
plot(time,y(:,3),'-k','LineWidth',2,...
'MarkerFaceColor','k');
grid on;

axis([0 10 0 120]);
xlabel('t [h]');
ylabel('T [^oC]');

FUNCTION :
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%
function f = semi_func(t,y)

% Global parameters
global cA0 cP0 T0
global VR Aw Uw rho cp TC
global dh E stoss T_B
global cA_zu cP_zu T_zu Vpunkt_zu

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%
% Variable names
cA

= y(1);

cP

= y(2);

= y(3);

time = t;
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%
% Reaction rate formula
rate = stoss * cA * exp(E*(1/T_B-1/(273+T)));

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%
% Equations of conc and temp change

%-------------------------------------------------% dcA/dt =
f(1) = Vpunkt_zu/VR * (cA_zu - cA) - rate;
%-------------------------------------------------% dcP/dt =

f(2) = Vpunkt_zu/VR * (cP_zu - cP) + rate;


%-------------------------------------------------% dT/dt =
f(3) = 1.0/rho/cp *(-dh * rate + Uw*Aw/VR*(TC - T)
+ rho*cp*Vpunkt_zu/VR*(T_zu-T));
%--------------------------------------------------

f = f';

You might also like