def test_setup(self): with cd(test_dir): with ScratchDir('.', copy_from_current_on_enter=True) as d: v = VaspJob("hello") v.setup() incar = Incar.from_file("INCAR") count = multiprocessing.cpu_count() if count > 1: self.assertGreater(incar["NPAR"], 1)
def test_setup(self): with cd(test_dir): with ScratchDir('.', copy_from_current_on_enter=True) as d: v = VaspJob("hello", auto_npar=True) v.setup() incar = Incar.from_file("INCAR") count = multiprocessing.cpu_count() # Need at least 3 CPUs for NPAR to be greater than 1 if count > 3: self.assertGreater(incar["NPAR"], 1)
def test_setup_run_no_kpts(self): # just make sure v.setup() and v.run() exit cleanly when no KPOINTS file is present with cd(os.path.join(test_dir, "kspacing")): with ScratchDir(".", copy_from_current_on_enter=True): v = VaspJob("hello", auto_npar=True) v.setup() with self.assertRaises(FileNotFoundError): # a FileNotFoundError indicates that v.run() tried to run # subprocess.Popen(cmd, stdout=f_std, stderr=f_err) with # cmd == "hello", so it successfully parsed the input file # directory. v.run()
def test_setup(self): os.chdir(test_dir) v = VaspJob("hello") v.setup() incar = Incar.from_file("INCAR") count = multiprocessing.cpu_count() if count > 1: self.assertGreater(incar["NPAR"], 1) shutil.copy("INCAR.orig", "INCAR") os.remove("INCAR.orig") os.remove("KPOINTS.orig") os.remove("POTCAR.orig") os.remove("POSCAR.orig")
def test_continue(self): # Test the continuation functionality with cd(os.path.join(test_dir, 'postprocess')): # Test default functionality with ScratchDir('.', copy_from_current_on_enter=True) as d: v = VaspJob("hello", auto_continue=True) v.setup() self.assertTrue(os.path.exists("continue.json"), "continue.json not created") v.setup() self.assertEqual(Poscar.from_file("CONTCAR").structure, Poscar.from_file("POSCAR").structure) self.assertEqual(Incar.from_file('INCAR')['ISTART'], 1) v.postprocess() self.assertFalse(os.path.exists("continue.json"), "continue.json not deleted after postprocessing") # Test explicit action functionality with ScratchDir('.', copy_from_current_on_enter=True) as d: v = VaspJob("hello", auto_continue=[{"dict": "INCAR", "action": {"_set": {"ISTART": 1}}}]) v.setup() v.setup() self.assertNotEqual(Poscar.from_file("CONTCAR").structure, Poscar.from_file("POSCAR").structure) self.assertEqual(Incar.from_file('INCAR')['ISTART'], 1) v.postprocess()