\(\newcommand{\AA}{\text{Å}}\)

CRYSTALpytools.io.phonopy module

Classes and methods to parse files used by Phonopy. Currently only YAML and FORCE_CONSTANTS files are supported.

_phonon_rep(dumper, value)

Formatting output phonon info.

_header_rep(dumper, value)

Formatting output header info.

class YAML(struc, dim, calculator='crystal', primitive='auto', **kwargs)

Bases: object

Read and write phonopy YAML files. Phonopy python API is used for writing. The Phonopy instance is saved in self._phonopy attribute, with basic geometry and calculator information.

Note

Phonopy default units (\(\AA\), AMU, THz, eV) are used for all calculators, which leads to no error as far as developers are aware of.

Parameters:
  • struc (Structure|CStructure) – Pymatgen Structure class, unit cell.

  • dim (list[int]) – 1*3 or 1*9 list of supercell expansion matrix, i.e., the --dim option of phonopy.

  • calculator (str) – Name of calculator. Will be used to determine the conversion factors.

  • primitive (str|array) – 9*1 primitive matrix in phonopy convention, or ‘auto’ to automatically identify the primitive cell.

  • **kwargs – Other attributes. Listed below.

  • qpoint (array) – nQpoint*4, Fractional coordinates and weight.

  • frequency (array) – nQpoint*nMode, In THz.

  • mode_symm (array) – nQpoint*nMode str, in Mulliken symbols.

  • eigenvector (array) – nQpoint*nMode*nAtom*3 complex, Mass-weighted and phased, normalized to 1.

classmethod read(struc, phonon='')

Read data from YAML. Currently ‘phonopy’, ‘phononpy_disp’ (structure only), ‘mesh’, ‘band’, ‘qpoints’ and ‘irreps’ are supported.

Parameters:
  • struc (str) – Geometry information. Only for ‘phonopy’, ‘phononpy_disp’, ‘mesh’ and ‘band’

  • phonon (str) – Frequency information, including q points, frequency, eigenvector and irreducible representations. For ‘mesh’, ‘band’, ‘qpoints’ and ‘irreps’.

Returns:

cls

write_phonopy(filename='phonopy.yaml')

Save computational setups and structure into ‘phonopy.yaml’.

Parameters:

filename (str) – The YAML file name.

Returns:

None

write_qpoints(filename='qpoints.yaml', write_eigenvector=False)

Write vibration data into ‘qpoints.yaml’.

Parameters:
  • filename (str) – ‘qpoints’ formatted file name.

  • write_eigenvector (bool) – Whether to write eigenvector if present.

Returns:

None

write_mesh(filename='mesh.yaml', write_eigenvector=False)

Write vibration data into ‘mesh.yaml’. The mesh size is inferred from coordinates of qpoints, so it is important to use data obtained from the regular mesh grid.

Parameters:
  • filename (str) – ‘mesh’ formatted file name.

  • write_eigenvector (bool) – Whether to write eigenvector if present.

Returns:

None

write_band(filename='band.yaml')

Write phonon band structure into ‘band.yaml’. The line segment is inferred from coordinates of qpoints, so it is important to use data sampled by a path.

Parameters:

filename (str) – ‘band’ formatted file name.

Returns:

None

_write_phonon(rlattmx, method, eigvec)

Internal method for dumping ‘mesh’, ‘qpoints’ and ‘band’ files.

Parameters:
  • rlattmx (array) – Reciprocal lattice matrix.

  • method (str) – ‘mesh’, ‘qpoints’ or ‘band’.

  • eigvec (bool) – Whether to dump eigenvectors.

Returns:

phonon (list[dict]) – Phonon information.

read_FC(input='FORCE_CONSTANTS')

Read force constant (Hessian) matrix in Phonopy/VASP FORCE_CONSTANTS format. Units: ‘eV’ and ‘\(\AA\)’.

Parameters:

input (str) – The input file name

Returns:

hess (array) – nMode*nMode array. Mass-unweighted Hessian matrix.

write_FC(hess, output='FORCE_CONSTANTS')

Write force constant (Hessian) matrix into Phonopy/VASP FORCE_CONSTANTS format. Input units: ‘eV’ and ‘\(\AA\)’.

Parameters:
  • hess (array) – nMode*nMode array. Mass-unweighted Hessian matrix.

  • output (str) – The output name

Returns:

None