def test_selective_dynamics(self): output_filename = os.path.join(test_dir, "vasprun.xml.indirect.gz") vr = Vasprun(output_filename) # assert that the max force is above the threshold max_constrained = np.max(np.linalg.norm(vr.ionic_steps[-1]['forces'], axis=1)) self.assertTrue(max_constrained > 0.5) handler = MaxForceErrorHandler(output_filename, max_force_threshold=0.5) self.assertFalse(handler.check())
def test_check_correct(self): #NOTE: the vasprun here has had projected and partial eigenvalues removed subdir = os.path.join(test_dir, "max_force") os.chdir(subdir) shutil.copy("INCAR", "INCAR.orig") shutil.copy("POSCAR", "POSCAR.orig") h = MaxForceErrorHandler() self.assertTrue(h.check()) d = h.correct() self.assertEqual(d["errors"], ['MaxForce']) os.remove(os.path.join(subdir, "error.1.tar.gz")) incar = Incar.from_file('INCAR') poscar = Poscar.from_file('POSCAR') contcar = Poscar.from_file('CONTCAR') shutil.move("INCAR.orig", "INCAR") shutil.move("POSCAR.orig", "POSCAR") self.assertEqual(poscar.structure, contcar.structure) self.assertAlmostEqual(incar['EDIFFG'], 0.005)