from __future__ import division
#given
#according to reduced phase rule, we have
#D=C-P+2
C=2 # for two component system
P=1
for P in range (1,6):
print "P =",P,' ',
#no of variables
V=P*(C-1)+2
#degrees of freedom
D=C-P+2
print "D =",D
print "we can see that for P=5 we have D=-1 i.e non existent so,two components cannot have more than 4 phases in equilibrium"
from __future__ import division
#given
#density of alpha and beta phases
rhoalpha=10300 #kg/m**3
rhobeta=7300 #kg/m**3
#refer to fig-8.5 in book
#at point B, the composition of lead in alpha-phase is 82% and that of tin in alpha-phase is 18%
leadalpha=82
tinalpha=18
#so we get
#82/rholead+18/rhotin=100/rhoalpha -----------(1)
#similarly at point E
#the composition of tin and lead resp are 97% and 3%
leadbeta=3
tinbeta=97
#so we get
#3/rholead+97/rhotin=100/rhobeta ------(2)
#solving 1 and 2
#we get
rholead=11364.1 #kg/m**3
rhotin=7220.14 #kg/m**3
#let density of eutectic composition is rhoe. knowing the compositions at point D, we can write
#38/rholead+62/rhotin=100/rhoe
#so
rhoe=100/(38/rholead+62/rhotin) #kg/m**3
#it is given that there is 88% eutectic composition by volume. its conversion in weight proportions yeild
W=88/100*rhoe #kgf
Wlead=38/100*W #Kgf
Wtin=62/100*W #kgf
#there is 12% beta phase by volume which on converion to weight proportion gives
Wdash=12/100*rhobeta #Kgf
Wdashlead=3/100*Wdash #kgf
Wdashtin=97/100*Wdash #kgf
#total weight of lead and tin can be estimated now as
Wddashlead=Wlead+Wdashlead #kgf
Wddashtin=Wtin+Wdashtin #kgf
#percentafe of tin
percenttin=Wddashtin/(Wddashtin+Wddashlead)*100
print "percentace of tin is %0.2f"%(percenttin)
#given
#melting point of A and B
MptA=1250 #degrees celcius
MptB=1900 #degrees celcius
#part(a)
#according to the conditions given in question phase diagram can be drawn as shown in fig 8.10 given in book
#part(b)
#at 1250 degrees celcius , it is a peritectic solution
#equation representing the equilibrium is given in the book which denotes forward reaction as cooling and backward as heating
#part (c)
#we are just considering a tie line just above the peritectic line at temp 1251 degrees celcius
#at this point
Cs1=80
Cl1=30
C01=75
#point below peritectic line has temp as 1249 degrees celcius
Cs2=80
Cl2=50
C02=75
#weight fraction of the phase present in the material of overall composition 75% B at 1251 degrees celcius and 75% B at 1249 degrees
f_alpha1=(Cs1-C01)/(Cs1-Cl1)*100 #%
f_beta1=(C01-Cl1)/(Cs1-Cl1)*100 #%
f_alpha2=(Cs2-C02)/(Cs2-Cl2)*100 #%
f_beta2=(C02-Cl2)/(Cs2-Cl2)*100 #%
#part (d)
# 75% B at room temp
Cs3=90
Cl3=30
C03=75
f_alpha3=(Cs3-C03)/(Cs3-Cl3)*100 #%
f_beta3=(C03-Cl3)/(Cs3-Cl3)*100 #%
#the microstructure is also shown in book at page no 243
print "weight fraction of the phase present in the material of overall composition 75 percent B at 1251 degrees celcius and 75percent B at 1249 degrees are %d, %d, %0.2f, %0.2f and at 75 percent concentration of B at room temp is %d, %d"%(f_alpha1,f_beta1,f_alpha2,f_beta2,f_alpha3,f_beta3)
#given
#according to the given conditions in the ques the graph can be drawn as shown in fig 8.12
#the given temp 576.9 degees celcius is just below the eutectic temp 577 degres celcius
#from the graph, we can have the following values
C_beta_e=100
C_e=1.65
C_0=10
#hence weight fraction is given by
W_alpha=(C_beta_e-C_0)/(C_beta_e-C_e)
print "the weight fraction of alpha in an alloy containing 10percent Si at 576.9 degrees celcius is %0.3f "%(W_alpha)
#given
#weight percent of tin and lead are
W1=90
W2=10
#let the amount of tin that can be added to the crucible without changing the system's solidificarion is "m"
#eutectic arm extends to 97% tin
#therefore, with the addition of "m" gram of tin, the composition of alloy should not exceed 97% tin
#therefore
#(900+m)/(1000+m)=97/100
#so
m=(97/100*1000-900)/(1-97/100)/1000 #kg because 1kg=1000g
print "maximum %0.2f kg of tin can be added without changing the systems temperature"%(m)
#given
#the eutectoidal mixture of pearlite consists of two phases viz. alpha (ferrite) and Fe3C (cementite). the eutectoid composition contains 0.83% carbon. the lever rule is applied in which the lever arm has ferrite (=0% carbon) at one end and cementite (6.67% carbon) at the other end. the fulcrum is taken at 0.83% carbon. hence by applying lever rule, we get
Walpha=(6.67-0.83)/(6.67-0.00)
WFe3C=(0.83-0.0)/(6.67-0.0)
print "the weight fractions of ferrite and cementite are %0.3f and %0.3f resp"%(Walpha,WFe3C)