In [1]:

```
from __future__ import division
import math
# Python Code Ex5.1 Variation of fraction of atoms in a solid
# with temperature Page-158 (2010)
#Variable declaration
E = 1.5; # Energy of the solid, electron-volt
T1 = 300; # First absolute temperature, K
T2 = 1500; # Second absolute temperature, K
k = 8.614*10**-5; # Boltzmann constant, electron-volt/K
#Calculation
# Now fraction of atoms = f_atom = n/N = math.exp(-E/(k*T)
f_atom_300 = math.exp(-E/(k*T1)); # Fraction of atoms in the solid at 300 K
f_atom_1000 = math.exp(-E/(k*T2)); # Fraction of atoms in the solid at 1000 K
#Result
print"\nThe fraction of atoms in the solid at 300 K, is :"
print round((f_atom_300*10**26),2)*10**-26
print"\nThe fraction of atoms in the solid at 1000 K, is :"
print round((f_atom_1000*10**6),2)*10**-6
```

In [2]:

```
from __future__ import division
import math
# Python Code Ex5.2 Vacancy formation in copper Page-159 (2010)
#Variable declaration
E = 1; # Energy of formation of vacancy in copper, electron-volt
T = 1356; # Melting point of copper, K
k = 8.614*10**-5; # Boltzmann constant, electron-volt
N = 6.023*10**23; # Avogadro's number
#Calculation
# Now fraction of vacancies = f_vacancy = n/N = math.exp(-E/(k*T)
f = math.exp(-E/(k*T)); # Fraction of vacancies in the solid at 300 K
n = N*f; # Number of vacancy per mole
delta_d = n + N; # Change in the density due to creation of vacancy
# Relative change in the density of copper due to vacancy formation
f_d = delta_d/N;
#Result
print"\nThe relative change in the density of copper due to"
print" vacancy formation (n+N)/N, is :",round(f_d,4),": 1"
```

In [3]:

```
from __future__ import division
import math
# Python Code Ex5.3 Concentration of Schottky imperfections Page-159 (2010)
#Variable declaration
N = 6.023*10**23; # Avogadro's number
k = 8.614*10**-5; # Boltzmann's constant, eV/K
T1 = 27+273; # First absolute temperature, K
T2 = 1000; # Second absolute temperature, K
d = 1*10**-10; # Interatomic spacing assumed to be unit angstrom, m
# Concentration of Schottky defects in an fcc crystal at 300 K temperature
C_300 = 1*10**-10;
#Calculation
n = C_300*N; # Number of Schottky imperfections per mole
V = d**3; # Volume of the unit cube, metre cube
V_mole = V*N;# Volume occupied by one mole of atoms in fcc crystal, metre cube
V_per_defect = V_mole/n; # Volume per defect, metre cube
a = (V_per_defect)**(1/3); # Average separation between the defects, m
E_v = 23.03*k*T1; # Energy of the solid, electron-volt
C_1000 = math.exp(-E_v/(k*T2)); # Schottky defect concentration at 1000 K
#Result
print"\nThe average separation between the defects, is :"
print round((a*10**7),1)*10**-7,"m"
print"\nThe expected concentration of Schottky defect at 1000 K, n/N, is :"
print round((C_1000*10**2),2)*10**-3
```

In [4]:

```
from __future__ import division
import math
#PythonCodeEx5.4 Number of Schottky imperfections in NaCl crystalPage-160(2010)
#Variable declaration
N = 6.023*10**23; # Avogadro's number
k = 8.614*10**-5; # Boltzmann's constant, eV/K
T = 27+273; # Absolute room temperature, K
Ep = 2; # Energy required to remove a pair of Na+ and Cl- ions, electron-volt
#Calculation and Results
# Now Concentration of imperfections in a crystal is given by
# n/N = math.exp(-Ep/(2*k*T)), solving for n
# No. of Schottky imperfections present in NaCl crystal
n = N*math.exp(-Ep/(2*k*T));
print"\nNo. of Schottky imperfections present in NaCl crystal is :"
print round((n*10**-6),2)*10**6
V = 26.83; # Volume of one mole of the crystal, cm cube
n = n/V; # Number per mole volume of the crystal, per cm cube
print"\nConcentration of Schottky imperfections present in NaCl crystal is :"
print round((n*10**-5),2)*10**5," per cm cube"
```

In [5]:

