hecss.util¶
Helper functions
__all__ = ['normalize_conf', 'load_dfset', 'get_dfset_len', 'write_dfset', 'calc_init_xscale']
module-attribute
¶
flatten = itertools.chain.from_iterable
module-attribute
¶
calc_init_xscale(cryst, xsl, skip=None)
¶
Calculate initial xscale amplitude correction coefficients
from the history exported from the previous calculation
(with xscale_list argument).
INPUT¶
cryst : ASE structure
xsl : List of amplitude correction coefficients. The shape of
each element of the list must be cryst.get_positions().shape
skip : Number of samples to skip at the start of the xsl list
OUTPUT¶
Array amplitude correction coefficients with the same shape as
cryst.get_positions(). Assign it to sampler.xscale_init before
calling sample() for a new temperature stream.
Source code in hecss/util.py
create_asap_calculator(model)
¶
get_cell_data(cell)
¶
Convert an ASE cell to a spglib cell tuple.
Returns (lattice, positions, numbers) with the lattice rows in spglib
order, fractional positions and atomic numbers.
Source code in hecss/util.py
get_dfset_len(fn)
¶
Return the number of configurations in a DFSET file, or 0 if absent.
load_dfset(fn)
¶
Load an ALAMODE DFSET file into a list of sample tuples.
Each tuple is (number, configuration, positions, forces, energy) with
positions in Angstrom and forces in eV/Angstrom.
Source code in hecss/util.py
normalize_conf(c, base)
¶
Normalize configuration c relative to the reference structure base.
Atomic displacements crossing periodic boundaries are unwrapped so that they remain small and differentiable: an atom moving from (0,0,0) to (-0.01, 0, 0) is stored by PBC as (0.99, 0, 0), which would otherwise look like a displacement of almost one full cell vector.
The result is (cartesian_positions, fractional_positions). Displacements
above half a cell are ambiguous; for safety this implementation raises
AssertionError when any fractional component exceeds 1/3. It is not
suitable for trajectories with systematic drift; consider the dxutils
package for that case.
Source code in hecss/util.py
select_asap_model(comp='SiC')
¶
Select the latest working OpenKIM model whose name contains comp.
Models are tried with ASAP3 and those that fail to load are skipped,
since names and availability are not stable across installations.
Returns the model name, or None when no working model is found.
Source code in hecss/util.py
write_dfset(fn, c, comment='')
¶
Append one sample to fn in ALAMODE DFSET format.
c is a (number, configuration, positions, forces, energy) tuple;
positions and forces are converted from ASE units to the units used by
ALAMODE. comment, when given, is written as a ## line before the
sample. The file is created if it does not exist.