def test_faked_error_recovery(self): """ Run a calculation that *should* throw a symmetry error, and try to recover from the error. If CASTEP is not present, monkey patch such that ComputeTask copies the output files it would have expected. """ seed = REAL_PATH + "data/symmetry_failure/Sb.res" cell_dict, s = cell2dict(REAL_PATH + "/data/symmetry_failure/KSb.cell", verbosity=VERBOSITY, db=False) assert s param_dict, s = param2dict( REAL_PATH + "/data/symmetry_failure/KSb.param", verbosity=VERBOSITY, db=False, ) assert s ncores = 1 executable = REAL_PATH + "data/symmetry_failure/monkey_patch_move.sh" node = None relaxer = ComputeTask( ncores=ncores, nnodes=None, node=node, res=seed, param_dict=param_dict, cell_dict=cell_dict, verbosity=VERBOSITY, executable=executable, exec_test=False, polltime=1, start=False, ) with self.assertRaises(CalculationError): relaxer.begin() bad_castep_exists = isdir("bad_castep") completed_exists = isdir("completed") self.assertTrue(bad_castep_exists) self.assertFalse(completed_exists) self.assertTrue(relaxer.final_result is None) self.assertEqual(relaxer._num_retries, 3) self.assertTrue("symmetry_generate" not in relaxer.calc_doc) self.assertTrue("snap_to_symmetry" not in relaxer.calc_doc) self.assertTrue("symmetry_tol" not in relaxer.calc_doc)
def test_failed_relaxation(self): """ Set a relaxation up to fail. """ seed = "_LiAs_testcase.res" shutil.copy( REAL_PATH + "data/structures/LiAs_testcase_bad.res", "_LiAs_testcase.res" ) cell_dict, s = cell2dict( REAL_PATH + "/data/LiAs_tests/LiAs.cell", verbosity=VERBOSITY, db=False ) assert s param_dict, s = param2dict( REAL_PATH + "/data/LiAs_tests/LiAs.param", verbosity=VERBOSITY, db=False ) assert s param_dict["geom_max_iter"] = 3 executable = "castep" node = None shutil.copy(REAL_PATH + "data/pspots/Li_00PBE.usp", ".") shutil.copy(REAL_PATH + "data/pspots/As_00PBE.usp", ".") relaxer = ComputeTask( ncores=NCORES, nnodes=None, node=node, res=seed, param_dict=param_dict, cell_dict=cell_dict, verbosity=VERBOSITY, killcheck=True, memcheck=False, reopt=True, executable=executable, rough=0, fine_iter=3, start=False, ) with self.assertRaises(CalculationError): relaxer.begin() bad_exists = isfile("bad_castep/_LiAs_testcase.res") num = reset_job_folder() self.assertTrue(bad_exists, "couldn't find output file!") self.assertEqual(num, 0)
def test_missing_exec(self): """ Ensure failure if exec misses. """ cell_dict, s = cell2dict(REAL_PATH + "/data/LiAs_tests/LiAs.cell", verbosity=VERBOSITY, db=False) assert s param_dict, s = param2dict(REAL_PATH + "/data/LiAs_tests/LiAs.param", verbosity=VERBOSITY, db=False) assert s node = None nnodes = None seed = REAL_PATH + "/data/structures/LiAs_testcase.res" fall_over = False try: ComputeTask( ncores=NCORES, nnodes=nnodes, node=node, res=seed, param_dict=param_dict, cell_dict=cell_dict, verbosity=VERBOSITY, killcheck=True, reopt=False, executable="THIS WAS MEANT TO FAIL, DON'T WORRY", start=True, ) except CriticalError: fall_over = True self.assertTrue(fall_over)
def test_dont_restart_completed_calc(self): """ Set a relaxation up to fail. """ shutil.copy( REAL_PATH + "data/no_steps_left_todo/cache/NaP_intermediates_stopped_early.res", ".", ) shutil.copy( REAL_PATH + "data/no_steps_left_todo/cache/NaP_intermediates_stopped_early.castep", ".", ) cell_dict, s = cell2dict( REAL_PATH + "data/no_steps_left_todo/NaP.cell", verbosity=VERBOSITY, db=False, ) self.assertTrue(s) param_dict, s = param2dict( REAL_PATH + "data/no_steps_left_todo/NaP.param", verbosity=VERBOSITY, db=False, ) self.assertTrue(s) executable = "castep" node = None seed = "NaP_intermediates_stopped_early.res" with self.assertRaises(CalculationError): ComputeTask( ncores=NCORES, nnodes=None, node=node, res=seed, param_dict=param_dict, cell_dict=cell_dict, verbosity=VERBOSITY, killcheck=True, memcheck=False, exec_test=False, reopt=True, executable=executable, max_walltime=5, start=True, ) print("Process completed!") bad_exists = [] bad_exists.append( isfile("bad_castep/NaP_intermediates_stopped_early.res")) bad_exists.append( isfile("bad_castep/NaP_intermediates_stopped_early.castep")) bad_exists = all(bad_exists) good_exists = all( isdir(path) for path in ["input", "bad_castep", "logs"]) self.assertTrue(bad_exists) self.assertTrue(good_exists)
def test_benchmark_dual_core_scf(self): """ Test the time taken to perform a set number of SCF steps on 2 cores. CASTEP prints no total timing data for single core jobs. """ from os import makedirs seed = "_LiC.res" shutil.copy(REAL_PATH + "data/structures/LiC.res", "_LiC.res") cell_dict, s = cell2dict( REAL_PATH + "/data/benchmark/LiC_scf/LiC_scf.cell", verbosity=VERBOSITY, db=False, ) self.assertTrue(s) param_dict, s = param2dict( REAL_PATH + "/data/benchmark/LiC_scf/LiC_scf.param", verbosity=VERBOSITY, db=False, ) self.assertTrue(s) shutil.copy(REAL_PATH + "data/pspots/Li_00PBE.usp", ".") shutil.copy(REAL_PATH + "data/pspots/C_00PBE.usp", ".") with self.assertRaises(CalculationError): ComputeTask( ncores=2, nnodes=None, node=None, res=seed, param_dict=param_dict, cell_dict=cell_dict, verbosity=0, executable=EXECUTABLE, start=True, ) outputs_exist = [ isfile("bad_castep/_LiC.res"), isfile("bad_castep/_LiC.castep"), ] results, s = castep2dict("bad_castep/_LiC.castep", db=False) makedirs(REAL_PATH + "/data/benchmark/results", exist_ok=True) shutil.copy( "bad_castep/_LiC.castep", REAL_PATH + "/data/benchmark/results/_LiC_2core_castep{}.castep".format( results.get("castep_version", "xxx") ), ) self.assertTrue(all(outputs_exist), "couldn't find output files!") self.assertTrue(s, "couldn't read output files!") self.assertLess(results["_time_estimated"], 8)
def test_magres(self): for _f in glob.glob(REAL_PATH + "data/magres_workflow/*"): shutil.copy(_f, ".") cell_dict, _ = cell2dict("Si.cell", db=False) param_dict, _ = param2dict("Si.param", db=False) _ = ComputeTask( res="Si2.res", ncores=NCORES, nnodes=None, node=None, cell_dict=cell_dict, param_dict=param_dict, verbosity=VERBOSITY, compute_dir="tmpier_tst", workflow_kwargs={"final_elec_energy_tol": 1e-9}, ) self.assertTrue(os.path.isfile("completed/Si2.check")) self.assertTrue(os.path.isfile("completed/Si2.bands")) self.assertTrue(os.path.isfile("completed/Si2.castep")) self.assertTrue(os.path.isfile("completed/Si2.magres")) self.assertTrue(os.path.isfile("completed/Si2.cell_magres")) self.assertTrue(os.path.isfile("completed/Si2.param_magres")) self.assertTrue(os.path.isfile("completed/Si2.cell_scf")) self.assertTrue(os.path.isfile("completed/Si2.param_scf")) param, s = param2dict("completed/Si2.param_scf") self.assertTrue(s, msg="Failed to read param file") self.assertEqual(param["elec_energy_tol"], 1e-12) param, s = param2dict("completed/Si2.param_magres") self.assertEqual(param["elec_energy_tol"], 1e-12) self.assertTrue(s, msg="Failed to read param file") magres, s = magres2dict("completed/Si2.magres") self.assertTrue(s, msg="Failed to read magres file") a = 3.866895 np.testing.assert_array_almost_equal(magres["lattice_abc"], np.array([[a, a, a], [60, 60, 60]]), decimal=3) np.testing.assert_array_almost_equal(magres["chemical_shielding_isos"], np.array([129.577, 129.577]), decimal=2) self.assertTrue(os.path.isfile("completed/Si2.cell")) self.assertTrue(os.path.isfile("completed/Si2.res"))
def test_old_file(self): """ Run a calculation with an executable that only does "sleep", in the presence of a file that was written previouisly, and check that run3 will stop the calculation early as no file is written. """ seed = REAL_PATH + "data/symmetry_failure/Sb.res" with open("Sb.castep", "w") as f: f.write("I am a CASTEP file, for sure.") cell_dict, s = cell2dict(REAL_PATH + "/data/symmetry_failure/KSb.cell", verbosity=VERBOSITY, db=False) assert s param_dict, s = param2dict( REAL_PATH + "/data/symmetry_failure/KSb.param", verbosity=VERBOSITY, db=False, ) assert s executable = REAL_PATH + "data/missing_file_test/monkey_patch_sleep.sh" node = None relaxer = ComputeTask( ncores=NCORES, nnodes=None, node=node, res=seed, param_dict=param_dict, cell_dict=cell_dict, verbosity=VERBOSITY, executable=executable, exec_test=False, polltime=1, start=False, ) with self.assertRaises(CalculationError): relaxer.begin() self.assertTrue(relaxer.final_result is None)
def test_bulk_mod(self): for _f in glob.glob(REAL_PATH + "data/elastic_workflow/*"): shutil.copy(_f, ".") cell_dict, _ = cell2dict("bulk_mod.cell", db=False) param_dict, _ = param2dict("bulk_mod.param", db=False) _ = ComputeTask( res="Si2.res", ncores=NCORES, nnodes=None, node=None, cell_dict=cell_dict, param_dict=param_dict, verbosity=VERBOSITY, compute_dir="/tmp/scratch_test", workflow_kwargs={ "plot": False, "num_volumes": 5 }, ) self.assertFalse(os.path.isfile("completed/Si2.bib")) self.assertTrue(os.path.isfile("completed/Si2.check")) self.assertTrue(os.path.isfile("completed/Si2.bulk_mod.results")) self.assertTrue(os.path.isfile("completed/Si2.bulk_mod.res")) self.assertTrue(os.path.isfile("completed/Si2.bulk_mod.castep")) with open("completed/Si2.bulk_mod.results", "r") as f: flines = f.readlines() B = [] for line in flines: if "bulk modulus" in line: B.append(float(line.split()[3])) # check all computed bulk mods are between 88-92 self.assertEqual(len(B), 3) self.assertTrue(all(abs(b - 90) < 2) for b in B) self.assertFalse(os.path.isfile("completed/Si2.bulk_mod.pdf")) self.assertTrue(os.path.isfile("completed/Si2.res")) self.assertTrue(os.path.isfile("completed/Si2.geom")) self.assertTrue(os.path.isfile("completed/Si2.castep")) self.assertTrue(os.path.isfile("completed/Si2.bulk_mod.cell")) self.assertFalse(os.path.exists("/tmp/scratch_test")) self.assertFalse(os.path.exists("scratch_test_link"))
def test_scf(self): """ Perform SCF on structure from file. """ seed = "_LiC.res" shutil.copy(REAL_PATH + "data/structures/LiC.res", "_LiC.res") cell_dict, s = cell2dict(REAL_PATH + "/data/LiC_tests/LiC_scf.cell", verbosity=VERBOSITY, db=False) assert s param_dict, s = param2dict(REAL_PATH + "/data/LiC_tests/LiC_scf.param", verbosity=VERBOSITY, db=False) assert s executable = "castep" node = None shutil.copy(REAL_PATH + "data/pspots/Li_00PBE.usp", ".") shutil.copy(REAL_PATH + "data/pspots/C_00PBE.usp", ".") ComputeTask( ncores=NCORES, nnodes=None, node=node, res=seed, param_dict=param_dict, cell_dict=cell_dict, verbosity=VERBOSITY, killcheck=True, reopt=True, executable=executable, compute_dir="/tmp/compute_test", start=True, ) completed_exists = [ isfile("completed/_LiC.res"), isfile("completed/_LiC.castep"), isfile("completed/_LiC-out.cell"), ] base_file_exists = [ isfile("_LiC.res"), isfile("_LiC.castep"), isfile("_LiC.res.lock"), ] self.assertFalse(any(base_file_exists), "failed to clean up files!") self.assertTrue(all(completed_exists), "couldn't find output files!")
def test_memcheck(self): """ Test the memory checker will not proceed with huge jobs. """ shutil.copy( REAL_PATH + "data/structures/LiAs_testcase.res", "_LiAs_testcase.res" ) shutil.copy(REAL_PATH + "data/pspots/Li_00PBE.usp", ".") shutil.copy(REAL_PATH + "data/pspots/As_00PBE.usp", ".") cell_dict, s = cell2dict( REAL_PATH + "data/LiAs_tests/LiAs.cell", verbosity=VERBOSITY, db=False ) self.assertTrue(s) param_dict, s = param2dict( REAL_PATH + "data/LiAs_tests/LiAs.param", verbosity=VERBOSITY, db=False ) self.assertTrue(s) with self.assertRaises(MaxMemoryEstimateExceeded): ComputeTask( ncores=NCORES, nnodes=None, node=None, res="_LiAs_testcase.res", param_dict=param_dict, cell_dict=cell_dict, verbosity=VERBOSITY, killcheck=True, memcheck=True, maxmem=1, start=True, ) files_that_should_not_exist = ["_LiAs_testcase.res.lock", "jobs.txt"] folders_that_should_exist = ["logs"] folders_that_should_not_exist = ["bad_castep", "input", "completed"] correct_files = all( [not isfile(_file) for _file in files_that_should_not_exist] ) correct_folders = all([isdir(folder) for folder in folders_that_should_exist]) correct_folders *= all( [not isdir(folder) for folder in folders_that_should_not_exist] ) self.assertTrue(correct_folders) self.assertTrue(correct_files)
def test_relax_to_file(self): """ Relax structure from file to file. """ seed = "_Li.res" shutil.copy(REAL_PATH + "data/structures/Li.res", "_Li.res") cell_dict, s = cell2dict(REAL_PATH + "/data/LiAs_tests/LiAs.cell", verbosity=VERBOSITY, db=False) assert s param_dict, s = param2dict(REAL_PATH + "/data/LiAs_tests/LiAs.param", verbosity=VERBOSITY, db=False) assert s executable = "castep" node = None shutil.copy(REAL_PATH + "data/pspots/Li_00PBE.usp", ".") shutil.copy(REAL_PATH + "data/pspots/As_00PBE.usp", ".") ComputeTask( ncores=NCORES, nnodes=None, node=node, res=seed, param_dict=param_dict, cell_dict=cell_dict, verbosity=VERBOSITY, killcheck=True, reopt=True, executable=executable, exec_test=False, start=True, ) print("Process completed!") completed_exists = isfile("completed/_Li.res") base_files_exist = [ isfile("_Li.res"), isfile("_Li.res.lock"), isfile("_Li.castep"), ] self.assertTrue(completed_exists, "couldn't find output file!") self.assertFalse(any(base_files_exist), "couldn't clean input files")
def test_phonon(self): for _f in glob.glob(REAL_PATH + "data/phonon_workflow/*"): shutil.copy(_f, ".") cell_dict, _ = cell2dict("Si.cell", db=False) param_dict, _ = param2dict("Si.param", db=False) _ = ComputeTask( res="Si2.res", ncores=NCORES, nnodes=None, node=None, cell_dict=cell_dict, param_dict=param_dict, verbosity=VERBOSITY, compute_dir="tmpier_tst", ) self.assertFalse(os.path.isfile("completed/Si2.bib")) self.assertTrue(os.path.isfile("completed/Si2.check")) self.assertTrue(os.path.isfile("completed/Si2.bands")) self.assertTrue(os.path.isfile("completed/Si2.castep")) self.assertTrue(os.path.isfile("completed/Si2.phonon")) self.assertTrue(os.path.isfile("completed/Si2.phonon_dos")) phon, s = phonon2dict("completed/Si2.phonon") a = 2.7355124 np.testing.assert_array_almost_equal(phon["lattice_cart"], np.array([[0, a, a], [a, 0, a], [a, a, 0]]), decimal=3) a = 3.869 np.testing.assert_array_almost_equal(phon["lattice_abc"], np.array([[a, a, a], [60, 60, 60]]), decimal=3) self.assertTrue(s, msg="Failed to read phonon file") self.assertGreater(np.min(phon["eigenvalues_q"]), -0.05) self.assertTrue(os.path.isfile("completed/Si2.cell")) self.assertTrue(os.path.isfile("completed/Si2.res"))
def test_scf_max_walltime(self): """ Perform SCF on structure from file. """ seed = "_LiC.res" shutil.copy(REAL_PATH + "data/structures/LiC.res", "_LiC.res") cell_dict, s = cell2dict(REAL_PATH + "/data/LiC_tests/LiC_scf.cell", verbosity=VERBOSITY, db=False) assert s param_dict, s = param2dict(REAL_PATH + "/data/LiC_tests/LiC_scf.param", verbosity=VERBOSITY, db=False) assert s executable = "castep" node = None shutil.copy(REAL_PATH + "data/pspots/Li_00PBE.usp", ".") shutil.copy(REAL_PATH + "data/pspots/C_00PBE.usp", ".") with self.assertRaises(WalltimeError): ComputeTask( ncores=NCORES, nnodes=None, node=node, res=seed, param_dict=param_dict, cell_dict=cell_dict, verbosity=VERBOSITY, timings=(5, time.time()), polltime=2, executable=executable, compute_dir="/tmp/compute_test", start=True, ) base_file_exists = [ isfile("_LiC.res"), isfile("_LiC.castep"), ] self.assertFalse(isfile("_LiC.res.lock"), "failed to clean up lock") self.assertTrue(all(base_file_exists), "failed to keep valid files!")
def test_full_spectral(self): for _f in glob.glob(REAL_PATH + "data/spectral_workflow/*"): shutil.copy(_f, ".") cell_dict, _ = cell2dict("Si.cell") param_dict, _ = param2dict("Si.param", db=False) _ = ComputeTask( res="Si2.res", ncores=NCORES, nnodes=None, node=None, cell_dict=cell_dict, param_dict=param_dict, verbosity=VERBOSITY, compute_dir=None, ) self.assertFalse(os.path.isfile("completed/Si2.bib")) self.assertTrue(os.path.isfile("completed/Si2.check")) self.assertTrue(os.path.isfile("completed/Si2-out.cell_dispersion")) self.assertTrue(os.path.isfile("completed/Si2-out.cell_dos")) self.assertTrue(os.path.isfile("completed/Si2-out.cell_scf")) self.assertTrue(os.path.isfile("completed/Si2.adaptive.agr")) self.assertTrue(os.path.isfile("completed/Si2.adaptive.dat")) self.assertTrue(os.path.isfile("completed/Si2.bands")) self.assertTrue(os.path.isfile("completed/Si2.bands_dispersion")) self.assertTrue(os.path.isfile("completed/Si2.bands_dos")) self.assertTrue(os.path.isfile("completed/Si2.castep")) self.assertTrue(os.path.isfile("completed/Si2.castep_bin")) self.assertTrue(os.path.isfile("completed/Si2.castep_dispersion")) self.assertTrue(os.path.isfile("completed/Si2.castep_dos")) self.assertTrue(os.path.isfile("completed/Si2.castep_scf")) self.assertTrue(os.path.isfile("completed/Si2.cell")) self.assertTrue(os.path.isfile("completed/Si2.cell_dispersion")) self.assertTrue(os.path.isfile("completed/Si2.cell_dos")) self.assertTrue(os.path.isfile("completed/Si2.cell_scf")) self.assertTrue(os.path.isfile("completed/Si2.cst_esp")) self.assertTrue(os.path.isfile("completed/Si2.dome_bin")) self.assertTrue(os.path.isfile("completed/Si2.dome_bin_broadening")) self.assertTrue(os.path.isfile("completed/Si2.dome_bin_dispersion")) self.assertTrue(os.path.isfile("completed/Si2.dome_bin_dos")) self.assertTrue(os.path.isfile("completed/Si2.dome_bin_pdos")) self.assertTrue(os.path.isfile("completed/Si2.odi")) self.assertTrue(os.path.isfile("completed/Si2.odi_broadening")) self.assertTrue(os.path.isfile("completed/Si2.odi_pdis")) self.assertTrue(os.path.isfile("completed/Si2.odi_pdos")) self.assertTrue(os.path.isfile("completed/Si2.odo")) self.assertTrue(os.path.isfile("completed/Si2.odo_broadening")) self.assertTrue(os.path.isfile("completed/Si2.odo_pdis")) self.assertTrue(os.path.isfile("completed/Si2.odo_pdos")) self.assertTrue(os.path.isfile("completed/Si2.param")) self.assertTrue(os.path.isfile("completed/Si2.param_dispersion")) self.assertTrue(os.path.isfile("completed/Si2.param_dos")) self.assertTrue(os.path.isfile("completed/Si2.param_scf")) self.assertTrue(os.path.isfile("completed/Si2.pdis.dat")) self.assertTrue(os.path.isfile("completed/Si2.pdos.dat")) self.assertTrue(os.path.isfile("completed/Si2.pdos_bin")) self.assertTrue(os.path.isfile("completed/Si2.pdos_bin_broadening")) self.assertTrue(os.path.isfile("completed/Si2.pdos_bin_dispersion")) self.assertTrue(os.path.isfile("completed/Si2.pdos_bin_dos")) self.assertTrue(os.path.isfile("completed/Si2.pdos_bin_pdis")) self.assertTrue(os.path.isfile("completed/Si2.pdos_bin_pdos")) self.assertTrue(os.path.isfile("completed/Si2.res"))
def test_relax_to_queue(self): """ Mimic GA and test Queue relaxations. """ newborn, s = res2dict( REAL_PATH + "/data/structures/LiAs_testcase.res", verbosity=VERBOSITY, db=False, ) assert s cell_dict, s = cell2dict(REAL_PATH + "/data/LiAs_tests/LiAs.cell", verbosity=VERBOSITY, db=False) assert s param_dict, s = param2dict(REAL_PATH + "/data/LiAs_tests/LiAs.param", verbosity=VERBOSITY, db=False) assert s node = None executable = "castep" newborn["source"] = [REAL_PATH + "/data/GA_TESTCASE.res"] shutil.copy(REAL_PATH + "data/pspots/Li_00PBE.usp", ".") shutil.copy(REAL_PATH + "data/pspots/As_00PBE.usp", ".") queue = mp.Queue() relaxer = ComputeTask( ncores=NCORES, nnodes=None, node=node, res=newborn, param_dict=param_dict, cell_dict=cell_dict, verbosity=VERBOSITY, killcheck=True, reopt=False, executable=executable, output_queue=queue, start=True, ) # store proc object with structure ID, node name, output queue and number of cores proc = (1, node, mp.Process(target=relaxer.relax), NCORES) proc[2].start() while proc[2].is_alive(): time.sleep(1) result, success = castep2dict("completed/GA_TESTCASE.castep") queue_result = queue.get() match_dict = dict() for key in queue_result: if key in ["source", "site_occupancy", "geom_iter"]: continue match_dict[key] = queue_result[key] == result[key] if not match_dict[key]: print(key, queue_result[key], result[key]) completed_exists = isfile("completed/GA_TESTCASE.res") input_exists = isfile("input/GA_TESTCASE.res") self.assertTrue(completed_exists, "couldn't find output file!") self.assertTrue(input_exists, "couldn't find shutil.copy of input file!") self.assertTrue(success, "couldn't parse output file!") self.assertTrue(all([match_dict[key] for key in match_dict]))
def test_benchmark_manycore_scf(self): """ Test the time taken to perform a set number of SCF steps on many cores. """ from os import makedirs seed = "_LiC.res" shutil.copy(REAL_PATH + "data/structures/LiC.res", "_LiC.res") cell_dict, s = cell2dict( REAL_PATH + "/data/benchmark/LiC_scf/LiC_scf.cell", verbosity=VERBOSITY, db=False, ) self.assertTrue(s) param_dict, s = param2dict( REAL_PATH + "/data/benchmark/LiC_scf/LiC_scf.param", verbosity=VERBOSITY, db=False, ) self.assertTrue(s) shutil.copy(REAL_PATH + "data/pspots/Li_00PBE.usp", ".") shutil.copy(REAL_PATH + "data/pspots/C_00PBE.usp", ".") with self.assertRaises(CalculationError): ComputeTask( ncores=NCORES, nnodes=None, node=None, res=seed, param_dict=param_dict, cell_dict=cell_dict, verbosity=0, executable=EXECUTABLE, start=True, ) outputs_exist = [ isfile("bad_castep/_LiC.res"), isfile("bad_castep/_LiC.castep"), ] results, s = castep2dict("bad_castep/_LiC.castep", db=False) makedirs(REAL_PATH + "/data/benchmark/results", exist_ok=True) shutil.copy( "bad_castep/_LiC.castep", REAL_PATH + "/data/benchmark/results/_LiC_{}core_castep{}.castep".format( results.get("num_mpi_processes", 0), results.get("castep_version", "xxx"), ), ) self.assertTrue(all(outputs_exist), "couldn't find output files!") self.assertTrue(s, "couldn't read output files!") print(results["_time_estimated"]) benchmark_data = {2: 2 * 7.4, 4: 4 * 4.0, 12: 16.8, 14: 22.4, 18: 23.4} warnings.warn( RuntimeWarning( "Run took {} s with {} MPI processes, with cumulative CPU time of {:.1f} s. Benchmark data\n = {}" .format( results["_time_estimated"], results["num_mpi_processes"], results["_time_estimated"] * results["num_mpi_processes"], benchmark_data, )))