def setup_solids(): with app.context(): aims_data, ds = app.get('solids') aims_data_atoms = aims_data['atoms'].assign(ene=lambda x: x.data.apply( lambda y: y['energy'][0]['value'][0] if y else None, 1)).groupby('symbol').apply( lambda x: x.iloc[x.reset_index()['ene'].idxmin()]['data']) aims_data['solids'].sort_index(inplace=True) for species, data in aims_data_atoms.items(): n = len(aims_data['solids'].loc(0)[:, :, species]) aims_data['solids'].loc[_I[:, :, species], 'data'] = n * [data] pts = pd.concat( dict( aims_data['solids'].gridfile.loc[:, [1.], ['crystal']] .apply(lambda x: pd.read_hdf(x)) ), names='label scale fragment i_point'.split() )['i_atom part_weight rho rho_grad_norm kin_dens'.split()] \ .set_index('i_atom', append=True) \ .assign(kin_dens=lambda x: x.kin_dens/2) alpha_vvs = pd.concat( { C_vv: pts.pipe(calc_vvpol, mbd.omega_grid[0], C=C_vv).groupby( 'label scale fragment i_atom'.split()).sum() for C_vv in [0.0093, 0.0101] }, names=['C_vv']) return aims_data['solids'], pts, ds, alpha_vvs
def setup_C6_set(): coords = (pd.read_hdf(resource_filename( 'mbdvv', 'data/C6-data.h5'), 'coords').reset_index().rename( { 'system': 'label', 'level_1': 'i_atom' }, axis=1).assign(i_atom=lambda x: x.i_atom + 1).set_index( 'label i_atom'.split())) with app.context(): aims_data = app.get('C6s') hirsh = { label: data['volumes'] / data['free_atoms']['volumes'][data['free_atoms']['species'] - 1] for (label, _, _), data, _ in aims_data.itertuples() } hirsh = pd.DataFrame([(label, i, val) for label, arr in hirsh.items() for i, val in enumerate(arr)], columns='label i_atom hirsh'.split()).set_index( 'label i_atom'.split()).hirsh ref = (pd.read_hdf(resource_filename('mbdvv', 'data/C6-data.h5'), 'C6_ref').set_index('system1 system2'.split())) pts = pd.concat( dict( aims_data['gridfile'] .loc[:, 1., 'main'] .apply(lambda x: pd.read_hdf(x)) ), names=('label', 'i_point') )['i_atom part_weight rho rho_grad_norm kin_dens'.split()] \ .set_index('i_atom', append=True) return coords, hirsh, ref, pts
def setup_x23(): with app.context(): aims_data, ds, alpha_vvs = app.get('x23') alpha_vvs = pd.concat( { C: pd.read_hdf(alpha_vv['alpha.h5'].path) for C, alpha_vv in alpha_vvs.items() }, names=['C_vv']) alpha_vvs.index = alpha_vvs.index.set_names('label', 1) return aims_data, ds, alpha_vvs
def integrate_atomic_vv(dsname=None, C=None): from pymbd import MBDCalc import pandas as pd from mbdvv.app import app from mbdvv.functasks import evaluate_vv_batch from multiprocessing import Pool with app.context(): df = app.get(dsname)[0] with MBDCalc(4) as mbd_calc: freq = mbd_calc.omega_grid[0] args_list = [(key, x, freq, C) for key, x in df.gridfile.groupby('label')] with Pool() as pool: pd.concat(dict(pool.starmap(evaluate_vv_batch, args_list))).to_hdf('alpha.h5', 'alpha')
def setup_layered(): with app.context(): return app.get('layered')
def setup_surface(): with app.context(): return app.get('surface')