Question

800 OC 700 °C Liquid B Liquid a Liquid 15% 50%, 300 C 85% Eutectic point Eutectic line 100% 100% Composition Using the simplified phase diagram, which substitutes straight lines for the curved lines typical of phase diagrams, write a MATLAB program that takes as input the mass percent of B and the temperature in units of degrees Celsius and returns the phases that may exist under those conditions. The equation of the line dividing the phases must be found in the program using polyfit. The program should produce a formatted output statement to the command window, similar to For the composition of xs A, y B and a temperature of T degrees Celsius the phase is PHASE, where x, y,T an Phase are replaced by the actual values. The program should also reproduce the graph as shown here with all phase division lines, and indicate the point entered by the user with a symbol. Your MATLAB program should include special notes if the provided conditions are on the eutectic line or at the eutectic point.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%Problem Statement: Take a user-set percent composition for a solution and
%its temperature, then determine its phase.

%Variables
%point11-point62 - reference points to calculate the phase lines
%point71-point72 - reference points for the eutectic point & line
%line1-line6 - coefficients for the phase lines
%m1-m6 - slope of the phase lines
%b1-b2 - y-intercepts of the phase lines
%xpf1-xpf6 - points to use for the phase lines
%ypf1-ypf6 - lines to divide the phases
%b - mass percent of B
%t - temperature of the solution [deg C]
%a - mass percent of A
%phase - phase of the solution based on percent B and temperature

clear
clc
close all


%Use polyfit to solve for the phase lines

point11=[0,15];
point12=[0,300];
line1=polyfit(point11,point12,1);
m1=line1(1);
b1=line1(2);
xpf1=linspace(min(point11),max(point11),100);
ypf1=m1*xpf1+b1;
point21=[0,15];
point22=[700,300];
line2=polyfit(point21,point22,1);
m2=line2(1);
b2=line2(2);
xpf2=linspace(min(point21),max(point21),100);
ypf2=m2*xpf2+b2;
point31=[0,50];
point32=[700,300];
line3=polyfit(point31,point32,1);
m3=line3(1);
b3=line3(2);
xpf3=linspace(min(point31),max(point31),100);
ypf3=m3*xpf3+b3;
point41=[50,100];
point42=[300,800];
line4=polyfit(point41,point42,1);
m4=line4(1);
b4=line4(2);
xpf4=linspace(min(point41),max(point41),100);
ypf4=m4*xpf4+b4;
point51=[100,85];
point52=[800,300];
line5=polyfit(point51,point52,1);
m5=line5(1);
b5=line5(2);
xpf5=linspace(min(point51),max(point51),100);
ypf5=m5*xpf5+b5;
point61=[85,100];
point62=[300,0];
line6=polyfit(point61,point62,1);
m6=line6(1);
b6=line6(2);
xpf6=linspace(min(point61),max(point61),100);
ypf6=m6*xpf6+b6;
point71=[15,85];
point72=[300,300];

%Allow the user to set the percent of B

b=input('Enter the mass percent of B: ');

%Return an error if the percent of B is not a valid number

if b<0 || b>100
    error('Please enter a value between 0 and 100.')
end

%Allow the user to set the temperature

t=input('Enter the temperature [deg C]: ');

%Solve for percent composition of A

a=100-b;

%Determine phase based on temperature and percent composition of B using
%the phase lines

if t<300
       if b<15 && t>m1*b+b1
           phase='alpha';
       elseif b<15 && t<m1*b+b1
           phase='alpha + beta';
       elseif b>=15 && b<=85
           phase='alpha + beta';
       elseif b>85 && t>m6*b+b6
           phase='beta';
       else phase='alpha + beta';
       end
elseif b<15
    if t<m2*b+b2
        phase='alpha';
    elseif t<m3*b+b3
        phase='alpha + Liquid';
    else phase='Liquid';
    end
elseif b>=15 && b<=50
    if t<m3*b+b3
        phase='alpha + Liquid';
    else phase='Liquid';
    end
elseif b>50 && b<=85
    if t<m4*b+b4
        phase='beta + Liquid';
    else phase='Liquid';
    end
else
    if t<m5*b+b5
        phase='beta';
    elseif t<m4*b+b4
        phase='beta + Liquid';
    else phase='Liquid';
    end
end

%Print out a message if the point falls on the eutectuc line or point

if b>=15 && b<=85 && t==300
    fprintf('The provided conditions fall on the eutectic line.\n')
