def rotate_coeffs(coeffs, obasis, rmat): '''Apply a rotation to all cartesian basis functions. **Arguments:** coeffs Expansion coefficients of a set of functions (orbitals) in a local basis. shape=(nbasis,nfn) obasis The local basis set object. rmat The rotation matrix. ''' if obasis.nbasis != coeffs.shape[0]: raise TypeError( 'The shape of the coefficients array does not match the basis set size' ) if obasis.shell_types.min() < 0: raise TypeError('Pure functions are not supported in rotate_coeffs.') result = np.zeros(coeffs.shape) # 1) undo the part normalization of the basis functions due to the cartesian powers lmax = obasis.shell_types.max() powers = get_cartesian_powers(lmax) factors = [] for ishell in xrange(obasis.nshell): shell_type = obasis.shell_types[ishell] icart0 = ((shell_type + 2) * (shell_type + 1) * (shell_type)) / 6 shellsize = ((shell_type + 2) * (shell_type + 1)) / 2 for ifn in xrange(shellsize): ipow = icart0 + ifn factors.append( np.sqrt( fac2(2 * powers[ipow, 0] - 1) * fac2(2 * powers[ipow, 1] - 1) * fac2(2 * powers[ipow, 2] - 1))) factors = np.array(factors) # replace the array coeffs by the one with undone normalization coeffs = coeffs / factors.reshape(-1, 1) # 2) the actual rotation ibasis0 = 0 for ishell in xrange(obasis.nshell): shell_type = obasis.shell_types[ishell] icart0 = ((shell_type + 2) * (shell_type + 1) * (shell_type)) / 6 shellsize = ((shell_type + 2) * (shell_type + 1)) / 2 for iorb in xrange(coeffs.shape[1]): result[ibasis0:ibasis0 + shellsize, iorb] = rotate_cartesian_multipole( rmat, coeffs[ibasis0:ibasis0 + shellsize, iorb], 'coeffs') ibasis0 += shellsize # 3) apply the part of the normalization of the basis functions due to the cartesian powers result *= factors.reshape(-1, 1) return result
def rotate_coeffs(coeffs, obasis, rmat): """Apply a rotation to all cartesian basis functions. **Arguments:** coeffs Expansion coefficients of a set of functions (orbitals) in a local basis. shape=(nbasis,nfn) obasis The local basis set object. rmat The rotation matrix. """ if obasis.nbasis != coeffs.shape[0]: raise TypeError("The shape of the coefficients array does not match the basis set size") if obasis.shell_types.min() < 0: raise TypeError("Pure functions are not supported in rotate_coeffs.") result = np.zeros(coeffs.shape) # 1) undo the part normalization of the basis functions due to the cartesian powers lmax = obasis.shell_types.max() powers = get_cartesian_powers(lmax) factors = [] for ishell in xrange(obasis.nshell): shell_type = obasis.shell_types[ishell] icart0 = ((shell_type + 2) * (shell_type + 1) * (shell_type)) / 6 shellsize = ((shell_type + 2) * (shell_type + 1)) / 2 for ifn in xrange(shellsize): ipow = icart0 + ifn factors.append( np.sqrt(fac2(2 * powers[ipow, 0] - 1) * fac2(2 * powers[ipow, 1] - 1) * fac2(2 * powers[ipow, 2] - 1)) ) factors = np.array(factors) # replace the array coeffs by the one with undone normalization coeffs = coeffs / factors.reshape(-1, 1) # 2) the actual rotation ibasis0 = 0 for ishell in xrange(obasis.nshell): shell_type = obasis.shell_types[ishell] icart0 = ((shell_type + 2) * (shell_type + 1) * (shell_type)) / 6 shellsize = ((shell_type + 2) * (shell_type + 1)) / 2 for iorb in xrange(coeffs.shape[1]): result[ibasis0 : ibasis0 + shellsize, iorb] = rotate_cartesian_multipole( rmat, coeffs[ibasis0 : ibasis0 + shellsize, iorb], "coeffs" ) ibasis0 += shellsize # 3) apply the part of the normalization of the basis functions due to the cartesian powers result *= factors.reshape(-1, 1) return result
def _get_cp2k_norm_corrections(l, alphas): """Compute the corrections for the normalization of the basis functions. This correction is needed because the CP2K atom code works with non-normalized basis functions. HORTON assumes Gaussian primitives are always normalized. Parameters ---------- l : int The angular momentum of the (pure) basis function. (s=0, p=1, ...) alphas : float or np.ndarray The exponent or exponents of the Gaussian primitives for which the correction is to be computed. Returns ------- corrections : float or np.ndarray The scale factor for the expansion coefficients of the wavefunction in terms of primitive Gaussians. The inverse of this correction can be applied to the contraction coefficients. """ expzet = 0.25 * (2 * l + 3) prefac = np.sqrt(np.sqrt(np.pi) / 2.0**(l + 2) * fac2(2 * l + 1)) zeta = 2.0 * alphas return zeta**expzet / prefac
def _get_cp2k_norm_corrections(l, alphas): """Compute the corrections for the normalization of the basis functions. This correction is needed because the CP2K atom code works with non-normalized basis functions. HORTON assumes Gaussian primitives are always normalized. Parameters ---------- l : int The angular momentum of the (pure) basis function. (s=0, p=1, ...) alphas : float or np.ndarray The exponent or exponents of the Gaussian primitives for which the correction is to be computed. Returns ------- corrections : float or np.ndarray The scale factor for the expansion coefficients of the wavefunction in terms of primitive Gaussians. The inverse of this correction can be applied to the contraction coefficients. """ expzet = 0.25*(2*l + 3) prefac = np.sqrt(np.sqrt(np.pi)/2.0**(l + 2)*fac2(2*l + 1)) zeta = 2.0*alphas return zeta**expzet/prefac
def _get_cp2k_norm_corrections(l, alphas): from horton.gbasis.cext import fac2 expzet = 0.25 * (2 * l + 3) prefac = np.sqrt(np.sqrt(np.pi) / 2.0**(l + 2) * fac2(2 * l + 1)) zeta = 2 * np.array(alphas) return zeta**expzet / prefac
def _get_cp2k_norm_corrections(l, alphas): expzet = 0.25*(2*l + 3) prefac = np.sqrt(np.sqrt(np.pi)/2.0**(l+2)*fac2(2*l+1)) zeta = 2*np.array(alphas) return zeta**expzet/prefac
def _get_cp2k_norm_corrections(l, alphas): from horton.gbasis.cext import fac2 expzet = 0.25*(2*l + 3) prefac = np.sqrt(np.sqrt(np.pi)/2.0**(l+2)*fac2(2*l+1)) zeta = 2*np.array(alphas) return zeta**expzet/prefac