finding the location of a point in diagram

3 views (last 30 days)
Hello eveyone.
I have a thermodynamics problem and i wanted to solve it with matlab.
This problem is about Cd_Bi phase diagram and I drew the phase diagram according the equations that I had but there's still one part remaining.
I want user to give the X_Cd and the T (marking a point) then I say that where that point is located according to the phase diagram. I tried to do that but I couldnt.
Can you please help me with this?
clc
clear
close all
R = 8.314;
syms f(x) ;
syms g(x) ;
T_m_Bi = 544;
T_m_Cd = 594;
delta_H0_Bi = 10900;
delta_H0_Cd = 6400;
delta_S0_Bi = 20 ;
delta_S0_Cd = 10.77;
f(x) = 1.2 - (16.45e-3 * x ) + (21.1e5 .* x^-2 );
g(x) = 7.5 - 12.3e-3 .* x;
G1 = g(x) / x;
F1(x) = f(x) / x;
F = int(f,T_m_Bi,x,'IgnoreAnalyticConstraints',true);
G = int(g,T_m_Cd,x,'IgnoreAnalyticConstraints',true);
F1_prime = int(F1,x,T_m_Bi,x,'IgnoreAnalyticConstraints',true);
G1_prime = int(G1,T_m_Cd,x,'IgnoreAnalyticConstraints',true);
delta_G_Bi(x) = delta_H0_Bi + F - x * (delta_S0_Bi + F1_prime);
delta_G_Cd(x) = delta_H0_Cd + G - x * (delta_S0_Cd + G1_prime);
X_Bi(x) = exp(-delta_G_Bi/(R * x));
y = finverse(X_Bi);
X_Cd(x) = exp(-delta_G_Cd/(R * x));
X1 = matlabFunction(X_Bi);
X2 = matlabFunction(X_Cd);
Y = @(x) X1(x) + X2(x) - 1;
S = fsolve(Y,406);
T = S : 1 : 600;
P = 0 : 0.1 : 1;
x1 = [0 1];
y = [S S];
plot(1-X1(T),T,'g--')
hold on
plot(X2(T),T,'--')
line(x1,y);
axis([0,1,380,600]);
text(0.05,460,'liquid + solid Bi')
text(0.75,460,'liquid + solid Cd')
text(0.5,500,'liquid')
text(0.38,395,'solid Bi + solid Cd')
xlabel('X_C_d');
ylabel('T, K');
x = input('Enter');
t = input('enter');
if x < X1(S)
if t > finverse(1-X_Bi(x))
disp('LIQUID')
elseif t < finverse(1-X_Bi(x)) && t > S
disp('LIQUID + SOLID Bi')
else
disp('SOLID Bi + SOLID Cd')
end
else
if t > finverse(X_Cd(x))
disp('LIQUID')
elseif t < finverse(X_Cd(x)) && t > S
disp('LIQUID + SOLID Cd')
else
disp('SOLID Bi + SOLID Cd')
end
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!