output.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:exatomic 作者: exa-analytics 项目源码 文件源码
def parse_basis_set(self):
        # Find the basis set
        start = self.find(_re_bas_00, keys_only=True)[-1] + 3
        stopa = self.find_next(_re_bas_01, start=start, keys_only=True)
        stopb = self.find_next(_re_bas_02, start=start, keys_only=True)
        try: stop = min(stopa, stopb)
        except TypeError: stop = stopa
        # Grab everything
        df = pd.read_fwf(StringIO('\n'.join(self[start:stop])),
                         widths=[4, 2, 12, 4],
                         names=['n', 'L', 'alpha', 'symbol'])
        # Where atom types change
        idxs = [0] + df['n'][df['n'] == '---'].index.tolist() + [df.shape[0]]
        sets, shells = [], []
        for i, (start, stop) in enumerate(zip(idxs, idxs[1:])):
            sets.append(np.repeat(i - 1, stop - start))
            shells.append(np.arange(-1, stop - start - 1))
        df['set'] = np.concatenate(sets)
        df['shell'] = np.concatenate(shells)
        # Atom table basis set map
        basmap = df['symbol'].dropna()
        basmap = basmap[basmap.str.endswith(')')].str.strip(')')
        basmap = {val: df['set'][key] + 1 for
                  key, val in basmap.to_dict().items()}
        # Discard the garbage
        drop = df['n'].str.strip().str.isnumeric().fillna(False)
        df.drop(drop[drop == False].index, inplace=True)
        df.drop('symbol', axis=1, inplace=True)
        # Clean up the series
        df['alpha'] = df['alpha'].astype(np.float64)
        df['n'] = df['n'].astype(np.int64)
        df['L'] = df['L'].str.lower().map(lmap)
        df['d'] = np.sqrt((2 * df['L'] + 1) / (4 * np.pi))
        df['r'] = df['n'] - (df['L'] + 1)
        df['frame'] = 0
        self.basis_set = BasisSet(df, gaussian=False, spherical=False)
        self.atom['set'] = self.atom['symbol'].map(basmap)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号