Phono3py: Anharmonic Lattice Dynamics
Phono3py is a Python package for calculating anharmonic lattice dynamics properties, such as lattice thermal conductivity and phonon lifetimes, using a supercell approach and third-order force constants. It is commonly used in conjunction with first-principles calculation codes (e.g., VASP, Quantum ESPRESSO) that provide the necessary force information. The current version is 3.30.1. It maintains an active development and release cadence, often in sync with its harmonic counterpart, Phonopy.
Warnings
- breaking Phono3py v3.x introduced significant API changes, notably requiring Phonopy v2.20 or later and transitioning from `ase.Atoms` to `phonopy.atoms.PhonopyAtoms` for cell definition. Direct use of `ase.Atoms` for input cell data will lead to errors.
- gotcha Phono3py relies on specific force constant data formats (e.g., `fc2.hdf5`, `fc3.hdf5` or `fc3.phonon3py`). Incorrect indexing (e.g., atomic indices, Cartesian components), shape, or file format can lead to subtle errors, incorrect results, or crashes.
- gotcha Calculations involving large supercells (e.g., > 4x4x4) can be computationally intensive and consume significant memory, especially for third-order force constants, due to the cubic scaling of interactions.
- gotcha Phono3py has underlying C/Fortran dependencies (like `spglib` for space group analysis, and `BLAS`/`LAPACK` for linear algebra) that are typically handled by `pip` but can cause installation or runtime issues in specific, non-standard environments (e.g., HPC clusters, systems with custom scientific library installations).
Install
-
pip install phono3py
Imports
- Phono3py
from phono3py import Phono3py
- PhonopyAtoms
from phonopy.structure.atoms import PhonopyAtoms
Quickstart
import numpy as np
from phonopy import Phonopy
from phonopy.structure.atoms import PhonopyAtoms
from phono3py import Phono3py
# Define a simple silicon unit cell (diamond structure) for demonstration
a = 5.43 # Lattice parameter for Si
# Unit cell basis vectors (face-centered cubic)
lattice = np.array([
[a/2, a/2, 0],
[a/2, 0, a/2],
[0, a/2, a/2]
])
# Atoms in the unit cell (fractional coordinates)
positions = np.array([
[0, 0, 0],
[0.25, 0.25, 0.25]
])
symbols = ['Si', 'Si']
# Create a PhonopyAtoms object for the unit cell
unit_cell = PhonopyAtoms(cell=lattice, scaled_positions=positions, symbols=symbols)
# Define supercell matrix (e.g., 2x2x2 supercell)
supercell_matrix = np.diag([2, 2, 2])
# Initialize Phonopy object (a prerequisite for Phono3py)
phonon = Phonopy(unit_cell, supercell_matrix)
# Define a primitive matrix if different from the unit cell.
# For FCC structures, a typical primitive cell matrix is:
primitive_matrix = np.array([
[0, 0.5, 0.5],
[0.5, 0, 0.5],
[0.5, 0.5, 0]
])
# Initialize Phono3py object with the Phonopy object and supercell matrix
ph3 = Phono3py(phonon, supercell_matrix, primitive_matrix=primitive_matrix)
print("Phono3py object initialized successfully.")
print(f"Number of atoms in primitive cell: {ph3.primitive.numbers.shape[0]}")
print(f"Number of atoms in supercell: {ph3.supercell.numbers.shape[0]}")