```
from __future__ import division
import math
# Python Code Ex5.5 Average energy required to create one
#Schottky defect in NaCl Page-160 (2010)
#Variable declaration
N = 6.023*10**23; # Avogadro's number
k = 8.614*10**-5; # Boltzmann's constant, eV/K
T = 27+273; # Absolute room temperature, K
r = 2.82*10**-10; # Interatomic separation of NaCl cryastal, m
n = 5*10**+11; # Density of defects, per metre cube
#Calculation
#Ep = 2;//Energy required to remove a pair of Na+ and Cl- ions, electron-volt
a = 2*r; # Lattice parameter of unit cell of NaCl, m
V = a**3; # Volume of the unit cell of sodium, metre cube
n_ip = 4; # Number of ion-pairs of NaCl
N = n_ip/V; # No. of ion-pairs in unit volume of an ideal NaCl crystal
# Now n/N = math.exp(-Ep/(2*k*T)), solving for Ep
# Average energy required to create one Schottky defect, electron-volt
Ep = 2*k*T*math.log(N/n);
#Result
print"\nThe Average energy required to create one Schottky defect"
print" in NaCl crystal is :",round(Ep,2),"eV"
```

In [6]:

```
from __future__ import division
import math
# Python Code Ex5.6 Ratio of Frenkel defects at two different temperatures
# in an ionic crystal Page-161 (2010)
#Variable declaration
k = 8.614*10**-5; # Boltzmann's constant, eV/K
Ef = 1.4; # Average energy required to create a Frenkel defect, eV
T1 = 300; # First absoluite temperature, K
T2 = 600; # Second absolute temperature, K
#Calculation
# The concentration of Frenkel defect for given Ef
#and absolute temperature T is given by
# n = A*math.exp(-Ef/(2*k*T)), per metre cube, so that
# n1 = A*math.exp(-Ef/(2*k*T1)), per metre cube, and
# n2 = A*math.exp(-Ef/(2*k*T2)), per metre cube, therefore,
# n1/n2 = math.exp((-Ef/k)*(1/T1 - 1/T2)), the ratio of Frenkel defects is
n300_r_n600 = math.exp((-Ef/(2*k))*(1/T1 - 1/T2));# Frenkel defect ratio
#Result
print"\nThe ratio of Frenkel defect, n300_r_n600, is :"
print round((n300_r_n600*10**6),2)*10**-6
```

In [7]:

```
from __future__ import division
import math
# Python Code Ex5.7 Dislocation density of bcc structure of iron Page-163(2010)
#Variable declaration
L = 0.15; # Length of the strip, m
t = 0.02; # Thickness of the iorn strip, m
r = 0.12; # Radius of curvature of the bent, m
a = 2.81*10**-10; # Lattice parameter of the bcc structure of iron, m
#Calculation
b = (3)**0.5*a/2; # Magnitude of Burger vector, m
# For n positive edge dislocations
# n*b = L*t/r, solving for n/(L*t)
# n/(L*t) = 1/(r*b), Number of dislocation line piercing through
#a unit area of the plane of the paper, per metre square
# Dislocation density in bcc structure of iron, number per metre square
d = 1/(r*b);
#Result
print"\nThe dislocation density in bcc structure of iron :"
print round((d*10**-10),2)*10**10,"dislocations per Sq. m"
```

In [8]:

```
from __future__ import division
import math
# Python Code Ex5.8 Minimum dislocation density in aluminium Page-164 (2010)
#Variable declaration
b = 3*10**-10; # Magnitude of Burgers vector, m
r = 0.05; # Radius of curvatur of the aluminium crystal, m
#Calculation
# For n positive edge dislocations
# n*b = L*t/r, solving for n/(L*t)
# n/(L*t) = 1/(r*b), Number of dislocation line piercing through
#a unit area of the plane of the paper, per Sq.m
d = 1/(r*b); # Minimum dislocation density in aluminium, number per Sq. m
#Result
print"\nThe minimum dislocation density in aluminium,"
print round((d*10**-10),1)*10**10,"dislocations per Sq. m"
```

In [9]:

```
from __future__ import division
import math
# Python Code Ex5.9 Determining total force from its resolved component
# in a given direction: Page-168 (2010)
#Variable declaration
h1 = 1; k1 = -1; l1 = 0 # Miller indices for first set of planes
h2 = 1; k2 = 0; l2 = 0; # Miller indices for second set of planes
F_100 = 130; # Resolved component of force along [100] direction, N
#Calculation
w=(h1*h2+k1*k2+l1*l2)/((h1**2+k1**2+l1**2)**0.5*(h2**2+k2**2+l2**2)**0.5)
cos_theta = w;# Cosine of angle between [1 -1 0] and [100] directions
# As F/F_100 = cos_theta, solving for F
F_110 = F_100/cos_theta; # Applied force along [1 -1 0] direction, N
#Result
print"\nThe applied force along [1-10] direction =",round(F_110,2),"N"
```

