Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Replies: 0

 martin Luther King Jr Posts: 2 From: Greensboro Registered: 2/25/08
Posted: Feb 25, 2008 10:39 PM

mathlab (Chemical) Feb 25, 2008
I have the following program and it has some sub function group.
Here problem is while I am running the subscript, it can not connect with equilibrium_1 function giving message as:

??? Undefined function or method 'equilibrium_1' for input arguments of type 'double'.

Error in ==> ethanol_reforming at 160
[r1,r2,r3,SHIE,SHIS,SHICO1,SHICO2,SHIH,SHIM]=equilibrium_1(PHIE(i,j),PHIS(i,j),PHICO1(i,j),PHICO2(i,j),PHIH(i,j),PHIM(i,j));

Subcript:::::

dbstop if error;
global Ps Po T TUBEVELOCITY Pr RL CATALYST_WT EN RG PI SA;
Ps=input('Separation side total Pressure ===');
Pr=input('Reaction Side total Pressure ===');
Po=input('Reference Pressure ===');
T=input('Reaction Temperature ===');
Ca=input('The Molar Flow Rate of Argon in the reaction side ===');
Ce=input('The Molar Flow Rate of Ethanol(Mol/S) ===');
Ex=input('The Ratio(with excess)of Steam ===');
EN=input('What is Your Permeability Exponent ===');
SFLOWAO=input('What is your sweep gas flow rate in separation side ===');
SA=1e5;
Cs=Ce*Ex;
Ct=Ca+Ce+Cs;
Cc1=1e-7;
Cc2=1e-7;
Ch=1e-7;
Cm=1e-7;
RG=8.314;
PI=3.14;

% SHIAO=0.0;
% SHIEO=0.0;
% SHISO=0.0;
% SHIMO=0.0;
% SHICO1O=0.0;
% SHICO2O=0.0;
% SHIHO=0.0;
TBDMLSVO=1.0;

flow(1)=Ca;
flow(2)=Ce;
flow(3)=Cs;
flow(4)=1e-7;
flow(5)=1e-7;
flow(6)=1e-7;
flow(7)=1e-7;
flowtot=flow(1)+flow(2)+flow(3)+flow(4)+flow(5)+flow(6)+flow(7);

[ph]=convert(flow);
SHIMO=0.0;
SHISO=0.0;
SHICO2O=0.0;
SHICO1O=0.0;
SFLOWHO=0.0;
SPHIHO=SFLOWHO/(SFLOWAO+SFLOWHO)*Ps/Po;
CATALYST_WT=21.58e-3; %%% Weight of catalyst used in the sample
% Ca_load=6.23656; %%% [Since Catalyst surface area=9.3 sqm/gm & BET surface area=58m^2]

RL=input('What is the reactor length==');
H=ro-ri;

reactV=PI*ri.^2*RL;
eps=input('Enter The Void Fraction==');
TUBEVELOCITY=(flowtot*RG*T)/(Pr*PI*ri^2*RL*eps);
%% Grid And Dimensionless Modulous %%%
N=input('Grid Size In Z Direction==');
Dr=1.0/M;

%%%%% Spherical Equivalent Diameter of Catalyst %%%
Dp=2.25e-4;
%% Formula Molecule Of Components%%%
FM(1)=39.95;%%Molecular weight of Argon%%
FM(2)=46; %%% Ethanol molecular weight%%%
FM(3)=18.0;%%water molecular weight%%
FM(4)=28.0;%%% carbon monoxide molecular weight%%
FM(5)=44.0;%%carbon dioxide molecular weight%%%
FM(6)=28.0;%%methane molecular weight%%
FM(7)=2.0; %%hydrogen molecular weight%%%

GA=(flow(1)*FM(1)+flow(2)*FM(2)+flow(3)*FM(3))*10^(-3);
G=GA/(pi*ri^2);

YM=zeros(1,7);
for i=1:7;
YM(i)=flow(i)/flowtot;
end
[vis]=viscosity(T,Pr,FM,YM);
ReNo=Dp*G/vis;
Sc=1.2;
Pec1=0.4/(ReNo*Sc)^0.8+0.09/(1.0+10/(ReNo*Sc));
Pec=1/Pec1;
DelZ1=0.5*Pec*(ri*Dr)^2/(Dp*RL);
NI=1/DelZ1;
DelZ=1/N;
% DelRV=reactV/N;
DIM=Dp*RL*DelZ/(ri*Dr)^2;
DIMA=DIM/Pec;
DIMM=DIMA;
DIMCO1=DIMA;
DIMCO2=DIMA;
DIMH=DIMA;
DIMS=DIMA;

%%%Calculation of permeation Constant %%%