end
if b==50 && t==300
    fprintf('The provided conditions fall on the eutectic point.\n')
end

%Output a formatted statement to display the phase

fprintf('For the composition of %0.2f%% A, %0.2f%% B and a temperature of %0.0f degrees Celsius, the phase is %s.\n',a,b,t,phase)

%Create a plot of the phase lines and the user's set point

figure('color','white')

%Set axes

axis([0 100 0 1000])

%Plot the phase lines, eutectic line, eutectic point, and the user's point

plot(xpf1,ypf1,'-b')
hold on
plot(xpf2,ypf2,'-b')
plot(xpf3,ypf3,'-b')
plot(xpf4,ypf4,'-b')
plot(xpf5,ypf5,'-b')
plot(xpf6,ypf6,'-b')
plot(point71,point72,'-k')
plot(b,t,'ro','MarkerFaceColor','r')

%Assign a title and axes labels

title('Phase Diagram of Elements A and B')
xlabel('Percent Composition of B')
ylabel('Temperature (T) [deg C]')

%Set scaling for the axes

set(gca,'XTick',0:10:100,'YTick',0:100:1000)

%Place the phase names on the graph

text(40,200,'alpha+beta')
text(45,600,'Liquid')
text(90,300,'beta')
text(3,300,'alpha')
text(15,375,'alpha + Liquid')
text(62,375,'beta + Liquid')


Enter the mass percent of B: 67 Enter the temperature [deg C]: 45 For the composition of 33.00% A, 67.00% B and a temperature

Add a comment
Know the answer?
Add Answer to:
Using the simplified phase diagram, which substitutes straight lines for the curved lines typical of phase...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Just part c please 2,) Using the Pb - Sn phase diagram, at the points indicated below, determine the followhg draw tie lines and indicate important values on diagram) I. The phases present II. The co...

    Just part c please 2,) Using the Pb - Sn phase diagram, at the points indicated below, determine the followhg draw tie lines and indicate important values on diagram) I. The phases present II. The composition of each phase I. The relative amounts of each phase(expressed in weight percentages) 182°C eutectic. c= 85% Sn b) T= 200°C c- IL= 2,) Using the Pb - Sn phase diagram, at the points indicated below, determine the followhg draw tie lines and indicate...

  • 2. [20pt] Consider the temperature-composition phase diagram shown below, which represents a solid-liquid equilibrium based on...

    2. [20pt] Consider the temperature-composition phase diagram shown below, which represents a solid-liquid equilibrium based on a (liquid) mixture of A and B at high temperature. Temperature, T DY 0.16 0.23 0.57 0.67 0.84 0.2 0.8 0.4 0.6 Mole fraction of B, XE (a) Label all regions of the diagram according to the chemical species exist in that region and their phases. Be precise the composition of solid formed. (10pt) (b) Indicate the number of species and phases present at...

  • 6. The Ag-Al phase diagram is shown below with #1-6 indicating specific points on the diagram....

    6. The Ag-Al phase diagram is shown below with #1-6 indicating specific points on the diagram. The upper x-axis is in weight % Al, the lower x-axis is atomic % Al, and the y- axis is temperature in Kelvn. Answer the following questions: a) Give the degrees of freedom for each of the six points (Note that point 5 is the bottom tip of the β region). b) What maximum wt. % Ag is soluble in Al and at what...

  • GENERAL FEATURES OF A PHASE DIAGRAM; HYBRID ORBITALS AND FORMAL CHARGE MODEL 1 solid structure liquid...

    GENERAL FEATURES OF A PHASE DIAGRAM; HYBRID ORBITALS AND FORMAL CHARGE MODEL 1 solid structure liquid rc Pressure in atm solid structure Il Temperature in K — KEY QUESTIONS 1. What quantities are plotted on the x-and y-axes of a phase diagram? 2. 2. How many different phases are shown by the phase diagram in the model? b. What are the labels used to identify them? 3. What do the solid lines in a phase diagram represent 4. 2. How...

  • Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the...

    Write a MATLAB Graphical User Interface (GUI) to simulate and plot the projectile motion – the motion of an object projected into the air at an angle. The object flies in the air until the projectile returns to the horizontal axis (x-axis), where y=0. This MATLAB program should allow the user to try to hit a 2-m diameter target on the x-axis (y=0) by varying conditions, including the lunch direction, the speed of the lunch, the projectile’s size, and the...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT