0% found this document useful (0 votes)
28 views

Function: % MATLAB Programming % Dibuat Oleh: M.Ikchsan Fajrin % NRP: 122016019p

This document contains MATLAB code to solve a system of ordinary differential equations (ODEs) describing a chemical reaction process. It defines an ODE function that calculates reaction rates and species concentrations. The code then uses the ODE solver ode45 to integrate the system from initial conditions and plot the molar flow rates over time.

Uploaded by

enongg_
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Function: % MATLAB Programming % Dibuat Oleh: M.Ikchsan Fajrin % NRP: 122016019p

This document contains MATLAB code to solve a system of ordinary differential equations (ODEs) describing a chemical reaction process. It defines an ODE function that calculates reaction rates and species concentrations. The code then uses the ODE solver ode45 to integrate the system from initial conditions and plot the molar flow rates over time.

Uploaded by

enongg_
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

% MATLAB Programming

% Dibuat oleh : M.Ikchsan Fajrin


% NRP : 122016019p

function dYfuncvecdW = ODEfun(W,Yfuncvec);


Fa = Yfuncvec(1);
Fb = Yfuncvec(2);
Fc = Yfuncvec(3);
Fd = Yfuncvec(4);
p = Yfuncvec(5);

Ft = Fa + Fb + Fc + Fd;

k1a = 100;
k2c = 1500;
Cto = 0,2;
V = 1000;

Ca = Cto * Fa / Ft * p;
Cb = Cto * Fb / Ft * p;
Cc = Cto * Fc / Ft * p;
Cd = Cto * Fd / Ft * p;

r1a = -k1a*Ca*(Cb^2);
r1b = 2*r1a;
rb = r1b;
r2c = -k2c*(Ca^2)*(Cc^3);
r2a = (2/3)*r2c;
r2d = -(1/3)*r2c;
r1c = -r1a;
rd = r2d;
ra = r1a + r2a;
rc = r1c + r2c;

v = 100;
alpha = 0.0019;
Fto = 20;
if (W > 0.0001)
Scd = Fc / Fd;
else
Scd = 0;
end
% Differential equations
dFadW = 0 - (alpha / 2 / Fa * Ft / Fto);
dFbdW = 0 - (alpha / 2 / Fb * Ft / Fto);
dFcdW = 0 - (alpha / 2 / Fc * Ft / Fto);
dFddW = 0 - (alpha / 2 / Fd * Ft / Fto);
dpdW = 0 - (alpha / 2 / p * Ft / Fto);
dYfuncvecdW = [dFadW; dFbdW; dFcdW; dFddW; dpdW];

clc
tspan = [0 10]
y0 = [10;10;10;10;10]; % Kondisi awal dari beberapa variabel bebas
Fa,Fb,Fc,Fd,and y
[w,y]=ode45(@ODEfun,tspan,y0)
Plot(W,Fa,W,Fb,W,Fc,W,Fd,W,p)
Legend('Fa','Fb','Fc','Fd','p')
Xlabel('Fi')
Ylabel('W')
Title('Molar Flow Rate Profile')

You might also like