if __name__ == '__main__': elements = ['Pd', 'O'] rcuts = None powers = {'O-Pd': range(2, 7), 'O-O': range(2, 7), 'Pd-Pd': range(2, 7)} kptdensity = 3.0 calc = TANGO( elements, DftCalc=CP2KCalculator, DftbPlusCalc=DftbPlusCalculator, kptdensity=kptdensity, initial_training='random_vc_relax', generator=generator, maximum_angular_momenta={ 'Pd': 2, 'O': 1 }, rcuts=rcuts, powers=powers, update_rcuts=False, kBT=1., comparator=comparator, max_select=20, ) os.environ['ASE_CP2K_COMMAND'] = 'mpirun -np 20 cp2k_shell.popt' N = 1 for i in range(5): calc.run(steps=1, go_steps=0,
dbfiles = ['training.db'] force_scaling = 0.0 # how the forces should be weighted w.r.t. the forces; # this does not matter here because the forces are zero by symmetry rcov = covalent_radii[atomic_numbers['Si']] rcuts = { 'Si-Si': 1.5 * 2 * rcov } # 'outer' cutoff as approximately 1.5 times the NN distance rmins = { 'Si-Si': 0.8 * 2 * rcov } # 'inner' cutoff below which we switch to exponential repulsion powers = { 'Si-Si': range(2, 7) } # standard (rcut-r)**2 + ... + (rcut-r)**6 polynomial calc = TANGO( elements, DftbPlusCalc=DftbPlusCalculator, kptdensity=kptdensity, rmins=rmins, rcuts=rcuts, powers=powers, fit_constant=fit_constant, kBT=kBT, mode=mode, force_scaling=force_scaling, maximum_angular_momenta=mam, ) residual = calc.fit_repulsion(dbfiles, run_checks=True) print('Residual:', residual)
dimersdbfile = 'dimers.' + dbext atomicfile = 'atomic_energies.json' generate_training_data(dbext) with open(atomicfile, 'r') as f: atomic_energies = json.load(f) for mode in ['poly', 'exp_poly', 'exp_spline']: rmins = {pair: 0.7 * 2 * rcov} if mode == 'exp_poly' else None powers = {pair: range(2, 7) if 'poly' in mode else range(4)} calc = TANGO([element], DftCalc=None, DftbPlusCalc=DftbPlusCalc, mode=mode, kptdensity=None, maximum_angular_momenta=mam, fit_constant='element', kBT=2.0, force_scaling=0., rcuts=rcuts, rmins=rmins, powers=powers) residual = calc.fit_repulsion([dbfile], run_checks=False, atomic_energies=atomic_energies, dimersdb=dimersdbfile) suffix = '%s_%s' % (dbext, mode) assert residual < 0.02, (suffix, residual) os.system('mv %s.pdf %s_%s.pdf' % (pair, pair, suffix))
if __name__=='__main__': elements = ['Xx'] rcov = covalent_radii[atomic_numbers['Xx']] rcuts = {'Xx-Xx': 1.5 * 2 * rcov} rmins = {'Xx-Xx': 0.6 * 2 * rcov} powers = {'Xx-Xx': range(2, 4)} kptdensity = 1.5 calc = TANGO(elements, DftCalc=CP2KCalculator, DftbPlusCalc=DftbPlusCalc, kptdensity=kptdensity, initial_training='random_vc_relax', generator=generator, maximum_angular_momenta={'Xx': MAM}, mode='exp_poly', rcuts=rcuts, rmins=rmins, powers=powers, kBT=10., comparator=comparator, max_select=20, ) N = 1 calc.run(steps=1, go_steps=0, recalculate_dftb=True, run_go=run, number_of_go_runs=2, restart_go=True) N = 4 calc.run(steps=1, go_steps=10, recalculate_dftb=True, run_go=run, number_of_go_runs=2, restart_go=True)
mam = {'C': 1, 'N': 1} dbfile = 'training.json' if os.path.exists(dbfile): os.remove(dbfile) generate_database(dbfile, rc) for mode in ['poly', 'exp_poly', 'exp_spline']: powers = {pair: range(2, 7) if 'poly' in mode else range(4)} rmins = {pair: rmin} if 'exp' in mode else None calc = TANGO( elements, DftCalc=None, DftbPlusCalc=DftbPlusCalc, mode=mode, kptdensity=None, maximum_angular_momenta=mam, fit_constant=None, kBT=2., force_scaling=1., rcuts=rcuts, rmins=rmins, powers=powers, referencing=[range(18), [18, 19]], ) residual = calc.fit_repulsion([dbfile], run_checks=False) eps = 1e-6 if 'poly' in mode else 1e-2 assert residual < eps, (mode, residual, eps) os.system('mv %s.pdf %s_%s.pdf' % (pair, pair, mode))