pwtools.pwscf.atpos_str_fast

pwtools.pwscf.atpos_str_fast(symbols, coords)[source]

Fast version of atpos_str() for usage in loops. We use a fixed string dtype U32 to convert the array coords to string form. We also avoid all asserts for speed.

Parameters:
  • symbols (list of strings with atom symbols, (natoms,), must match with the) – rows of coords

  • coords (array (natoms, 3) with atomic coords, can also be (natoms, >3) to) – add constraints on atomic forces in PWscf

Return type:

string

Notes

The string dtype + flatten trick used here is the fastest way to convert a numpy array to string. However the number of digits is limited to 32 chars. We use 32 b/c

>>> array([pi]*2).astype('U')
array(['3.141592653589793', '3.141592653589793'], dtype='<U32')

< means little endian and is based on the machine arch automatically.

Needs about 1/3 of the time of atpos_str().