In [10]:

```
from __future__ import division
import math
# Python Code Ex5.10 Determining resolved componet of shearing force
#in a given direction: Page-168 (2010)
#Variable declaration
h1 = 1; k1 = 1; l1 = 1 # Miller indices for first set of planes
h2 = 1; k2 = 1; l2 = 0; # Miller indices for second set of planes
F_111 = 660; # Shearing force along [111] direction, N
#Calculation
w=(h1*h2+k1*k2+l1*l2)/((h1**2+k1**2+l1**2)**0.5*(h2**2+k2**2+l2**2)**0.5)
cos_theta = w;# Cosine of angle between [1 -1 0] and [100] directions
# As F_110/F_111 = cos_theta, solving for F_110
# Resolved component of shearing force along [110] direction, N
F_110 = F_111*cos_theta;
#Result
print"\nThe resolved component of shearing force along[110]direction,F_110 ="
print round(F_110,2),"N"
```

In [11]:

```
from __future__ import division
import math
# Python Code Ex5.11 Dependence of applied stress
#on the slip direction of a copper: Page-169 (2010)
#Variable declaration
# Critical shear stress for the <-110>{111} slip system, mega-pascal (MPa)
tau_critical = 1;
# For directions [001] and [-111]
h1 = 0; k1 = 0; l1 = 1 # Miller indices for first set of planes
h2 = -1; k2 = 1;l2 = 1;# Miller indices for second set of planes
#Calculation and Result
w=(h1*h2+k1*k2+l1*l2)/((h1**2+k1**2+l1**2)**0.5*(h2**2+k2**2+l2**2)**0.5)
cos_phi = w;# Cosine of angle between [001] and [-111] directions
# For directions [001] and [101]
h1 = 0; k1 = 0; l1 = 1 # Miller indices for first set of planes
h2 = 1; k2 = 0; l2 = 1;# Miller indices for second set of planes
cos_lambda = w;# Cosine of angle between [001] and [101] directions
# Stress along [001] direction, newton per metre square
sigma = tau_critical/(cos_phi*cos_lambda);
print "\nThe stress required to be applied along [001] direction "
print" to produce slip in the [101] direction on the (-111) plane = "
print round(sigma,2),"MPa"
# For directions [001] and [110]
h1 = 0; k1 = 0; l1 = 1 # Miller indices for first set of planes
h2 = 1; k2 = 1;l2 = 0; # Miller indices for second set of planes
w=(h1*h2+k1*k2+l1*l2)/((h1**2+k1**2+l1**2)**0.5*(h2**2+k2**2+l2**2)**0.5)
cos_lambda = w;# Cosine of angle between [001] and [110] directions
if cos_lambda <> 0:
# Stress along [001] direction, newton per metre square
print"\nThe stress required to be applied along [001] direction"
print"to produce slip in the [110] direction on the(-111) plane = "
print sigma,"MPa"
else:
print"\nSince cos_lambda = 0, this implies that slip cannot occur "
print"in[110] direction when the stress is applied along [001] direction"
```

In [12]:

```
from __future__ import division
import math
# Python Code Ex5.12 Resolved stress in a direction from applied stress
# in some other direction of bcc iron: Page-169 (2010)
#Variable declaration
sigma = 123; # Axial stress applied in the direction [110] of bcc iron, MPa
# For directions [010] and [110]
h1 = 0; k1 = 1; l1 = 0 # Miller indices for first set of planes
h2 = 1; k2 = 1; l2 = 0; # Miller indices for second set of planes
#Calculation
w=(h1*h2+k1*k2+l1*l2)/((h1**2+k1**2+l1**2)**0.5*(h2**2+k2**2+l2**2)**0.5)
cos_phi = w;# Cosine of angle between [010] and [110] directions
# For directions [110s] and [101]
h1 = 1; k1 = 0; l1 = 1 # Miller indices for first set of planes
h2 = 1; k2 = 1; l2 = 0; # Miller indices for second set of planes
cos_lambda = w;# Cosine of angle between [110] and [101] directions
# Resolved shear stress in the [101] direction on the (010) plane, MPa
tau = sigma*cos_phi*cos_lambda;
#Result
print"\nThe resolved shear stress in the [101] direction on the (010) plane ="
print round(tau,2),"MPa"
```

In [13]:

