Undefined function or variable "C".Error in line
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Chinaemerem Valentine Nwobi
am 22 Mai 2019
Beantwortet: Chinaemerem Valentine Nwobi
am 22 Mai 2019
Hi
I've been given a function by my professor that calculates PT flash for non -ideal systems. I'm trying to use it to simulate an experiment. But continously get error.
I think it may be the way i've set my input up.
The function is below:
function[Xeq, Yeq, alphaV, Fl, Fv]=PTFLASH_VLE_Wilson(C,MW,rhoL,BIP,P,T,Z)
%this is a function that calculates PT flash for non -ideal systems where K
%cannot be explicit since it depends on X which is also a variable
c=length(Z);
for i=1:c
Ps=exp((C(i,1))+(C(i,2)/T)+(C(i,3)*log(T))+(C(i,4)*T^C(i,5)));
end
% validating the possibility of having VLE
[PB,y]=PB_VLE_Wilson(Z,C,MW,rhoL,T,BIP);
[PD,x]=PD_VLE_wilson (C,MW,rhoL,BIP,T,Z);
% checking if there is VLE
if P<=PD %% y here represents the mole fraction of componenets
Xeq=0;
Yeq=y;
alphaV=1;
Fl=0;
Fv=P*Z;
elseif P>=PB %% x here represents the mole fraction of components
Xeq=x;
Yeq=0;
alphaV=0;
[gamma,a]=ACTIVITY_WILSON(MW,rhoL,BIP,T,Xeq);
Fl=Ps.*Xeq.*gamma;
Fv=0;
else
Xeq=(x+y)/2 ; % first guess on x
[gamma,a]=ACTIVITY_WILSON(MW,rhoL,BIP,T,Xeq); %first guess on gamma
K=(Ps.*gamma)/P; % first guess on K
Psi_0=sum(z.*(K-1));
Psi_1=sum(z.*(K-1)./K);
if Psi_0*Psi_1>=0 % bad initial guess
Xeq=0;
Yeq=0;
alphaV=0;
Fl=0;
Fv=0;
disp("bad initial guess")
else %supposedly good initial guess
Fl=zeros(1,c); % trick to enter the while cycle at the begininng
Fv=Fl+1;
iter=0; % initialization of iteration count
while max(abs((Fv-Fl)./Fv))>0.00001 && iter<10000 && Psi_0*Psi_1<0
[ alphaV ] = RACHFORDRICE_BISECT( K,Z );
xeq=Z./((1-alphaV)+alphaV*K);
Yeq=K.*xeq;
[gamma,a]=ACTIVITY_WILSON(MW,rhoL,BIP,T,Z); %Gamma new guess
K=(Ps.*gamma)/P;
psi_0=sum(z.*(K-1));
psi_1=sum(z.*(K-1)./K);
Fv=P*Yeq;
Fl=Ps.Xeq.*gamma;
iter=iter+1;
end
end
end
end
The input:
T=320;
Z=[0.1 0.9];
P=1.5E04
MW=[60.09 100.16];
rhoL=[803 802];
T=303.15;
BIP=[196.250 386.133;196.250 386.133];
C=[88.1834 -8498.6 -9.0766 8.330e18 6;153.23 -10055 -19.488 1.6426e5 2];
C1=[88.134 153.23];
C2=[-8498.6 -10055];
C3=[-9.0766 -19.488];
C4=[8.330e18 1.6426e5];
C5=[6 2];
C = [C1' C2' C3' C4' C5'];
Tc=[301 263];
1 Kommentar
Antworten (2)
KALYAN ACHARJYA
am 22 Mai 2019
Bearbeitet: KALYAN ACHARJYA
am 22 Mai 2019
I didnot find the same error, in my case the error is expected that I dont have PB_VLE_Wilson function file.
P =
15000
Undefined function or variable 'PB_VLE_Wilson'.
Why you are considering two C
C=[88.1834 -8498.6 -9.0766 8.330e18 6;153.23 -10055 -19.488 1.6426e5 2];
......
C = [C1' C2' C3' C4' C5'];
Is this both are same, if not in this case peivious C is replaced by later C, whch pass to the finction.
3 Kommentare
KALYAN ACHARJYA
am 22 Mai 2019
I am tired now there are more functions
Undefined function or variable 'ACTIVITY_WILSON'.
Siehe auch
Kategorien
Mehr zu Thermal Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!