6. Running ALAMODE#
ALAMODE consists of two programs.
alm extracts the interatomic force constants (IFCs) from forces calculated by DFT,
and anphon uses these force constants to calculate phonon properties.
The chart below shows how the two programs, the DFT code, and the helper scripts in the tools/ directory work together.
The Input file builder writes a starting input file for either program from a POSCAR.
Overall workflow. Blue: alm; green: anphon; grey: DFT calculations; yellow: helper scripts in tools/.#
Overall workflow. Blue: alm; green: anphon; grey: DFT calculations; yellow: helper scripts in tools/.#
6.1. Step 1: Force constants with alm#
How to obtain the force constants. The harmonic force constants are calculated first; they are needed to generate the random displacements for the anharmonic force constants.#
How to obtain the force constants. The harmonic force constants are calculated first; they are needed to generate the random displacements for the anharmonic force constants.#
Prepare the DFT reference. Converge the cutoff energy and the \(k\)-point density, then relax the primitive cell until the forces are negligible. Phonons are sensitive to the lattice constant, especially in polar materials such as perovskites.
Choose a supercell. The suitable size depends on the material and the properties of interest. Give the primitive cell to alm and let it generate the supercell with SUPERCELL (recommended), or build the supercell with an external tool such as pymatgen or ASE and give it to alm as it is.
Harmonic force constants (FC2). Run alm with
MODE = suggestandNORDER = 1to obtain the displacement patterns (PREFIX.pattern_HARMONIC), and create the displaced structures withdisplace.py:$ alm alm.in > alm.log $ displace.py --VASP POSCAR --mag 0.01 --prefix disp --pattern_file PREFIX.pattern_HARMONIC
With
SUPERCELL, the VASP, Quantum ESPRESSO, OpenMX, and LAMMPS interfaces take the supercell from the pattern file, so an input file of the unit cell given to alm is enough. They write the displaced supercells and the undisplaced supercell (SPOSCAR0for VASP,supercell0.pw.infor QE,supercell0.datfor OpenMX,supercell0.lammpsfor LAMMPS). The QE and OpenMX files keep the \(k\)-point mesh of the unit-cell input, so reduce it for the supercell. For LAMMPS, the supercell must fit a LAMMPS box without rotation (a along x, b in the xy plane), as it does for a diagonalSUPERCELLof the cell in the LAMMPS data file. The xTAPP interface does not build the supercell: give it an input file of the supercell with the same atom order as the supercell built by alm (listed in the header of the pattern file).Calculate the forces of all structures with DFT, and collect the displacements and forces into one file (
DFSET), using the undisplaced supercell as the reference (one of the files above, or your own supercell file if you built it externally):$ extract.py --VASP SPOSCAR0 vasprun*.xml > DFSET $ extract.py --QE supercell0.pw.in disp*.pw.out > DFSET
Then set
MODE = optimize, give theDFSETfile in the&optimizefield, and run alm again withLMODEL = ols. The harmonic force constants are written toPREFIX.h5.Anharmonic force constants (FC3, FC4, …) — needed for
kappa,SCPH,QHA, and more. The recommended way is to fit them to random displacements:Calculate the harmonic phonons of the supercell with anphon (
MODE = phonons,KPMODE = 0) using the harmonic force constants, withPRINTEVEC = 1. This writes the phonon eigenvectors toPREFIX.evec.h5.displace.py --VASP SPOSCAR0 --prim POSCAR --random_normalcoord --evec PREFIX.evec.h5 --temp Tgenerates structures sampled at the temperatureT(--VASP SPOSCAR0gives the supercell,--primthe primitive cell). Alternatively,--randomadds random displacements to snapshots of a molecular-dynamics run.Calculate the forces with DFT and make a
DFSETfile as in step 3.Run alm with
MODE = optimize,NORDER = 2or larger, andLMODEL = enetoradaptive-lasso. Give the harmonic force constants withFC2FIXso that only the anharmonic terms are fitted.
The result,
PREFIX.h5, contains everything anphon needs.
displace.py and extract.py support VASP, Quantum ESPRESSO, OpenMX, xTAPP, and LAMMPS.
Other codes, such as ASE calculators, WIEN2k, and CRYSTAL, can be used as described in Using other codes (ASE calculators, WIEN2k, CRYSTAL, …).
The DFSET format is described here, and a complete example is given in Si : Anharmonic interatomic force constants (IFCs).
The input variables of alm are listed here.
6.2. Step 2: Phonon properties with anphon#
Choosing MODE. Each box lists the force constants (FC2: harmonic, FC3: cubic, FC4: quartic) that PREFIX.h5 must contain.#
Choosing MODE. Each box lists the force constants (FC2: harmonic, FC3: cubic, FC4: quartic) that PREFIX.h5 must contain.#
Set MODE and FCSFILE = PREFIX.h5 in the &general field of the anphon input, and run:
$ anphon anphon.in > anphon.log
$ mpirun -np 8 anphon anphon.in > anphon.log # with MPI
OpenMP threads are set by OMP_NUM_THREADS and can be combined with MPI.
The main output files are:
|
Main output files |
|---|---|
phonons |
|
kappa |
|
selfenergy |
|
SCPH |
|
QHA |
|
The input variables of anphon are listed here, and all output files here.
6.3. Finite-temperature calculations (SCPH and QHA)#
Options of the finite-temperature calculations, and how to use their results in later calculations.#
Options of the finite-temperature calculations, and how to use their results in later calculations.#
RELAX_STRselects what is relaxed at each temperature: nothing, the atomic positions, or the atomic positions and the cell.Relaxing the cell also needs the elastic constants and the coupling between strain and forces. They come from DFT calculations of strained cells, prepared with the strain tools and given as
STRAINFILE. If the coupling between strain and forces is zero by symmetry,STRAIN_COUPLING = 0skips these DFT calculations and estimates the rest from the force constants.The results at every temperature are stored in
PREFIX.scph.h5 orPREFIX.qha.h5. To use them in a laterMODE = kappaorphononscalculation, keepFCSFILEpointing to the original IFCs, setDFC2FILEto the SCPH/QHA result file, and setFC2_TEMPERATUREto a stored temperature. If the structure was relaxed, also setRELAXED_STRUCTURE = 1;FCSFILEmust then contain the same FC4 (and, after aSTRAIN_FC5 = 1relaxation, the same FC5) as used in the SCPH/QHA run. Forkappa, setTMIN = TMAX = FC2_TEMPERATUREfor each run.
6.4. Step 3: Analyze the results#
Script |
Reads |
Shows |
|---|---|---|
|
|
Phonon dispersion |
|
|
Phonon density of states |
|
|
Phonon lifetimes, mean free paths, cumulative thermal conductivity |
For example:
$ plotband.py PREFIX.bands
$ analyzer.py --calc tau --temp 300 --h5 PREFIX.kappa.h5
$ analyzer.py --calc cumulative --temp 300 --h5 PREFIX.kappa.h5
Each script prints its options with -h.
Complete examples are given in the Tutorial.