Utility functions

Helper functions

source

normalize_conf

 normalize_conf (c, base)

Normalize the configuration c relative to the basic structure base. Normalization is performed by “nuwrapping” the displacements of atoms when they cross the periodic boundary conditions in such a way that the atoms are not “jumping” from one side of the cell to the other.

E.g. if the atom at r=(0,0,0) goes to the relative position (-0.01, 0, 0) it is “wrapped” by PBC to the r=(0.99, 0, 0). Thus if we naiively calculate the displacement we will get a large positive displacement (0.99 of the cell vector) instead of a small negative one.

This function reverses that process making the positions suitable for differentiation. The positions may be part of a continous trajectory or just independent configurations. This makes it impossible for described procedure to work if the displacements are above 1/2 of the unit cell. For sefety this implementation is limited to displacements < 1/3 of the unit cell. If any coordinate changes by more then 1/3 the function will rise an AssertionError exception.

This implementation is not suitable for tracking positions in the system with systematic drift (e.g. long MD trajectory with non-perfect momentum conservation). For stronger implementation suitable for such cases look at dxutils package.


source

load_dfset

 load_dfset (fn)

Load contents of the DFSET flie and return dfset array


source

get_dfset_len

 get_dfset_len (fn)

source

write_dfset

 write_dfset (fn, c, comment='')

Append displacement-force data from the conf to the fn file. The format is suitable for use as ALAMODE DFSET file. Optionaly you can provide configuration number in n. File need not exist prior to first call. If it does not it will be created.

/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/fastcore/docscrape.py:225: UserWarning: Unknown section Input
  else: warn(msg)
/opt/hostedtoolcache/Python/3.9.19/x64/lib/python3.9/site-packages/fastcore/docscrape.py:225: UserWarning: Unknown section Output
  else: warn(msg)

source

calc_init_xscale

 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).