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 where N is the number of atoms

Return type:

NumPy (N,N,3,3) array

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 array
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/dictionary/NumPy array) – second order force constant matrix; dict should contain second order force constants (others will be ignored) and be sparse in permutations
  • format (str) – specify the file-format, if None tries 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:
  • filename (str) – output file name
  • fc3 (dictionary/NumPy array) – third order force constant matrix; if dict it may contain other order force constants aswell since these are filterd, however should be sparse in permutations

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/NumPy array) – target value
  • pos_array (list of lists/NumPy arrays) – 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 object) – primitive configuration (equivalent to POSCAR file used in the shengBTE calculation)
  • atoms_super (ASE Atoms object) – supercell configuration (equivalent to SPOSCAR file used in the 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. 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 object) – primitive configuration (equivalent to POSCAR file used in the shengBTE calculation)
  • atoms_super (ASE Atoms object) – supercell configuration (equivalent to SPOSCAR file used in the shengBTE calculation)
  • fc3_dict (dictionary) – third order force constant matrix; the dictionary be sparse in permutations