```
from __future__ import division
import math
# Python Code Ex5.13 Determining critical resolved shear stress
#from applied stress in a given direction of aluminium: Page-170 (2010)
#Variable declaration
sigma_critical = 3.5; # Applied stress in the [1 -1 1] direction, MPa
# For directions [111] and [1 -1 1]
h1 = 1; k1 = 1; l1 = 1; # Miller indices for first set of planes
h2 = 1; k2 = -1; l2 = 1; # Miller indices for second set of planes
#Calculation
# Cosine of angle between [111] and [1 -1 1] directions
w=(h1*h2+k1*k2+l1*l2)/((h1**2+k1**2+l1**2)**0.5*(h2**2+k2**2+l2**2)**0.5)
cos_phi = w;
# For directions [1 - 1 0] and [1 -1 1]
h1 = 1; k1 = -1; l1 = 0 # Miller indices for first set of planes
h2 = 1; k2 = -1; l2 = 1; # Miller indices for second set of planes
cos_lambda = w# Cosine of angle between [1 -1 0] and [1 -1 1] directions
# The critical resolved shear stress in the [1 -1 0] direction
#on the (111) plane, MPa
tau_c = sigma_critical*cos_phi*cos_lambda;
#Result
print"\nThe critical resolved shear stress in the [1 -1 0] direction "
print"on the (111) plane = ",round(tau_c,2),"MPa"
```

In [14]:

```
from __future__ import division
import math
# Python Code Ex5.14 Determining the direction in which slip is
#initiated by the applied stress in zinc: Page-170 (2010)
#Variable declaration
sigma = 2.3;# Applied stress when the plastic deformation is first observed,MPa
#Angle which the normal to the basal plane makes with the tensile axis of zinc,
phi = 60 ;
#Calculation and Result
# Function to find the value of resolved shear stress
def stress(lamb):
tau = sigma*math.cos(math.radians(phi))*math.cos(math.radians(lamb));
return tau
lamb=[]
# Angles which the three slip directions x1, x2 and x3 respectively
# makes with the tensile axis, degrees
lamb = [38,45,84];
t = []; # Initialize a one-dimensional vector of three elements
for i in range(3):
# Calculate the value of resolved shear stress by calling stress function
t.append(stress(lamb[i]));
# Display resloved shear stress for each direction, MPa
print "\ntau",i+1,"= ",round(t[i],2)," MPa"
# Locate for the largest resolved stress value
big = t[0];
for i in range(1,3):
if t[i] > big:
big = t[i] # Set largest valuse of resolved stress if the condition meets
print"\nThe slip is initiated along direction x1 at tau_c=",round(big,2),"MPa"
```

In [15]:

```
from __future__ import division
import math
# Python Code Ex5.15 Determining applied tensile stress
#in a direction to initiate plastic deformation: Page-170 (2010)
#Variable declaration
tau_critical = 0.7; # Critical resolved shear stress for fcc crystal, MPa
# For directions [100] and [1 1 1]
h1 = 1; k1 = 0; l1 = 0; # Miller indices for first set of planes
h2 = 1; k2 = 1; l2 = 1; # Miller indices for second set of planes
#Calculation
# Cosine of angle between [100] and [1 1 1] directions
w=(h1*h2+k1*k2+l1*l2)/((h1**2+k1**2+l1**2)**0.5*(h2**2+k2**2+l2**2)**0.5)
cos_phi = w;
# For directions [1 0 0] and [1 -1 0]
h1 = 1; k1 = 0; l1 = 0 # Miller indices for first set of planes
h2 = 1; k2 = -1; l2 = 0; # Miller indices for second set of planes
cos_lambda = w;# Cosine of angle between [1 0 0] and [1 -1 0] directions
# The critical resolved shear stress in the [1 -1 0] direction
# on the (1 1 1) plane, MPa
sigma_c = tau_critical/(cos_phi*cos_lambda);
#Result
print"\nThe critical resolved shear stress in the [1 -1 0] direction "
print "on the (1 1 1) plane = ",round(sigma_c,2)," MPa"
```

In [16]:

```
from __future__ import division
import math
# Python Code Ex5.16 Dislocation width in copper: Page-175 (2010)
#Variable declaration
a = 3.61e-010; # Lattice parameter of copper, m
#For simplicity, assume shear modulus of copper to be unity,netwon per metre sq
mu = 1;
#Calculation
# Shear stress to initiate plastic deformation, newton per metre square
tau_PN = mu/1e+05;
b = a/(2)**0.5; # Burger vector magnitude for fcc crystal of copper, m
# As stress necessary to move a dislocation in a crystal is given by
# tau_PN = mu*math.exp(-2*%math.pi*w/b), solving for w
w = b*math.log(mu/tau_PN)/(2*math.pi); # Width of the dislocation in copper, m
#Result
print"\nThe width of dislocation in copper =",round(w/(1*10**-10),2),"angstrom"
```