D=2.3e-7*exp(-2610/T); %%Fan 96 data are calculated%%
Qh=3.507e-7*exp(-1455/T);%%Film thickness==9.77 micrometer%%;
Der=TUBEVELOCITY*Dp/Pec;
Alpha=2*pi*(RL*DelZ)*Qh*Po^EN/log(ro/ri);
Beta=8.314*T*Qh*ri/(H*Po^(1-EN)*Der);
j=1;
V(j)=TBDMLSVO;
%% Reinitialization of the partial pressure in the reaction inlet side
%% (assuming flow rate in the feed
Cs=Ce*Ex;
%Ct=Ca+Ce+Cs;
Cc1=1e-7;
Cc2=1e-7;
Ch=1e-7;
Cm=1e-7;
Ct=Ca+Cm+Cs+Ce+Cc1+Cc2+Ch;
PHIAO=Ca/Ct*Pr/Po;
PHIEO=Ce/Ct*Pr/Po;
PHISO=Cs/Ct*Pr/Po;
PHIMO=Cm/Ct*Pr/Po;
PHICO1O=Cc1/Ct*Pr/Po;
PHICO2O=Cc2/Ct*Pr/Po;
PHIHO=Ch/Ct*Pr/Po;

% PHIA=zeros(M,N);
% PHIE=zeros(M,N);
% PHIS=zeros(M,N);
% PHICO1=zeros(M,N);
% PHICO2=zeros(M,N);
% PHIH=zeros(M,N);
% PHIM=zeros(M,N);
%
%
%
% VPHIA=zeros(M,N);
% VPHIE=zeros(M,N);
% VPHIS=zeros(M,N);
% VPHIM=zeros(M,N);
% VPHICO1=zeros(M,N);
% VPHICO2=zeros(M,N);

for i=1:M;
PHIA(i,j)=PHIAO;
PHIE(i,j)=PHIEO;
PHIS(i,j)=PHISO;
PHIM(i,j)=PHIMO;
PHICO1(i,j)=PHICO1O;
PHICO2(i,j)=PHICO2O;
PHIH(i,j)=PHIHO;
VPHIA(i,j)=V(j)*PHIA(i,j);
VPHIE(i,j)=V(j)*PHIE(i,j);
VPHIS(i,j)=V(j)*PHIS(i,j);
VPHIM(i,j)=V(j)*PHIM(i,j);
VPHICO1(i,j)=V(j)*PHICO1(i,j);
VPHICO2(i,j)=V(j)*PHICO2(i,j);
[r1,r2,r3,SHIE,SHIS,SHICO1,SHICO2,SHIH,SHIM]=equilibrium_1(PHIE(i,j),PHIS(i,j),PHICO1(i,j),PHICO2(i,j),PHIH(i,j),PHIM(i,j));
end

unction [viscomix]=viscosity(T,Pr,FM,YM)
%% viscosity of ethanol;
% YM(1)=39.95;%%Molecular weight of Argon%%
% YM(2)=46; %%% Ethanol molecular weight%%%
% YM(3)=18.0;%%water molecular weight%%
% YM(4)=28.0;%%% carbon monoxide molecular weight%%
% YM(5)=44.0;%%carbon dioxide molecular weight%%%
% YM(6)=28.0;%%methane molecular weight%%
% YM(7)=2.0; %%hydrogen molecular weight%%%

tc1=513.9;
pc1=61.4*1.01325e5;
Tre1=T/tc1;
% T=573.15;
% Pr=1.01325e5;

if Tre1<1.5 Nvis=0.00034*Tre1^0.94;
else Nvis=0.001778*(4.58*Tre1-1.67)^0.625;
end;
visco(2)=(4.64e-4*Nvis.*FM(2)^0.5*pc1^0.667/tc1^(1/6))*10^-2;

%% viscosity of methane%%
tc2=190.6;
pc2=46.0*1.01325e5;
Tre2=T/tc2;
if Tre2<1.5 Nvis=0.00034*Tre2^0.94;
else Nvis=0.001778*(4.58*Tre2-1.67)^0.625;
end;
visco(4)=(4.64e-4*Nvis.*FM(4)^0.5*pc2^0.667/tc2^(1/6))*10^-2;
%viscosity of argon,steam,hydrogen, carbon monoxide and carbon dioxide%%%
visco(1)=5e-7*T+7e-5;
visco(3)=4e-7*T-1e-5;
visco(5)=3E-07*T+9e-5;
visco(6)=4e-7*T+3e-5;
visco(7)=2e-7*T+5e-5;
for i=1:7;
for j=1:7;
Q(i,j)=(1+(visco(i)/visco(j))^0.5*(FM(i)/FM(j))^0.25)^2/(sqrt(8)*(1+FM(i)/FM(j))^0.5);
end;
end;

for k=1:7;
num(k)=visco(k);
for m=1:7;
sum=0;

denom1(m)=Q(k,m)*(YM(m)/YM(k));
sum=sum+denom1(m);
end;
denom(k)=1+sum;
viscomix_I(k)=num(k)/denom(k);
end;
% viscomix_J=transpose(viscomix_I);
% viscomix=sum(viscomix_J);
viscomix=viscomix_I(1)+viscomix_I(2)+viscomix_I(3)+viscomix_I(4)+viscomix_I(5)+viscomix_I(6)+viscomix_I(7);

% viscos=sum(viscomix_I);

THIS CAN NOT GET CONNECTED WITH SCRIPT WHERE I CALL TAHIS FUNCTION

function [r2,r3,SHeth,SHs,SHco1,SHco2,SHh2,SHch4]=equilibrium_1(PCH3CH2OH,PH2O,PCO,PCO2,PH2,PCH4)
DELSCH3CH2O=-34.6;
DELHCH3CH2O=-15.0;
DELSCO2=-47.5;
DELHCO2=-17.0;
DELSCO=-49.2;
DELHCO=-20.0;
DELSCH4=-58.3;
DELHCH4=-30.1;
DELSHCOO=112.3;
DELHHCOO=100.0;
DELSH2=-101.5;
DELHH2=-50;
DELSCH3CHO=-38.7;
DELHCH3CHO=-15.0;
DELSOH=-44.6;
DELHOH=-20.0;
R=8.314;
F=1000;
% PCH3CH2OH=0.356;
% PCH4=9.1431e-6;
% PH2O=1.6046;
% PCO=9.1431e-6;
% PCO2=9.1431e-6;
% PH2=9.1431e-6;
% TUBEVELOCITY=0.474;
% Po=1.01325e5;
% CATALYST_WT=21.58/1000;
% RL=0.1;
% T=473.15;
% R1=1.702e-2;
KCH3CH2O=exp(DELSCH3CH2O/R-DELHCH3CH2O*F/R/T);
KCO2=exp(DELSCO2/R-DELHCO2*F/R/T);
KCO=exp(DELSCO/R-DELHCO*F/R/T);
KCH4=exp(DELSCH4/R-DELHCH4*F/R/T);
KHCOO=exp(DELSHCOO/R-DELHHCOO*F/R/T);
KH2=exp(DELSH2/R-DELHH2*F/R/T);
KCH3CHO=exp(DELSCH3CHO/R-DELHCH3CHO*F/R/T);
KOH=exp(DELSOH/R-DELHOH*F/R/T);
kri=1.16e+20;
Er=82.7;
Kr=kri*exp(-Er/R/T);
kwi=4.64e+16;
Ew=43.6;
Kw=kwi*exp(-Ew/R/T);
Kdi=4.46e+19;
Ed=71.3;
Cst=sqrt(1.04e-21);
Kd=Kdi*exp(-Ed/R/T);

Krs=KCH3CH2O*Kr/(KCH3CHO*KH2);
Kws=KHCOO*Kw/(KOH*KCO);
Kds=KCH3CHO*Kd/(KCH4*KCO);
r1_fraction=(1-PCO2^2*PH2^4/(Krs*PCH3CH2OH*PH2O^2));
r2_fraction=(1-PH2O*PCO/(Kws*PH2*PCO2));
r3_fraction=(1-PH2O^2*PCH4*PCO/(Kds*PCO2^2*PH2^3));
% if r1_fraction>=1
% r1_fraction=0.0;
% end
% if r2_fraction>=1
% r2_fraction=0.0;
% end
% if r3_fraction>=1
% r3_fraction=0.0;
% end

DEN=1+KCO2*PCO2+KCO*PCO+KCH4*PCH4+KHCOO*PH2^0.5*PCO2+KH2*PH2^0.5+KCH3CHO*PH2^0.5*PCO2^0.5/PH2O^3+KCH3CH2O*PCH3CH2OH/PH2^0.5+KOH*PH2O/PH2^0.5
r1=Kr*KCH3CH2O*(PCH3CH2OH/PH2^0.5)*(r1_fraction)/DEN*Cst^2;
r2=Kw*KHCOO*PCO2*(r2_fraction)/DEN*Cst^2;
r3=Kd*KCH3CHO*(PCO2^2*PH2^3/PH2O^2)*(r3_fraction)/DEN*Cst^2;
SA=1e5;
raco2=(2*r1+r2)*SA;
raco1=(r3-r2)*SA;
rh2=(6*r1+r2+r3)*SA;
rch4=r3*SA;
ras=(3*r1+r2)*SA;
raeth=(r1+r3)*SA;
factor1=CATALYST_WT/(3.14*R1^2*RL);
factor2=8.314*RL*T/TUBEVELOCITY/Po;
SHeth=raeth*factor1*factor2;
SHs=ras*factor1*factor2;
SHco1=raco1*factor1*factor2;
SHco2=raco2*factor1*factor2;
SHh2=rh2*factor1*factor2;
SHch4=rch4*factor1*factor2;
end