コード例 #1
0
 def do_check(self, pot, **kwargs):
     cgd = CGDescent(_xrand, pot, **kwargs)
     res = cgd.run()
     self.assertAlmostEqual(res.energy, _emin, 4)
     self.assertTrue(res.success)
     self.assertLess(np.max(np.abs(res.coords - _xmin)), 1e-2)
     self.assertGreater(res.nfev, 0)
コード例 #2
0
    def test_reset(self):
        cgd1 = CGDescent(self.x0, self.pot)
        cgd1.run()
        res1 = cgd1.get_result()

        x2 = self.x0.copy()
        x2[1] = 2.
        cgd2 = CGDescent(x2, self.pot)
        cgd2.reset(self.x0)
        cgd2.run()
        res2 = cgd2.get_result()

        self.assertEqual(res1.rms, res2.rms)
        self.assertEqual(res1.nfev, res2.nfev)
        self.assertEqual(res1.nsteps, res2.nsteps)
        self.assertTrue(np.all(res1.coords == res2.coords))
コード例 #3
0
ファイル: pele_quenches.py プロジェクト: spraharsh/basinerror
def quench_pycg_descent(pot, x0, nsteps=2000, **kwargs):
    """ "subroutine" for quenching using cvode.
    Parameters
    ----------
    pot: BasePotential
        potential to quench
    x0: ndarray[ndim*nparticles]
        initial coordinates
    nsteps: int
        maximum number of steps
    """
    cgd = CGDescent(pot, x0, **kwargs)
    res = cgd.run(nsteps)
    return res_to_dict(res)
コード例 #4
0
 def test_result(self):
     cgd = CGDescent(_xrand, _EG())
     res = cgd.run()
     self.assertIn("gnorm", res)
     self.assertIn("itersub", res)
     self.assertIn("numsub", res)
     self.assertIn("nfunc", res)
     self.assertIn("ngrad", res)
     self.assertIn("energy", res)
     self.assertIn("grad", res)
     self.assertIn("success", res)
     self.assertIn("coords", res)
     self.assertIn("rms", res)
     self.assertIn("nsteps", res)
     self.assertIn("nfev", res)
コード例 #5
0
 def test_raises(self):
     pot = _lj_cpp._ErrorPotential()
     with self.assertRaises(RuntimeError):
         cgd = CGDescent(_xrand, pot)
         cgd.run()
コード例 #6
0
 def test_run_niter(self):
     cgd1 = CGDescent(_xrand, _EG())
     res1 = cgd1.run()
     cgd2 = CGDescent(_xrand, _EG())
     res2 = cgd2.run(res1.nsteps)
     self.assert_same(res1, res2)
コード例 #7
0
 def test_raises(self):
     with self.assertRaises(NotImplementedError):
         cgd = CGDescent(_xrand, _Raise())
         cgd.run()