In [17]:

```
from __future__ import division
import math
# Python Code Ex5.17 Change in number of vacancies
#due to disloaction motion: Page-176 (2010)
#Variable declaration
l = 1e-03; # Edge dislocation length of simple cubic crystal, m
d = 1e-06; # Distance of dislocation climb in, m
a = 3e-10; # Lattice parameter of scc, m
#Calculation
A = a**2; # Area of the unit cell, metre square
A_affected = l*d;# Affected area when the dislocation climbs down, metre square
# N.B.: Area of one unit cell in scc contributes one atom
N = A_affected/A;# Number of vacancies created within the affected area
#Result
print"\nThe number of vacancies lost or created =", round(N)
```

In [18]:

```
from __future__ import division
import math
# Python Code Ex5.18 Minimum number of dislocations
#in motion from shearing rate of copper: Page-176 (2010)
#Variable declaration
a = 3.61e-010; # Lattice parameter of copper, m
epsilon_dot = 10/60; # Strain rate of plastic deformation, mm per sec
v_d = 1e+06; # Velocity of dislocation, mm per sec
V = 1e+03; # Volume of the crystal, mm cube
b = a*1e+03/(2)**0.5;# Burger vector magnitude for fcc crystal of copper, mm
#Calculation
# Strain rate of plastic deformation is given by
# epsilon_dot = rho*b*v_d, solving for rho
rho = epsilon_dot/(b*v_d); # Density of the mobile disloacations, per mm cube
N = round(rho*V); # Number of dislocations in motion in the whole cube
#Result
print"\nThe number of dislocations in motion in the whole cube = ", N
```

In [19]:

```
from __future__ import division
import math
# Python Code Ex5.19 Elastic energy of line imperfection stored in Al:Page-178
#Variable declaration
rho = 1e+010; # Dislocation density of Al, per metre square
mu = 25.94e+09; # Shear molulus of aluminium, newton per metre square
a = 4.05e-010; # Lattice parameter of aluminium, m
#Calculation
b = a/(2)**0.5; # Burger vector magnitude for fcc crystal of Al, m
# Elastic energy per unit length of the dislocation, joule per metre
E_bar = mu*b**2/2;
E = E_bar*rho; # Elastic energy stored in the crystal, joule per metre cube
#Result
print"\nThe elastic energy stored in the crystal ="
print round(E,2),"joule per metre cube"
```

In [20]:

```
from __future__ import division
import math
# Python Code Ex5.20 Spacing between dislocations
#in a tilt boundary in fcc Ni: Page-187 (2010)
#Variable declaration
theta = 2; # Angle of tilt, degree
a = 3.52e-010; # Lattice parameter of Al, m
# Calculation
b = a/(2)**0.5; # Burger vector magnitude for fcc Ni, m
# The vertical spacing between two neighbouring edge dislocations, m
h = b/math.tan(math.radians(theta));
#Result
print"\nThe spacing between dislocations in a tilt boundary in fcc Ni ="
print round(h/(1*10**-10),2),"angstrom"
```

In [21]:

```
from __future__ import division
import math
# Python Code Ex5.21 Determining tilt angle from dislocation
#spacing in the boundary of Cu: Page-188 (2010)
#Variable declaration
a = 3.61e-010; # Lattice parameter of Cu, m
h = 1.5e-06;#The vertical spacing between
#two neighbouring edge dislocations, m
#Calculation
b = a/(2)**0.5; # Burger vector magnitude for fcc Cu, m
tan_theta = math.atan(b/h); # tangent of tilt angle between
# two tilt boundaries of Cu, radian
#Result
print"\nThe tilt angle between two tilt boundaries of Cu = "
print round(tan_theta,5),"radian"
```

In [22]:

```
from __future__ import division
import math
# Python Code Ex5.22 Determining tilt angle from dislocation spacing
# in the boundary of Cu: Page-188 (2010)
#Variable declaration
b = 0.4e-09; # Burger vector magnitude for fcc Cu, m
h = 3.0e-06;#The vertical spacing between two neighbouring edge dislocations,m
#Calculation
# tangent of tilt angle between two tilt boundaries of Cu, radian
tan_theta = math.atan(b/h);
#Result
print"\nThe tilt angle between two tilt boundaries of Cu ="
print round((tan_theta*10**4),2)*10**-4,"radian"
```