why does code get wrong output for K(c7+) ?
Afficher commentaires plus anciens
%This program calculate K-factor from Wilson Equation
%mixture contain:
%1=C1,2=C2,3=C3,4=i-C4,5=n-C4,6=i,C5,7=n,C5,8=C6,9=CO2,10=N2,11=C7+
clear
clc
clf
disp('calculating K-factore from Wilson equation')
disp('')
disp('mixture contain C1,C2,C3,i-C4,n-C4,i-C5,n-C5,C6,CO2,N2,C7+')
%input
P=input('pressure(psia)=');
T=input ('Temperature(R)=');
M_C7p=input('Molecular weight of C7+=');
gama=input('Relative density of C7+=');
%matrix of critical Temprature
Tc_c7p=608+364*(log10(M_C7p-71.2))+((2450*log10(M_C7p))-3800)*log10(gama);
Tc=[343.37 550.09 666.01 734.98 765.65 829.1 845.7 913.7 547.91 227.6 Tc_c7p];
%matrix of critical Pressure
Pc_c7p=1.188-431*log10(M_C7p-61.1)+(2.319-(852*log10(M_C7p-53.7)))*(gama-.8);
Pc=[667.8 707.8 616.3 529.1 550.7 490.4 488.6 436.9 1071 493.1 Pc_c7p];
%matrix of accentric factor
w=[.0104 .0986 .1524 .1848 .2010 .2223 .2539 .3007 .225 .040];
%matrix of normal boiling point
Tb=[94 303 416.25 471 491 542 557 610 194 109];
Tb_c7p=.0004347*(Tc_c7p^2)+265;
w_c7p=(3/7)*((log10(Pc_c7p/14.7))/((Tc_c7p/Tb_c7p)-1));
w=[w w_c7p];
for i=1:11
K(i)=(Pc(i)/P)*exp(5.37*(1+w(i))*(1-(Tc(i)/T)));
end
fprintf('K(c1)=%f\n K(c2)=%f\n K(c3)=%f\n K(i-c4)=%f\n',K(1),K(2),K(3),K(4))
fprintf('K(n-c4)=%f\n K(i-c5)=%f\n K(n-c5)=%f\n K(c6)=%f\n',K(5),K(6),K(7),K(8))
fprintf('K(co2)=%f\n K(N2)=%f\n K(c7+)=%f\n',K(9),K(10),K(11))
7 commentaires
Jan
le 3 Juin 2018
Please post only one thread per question. I've closed the other one, and mentioned there, that the question contains too few information to be answered.
Dennis
le 4 Juin 2018
Your K values can have quite a few leading 0s. You could change your output from floating point to exponential (%e instead of %f).
mohammad zamehrian
le 4 Juin 2018
Dennis
le 4 Juin 2018
You can increase the number of digits shown. %.12f will show 12 digits after decimal point.
mohammad zamehrian
le 4 Juin 2018
Dennis
le 4 Juin 2018
Run your code and type vpa(K) it will prompt your K values with 32 digits. When i run your code it works, but i am guessing input values.
mohammad zamehrian
le 4 Juin 2018
Réponses (0)
Catégories
En savoir plus sur Numerical Integration and Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!