Antoine's equation - K values
13 views (last 30 days)
Show older comments
I need to write code for this problem in Octave, this is MathCad file.

I don't know how to code this part with Kvalues.
s = [0.3; 0.5; 0.2];
P = 10;
fi = 0.7;
n = 3;
A = [9.1058; 9.0580; 9.2131];
B = [1872.46; 2154.9; 2477.07];
C = [-25.16; -34.42; -39.94];
Tmin = [164; 195; 220];
Tmax = [249; 290; 330];
Pn = 10.^(A-B./(T+C));
K = Pn./P
f = @(T) (sum(s/(1+fi*(Kvrednost)-1)))-1 ;
Tguess = 50 ;
Temperatura = fzero(f, Tguess)
0 Comments
Accepted Answer
Alan Stevens
on 5 Dec 2020
Like this perhaps:
s = [0.3; 0.5; 0.2];
P = 10;
fi = 0.7;
n = 3;
A = [9.1058; 9.0580; 9.2131];
B = [1872.46; 2154.9; 2477.07];
C = [-25.16; -34.42; -39.94];
Tmin = [164; 195; 220];
Tmax = [249; 290; 330];
f = @(T) sum(s./(1+fi*(Kfn(n,P,T,A,B,C)-1)))-1 ;
Tguess = 50 ;
Temperatura = fzero(f, Tguess);
disp(Temperatura)
function K = Kfn(n,P,T,A,B,C)
T = T + 273.15;
K = zeros(n,1);
for i = 1:n
Pn = A(i) - B(i)/(T + C(i));
Pn = exp(Pn);
K(i) = Pn/P;
end
end
More Answers (3)
David Vujic
on 7 Dec 2020
2 Comments
Alan Stevens
on 7 Dec 2020
In Mathcad log is log to the base 10; in MATLAB it is log to the base e. Change
A = (Tmk/(1-Tmk))*log(pc(i)/1.01325);
to
A = (Tmk/(1-Tmk))*log10(pc(i)/1.01325);
David Vujic
on 21 Dec 2020
2 Comments
Alan Stevens
on 21 Dec 2020
fzero only allows you to find a single value.
The Mathcad calculation you have here is very heavy-handed! The parameters can be calculated in the following straightforward manner:
Fxf = 179*[0.015; 0.025; 0.59; 0.37];
DxD1 = Fxf(1);
DxD2 = 0.89*Fxf(2);
BxB2 = -DxD2 + Fxf(2) ;
BxB4 = Fxf(4);
BxB3 = 0.9995*Fxf(3);
DxD3 = -BxB3 + Fxf(3);
D = DxD1 + DxD2 + DxD3;
B = BxB2 + BxB3 + BxB4;
xD = [DxD1; DxD2; DxD3; 0]/D;
xB = [0; BxB2; BxB3; BxB4]/B;
disp(['D = ', num2str(D)])
disp(['B = ', num2str(B)])
disp('xD = '), disp(xD)
disp('xB = '), disp(xB)
David Vujic
on 1 Feb 2021
4 Comments
Alan Stevens
on 1 Feb 2021
I think you have your functions f1 and f2 defined with the wrong operator.
Instead of
f1 = @(T) sum(s.*(Kfn(n,Pvrha,T,A,B,C)))-1;
use
f1 = @(T) sum(s./(Kfn(n,Pvrha,T,A,B,C)))-1;
and instead of
f2 = @(T) sum(s./(Kfn(n,Pdno,T,A,B,C)))-1 ;
use
f2 = @(T) sum(s.*(Kfn(n,Pdno,T,A,B,C)))-1 ;
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


