import math
#given data
A=26.98                                 #atomic weight of Al
N=6.023*10**26                          #Avogadro's number
p=2700                                  #Density
n=4                                     #FCC structure
a=(n*A/(N*p))**(1./3)
print"Unit cell dimension of Al=","{0:.3e}".format(a),"m"
import math
#given data
As=28.1                                 #atomic weight of Si
Ag=69.7                                 #atomic weight of Ga
Aa=74.9                                 #atomic weight of As
a_s=5.43*10**-8                         #lattice constant of Si
aga=5.65*10**-8                         #lattice constant of GaAs
ns=8                                    #no of atoms/unit cell in Si
nga=4                                   #no of atoms/unit cell in GaAs
N=6.023*10**23                          #Avogadro's number
#p=(n*A)/(N*a**3) this is formula for density
#for Si
ps=(ns*As)/(N*a_s**3)
print"1) Density of Si=",round(ps,4),"gm/cm^3"
#for GaAs
Aga=Ag+Aa                               #molecular wt of GaAs
pga=(nga*Aga)/(N*aga**3)
print"2) Density of GaAs=",round(pga,4),"gm/cm^3"
import math
#given data
A=63.5                                  #atomic weight of Cu
N=6.023*10**23                          #Avogadro's number
n=4                                     #FCC structure
r=1.28*10**-8                            #atomic radius of Cu
#for FCC
a=4*r/(sqrt(2))                         #lattice constant
p=(n*A)/(N*a**3)
print"Density of Cu=",round(p,4),"gm/cm^3"
import math
#given data
A=50                                    #atomic weight of chromium
N=6.023*10**23                          #Avogadro's number
p=5.96                                  #Density
n=2                                     #BCC structure
#step 1 : claculation for lattice constant (a)
a=(n*A/(N*p))**(1./3)
#step 2 : radius of an atom in BCC
r=sqrt(3)*a/4
#step 3 : Atomic packing factor (APF)
APF=n*((4./3)*math.pi*r**3)/a**3
print"Atomic packing factor (APF)=",round(APF,4)
import math
#given data
A=120                                   #atomic weight of chromium
N=6.023*10**23                          #Avogadro's number
p=5.2                                   #Density
n=2                                     #BCC structure
m=20                                    #mass
#step 1 : claculation for volume of unit cell(a**3)
a=(n*A/(N*p))
#step 2 : volume of 20 gm of the element
v=m/p
#step 3 :no of unit cell
x=v/a
print"no of unit cell=","{0:.3e}".format(x)
import math
#given data
A=132.91                                 #atomic weight of chromium
N=6.023*10**26                           #Avogadro's number
p=1900                                   #Density
a=6.14*10**-10                           #lattice constant
#step 1 : type of structure
n=(p*N*a**3)/A
print"n =",round(n)
print"BCC structure"
#step 2: no of atoms/m**3
x=n/a**3
print"no of atoms/m^3=","{0:.3e}".format(x)
import math
#given data
a=0.4049*10**-9                          #lattice constant
t=0.006*10**-2                           #thickness of Al foil
A=50*10**-4                              #Area of foil
V1=a**3                                  #volume of unit cell
V=A*t                                   #volume of the foil
N=V/V1                                  #no of unit cell in the foil
print"no of unit cell in the foil=","{0:.3e}".format(N)
import math
#given data
#refer diagram from textbook
#on joining centre of 3 anions,an equilateral triangle is formed and on joining centres of any anion and cation  a right angle triangle ABC os formed
#where AC=rc+ra
#and BC=ra
#m(angle (ACB))=30 degree
#therefore cos (30)=ra/(rc+ra)
#assume rc/ra=r
r=(1.0-math.cos(30.0*math.pi/180))/math.cos(math.pi*30/180)                 #by arrangimg terms we get value of r
print"critical radius ratio of ligancy 3=",round(r,4)
import math
#given data
#refer diagram from textbook
#in the said arrangement a cation is squeezed into 4 anions in a plane and 5th anion is in upper layer and 6th in bottom layer 
#join cation anion centres E and B and complete the triangle EBF
#in triangle EBF m(angle F)=90 and EF=BF
#m(angle B)=m(angle E)=45
#and EB=rc+ra and BF=ra
#cos(45)=ra/(rc+ra)
#assume rc/ra=r
p=math.cos(45*math.pi/180)
r=(1-p)/math.cos(45*math.pi/180)                 #by arrangimg terms we get value of r
print"critical radius ratio for ligancy 6 =",round(r,4)
import math
#given data
#refer diagram from textbook
#since plane is square hence it is same as ligancy 6
#in the said arrangement a cation is squeezed into 4 anions in a plane and 5th anion is in upper layer and 6th in bottom layer 
#join cation anion centres E and B and complete the triangle EBF
#in triangle EBF m(angle F)=90 and EF=BF
#m(angle B)=m(angle E)=45
#and EB=rc+ra and BF=ra
#cos(45)=ra/(rc+ra)
#assume rc/ra=r
r=(1-math.cos(45*math.pi/180))/math.cos(45*math.pi/180)                 #by arrangimg terms we get value of r
print"critical radius ratio for ligancy 8 =",round(r,4)
import math
#given data
#a tetrahedron CAEH can be considered with C as the apex of the tetrahedron.
#the edges AE,AH and EH of the tetrahedron will then be the face of the cube faces ABEF,ADHF,EFHG resp.
#from fig
#AO=ra+rc and AJ=ra
#AE=root(2)*a and AG=root(3)*a
#AO/AJ=AG/AE=(ra+rc)/ra=root(3)*a/root(2)*a
#assume rc/ra=r
r=(math.sqrt(3)-math.sqrt(2))/math.sqrt(2)
print"critical radius ratio for ligancy 4 = ",round(r,4)
import math
#given data
#ligancy 8 represents cubic arrangment .8 anions are at the corners and touch along cube edgs.Along the body diagonal the central cation and the corner anion are in contact.
#cube edge=2*ra
#refer diagram from textbook
#and body diagonal=root(3)*cube edge=root(3)[2*(rc+ra)]
#assume rc/ra=r
r=math.sqrt(3)-1.0
print"critical radius ratio of ligancy 8=",round(r,4)
import math
#given data
#for an ionic crystal exibiting HCP structure the arrangment of ions refere from textbook
#at centre we have a cation with radius rc=OA
#it is an touch with 6 anions with radius ra=AB
#OB=OC=ra+rc
#intrangle ODB ,m(angle (OBC))=60 degree ,m(angle (ODB))=90 degree
#therefore cos(60)=BD/OB=AB/(OA+OB)=ra/(rc+ra)
#assume rc/ra=r
r=(1.-math.cos(60*math.pi/180))/math.cos(60*math.pi/180)                 #by arrangimg terms we get value of r
print"critical radius ratio 0f HCP structure=",round(r,4)
import math
#given data
#intercept of planeare in proportion a,b/3,2*c
#as a,b and c are basic vectors the proportin of intercepts 1:1/3:2
#therefore reciprocal
r1=1
r2=3
r3=1./2
#taking LCM of 2 and 1 is 2
l=2
m1=(l*r1)
m2=(l*r2)
m3=(l*r3)
print"miler indices=",m3,m2,m1
import math
#given data
r=1.414                                 #atomic radius in amstrong unit
#for FCC structure
a=4*r/math.sqrt(2)
#part 1: plane(2,0,0)
#the interplanar spacing of plane
h1=2
k1=0
l1=0
#we know that d=a/sqrt(h**2+k**2+l**2)
d1=a/sqrt(h1**2+k1**2+l1**2)
print"1)interplanar spacing for (2,0,0) plane=",round(d1,4),"amstrong"
#part 2: plane(1,1,1)
#the interplanar spacing of plane
h2=1
k2=1
l2=1
#we know that d=a/sqrt(h**2+k**2+l**2)
d2=a/sqrt(h2**2+k2**2+l2**2)
print"2)interplanar spacing for(1,1,1) plane=",round(d2,4),"amstrong"
import math
#given data
n=4                                     #FCC structure
ro=2180                                 #density of NaCl
M=23+35.5                               #molecular weight of NaCl
N=6.023*10**26                          #Avogadro's number
a=((n*M)/(N*ro))**(1.0/3)
print"Lattice constant=","{0:.3e}".format(a),"m"
import math
#given data
n=4                                     #FCC structure
ro=8.9                                  #density of Cu atom
A=63.55                                 #atomic weight of Cu atom
N=6.023*10**23                          #Avogadro's number
a=((n*A)/(N*ro))**(1./3)
print"1) Lattice constant=","{0:.3e}".format(a),"cm"
r=math.sqrt(2)*a/4                       #radius of Cu atom
d=2*r                                    #diameter of Cu atom
print"2) Diameter of Cu atom=","{0:.3e}".format(d),"cm"
import math
#given data
n=8                                     #diamond structure
A=12.01                                 #atomic wt
N=6.023*10**23                          #Avogadro's number
a=3.75*10**-8                           #lattice constant of diamond
ro=(n*A)/(N*(a**3))
print"Density of diamond=",round(ro,4),"gm/cc"
import math
#given data
#intercept of planeare in proportion 3a:4b:infinity (plane parallel to z axis)
#as a,b and c are basic vectors the proportin of intercepts 3:4:infinity
#therefore reciprocal
r1=1./3
r2=1./4
r3=0
#taking LCM of 3 and 4 i.e. 12
l=12
m1=(l*r1)
m2=(l*r2)
m3=(l*r3)
print"miler indices=",(m3,m2,m1)
import math
#given data
#intercept of planeare in proportion 3a:-2b:3/2c
#as a,b and c are basic vectors the proportin of intercepts 3:-2:3/2
#therefore reciprocal
r1=1./3
r2=-1./2
r3=2./3
#taking LCM of 3, 2 and 3/2 is 6
l=6
m1=(l*r1)
m2=(l*r2)
m3=(l*r3)
print"miler indices=",(m3,m2,m1)
import math
#given data
#if a plane cut at length m,n,p on the three crystal axes,then
#m:n:p=xa:yb:zc
#when primitive vectors of unit cell and numbers x,y,z,are related to miller indices (h,k,l)of the plane by relation
#1/x:1/y:1/z=h:k:l
#since a=b=c (crystal is simple cubic)
#and (h,k,l)=(1,2,3)
#therefore reciprocal
r1=1./1
r2=1./2
r3=1./3
#taking LCM of 1 ,2 and 3 is 6
l=6
m=(l*r1)
n=(l*r2)
p=(l*r3)
print"ratio of intercepts=",(m,n,p)
import math
#given data
#primitive vectors
a=1.2                                   #in amstrong unit
b=1.8                                   #in amstrong unit
c=2                                    #in amstrong unit
#miller indices of the plane
h=2
k=3
l=1
#therefore intercepts are a/h,b/k,c/l
x=a/h
y=b/k
z=c/l
#this gives intercepts along x axis as x amstrong but it is given tthat plane cut x axis at 1.2 amstrong .
t=1.2/x
#this shows that the plane under consideration is another plane which is parallel to it(to keep miller indices same)
n=t*y                                   #Y intercept
p=t*z                                   #Z intercept
print"1) Y intercept=",n,"amstrong"
print"2)Z intercept=",p,"amstrong"
import math
#given data
#the interplanar spacing of plane
h=1
k=1
l=0
d=2                                     #interpanar spacing in amstrong unit
#we know that d=a/sqrt(h**2+k**2+l**2) therefore
a=d*math.sqrt(h**2+k**2+l**2)
#for FCC structure
r=math.sqrt(2)*a/4
print"radius r=",(r),"amstrong"
import math
#given data
n=4                                     #for FCC structure
#the interplanar spacing of plane
h=1
k=1
l=1
d=2.08*10**-10                          #distance
A=63.54                                 #atomic weight of Cu
N=6.023*10**26                          #amstrong no
#we know that d=a/sqrt(h**2+k**2+l**2) therefore
a=d*math.sqrt(h**2+k**2+l**2)
#also (a**3*q)=n*A/N
q=n*A/(N*a**3)
print"1)density=",round(q,4),"kg/m^3"
#for FCC structure
r=math.sqrt(2)*a/4
d=r*2
print"2)radius r=","{0:.3e}".format(r),"m"
print"3)diameter d=","{0:.3e}".format(d),"m"
import math
#given data
A=63.546                                #atomic weight of Cu
N=6.023*10**26                           #Avogadro's number
p=8930                                  #Density
n=1.23                                  #no.of electron per atom
#density=mass/volume
#therfore 1/volume=density/mass
#since electron concentration is needed, let us find out no of atoms/volume(x)
x=N*p/A
#now one atom contribute n=1.23 electron
#therefore x atoms contribute  y no of free electron
y=x*n
print"free electron concentration=","{0:.3e}".format(y),"electron/m^3"
import math
#given data
#primitive vectors
a=1.5                                   #in amstrong unit
b=2                                     #in amstrong unit
c=4.                                    #in amstrong unit
#miller indices of the plane
h=3
k=2
l=6
#therefore intercepts are a/h,b/k,c/l
x=a/h
y=b/k
z=c/l
#this gives intercepts along x axis as x amstrong but it is given that plane cut x axis at 1.2 amstrong .
t=1.5/x
#this shows that the plane under consideration is another plane which is parallel to it(to keep miller indices same)
n=t*y                                   #Y intercept
p=t*z                                   #Z intercept
print"1) Y intercept=",(n),"amstrong"
print"2)Z intercept=",(p),"amstrong"
import math
#given data
ro=7.87                                 #density of metal
A=55.85                                 #atomic wt of metal
N=6.023*10**23                          #Avogadro's number
a=2.9*10**-8                            #lattice constant of metal
n=(N*(a**3)*ro)/A
print"Number of atom per unit cell of a metal=",round(n,0)
import math
#given data
n=2                                     #BCC structure
ro=9.6*10**2                             #density of sodium crystal
A=23                                    #atomic weight of sodium crystal
N=6.023*10**26                           #Avogadro's number
a=((n*A)/(N*ro))**(1./3)
print"Lattice constant=","{0:.3e}".format(a),"m"
import math
#given data
ro=2.7*10**3                             #density of metal
A=27                                    #atomic wt of metal
N=6.023*10**26                           #Avogadro's number
a=4.05*10**-10                           #lattice constant of metal
n=(N*(a**3)*ro)/A
print"1) Number of atom per unit cell of a metal=",round(n,0)
r=math.sqrt(2)*a/4                           #radius of metal
print"2) atomic radius of a metal=","{0:.3e}".format(r),"m"
import math
#given data
n=2                                     #BCC structure
ro=5.98*10**3                           #density of chromium
A=50                                    #atomic wt of chromium
N=6.023*10**26                          #Avogadro's number
a=((n*A)/(N*ro))**(1./3)
print"1) Lattice constant=","{0:.3e}".format(a),"m"
#for BCC
r=math.sqrt(3)*a/4                           #radius of chromium
APF=(n*(4./3)*math.pi*(r**3))/(a**3)
print"2) A.P.F. for chromium=",round(APF,4)
import math
#given data
n=4                                     #FCC structure
ro=6250                                 #density
M=60.2                                  #molecular weight
N=6.023*10**26                           #Avogadro's number
a=((n*M)/(N*ro))**(1./3)
print"Lattice constant=","{0:.3e}".format(a),"m"
import math
#given data
a=2.82*10**-9                           #lattice constant
n=2                                     #FCC crystal
t=17.167                                #glancing angle in degree
q=math.pi/180*t                         #glancing angle in radians
#assuming reflection in (1,0,0) plane
h=1
k=0
l=0
d=a/math.sqrt(h**2+k**2+l**2)
#using Bragg's law , 2*d*sin(q)=n*la
la=2*d*sin(q)/n
print"wavlength of X-ray=","{0:.3e}".format(la),"m"
import math
#given data
n=8                                     #Diamond structure
ro=2.33*10**3                           #density of diamond
M=28.9                                  #atomic  weight of diamond
N=6.023*10**26                          #Avogadro's number
a=((n*M)/(N*ro))**(1./3)
print"1) Lattice constant=","{0:.3e}".format(a),"m"
r=math.sqrt(3)*a/8                           #radius of diamond structure
print"2) atomic radius of a metal=","{0:.3e}".format(r),"m"
import math
#given data
n=2                                     #BCC structure
ro=8.57*10**3                            #density of chromium
d=2.86*10**-10                           #nearest atoms distance
#d=sqrt(3)/2*a
a=2*d/math.sqrt(3)
#now use formulae a**3*ro=n*A/N
#therefore a**3*ro/n=mass of unit cell/(no of atoms pre unit cell)=mass of one atom
m=a**3*ro/n
print"mass of one atom=","{0:.3e}".format(m),"kg"
import math
#given data
d=4.255*10**-10                          #interplaner spacing
l=1.549*10**-10                          #wavelength of x ray
#part 1: for smallest glancing angle(n=1)
n1=1
#using Bragg's law n*l=2*d*sin(q)
q=math.degrees(math.asin(n1*l/(2*d)))
print"1)glancing angle=",round(q,4),"degree"
#part 2: for highst order
#for highest order sin(q) not exceed one i.e maximum value is one
#using Bragg's law n*l=2*d*sin(q)
n2=2*d/l                                #since sin(q)is one
print"2)highest order possible =",math.floor(n2)
import math
#given data
a=2.125*10**-10                          #lattice constant
d=a/2                                   #interplaner spacing
n=2                                     #second order maximum
l=0.592*10**-10                          #wavelength of rock salt crystal
#using Bragg's law
q=math.degrees(math.asin((n*l)/(2*d)))                    #glancing angle
print"glancing angle=",round(q,4),"degree"
import math
#given data
n1=1                                    #for 1st order
n2=2                                    #for 2nd order
t=3.4                                   #angle where 1st order reflection done
t1=t*math.pi/180                        #convert degree to radian
m=math.sin(t1)
#but from Bragg's law
#n*l=2*d*sin(t)
#for for constant distance(d) and wavelength(l) 
#order(n) is directly proportionl to sine of angle i.e (sin(t))
#n1/n2=sin(t1)/sin(t2)
#assume sin(t2)=a
a=n2/n1*m
t2=math.degrees(math.asin(a))                              #taking sin inverese in degree
print"second order reflection take place at an angle=",round(t2,4),"degree"
import math
#given data
V=50*10**3                              #operating voltage of x-ray
M=74.6                                  #molecular weight
p=1.99*10**3                            #density
n=4                                     #no of atoms per unit cell(for FCC structure)
h=6.63*10**-34                           #plank's constant
c=3*10**8                                #velocity 
e=1.6*10**-19                            #charge on electron
N=6.023*10**26                           #Avogadro's number
#step 1:clculating shortest wavelength
l=h*c/(e*V)
print"1)shortest wavelength=",(l),"m"
#step:2 calculating distance(d)
#now a**3*p=n*M/N therefore,
a=(n*M/(N*p))**(1./3)
#since KCl is ionic crystal herefore,
d=a/2
#step 3: calculaing glancing angle
#using Bragg's law
#n*l=2*d*sin(t)
#assume sin(t)=a, wavelength is minimum i.e l and n=1
n=1
a=n*l/(2*d)
t=math.degrees(math.asin(a))                             #taking sin inverese in degree
print"2) glancing angle=",round(t,4),"degree"
import math
#given data
n=1.0                                     #first order maximum
l=0.82*10**-10                          #wavelength of X ray
qd=7.0                                    #glancing angle in degree
qm=51./60                                #glancing angle in minute
qs=48./3600                              #glancing angle in second
q=qd+qm+qs                              #total glancin angle in degree
#using Bragg's law n*l=2*d*sin(q)
d=n*l/(2*math.sin(q*math.pi/180))
a=3*10**-10                              #lattice constant
#we know that d=a/root(h**2+k**2+l**2)
#assume root(h**2+k**2+l**2) =m
#arranging terms we get
m=a/d
print"square root(h**2+k**2+l**2)=",round(m,0)
print"hence possible solutions are (100),(010),(001)"
import math
#given data
n=1                                     #first order maximum
l=1j                                    #wavelength of X ray
#part 1:for(100)
#using Bragg's law n*l=2*d*sin(q)
q1=5.4                                   #glancing angle in degree
dl1=n*l/(2*math.sin(q1*math.pi/180))
#part 2:for(110)
#using Bragg's law n*l=2*d*sin(q)
q2=7.6                                   #glancing angle in degree
dl2=n*l/(2*math.sin(q2*math.pi/180))
#part 3:for(111)
#using Bragg's law n*l=2*d*sin(q)
q3=9.4                                   #glancing angle in degree
dl3=n*l/(2*math.sin(q3*math.pi/180))
#for taking ratio divide all dl by dl1
d1=dl1/dl1
d2=dl2/dl1
d3=dl3/dl1
print"cubic lattice structure is=",d1,d2,d3
import math
#given data
n=1                                     #first order maximum
l=1.54*10**-10                           #wavelength of rock salt crystal
q=21.7                                  #glancing angle in degree
#using Bragg's law n*l=2*d*sin(q)
d=n*l/(2*math.sin(q*math.pi/180))
print"lattice constant of crystal=","{0:.3e}".format(d),"meter"
import math
#given data
a=2.814*10**-10                          #lattice constant
#the interplanar spacing of plane
h=1
k=0
l=0
d=a/math.sqrt(h**2+k**2+l**2)
n=2                                     #first order maximum
l=0.714*10**-10                         #wavelength of X-ray crystal
#using Bragg's law
q=math.degrees(math.asin((n*l)/(2*d)))                     #glancing angle
print"glancing angle=",round(q,4),"degree"
import math
#given data
d=2.82*10**-10                           #interplaner spacing
t=10                                    #glancing angle
#for part 1
n=1                                     #first order maximum
#using Bragg's law n*l=2*d*sin(t)
l=2*d*math.sin(math.pi*t/180)/n
print"1)wavelength=","{0:.3e}".format(l),"meter"
#for part 2
n1=2
#using Bragg's law n*l=2*d*sin(q)
q=math.degrees(math.asin(n1*l/(2*d)))
print"2)glancing angle=",round(q,4),"degree"
#for part 3
#for highest order sin(q) not exceed one i.e maximum value is one
#using Bragg's law n*l=2*d*sin(q)
n2=2*d/l                                #since sin(q)is one
print"3)highest order possible =",(floor(n2))
import math
#given data
#for line -A
n1=1                                    #1st order maximum
q1=30                                   #glancing angle in degree
#using Bragg's law for line A n1*l1=2*d1*sin(q1)
#d1=n1*l1/(2*sin(q1))
#for line B
l2=0.97                                 #wavelength in amstrong unit
n2=3                                    #1st order maximum
q2=60                                   #glancing angle in degree
#using Bragg's law for line B n2*l2=2*d2*sin(q2)
#since for both lines A and B we use same plane of same crystal,therefore
#d1=d2
#therefore equution became n2*l2=2*n1*l1/(2*sin(q1))*sin(q2)
#by arranging terms we get
l1=n2*l2*2*math.sin(q1*math.pi/180)/(2*n1*math.sin(q2*math.pi/180))
print"wavelength of the line A=",round(l1,4),"amstrong"
import math
#given data
n=1.0                                     #first order minimum
d=5.5*10**-11                            #atomic spacing
e=1.6*10**-19                            #charge on one electron
Ee=10*10**3                              #energy in eV
E=e*Ee                                  #energy in Joule
m=9.1*10**-31                            #mass of elelctron
h=6.63*10**-34                           #plank's constant
l=h/math.sqrt(2*m*E)                         #wavelength
#using Bragg's law
q=math.degrees(math.asin((n*l)/(2*d)))                    #glancing angle
print"glancing angle=",round(q,4),"degree"
import math
#given data
a=2.814*10**-10                          #lattice constant
#for rock salt
d=a/2                                   #interplaner spacing
n=1                                     #first order maximum
l=1.541*10**-10                          #wavelength of rock salt crystal
#using Bragg's law
q=math.degrees(math.asin((n*l)/(2*d)))                     #glancing angl
print"glancing angle=",round(q,4),"degree"
import math
#given data
Ev=1.08                                 #average energy required to creaet a vacancy
k=1.38*10**-23                           #boltzman constant in J/K
e=1.6*10**-19                            #charge on 1 electron
K=k/e                                   #boltzman constant in eV/K
#for a low concentration of vacancies a relation is
#n=Nexp(-Ev/KT)
#since total no atom is 1 hence N=1
#at 1000k
T1=1000                                  #temperature
n1=math.exp(-Ev/(K*T1))
#at 500k
T2=500                                   #temperature
n2=math.exp(-Ev/(K*T2))
v=(n1)/(n2)                                #ratio of vacancies
print"ratio of vacancies=",round(v,4)
import math
#given data
Ev=1.95                                 #average energy required to creaet a vacancy
k=1.38*10**-23                           #boltzman constant in J/K
e=1.6*10**-19                            #charge on 1 electron
K=k/e                                   #boltzman constant in eV/K
T=500                                   #temperature
#for a low concentration of vacancies a relation is
#n=Nexp(-Ev/KT)
m=math.exp(-Ev/(K*T))                           #ratio of no of vacancies to no of atoms n/N
print"ratio of no of vacancies to no of atoms=","{0:.3e}".format(m)
import math
#given data
Ev=1.8                                  #average energy required to creaet a vacancy
k=1.38*10**-23                           #boltzman constant in J/K
e=1.6*10**-19                            #charge on 1 electron
K=k/e                                   #boltzman constant in eV/K
#for a low concentration of vacancies a relation is
#n=Nexp(-Ev/KT)
#ratio of vacancy is n/N assume be r=exp(-Ev/KT)
#since total no atom is 1 hence N=1
#at 1000k
t1=-119                                  #temperature in degree
T1=t1+273                               #temperature in kelvine
r1=math.exp(-Ev/(K*T1))
print"1)ratio of vacancies at -119 degree=","{0:.3e}".format(r1)
#at 500k
t2=80                                    #temperature in degree
T2=t2+273                               #temperature in kelvine
r2=exp(-Ev/(K*T2))
v=(r1)/(r2)                                #ratio of vacancies
print"2)ratio of vacancies at 80 degree=","{0:.3e}".format(r2)
import math
#given data
Ev=1.5                                  #energy of formaton of frankel defect
k=1.38*10**-23                          #boltzman constant in J/K
e=1.6*10**-19                           #charge on 1 electron
K=k/e                                   #boltzman constant in eV/K
T=700                                   #temperature
N=6.023*10**26                          #avogadro's no
#for a low concentration of vacancies a relation is
#n=Nexp(-Ev/KT)
m=math.exp(-Ev/(2*K*T))                        #ratio of no of vacancies to no of atoms n/N
qs=5.56                                 #specific density
q=5.56*10**3                            #real density ke/m**3
M=0.143                                 #molecular weight in kg/m**3
ma=M/N                                  #mass of one molecule
v=ma/q                                  #vol of one molecule
#v volume containe 1 molecule
#therefore 1 m**3 containe x molecule
x=1./v
d=m*x                                   #defect per m**3
dm=d*10**-9                              #defect per mm**3
print"number of frankel defects per mm^3=","{0:.3e}".format(dm)