hylight.findiff package¶
Submodules¶
hylight.findiff.collect module¶
Grab forces from a collection of single point computations and compute hessian.
- hylight.findiff.collect.dropwhile_err(pred, it, else_err)¶
itertools.dropwhile wrapper that raise else_err if it reach the end of the file.
- hylight.findiff.collect.get_forces(n, path)¶
Extract n forces from an OUTCAR.
- hylight.findiff.collect.get_forces_and_pos(n, path)¶
Extract n forces and atomic positions from an OUTCAR.
- hylight.findiff.collect.get_ref_info(path)¶
Load system infos from a OUTCAR.
This is an ad hoc parser, so it may fail if the OUTCAR changes a lot.
- Returns:
(atoms, ref, pops, masses)
atoms: list of species names
pos: positions of atoms
pops: population for each atom species
masses: list of SI masses
- hylight.findiff.collect.process_phonons(outputs, ref_output, basis_source=None, amplitude=0.01, nproc=1, symm=True, asr_force=False)¶
Process a set of OUTCAR files to compute some phonons using Force based finite differences.
- Parameters:
outputs – list of OUTCAR paths corresponding to the finite displacements.
ref_output – path to non displaced OUTCAR.
basis_source – (optional) read a displacement basis from a path. The file is a npy file from numpy’s save. If None, the basis is built from the displacements. If not None, the order of outputs must match the order of the displacements in the array.
amplitude – (optional) amplitude of the displacement, only used if basis_source is not None.
nproc – (optional) number of parallel processes used to load the files.
symm – (optional) If True, use symmetric differences. OUTCARs must be ordered as
[+delta_1, -delta_1, +delta_2, -delta_2, ...]
.asr_force – (optional,
False
) enforce the accoustic sum rule by projecting the dynamic matrix on the subspace where homogeneous translation of all modes leads to a null frequency.
- Returns:
the same tuple as the load_phonons functions.
Note
When using non canonical basis (displacements are not along a single degree of freedom of a single atom at a time) it may be important to provide the basis excplicity because it will avoid important rounding errors found in the OUTCAR.
hylight.findiff.gen module¶
Generate a collection of positions for finite differences computations.
- hylight.findiff.gen.gen_disp(ref, basis, amplitude=0.01, symm=False)¶
Iterate over displaced Poscar instances from a given set of directions.
Takes a reference position and displaces it into directions from basis to produce a set of positions for finite differences computations.
- Parameters:
ref – reference Poscar instancce
basis – nupy array where each row is a direction.
amplitude – (optional, 0.01) amplitude of the displacements in Angstrom.
symm – (optional, False) when True, generate both ref+delta and ref-delta POSCARs for each direction.
- hylight.findiff.gen.random_basis(n, seed=0)¶
Generate a random basis matrix or rank n.
- Parameters:
n – Rank of the basis
seed – (optional, 0) randomness seed.
- Returns:
a (n, n) orthonormal numpy array.
- hylight.findiff.gen.save_disp(ref, basis, disp_dest='.', amplitude=0.01, symm=False)¶
Produce displaced POSCARs from a given set of directions.
Takes a reference position and displaces it into directions from basis to produce a set of positions for finite differences computations.
- Parameters:
ref – reference Poscar instancce
basis – nupy array where each row is a direction.
disp_dest – (optional, “.”) directory name or callable that determine the destination of the POSCARs.
amplitude – (optional, 0.01) amplitude of the displacements in Angstrom.
symm – (optional, False) when True, generate both ref+delta and ref-delta POSCARs for each direction.
- hylight.findiff.gen.save_disp_from_basis(source, basis_source, disp_dest='.', amplitude=0.01, symm=False)¶
Produce displaced POSCARs from a given set of directions.
Takes a reference position and displaces it into directions from basis_source to produce a set of positions for finite differences computations.
- Parameters:
source – reference POSCAR
basis_source – Name of the basis set file. It is a npy file made with numpy’s save function. Each row is a direction.
disp_dest – (optional, “.”) directory name or callable that determine the destination of the POSCARs.
amplitude – (optional, 0.01) amplitude of the displacements in Angstrom.
symm – (optional, False) when True, generate both ref+delta and ref-delta POSCARs for each direction.
- hylight.findiff.gen.save_random_disp(source, disp_dest='.', basis_dest='basis.npy', amplitude=0.01, seed=0, symm=False)¶
Produce displaced POSCARs in random directions.
Takes a reference position and displaces it into random directions to produce a set of positions for finite differences computations. It also save the set of displacements in basis_dest.
- Parameters:
source – reference POSCAR
disp_dest – (optional, “.”) directory name or callable that determine the destination of the POSCARs.
basis_dest – (optional, “basis.npy”) Name of the basis set file. It is a npy file made with numpy’s save function.
amplitude – (optional, 0.01) amplitude of the displacements in Angstrom.
seed – (optional, 0) random seed to use to generate the displacements.
symm – (optional, False) when True, generate both ref+delta and ref-delta POSCARs for each direction.
Module contents¶
A module for finite differences computations.