masses for the atoms (has to have length ``mode.shape[1] // 3`` Returns ------- numpy.ndarray displacements per mode with final dimension ``(mode.shape[0], 3)``, the displacements are in Ang """ if mode.ndim == 1: return displacement(mode.reshape(1, -1), hw, mass).reshape(-1, 3) return _displacement(mode, hw, mass) # Electron rest mass in units of proton mass (the units we use for the atoms) _displacement_const = (2 * units('Ry', 'eV') * constant.m_e('amu'))**0.5 * units('Bohr', 'Ang') def _displacement(mode, hw, mass): """ Real space displacements """ idx = (hw < 0).nonzero()[0] U = mode.copy() U[idx, :] = 0. # Now create the remaining displacements idx = np.delete(_a.arangei(mode.shape[0]), idx) # Generate displacement factor factor = _displacement_const / hw[idx].reshape(-1, 1)**0.5 U.shape = (mode.shape[0], -1, 3)
mass : array_like masses for the atoms (has to have length ``mode.shape[1] // 3`` Returns ------- numpy.ndarray displacements per mode with final dimension ``(mode.shape[0], 3)``, displacements are in Ang """ if mode.ndim == 1: return displacement(mode.reshape(1, -1), hw, mass)[0] return _displacement(mode, hw, mass) # Rest mass in units of proton mass (the units we use for the atoms) _displacement_const = (2 * units('Ry', 'eV') * constant.m_e('amu')) ** 0.5 * units('Bohr', 'Ang') def _displacement(mode, hw, mass): """ Real space displacements """ idx = (hw == 0).nonzero()[0] U = mode.copy() U[idx, :] = 0. # Now create the remaining displacements idx = delete(_a.arangei(mode.shape[0]), idx) # Generate displacement factor factor = _displacement_const / fabs(hw[idx]).reshape(-1, 1) ** 0.5 U.shape = (mode.shape[0], -1, 3)