Beispiel #1
0
 def testWithNumericalForceWithPBCEnabled(self):
     atoms = Diamond(symbol="C", pbc=True)
     calculator = torchani.models.ANI1x().ase()
     atoms.set_calculator(calculator)
     dyn = Langevin(atoms, 5 * units.fs, 30000000 * units.kB, 0.002)
     dyn.run(100)
     f = torch.from_numpy(atoms.get_forces())
     fn = get_numeric_force(atoms, 0.001)
     df = (f - fn).abs().max()
     avgf = f.abs().mean()
     if avgf > 0:
         self.assertLess(df / avgf, 0.1)
Beispiel #2
0
 def testWithNumericalForceWithPBCEnabled(self):
     # Run a Langevin thermostat dynamic for 100 steps and after the dynamic
     # check once that the numerical and analytical force agree to a given
     # relative tolerance
     atoms = Diamond(symbol="C", pbc=True)
     calculator = self.model.ase()
     atoms.set_calculator(calculator)
     dyn = Langevin(atoms, 5 * units.fs, 30000000 * units.kB, 0.002)
     dyn.run(100)
     f = atoms.get_forces()
     fn = get_numeric_force(atoms, 0.001)
     self.assertEqual(f, fn, rtol=0.1, atol=0.1)
Beispiel #3
0
 def _testForce(self, pbc):
     atoms = Diamond(symbol="C", pbc=pbc)
     builtin = torchani.neurochem.Builtins()
     calculator = torchani.ase.Calculator(
         builtin.species, builtin.aev_computer,
         builtin.models, builtin.energy_shifter)
     atoms.set_calculator(calculator)
     dyn = Langevin(atoms, 5 * units.fs, 30000000 * units.kB, 0.002)
     dyn.run(100)
     f = torch.from_numpy(atoms.get_forces())
     fn = get_numeric_force(atoms, 0.001)
     df = (f - fn).abs().max()
     avgf = f.abs().mean()
     if avgf > 0:
         self.assertLess(df / avgf, 0.1)