}, } } # ------------------------------------------------------------------------------ # Set up the first calculation calc1 = code.new_calc() calc1.use_structure(structure1) calc1.use_parameters(ParameterData(dict=params1)) calc1.set_max_wallclock_seconds(2 * 60) calc1.set_resources({"num_machines": 1}) calc1.store_all() calc1.submit() print("submitted calculation 1: PK=%s" % calc1.pk) wait_for_calc(calc1) # check walltime exceeded assert calc1.res.exceeded_walltime is True assert calc1.res.energy is not None assert calc1.out.output_structure is not None print("OK, walltime exceeded as expected") # ------------------------------------------------------------------------------ # Set up and start the second calculation # parameters params2 = deepcopy(calc1.inp.parameters.get_dict()) del (params2['GLOBAL']['WALLTIME']) del (params2['MOTION']['GEO_OPT']['MAX_FORCE']) restart_wfn_fn = './parent_calc/aiida-RESTART.wfn'
], }, } }) calc.use_parameters(parameters) # resources calc.set_max_wallclock_seconds(3 * 60) # 3 min calc.set_resources({"num_machines": 1}) # store and submit calc.store_all() calc.submit() print("submitted calculation: PK=%s" % calc.pk) wait_for_calc(calc) # check energy expected_energy = -17.1566361119 if abs(calc.res.energy - expected_energy) < 1e-10: print("OK, energy has the expected value") else: print("ERROR!") print("Expected energy value: {}".format(expected_energy)) print("Actual energy value: {}".format(calc.res.energy)) sys.exit(3) sys.exit(0) # EOF
print("Usage: test_failure.py <code_name>") sys.exit(1) codename = sys.argv[1] code = test_and_get_code(codename, expected_code_type='cp2k') print("Testing CP2K failure...") # a broken CP2K input params = {'GLOBAL': {'FOO_BAR_QUUX': 42}} calc = code.new_calc() calc.use_parameters(ParameterData(dict=params)) calc.set_max_wallclock_seconds(2 * 60) calc.set_resources({"num_machines": 1}) calc.store_all() calc.submit() print("submitted calculation: PK=%s" % calc.pk) wait_for_calc(calc, ensure_finished_ok=False) if calc.has_failed(): print("CP2K failure correctly recognized") else: print("ERROR!") print("CP2K failure was not recognized") sys.exit(3) sys.exit(0) # EOF