IntRoduction to solid state physics
Practice Course
Sheng Yun Wu
Practice Course
Sheng Yun Wu
Week 2: Crystal Structure
This example generates a 3D visualization of a simple cubic crystal lattice structure to help students understand the arrangement of atoms.
This code visualizes a simple cubic crystal lattice where atoms are arranged in a regular grid. The function creates a 3D scatter plot where lattice points represent atoms. Students can change the lattice constant and the number of points to explore different configurations.
import matplotlib.pyplot as plt
import numpy as np
def plot_cubic_lattice(a, n_points=3):
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for x in np.arange(0, n_points * a, a):
for y in np.arange(0, n_points * a, a):
for z in np.arange(0, n_points * a, a):
ax.scatter(x, y, z, c='r', marker='o')
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.title("Simple Cubic Lattice")
plt.show()
# Lattice constant a = 1 unit
plot_cubic_lattice(1)
This example calculates the intercepts of a crystal plane using Miller indices and the lattice constant.
Miller indices describe the orientation of planes in a crystal lattice. In this example, students learn to calculate the intercepts of planes for given Miller indices, which helps in understanding how different planes in the lattice are arranged.
def miller_indices(h, k, l, a):
x_intercept = a / h if h != 0 else float('inf')
y_intercept = a / k if k != 0 else float('inf')
z_intercept = a / l if l != 0 else float('inf')
return x_intercept, y_intercept, z_intercept
# Example: Miller indices (1, 1, 1), lattice constant a = 1
h, k, l = 1, 1, 1
a = 1
x, y, z = miller_indices(h, k, l, a)
print(f"Intercepts along x, y, z axes: x = {x}, y = {y}, z = {z}")
Atomic Packing Factor (APF) is the fraction of volume in a crystal structure occupied by atoms. This example calculates APF for a Face-Centered Cubic (FCC) lattice.
In an FCC lattice, each unit cell has 4 atoms, and the APF is the ratio of the volume occupied by these atoms to the total volume of the unit cell. This example introduces students to important concepts like unit cells, atomic volume, and packing efficiency in crystals.
def apf_fcc():
atoms_per_unit_cell = 4 # For FCC
volume_of_atoms = atoms_per_unit_cell * (4/3) * np.pi * (0.25)**3
unit_cell_volume = (0.25 * np.sqrt(2))**3
apf = volume_of_atoms / unit_cell_volume
return apf
apf = apf_fcc()
print(f"Atomic Packing Factor for FCC: {apf:.2f}")
This example calculates the distance between atoms in a simple cubic lattice using the lattice constant.
The distance between atoms in a crystal is an important parameter that affects many material properties. In this example, students calculate the interatomic distance for a simple cubic lattice by directly using the lattice constant.
def interatomic_distance(a):
return a
# Example: Lattice constant a = 0.4 nm
a = 0.4e-9 # meters
distance = interatomic_distance(a)
print(f"Interatomic Distance: {distance:.2e} meters")
The d-spacing is the distance between two consecutive planes of atoms in a crystal. This example calculates d-spacing for a cubic crystal using Miller indices.
The d-spacing defines the distance between atomic planes in a crystal. Students use the Miller indices and lattice constant to calculate the spacing between specific planes, which is important in understanding diffraction patterns.
def d_spacing(a, h, k, l):
return a / np.sqrt(h**2 + k**2 + l**2)
# Example: Lattice constant a = 0.4 nm, Miller indices (1, 1, 1)
a = 0.4e-9 # meters
h, k, l = 1, 1, 1
d = d_spacing(a, h, k, l)
print(f"d-spacing: {d:.2e} meters")
This example generates a 2D visualization of a hexagonal crystal lattice.
This example helps students visualize a 2D hexagonal crystal lattice, which is common in materials like graphene. It introduces the concept of hexagonal close packing and how atoms arrange themselves in certain materials.
def plot_hexagonal_lattice(a, n_points=3):
fig, ax = plt.subplots()
for x in np.arange(0, n_points * a, a):
for y in np.arange(0, n_points * a, a * np.sqrt(3) / 2):
offset = a / 2 if int(y / (a * np.sqrt(3) / 2)) % 2 == 0 else 0
ax.scatter(x + offset, y, c='b')
ax.set_xlabel('X')
ax.set_ylabel('Y')
plt.title("2D Hexagonal Lattice")
plt.grid(True)
plt.show()
# Lattice constant a = 1 unit
plot_hexagonal_lattice(1)
This example calculates the volume of a unit cell for a body-centered cubic (BCC) structure based on the lattice constant.
The volume of the unit cell is a fundamental concept in crystallography. This example introduces the relationship between the lattice constant and the unit cell volume in a BCC structure.
def volume_bcc(a):
return a**3
# Example: Lattice constant a = 0.3 nm
a = 0.3e-9 # meters
volume = volume_bcc(a)
print(f"Volume of BCC Unit Cell: {volume:.2e} cubic meters")
The coordination number is the number of nearest neighbors surrounding an atom. This example calculates the coordination number for a simple cubic lattice.
Coordination number provides insight into the bonding and stability of a material. This example explains how atoms are arranged in a simple cubic lattice and introduces students to the concept of nearest neighbors.
def coordination_number_sc():
return 6 # Each atom is surrounded by 6 nearest neighbors in a simple cubic structure
coord_number = coordination_number_sc()
print(f"Coordination Number for Simple Cubic: {coord_number}")
This example calculates the number of atoms in an FCC unit cell.
The number of atoms per unit cell is crucial for understanding the density and mechanical properties of materials. This example calculates the number of atoms in an FCC unit cell, a common structure in metals like aluminum and copper.
def atoms_in_fcc():
corner_atoms = 8 * (1/8) # 8 corners, each shared by 8 unit cells
face_atoms = 6 * (1/2) # 6 faces, each shared by 2 unit cells
return corner_atoms + face_atoms
atoms_fcc = atoms_in_fcc()
print(f"Number of Atoms in FCC Unit Cell: {atoms_fcc}")
This example calculates the atomic packing factor (APF) for a simple cubic structure, which is the fraction of volume occupied by atoms in the unit cell.
The atomic packing factor (APF) is important for understanding the efficiency of space utilization in a crystal. In this example, students calculate the APF for a simple cubic structure, which helps them compare different crystal structures' packing efficiencies.
def apf_simple_cubic(a):
atom_volume = (4/3) * np.pi * (a/2)**3 # Volume of one atom
unit_cell_volume = a**3
return atom_volume / unit_cell_volume
# Example: Lattice constant a = 0.4 nm
a = 0.4e-9 # meters
apf = apf_simple_cubic(a)
print(f"Atomic Packing Factor for Simple Cubic: {apf:.2f}")
These 10 Python examples introduce students to fundamental concepts in Week 2: Crystal Structures, such as unit cells, Miller indices, coordination numbers, and atomic packing factors. The examples cover different types of crystal structures (simple cubic, FCC, BCC, hexagonal) and help students build a strong foundation in understanding how atoms are arranged in solid materials.