|
21 | 21 | from exatomic.core.frame import compute_frame_from_atom |
22 | 22 | from exatomic.core.frame import Frame |
23 | 23 | from exatomic.core.atom import Atom, Frequency |
24 | | -from exatomic.core.basis import BasisSet, BasisSetOrder, Overlap |
| 24 | +from exatomic.core.basis import (BasisSet, BasisSetOrder, Overlap, |
| 25 | + deduplicate_basis_sets) |
25 | 26 | from exatomic.core.orbital import Orbital, MOMatrix, Excitation |
26 | 27 | from exatomic.algorithms.basis import lmap, lorder |
27 | 28 | from numba import jit |
@@ -159,8 +160,11 @@ def _padx(srs): return [0] + srs.tolist() + [df.shape[0]] |
159 | 160 | except TypeError: |
160 | 161 | df[2] = df[2].str.replace('D', 'E').astype(np.float64) |
161 | 162 | sp = True |
| 163 | + df.rename(columns={0: 'alpha', 1: 'd'}, inplace=True) |
162 | 164 | # Deduplicate basis sets and expand 'SP' shells if present |
163 | | - df, setmap = _dedup(df, sp=sp) |
| 165 | + df, setmap = deduplicate_basis_sets(df, sp=sp) |
| 166 | + try: df.drop([2, 3], axis=1, inplace=True) |
| 167 | + except ValueError: pass |
164 | 168 | spherical = '5D' in self[found[_rebas03][0]] |
165 | 169 | if df['L'].max() < 2: |
166 | 170 | spherical = True |
@@ -531,7 +535,9 @@ def parse_basis_set(self): |
531 | 535 | shldx[1] += 1 |
532 | 536 | ptr += nprim |
533 | 537 | sp = False |
534 | | - sets, setmap = _dedup(pd.DataFrame.from_dict(ddict)) |
| 538 | + df = pd.DataFrame.from_dict(ddict) |
| 539 | + df.rename(columns={0: 'alpha', 1: 'd'}, inplace=True) |
| 540 | + sets, setmap = deduplicate_basis_sets(df) |
535 | 541 | self.basis_set = sets |
536 | 542 | self.meta['spherical'] = True |
537 | 543 | self.atom['set'] = self.atom['set'].map(setmap) |
@@ -623,48 +629,48 @@ def __init__(self, *args, **kwargs): |
623 | 629 | super(Fchk, self).__init__(*args, **kwargs) |
624 | 630 |
|
625 | 631 |
|
626 | | -def _dedup(sets, sp=False): |
627 | | - unique, setmap, cnt = [], {}, 0 |
628 | | - sets = sets.groupby('center') |
629 | | - chk = [0, 1] |
630 | | - for center, seht in sets: |
631 | | - for i, other in enumerate(unique): |
632 | | - if other.shape != seht.shape: continue |
633 | | - if np.allclose(other[chk], seht[chk]): |
634 | | - setmap[center] = i |
635 | | - break |
636 | | - else: |
637 | | - unique.append(seht) |
638 | | - setmap[center] = cnt |
639 | | - cnt += 1 |
640 | | - if sp: unique = _expand_sp(unique) |
641 | | - sets = pd.concat(unique).reset_index(drop=True) |
642 | | - try: sets.drop([2, 3], axis=1, inplace=True) |
643 | | - except ValueError: pass |
644 | | - sets.rename(columns={'center': 'set', 0: 'alpha', 1: 'd'}, inplace=True) |
645 | | - sets['set'] = sets['set'].map(setmap) |
646 | | - sets['frame'] = 0 |
647 | | - return sets, setmap |
648 | | - |
649 | | - |
650 | | -def _expand_sp(unique): |
651 | | - expand = [] |
652 | | - for seht in unique: |
653 | | - if np.isnan(seht[2]).sum() == seht.shape[0]: |
654 | | - expand.append(seht) |
655 | | - continue |
656 | | - sps = seht[2][~np.isnan(seht[2])].index |
657 | | - shls = len(seht.ix[sps]['shell'].unique()) |
658 | | - dupl = seht.ix[sps[0]:sps[-1]].copy() |
659 | | - dupl[1] = dupl[2] |
660 | | - dupl['L'] = 1 |
661 | | - dupl['shell'] += shls |
662 | | - last = seht.ix[sps[-1] + 1:].copy() |
663 | | - last['shell'] += shls |
664 | | - expand.append(pd.concat([seht.ix[:sps[0] - 1], |
665 | | - seht.ix[sps[0]:sps[-1]], |
666 | | - dupl, last])) |
667 | | - return expand |
| 632 | +# def _dedup(sets, sp=False): |
| 633 | +# unique, setmap, cnt = [], {}, 0 |
| 634 | +# sets = sets.groupby('center') |
| 635 | +# chk = [0, 1] |
| 636 | +# for center, seht in sets: |
| 637 | +# for i, other in enumerate(unique): |
| 638 | +# if other.shape != seht.shape: continue |
| 639 | +# if np.allclose(other[chk], seht[chk]): |
| 640 | +# setmap[center] = i |
| 641 | +# break |
| 642 | +# else: |
| 643 | +# unique.append(seht) |
| 644 | +# setmap[center] = cnt |
| 645 | +# cnt += 1 |
| 646 | +# if sp: unique = _expand_sp(unique) |
| 647 | +# sets = pd.concat(unique).reset_index(drop=True) |
| 648 | +# try: sets.drop([2, 3], axis=1, inplace=True) |
| 649 | +# except ValueError: pass |
| 650 | +# sets.rename(columns={'center': 'set', 0: 'alpha', 1: 'd'}, inplace=True) |
| 651 | +# sets['set'] = sets['set'].map(setmap) |
| 652 | +# sets['frame'] = 0 |
| 653 | +# return sets, setmap |
| 654 | +# |
| 655 | +# |
| 656 | +# def _expand_sp(unique): |
| 657 | +# expand = [] |
| 658 | +# for seht in unique: |
| 659 | +# if np.isnan(seht[2]).sum() == seht.shape[0]: |
| 660 | +# expand.append(seht) |
| 661 | +# continue |
| 662 | +# sps = seht[2][~np.isnan(seht[2])].index |
| 663 | +# shls = len(seht.ix[sps]['shell'].unique()) |
| 664 | +# dupl = seht.ix[sps[0]:sps[-1]].copy() |
| 665 | +# dupl[1] = dupl[2] |
| 666 | +# dupl['L'] = 1 |
| 667 | +# dupl['shell'] += shls |
| 668 | +# last = seht.ix[sps[-1] + 1:].copy() |
| 669 | +# last['shell'] += shls |
| 670 | +# expand.append(pd.concat([seht.ix[:sps[0] - 1], |
| 671 | +# seht.ix[sps[0]:sps[-1]], |
| 672 | +# dupl, last])) |
| 673 | +# return expand |
668 | 674 |
|
669 | 675 |
|
670 | 676 | def _basis_set_order(chunk, mapr, sets): |
|
0 commit comments