def parse_basis_set(self):
"""
Parses the primitive exponents, coefficients and shell if BSSHOW specified in SEWARD.
"""
found = self.find(_re_bas_0, _re_bas_1, _re_bas_2, keys_only=True)
bmaps = [i + 1 for i in found[_re_bas_0]]
atoms = [i + 2 for i in found[_re_bas_1]]
alphs = [i + 1 for i in found[_re_bas_2]]
widths = [11, 7, 8, 11, 10, 12]
names = _re_bas_0.split()
setmap, basmap = {}, []
for seht, (start, atst) in enumerate(zip(bmaps, atoms)):
stop = start
while self[stop].strip(): stop += 1
while self[atst].strip():
setmap[self[atst].split()[0]] = seht
atst += 1
basmap.append(pd.read_fwf(StringIO('\n'.join(self[start:stop])),
widths=widths, header=None, names=names))
basmap[-1]['set'] = seht
self.atom['set'] = self.atom['tag'].map(setmap)
basmap = pd.concat(basmap).reset_index(drop=True)
basmap['Shell'] = basmap['Shell'].map(lmap)
prims, pset, shell = [], 0, 0
for start, seht, L, nprim, nbas in zip(alphs, basmap['set'], basmap['Shell'],
basmap['nPrim'], basmap['nBasis']):
if pset != seht: shell = 0
# In case contraction coefficients overflow to next line
neat = len(self[start].split()) == len(self[start + 1].split())
if neat: block = self.pandas_dataframe(start, start + nprim, nbas + 2)
else:
stop = start + 2 * nprim
most = self[start:stop:2]
extr = self[start + 1:stop:2]
ncols = len(most[0].split()) + len(extr[0].split())
block = pd.read_csv(StringIO('\n'.join([i + j for i, j in zip(most, extr)])),
delim_whitespace=True, names=range(ncols))
alps = (pd.concat([block[1]] * nbas).reset_index(drop=True)
.str.replace('D', 'E').astype(np.float64))
ds = block[list(range(2, nbas + 2))].unstack().reset_index(drop=True)
pdf = pd.concat([alps, ds], axis=1)
pdf.columns = ['alpha', 'd']
pdf['L'] = L
pdf['shell'] = np.repeat(range(shell, shell + nbas), nprim)
pdf['set'] = seht
prims.append(pdf)
shell += nbas
pset = seht
prims = pd.concat(prims).reset_index(drop=True)
prims['frame'] = 0
self.basis_set = prims
评论列表
文章目录