مدلسازی راکتورهای شیمیایی با نرم افزار MATLAB

پیرجو

مدیر ارشد
مدیر کل سایت
مدیر ارشد
Nonisothermal Plug Flow Reactor


کد:
% rate1.m
% This function gives the right-hand side for a simple
% reactor problem which is isothermal.
function ydot=rate1(VR,y)
% y(1) is CA, y(2) is CB, y(3) is CC
% k=0.3 and u=0.5
CA=y(1);
rate=0.3*CA*CA;
ydot(1)=-2.*rate/0.5;
ydot(2) =+rate/0.5;
ydot(3)=0.;
ydot=ydot’;
plot(z,y(:,1),‘*-’,z,y(:,2),‘+-’,z,y(:,3),‘x-’)
% rateSO2.m for SO2 reaction
function ydot=rateSO2(z,y)
% X is concentration SO2 divided by the inlet concentration
X=y(1);
% T is temperature in degrees K
T=y(2);
k1=exp(-14.96+11070/T);
k2=exp(-1.331+2331/T);
Keq=exp(-11.02+11570/T);
term1=X*sqrt(1-0.167*(1-X));
term2=2.2*(1-X)/Keq;
denom=(k1+k2*(1-X))^2;
rate=(term1-term2)/denom;
ydot(1)=-50*rate;
ydot(2)=-4.1*(T-673.2)+1.02e4*rate;
ydot=ydot’;
y(1)=0.2; y(2)=573.2;
rateSO2(0.1,y)
ans=-0.001148 410.235
% run_SO2.m
% set the dimensionless initial conditions
y0=[1 673.2]
% set the integration range
zspan=[0 1]
% call the solver
[z y]=ode45(@rateSO2,zspan,y0)
% plot the result
plot(z,y(:,1),‘r-’)
xlabel(‘dimensionless axial position’)
legend(‘fraction converted’)
pause
plot(z,y(:,2),‘g-’)
xlabel(‘dimensionless axial position’)
legend(‘temperature (K)’)
 

پیرجو

مدیر ارشد
مدیر کل سایت
مدیر ارشد
مدلسازی راکتورهای شیمیایی با نرم افزار MATLAB

CONTINUOUS STIRRED TANK REACTORS​

کد:
% rate_T
function fn=rate_T(c)
global beta gamma flowvol
T=1+beta*(1-c)
rate=c*exp(gamma*(1-1/T))
fn=flowvol*(1-c)-rate
>> rate_T(0.5)
T=1.0750
rate=4.0547
fn=0.2953
ans=0.2953
>> fzero(@rate_T,0.5)
ans=0.73107565193641
% rate_T2
function fn=rate_T2(y)
global beta gamma flowvol
c=y(1);
T=y(2);
rate=c*exp(gamma*(1-1/T));
fn(1)=flowvol*(1-c)-rate;
fn(2)=flowvol*(1-T)+beta*rate;
>> feval(@rate_T2,[0.5 1.1])
ans=-3.29556351331856 0.27683452699778
global beta gamma flowvol
beta=0.25; gamma=30; flowvol=25;
fsolve(@rate_T2,[0.0 1.25])
 

پیرجو

مدیر ارشد
مدیر کل سایت
مدیر ارشد
مدلسازی راکتورهای شیمیایی با نرم افزار MATLAB

شبیه سازی معادلات توزیع دما در راکتور هسته ای در MATLAB

کد:
global n delta rspan options r T  
n = 100;
delta = 1.e-3;
rspan=linspace(delta,1,n+1);
options = odeset('RelTol',1e-12,'AbsTol',1e-12,'NormControl','on','MaxOrder',5);
T0=newton_mfile(@cp6_BV,2,1.e-10,0); 
r=[0;r];  
T=[[T0,0];T]; 
[Tdirect,rdirect] = cp6_direct(n);
figure(1)
hold off
Texact= 9/32-r.^2/4-r.^4/32;
plot(r,Texact,'r-')
hold on
grid on
plot(r,T(:,1),'b:');
plot(rdirect,Tdirect,'g--');
legend('Exact','Shooting','Direct')

%----------------------------------------------------

%newton_mfile

function x_root=newton_mfile(funhandle,x1,eps,reg)
del = max([1.e-10,eps^2]);
x_guess(1) = [x1];
f_guess(1) = feval(funhandle,x_guess(1));
if abs(f_guess) < eps
   x_root=x_guess;
   disp('excellent guess');
   return
