def gen_string_bfns(universe, kind='spherical'): """ Given an exatomic.container.Universe that contains complete momatrix and basis_set attributes, generates and returns the strings corresponding to how the basis functions would be written out with paper and pencil. This is mainly for debugging and testing generality to deal with different computational codes' basis function ordering schemes. Args universe (exatomic.container.Universe): must contain momatrix and basis_set Returns bastrs (list): list of strings of basis functions """ lmax = universe.basis_set['L'].cat.as_ordered().max() universe.basis_set['N'] = _vec_sloppy_normalize(universe.basis_set['alpha'].values, universe.basis_set['L'].values) bases = universe.basis_set.groupby('set') if hasattr(universe, 'basis_set_order'): centers = universe.basis_set_order.groupby('center') sh = solid_harmonics(lmax) bfns = [] bastrs = [] for i, (seht, x, y, z) in enumerate(zip(universe.atom['set'], universe.atom['x'], universe.atom['y'], universe.atom['z'])): spherical = universe.basis_set_summary.ix[seht].spherical xastr = 'x' if np.isclose(x, 0) else 'x - ' + str(x) yastr = 'y' if np.isclose(y, 0) else 'y - ' + str(y) zastr = 'z' if np.isclose(z, 0) else 'z - ' + str(z) nucpos = {'x': xastr, 'y': yastr, 'z': zastr} r2str = '(' + xastr + ')**2 + (' + yastr + ')**2 + (' + zastr + ')**2' if hasattr(universe, 'basis_set_order'): bas = bases.get_group(seht).groupby('L') basord = centers.get_group(i + 1) for L, ml, shfunc in zip(basord['L'], basord['ml'], basord['shell_function']): grp = bas.get_group(L).groupby('shell_function').get_group(shfunc) bastr = '' prefacs = _gen_prefactor(sh, L, ml, nucpos) bastrs.append(_enumerate_primitives_prefacs(prefacs, grp, r2str)) else: bas = bases.get_group(seht).groupby('shell_function') for f, grp in bas: if len(grp) == 0: continue l = grp['L'].values[0] if spherical: sym_keys = universe.spherical_gtf_order.symbolic_keys(l) for L, ml in sym_keys: bastr = '' prefacs = _gen_prefactor(sh, L, ml, nucpos) bastrs.append(_enumerate_primitives_prefacs(prefacs, grp, r2str)) else: subcart = universe.cartesian_gtf_order[universe.cartesian_gtf_order['l'] == l] prefacs = _cartesian_prefactor(l, subcart['x'], subcart['y'], subcart['z'], nucpos) for prefac in prefacs: bastrs.append(_enumerate_primitives_prefacs([prefac], grp, r2str)) return bastrs
def _normalize(self): """Normalization coefficients.""" if 'N' not in self.columns: self['N'] = _vec_sloppy_normalize(self['alpha'], self['L'])