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))
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)
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))