Matlab mathematival modeling problem chemical eng

1 Ansicht (letzte 30 Tage)
Georgios Stefanis
Georgios Stefanis am 12 Nov. 2021
Beantwortet: Bjorn Gustavsson am 12 Nov. 2021
function [f] = acidpretreat(t,x,)
%Components
xyl= x(1);
arab= x(2);
acet= x(3);
cel= x(4);
Xylo= x(5);
Arabi= x(6);
Acetic= x(7);
Furf= x(8);
%---------------------------------------------------------------------
%Data
R=8.314;
HA=0.8;
T=400; % kelvin
k10=2.37; k20=2.17; k1ac=2.37; k30=2.37; %min^-1%
n1=1.51; n2=0.29;n1ac=0.604;n3=1.359;
E1=83.3*1e3;E2=143.5*1e3;E1ac=83.3*1e3;E3=94.962*1e3; %J/mol
Bmax=120;
Xc=0.40680*1e-2; Xh1=0.22136*1e-2; Xh2=0.03786*1e-2;Xh3=0.03330*1e-2; %wt
xylmax=Xh1*Bmax; arabmax=Xh2*Bmax;acetmax=Xh3*Bmax;celmax=Xc*Bmax; %g/L
%---------------------------------------------------------------------
% initial concentrations
xyl_zero=Xh1*x;
arab_zero=Xh2*x;
acet_zero=Xh3*x;
cel_zero=Xc*x;
Xylo_zero=0;
Arabi_zero=0;
Acetic_zero=0;
Furf_zero=0;
% Effective coefficients
ef1=1/(1+(xyl/xylmax)^20);
ef2=1/(1+(arab/arabmax)^20);
ef3=1/(1+(acet/acetmax)^20);
ef4=1/(1+(cel/celmax)^20);
% Effective concentrations
xylef=0.95*ef1*xyl+((1-ef1)*xylmax);
arabef=0.95*ef2*arab+((1-ef2)*arabmax);
acetef=0.95*ef3*acet+((1-ef3)*acetmax);
celef=0.95*ef4*cel+((1-ef4)*celmax);
% K min^(-1)
K1=(k10*1e10)*(HA^n1)*exp(-E1/(R*T));
K2=(k20*1e15)*(HA^n2)*exp(-E2/R*T);
K3=(k30*1e10)*(HA^n3)*exp(-E3/R*T) ;
K1ac=k1ac*(10^10)*(HA^n1ac)*((xyl*((xyl_zero)^-1)))^2*exp(-E1ac/R*T);
% Rates
rxyl=-K1*xylef;
rarab=-K1*arabef;
racet=-K1ac*acetef;
rcel=-K3*celef;
rXylo=K1*xylef-K2*Xylo;
rArabi=K1*arabef-K2*Arabi;
rAcetic=K1ac*acetef;
rglu=K3*celef;
% Mass balance
dxyldt=rxyl;
darabdt=rarab;
4*((dacetdt)^2)+10*dacetdt = racet;
dceldt=rcel;
dXylodt=rXylo;
dArabidt=rArabi;
4*((dAceticdt)^2)+10*dAceticdt = rAcetic;
dgludt=rglu;
dfurfdt=K2*(Xylo+Arabi);
%-----------------------------------
f =[ dxyldt; darabdt; dacetdt; dceldt; dXylodt; dArabidt; dAceticdt;dgludt;dfurfdt];
end
comand window
[t, x] = ode23s(@acidpretreat, [0 240], [20])
Error using feval
Error: File: acidpretreat.m Line: 59 Column: 28
The expression to the left of the equals sign is not a valid target for an assignment.
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode23s (line 119)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

Antworten (1)

Bjorn Gustavsson
Bjorn Gustavsson am 12 Nov. 2021
You have at least a couple of syntax errors in your code, namely the lines:
4*((dacetdt)^2)+10*dacetdt = racet;
4*((dAceticdt)^2)+10*dAceticdt = rAcetic;
If you want to assign values to racet and rAcetic you have to put those variables on the LHS of the assignment-=.
In addition I strongly suggest you make use of the code-markup capacility of the answers editor - use the buttons over the "CODE" tab-label.
HTH

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by