end 
iter = 1;
check = logical(1);
tau=0.1;
while check
    iter = iter +1;
    x_guess(iter)=0;
    f_guess(iter)=0;
    f_h = feval(funhandle,x_guess(iter-1)+del);
    df=(f_h-f_guess(iter-1))/del;    
    dx(iter) = f_guess(iter-1)/df; 
    if iter >=  3
        tau=tau*dx(iter-1)/(dx(iter-1)-dx(iter));
    end
    if reg == 0
        x_guess(iter)=x_guess(iter-1)-dx(iter);
    else
        x_guess(iter)=x_guess(iter-1)-tau*dx(iter);
    end
    f_guess(iter) = feval(funhandle,x_guess(iter));
    if reg == 0 & abs(tau) < 1.0e-5 | abs(f_guess(iter)) < eps 
        x_root=x_guess(iter);
        check = logical(0);
    end
end
    
%-------------------------------------------------------

%cp6_BV

function f = cp6_BV(z)
global n delta rspan options r T
Tdelta  = z-1/4*delta^2-delta^4/32; 
dTdelta = -1/2*delta-delta^3/8;
[r,T] = ode15s(@rhs_cp6,rspan,[Tdelta dTdelta],options); 
f = T(end,1);  
%------------------------------------------------------------

%cp6_direct

function [T,r] = cp6_direct(N)

A = zeros(N+1);
S = zeros(N+1,1);
r = linspace(0,1,N+1)';
S(2:N) = -1 - r(2:N).^2/2;  
h = 1.0/N;
for i = 2:N 
    A(i,i-1) = 1/h^2-1/(2*h*r(i));
    A(i,i)   = -2/h^2;
    A(i,i+1) = 1/h^2+1/(2*h*r(i));
end
A(1,1:2) = [-1,1]; 
A(N+1,N+1) = 1;
T = inv(A)*S;
 

حــامد

مدیر بازنشسته
کاربر ممتاز
مدلسازی راکتورهای شیمیایی با نرم افزار MATLAB

CSTR - Continuously Stirred Tank Reactor

The CSTR model with A->B exothermic reaction is the most popular model in the database. It is a standard model that has been used in reaction engineering textbooks, simulation and control research, and demonstrations for industrial software.


The model has 2 states: the concentration of A and the temperature of the reaction vessel liquid. The manipulated variable is the jacket water temperature. At a jacket temperature of 305K, the reactor model has an oscillatory response. The oscillations are characterized by reaction run-away with a temperature spike. When the concentration drops to a low value, the reactor cools until the concentration builds and there is another run-away reaction.



CSTR - Continuously Stirred Tank Reactor with Intermediate Species

Models 1-5, 10 are all variations of the CSTR model. Model 3 in particular, has a reaction intermediary (B). There is an additional equation and variable to account for the intermediate reaction step.





Reactor 1 CSTR with Jacket Dynamics (A->B)

Reactor 2 CSTR with Jacket Dynamics (A-B-C-D)

Reactor 3 CSTR with Jacket Dynamics (A->B->C)

Reactor 4 2 CSTRs in Series (A->B)

Reactor 5 2 CSTRs in Series with Jacket Dyn (A->B)

Reactor 6 CSTR
اینم همه فایلها در یا فایل زیپ

فايل ضميمهhttp://www.www.www.iran-eng.ir/images/attach/rar.gifreactor.rar (53.0 كيلو بايت, 0 نمايش)
 

حــامد

مدیر بازنشسته
کاربر ممتاز
مدلسازی راکتورهای شیمیایی با نرم افزار MATLAB



Poly Reactor Yang Zhang's polyethylene reactor model




فايل ضميمهhttp://www.www.www.iran-eng.ir/images/attach/zip.gifmodel25.zip (35.7 كيلو بايت, )
 
آخرین ویرایش:

sayna

عضو جدید
کاربر ممتاز
باسلام
مدل سازی کاتالیست های بستر ثابت رو با برنامه متلب میخواستم.
ممنون میشم اگه کمکم کنید.یا اگه حتی توضیحی راجع به نحوه ی برنامه نویسی ش بدید
 

P O U R I A

مدیر مهندسی شیمی مدیر تالار گفتگوی آزاد
مدیر تالار
باسلام
مدل سازی کاتالیست های بستر ثابت رو با برنامه متلب میخواستم.
ممنون میشم اگه کمکم کنید.یا اگه حتی توضیحی راجع به نحوه ی برنامه نویسی ش بدید


سلام دوست من ...

تا اینجا که من اطلاع دارم برای مدل سازی کاتالیست های بستر ثابت رو با ایزوترم هایی که توسط دانشمندان بدست آمده می کنن و حل این معادلات که معمولا معادلات جزئی درجه دوم می باشند با توابعی مانند pdepe و ode45 و pdetool و simulink انجام میشه ....
 

Similar threads

بالا