Input/output

The functions and modules described below provide functionality for controlling the verbosity of the output as well as for reading and writing force constant matrices in different formats.

Logging

hiphive.io.logging.set_config(filename=None, level=None, continuous=None)[source]

Alters the way logging is handled.

Parameters:
  • filename (str) – name of file the log should be sent to
  • level (int) – verbosity level; see Python logging library for details
  • continuous (bool) – if True the progress will be continously updated

phonopy data files

This module provides functions for reading and writing data files in phonopy and phono3py formats.

hiphive.io.phonopy.read_phonopy_fc2(filename, format=None)[source]

Parse a second-order force constant file in phonopy format.

Parameters:
  • filename (str) – input file name
  • format (str) – specify the file-format, if None tries to guess the format from filename
Returns:

second-order force constant matrix (N,N,3,3 array) where N is the number of atoms

Return type:

numpy.ndarray

hiphive.io.phonopy.read_phonopy_fc3(filename)[source]

Parse a third order force constant file in phonopy hdf5 format.

Parameters:filename (str) – input file name
Returns:third order force constant matrix
Return type:numpy.ndarray
hiphive.io.phonopy.write_phonopy_fc2(filename, fc2, format=None)[source]

Write second-order force constant matrix in phonopy format.

Parameters:
  • filename (str) – output file name
  • fc2 (ForceConstants or numpy.ndarray) – second-order force constant matrix
  • format (str) – specify the file-format, if None try to guess the format from filename
hiphive.io.phonopy.write_phonopy_fc3(filename, fc3)[source]

Write third order force constant matrix in phonopy hdf5 format.

Parameters:

shengBTE data files

The io.shengBTE module provides functions for reading and writing data files in shengBTE format.

Todo

These functions have not really been tested, i.e. write a fc3 with write_shengBTE_fc3 and pass the file to shengBTE

hiphive.io.shengBTE.find_pos_in_array(pos, pos_array, dist_tol=1e-05)[source]

Return index of an entry specified by value in a list or an array.

Parameters:
  • pos (list or numpy.ndarray) – target value
  • pos_array (list(list) or list(numpy.ndarray)) – list/array to search
  • dist_tol (float) – tolerance imposed during testing
Returns:

index of matching entry in pos_array; None if no match has been found

Return type:

int

hiphive.io.shengBTE.read_shengBTE_fc3(filename, atoms_prim, atoms_super)[source]

Parse third order force constants file in shengBTE format.

Parameters:
  • filename (str) – input file name
  • atoms_prim (ase.Atoms) – primitive configuration (equivalent to POSCAR file used in shengBTE calculation)
  • atoms_super (ase.Atoms) – supercell configuration (equivalent to SPOSCAR file used in shengBTE calculation)
Returns:

dictionary with keys corresponding to triplets in atoms_super and values corresponding to their force constants as a NumPy (3,3,3) array. The dictionary is sparse in permutations.

Return type:

dict

hiphive.io.shengBTE.write_shengBTE_fc3(filename, atoms_prim, atoms_super, fc3_dict)[source]

Write third order force constants file in shengBTE format.

Parameters:
  • filename (str) – input file name
  • atoms_prim (ase.Atoms) – primitive configuration (equivalent to POSCAR file used in the shengBTE calculation)
  • atoms_super (ase.Atoms) – supercell configuration (equivalent to SPOSCAR file used in the shengBTE calculation)
  • fc3_dict (dict) – third order force constant matrix; the dictionary is sparse in permutations