You are on page 1of 10

DeenBandhu Chhotu Ram

University Of Science And


Technology, Murthal,
Sonepat

Process Modulation And Simulation Lab

By:
Shubham Mittal
14001005052
Chemical Engg.
8th Semester
Batch:2014-18
CONTENTS
EXPERIMENT NO-1

ISOTHERMAL CSTR
PROGRAMME
function Ca_dot = cstr(t,Ca,Ca_in)
q=1;
v=1;
k1=1;
Ca_dot = (q/v*(Ca_in-Ca))-k1*Ca;

clear all; close all; clc


Ca_in=1;
Ca=0.2;
[t,Ca] = ode15s(@(t,Ca)cstr(t,Ca,Ca_in),[0 5],Ca);
plot(t,Ca);
EXPERIMENT NO-

NON ISOTHERMAL CSTR

PROGRAMME

% Non isothermal cstr

function xdot=cstr1(t,x)
global u
% Input (1):
% Temperature of cooling jacket (K)
Tc = u;
% States (2):
% Concentration of A in CSTR (mol/m^3)
Ca = x(1,1);
% Temperature in CSTR (K)
T = x(2,1);
% Parameters:
% Volumetric Flowrate (m^3/sec)
q = 100;
% Volume of CSTR (m^3)
V = 100;
% Density of A-B Mixture (kg/m^3)
rho = 1000;
% Heat capacity of A-B Mixture (J/kg-K)
Cp = .239;
% Heat of reaction for A->B (J/mol)
mdelH = 5e4;
% E - Activation energy in the Arrhenius Equation (J/mol)
% R - Universal Gas Constant = 8.31451 J/mol-K
EoverR = 8750;
% Pre-exponential factor (1/sec)
k0 = 7.2e10;
% U - Overall Heat Transfer Coefficient (W/m^2-K)
% A - Area - this value is specific for the U calculation (m^2)
UA = 5e4;
% Feed Concentration (mol/m^3)
Caf = 1;
% Feed Temperature (K)
Tf = 350;

% Compute xdot:
xdot(1,1) = (q/V*(Caf - Ca) - k0*exp(-EoverR/T)*Ca);
xdot(2,1) = (q/V*(Tf - T) + mdelH/(rho*Cp)*k0*exp(-EoverR/T)*Ca +
UA/V/rho/Cp*(Tc-T));
% Step test for Model 1 - CSTR

global u
% Steady State Initial Conditions for the States
Ca_ss = 0.87725294608097;
T_ss = 324.475443431599;
x_ss = [Ca_ss;T_ss];
% Steady State Initial Condition for the Control
u_ss = 300;
% Open Loop Step Change
u = 290;
% Final Time (sec)
tf = 5;
[t,x] = ode15s('cstr1',[0 tf],x_ss);
% Parse out the state values
Ca = x(:,1);
T = x(:,2);

% Plot the results


figure(1);
plot(t,Ca,'r');

figure(2)
plot(t,T,'g');
EXPERIMENT NO-
BATCH REACTOR
PROGRAM
function dC=Batch(t,C)
%%
k1 = 1.5;
k2 = 1;
k3=1;
k4=0.7;

dC=zeros(4,1);

dC(1) = -k1*C(1) -k4*C(1)*C(2);


dC(2) = k1*C(1) - k2*C(2)+k3*C(3) - k4*C(1)*C(2);
dC(3) = k2*C(2) - k3*C(3);
dC(4)=k4*C(1)*C(2);

[t,C]= ode45('Batch',[0 20],[1 0 0 0]);


plot(t,C);
EXPERIMENT NO-

Gravity Flow Tank


PROGRAMME
%gravity flow tank
f0=35.2; %initial system is at steady state value
f0=0.5*35.1; %changing the initial flow rate
f=@(t,y) [0.0107*y(2)-0.00205*y(1).^2;(f0/110)-0.0624*y(1)]
%5 steady state values are obtained from the curve for flow rate of 35.1
%initially which are [4.977]
[t,y]=ode45(f,[0 1000],[4.57 4.74])
plot(t,y(:,1),'r',t,y(:,2),'b')
EXPERIMENT NO-

Euler’s Explicit Method


PROGRAMME
%%solving differential equation using euler explicit method
x0=0;
y0=1;
xEnd=5;
h=0.01;
n=(xEnd-x0)/h;
%%Initial values for solving
x=[x0:h:xEnd]';
y=zeros(n+1,1);
y(1)=y0;
%% solving using euler explicit method
for i=1:n
fi=x(i)+y(i);
y(i+1)=y(i)+h*fi;
end
plot(x,y,'r')
ytrue=2*exp(x)-(x-1);
hold on
plot(x,ytrue,'g')
error=abs(ytrue-y);
EXPERIMENT NO-
RungaKuttaMethod

PROGRAMME
function RungaKuttaMethod
%example of Runga-Kutta method of order 4.
%y* = y - t^2 + 1.
a = 0;
b = 4;
h = 0.1;
N=(b-a)/h;
t = zeros(1, N);
y = zeros(1, N);
y(1) = 0.5;

t(1) = a;
F = @(t,y) y - t^2 +1;
for i = 1:(N-1)

K1 = h*(F(t(i), y(i)));
K2 = h*(F(t(i)+0.5*h, y(i)+0.5*K1));
K3 = h*(F(t(i)+ 0.5*h, y(i)+ 0.5*K2));
K4 = h*(F(t(i) + h, y(i)+K3));
y(i+1) = y(i) + (K1 + 2*K2 + 2*K3 +K4)/6;
t(i+1) = a + i*h;
end
plot(t,y, 'r')
EXPERIMENT NO-

You might also like