def assign_mulliken_operator(operator, system, index): '''Fill in the mulliken operator in the first argument **Arguments:** operator A One body operator for the output system The system for which the Mulliken operator is to be constructed index The index of the atom (center) for which the Mulliken operator needs to be constructed This routine implies that the first ``natom`` centers in the object system.obasis corresponds to the atoms in the system object. ''' mask = np.zeros(system.obasis.nbasis, dtype=bool) begin = 0 for ishell in xrange(system.obasis.nshell): end = begin + get_shell_nbasis(system.obasis.shell_types[ishell]) if system.obasis.shell_map[ishell] != index: mask[begin:end] = True begin = end olp = system.get_overlap() operator.assign(olp) operator._array[mask] = 0.0 operator._array[:] = 0.5*(operator._array + operator._array.T)
def partition_mulliken(operator, obasis, index): '''Fill in the mulliken operator in the first argument **Arguments:** operator A Two index operator to which the Mulliken mask is applied obasis The localized orbital basis for which the Mulliken operator is to be constructed index The index of the atom (center) for which the Mulliken operator needs to be constructed This routine implies that the first ``natom`` centers in the obasis corresponds to the atoms in the system. ''' mask = np.zeros(obasis.nbasis, dtype=bool) begin = 0 for ishell in xrange(obasis.nshell): end = begin + get_shell_nbasis(obasis.shell_types[ishell]) if obasis.shell_map[ishell] != index: mask[begin:end] = True begin = end operator._array[mask] = 0.0 operator._array[:] = 0.5*(operator._array + operator._array.T)
def partition_mulliken(operator, obasis, index): '''Fill in the mulliken operator in the first argument. Parameters ---------- operator : np.ndarray, shape=(nbasis, nbasis), dtype=float A Two index operator to which the Mulliken mask is applied. obasis : GOBasis The localized orbital basis for which the Mulliken operator is to be constructed. index : int The index of the atom (center) for which the Mulliken operator needs to be constructed. This routine implies that the first ``natom`` centers in the obasis corresponds to the atoms in the system. ''' mask = np.zeros(obasis.nbasis, dtype=bool) begin = 0 for ishell in xrange(obasis.nshell): end = begin + get_shell_nbasis(obasis.shell_types[ishell]) if obasis.shell_map[ishell] != index: mask[begin:end] = True begin = end operator[mask] = 0.0 operator[:] = 0.5*(operator + operator.T)
def partition_mulliken(operator, obasis, index): '''Fill in the mulliken operator in the first argument **Arguments:** operator A Two index operator to which the Mulliken mask is applied obasis The localized orbital basis for which the Mulliken operator is to be constructed index The index of the atom (center) for which the Mulliken operator needs to be constructed This routine implies that the first ``natom`` centers in the obasis corresponds to the atoms in the system. ''' mask = np.zeros(obasis.nbasis, dtype=bool) begin = 0 for ishell in xrange(obasis.nshell): end = begin + get_shell_nbasis(obasis.shell_types[ishell]) if obasis.shell_map[ishell] != index: mask[begin:end] = True begin = end operator._array[mask] = 0.0 operator._array[:] = 0.5 * (operator._array + operator._array.T)
def partition_mulliken(operator, obasis, index): '''Fill in the mulliken operator in the first argument. Parameters ---------- operator : np.ndarray, shape=(nbasis, nbasis), dtype=float A Two index operator to which the Mulliken mask is applied. obasis : GOBasis The localized orbital basis for which the Mulliken operator is to be constructed. index : int The index of the atom (center) for which the Mulliken operator needs to be constructed. This routine implies that the first ``natom`` centers in the obasis corresponds to the atoms in the system. ''' mask = np.zeros(obasis.nbasis, dtype=bool) begin = 0 for ishell in xrange(obasis.nshell): end = begin + get_shell_nbasis(obasis.shell_types[ishell]) if obasis.shell_map[ishell] != index: mask[begin:end] = True begin = end operator[mask] = 0.0 operator[:] = 0.5 * (operator + operator.T)
def _get_molden_permutation(obasis, reverse=False): # Reorder the Cartesian basis functions to obtain the HORTON standard ordering. permutation_rules = { 2: np.array([0, 3, 4, 1, 5, 2]), 3: np.array([0, 4, 5, 3, 9, 6, 1, 8, 7, 2]), 4: np.array([0, 3, 4, 9, 12, 10, 5, 13, 14, 7, 1, 6, 11, 8, 2]), } permutation = [] for shell_type in obasis.shell_types: rule = permutation_rules.get(shell_type) if reverse and rule is not None: reverse_rule = np.zeros(len(rule), int) for i, j in enumerate(rule): reverse_rule[j] = i rule = reverse_rule if rule is None: rule = np.arange(get_shell_nbasis(shell_type)) permutation.extend(rule + len(permutation)) return np.array(permutation, dtype=int)
def _get_molden_permutation(obasis, reverse=False): # Reorder the Cartesian basis functions to obtain the HORTON standard ordering. permutation_rules = { 2: np.array([0, 3, 4, 1, 5, 2]), 3: np.array([0, 4, 5, 3, 9, 6, 1, 8, 7, 2]), 4: np.array([0, 3, 4, 9, 12, 10, 13, 5, 1, 6, 11, 14, 7, 8, 2]), } permutation = [] for shell_type in obasis.shell_types: rule = permutation_rules.get(shell_type) if reverse and rule is not None: reverse_rule = np.zeros(len(rule), int) for i, j in enumerate(rule): reverse_rule[j] = i rule = reverse_rule if rule is None: rule = np.arange(get_shell_nbasis(shell_type)) permutation.extend(rule+len(permutation)) return np.array(permutation, dtype=int)
def _get_orca_signs(obasis): """Return an array with sign corrections for orbitals read from ORCA. **Arguments:** obasis An instance of GOBasis. """ sign_rules = { -4: [1, 1, 1, 1, 1, -1, -1, -1, -1], -3: [1, 1, 1, 1, 1, -1, -1], -2: [1, 1, 1, 1, 1], 0: [1], 1: [1, 1, 1], } signs = [] for shell_type in obasis.shell_types: if shell_type in sign_rules: signs.extend(sign_rules[shell_type]) else: signs.extend([1] * get_shell_nbasis(shell_type)) return np.array(signs, dtype=int)
def _get_orca_signs(obasis): '''Return an array with sign corrections for orbitals read from ORCA. **Arguments:** obasis An instance of GOBasis. ''' sign_rules = { -4: [1,1,1,1,1,-1,-1,-1,-1], -3: [1,1,1,1,1,-1,-1], -2: [1,1,1,1,1], 0: [1], 1: [1,1,1], } signs = [] for shell_type in obasis.shell_types: if shell_type in sign_rules: signs.extend(sign_rules[shell_type]) else: signs.extend([1]*get_shell_nbasis(shell_type)) return np.array(signs, dtype=int)