easyunfold.utils
#
Utility functions
Module Contents#
Functions#
Write the kpoints to a file 

Write kpoints to a CASTEP input file. Optically can use an existing file as the template and update it. 

Write kpoints to VASP KPOINTS file 

Read kpoints in the VASP KPOINTS file line mode, the results are resolved to explicit kpoints 

Read the kpoints from a given file 

Read kpoints from a KPOINTS file containing reciprocal space coordinates (fractional) 

Read explicitly defined kpoints in a cell file to CASTEP 

Wrap the kpoints to range [0.5, 0.5) 

Find unique slices along the first dimension of an np.array. This function is not optimised for high performance and has a O(N^2) scaling. 

Reduce the kpoint set by finding duplicated kpoints 

Return two if two kpoints are equivalent to each other 
Data#
API#
 easyunfold.utils.RE_COMMENT#
None
 easyunfold.utils.write_kpoints(kpoints: Union[numpy.ndarray, list], outpath, *args, code='vasp', **kwargs)#
Write the kpoints to a file
 Parameters:
kpoints – A Nx3 array of the kpoint coordinates (fractional) to be written.
outpath – Path of the output file to be used.
code – The code that the kpoint file is used for.
 easyunfold.utils.write_kpoints_castep(kpoints: Union[numpy.ndarray, list], dest, source=None, tag='spectral', weights=None, **kwargs)#
Write kpoints to a CASTEP input file. Optically can use an existing file as the template and update it.
 easyunfold.utils.write_kpoints_vasp(kpoints: Union[numpy.ndarray, list], outpath: str = 'KPOINTS', comment: str = '', weights: Union[None, List[float]] = None, **kwargs)#
Write kpoints to VASP KPOINTS file
 Parameters:
kpoints – A list of kpoints to be written
outpath – Path to the output file
comments – Comments to be put into the
KPOINTS
fileweights – If given, the weighting of the kpoints, otherwise all kpoints are equal weighted.
 easyunfold.utils.read_kpoints_line_vasp(content, density=20)#
Read kpoints in the VASP KPOINTS file line mode, the results are resolved to explicit kpoints
 Returns:
The kpoints, the comment, the labels, and the weights at each kpoint
 easyunfold.utils.read_kpoints(path='KPOINTS', code='vasp', **kwargs)#
Read the kpoints from a given file
This function dispatches to codespecific function based on the
code
keyword variable.
 easyunfold.utils.read_kpoints_vasp(path='KPOINTS')#
Read kpoints from a KPOINTS file containing reciprocal space coordinates (fractional)
 Returns:
The kpoints, the comment, the labels, and the weights at each kpoint.
 easyunfold.utils.read_kpoints_castep(path, tag='spectral')#
Read explicitly defined kpoints in a cell file to CASTEP
 easyunfold.utils.wrap_kpoints(kpoints: Union[list, numpy.ndarray])#
Wrap the kpoints to range [0.5, 0.5)
 easyunfold.utils.find_unique(seq: numpy.ndarray, func=None)#
Find unique slices along the first dimension of an np.array. This function is not optimised for high performance and has a O(N^2) scaling.
 Returns:
A tuple of (unique, unique_idx, inv_mapping)
 easyunfold.utils.reduce_kpoints(kpoints: Union[list, numpy.ndarray], time_reversal=True, rounding_digits=10)#
Reduce the kpoint set by finding duplicated kpoints
 easyunfold.utils.kpoints_equal(k1, k2, time_reversal=False, atol=1e05)#
Return two if two kpoints are equivalent to each other