def itest_gbrv_flow(fwp, tvars): """The the GBRV flow: relaxation + EOS computation.""" factory = GbrvFactory() #pseudo = "si_pbe_v1_abinit.paw" pseudo = abidata.pseudo("Si.GGA_PBE-JTH-paw.xml") ecut = 2 pawecutdg = 2 * ecut if pseudo.ispaw else None flow = abilab.Flow(workdir=fwp.workdir, manager=fwp.manager, pickle_protocol=0) struct_types = ["fcc"] #, "bcc"] for struct_type in struct_types: work = factory.relax_and_eos_work(pseudo, struct_type, ecut, pawecutdg=pawecutdg, paral_kgb=tvars.paral_kgb) flow.register_work(work) flow.allocate() flow.build_and_pickle_dump() fwp.scheduler.add_flow(flow) assert fwp.scheduler.start() == 0 assert not fwp.scheduler.exceptions #work = flow[0] #t0 = work[0] #assert len(work) == 1 #t0.start_and_wait() #flow.check_status() # At this point on_all_ok is called. #assert t0.status == t0.S_OK #assert len(flow) == 2 #assert len(flow[1]) == 9 #assert not flow.all_ok #for task in flow[1]: # task.start_and_wait() flow.check_status() flow.show_status() assert all(work.finalized for work in flow) assert flow.all_ok
def itest_gbrv_gga_ncsoc_flow(fwp, tvars): """Testing the GBRV flow with GGA and ONCVPSP+SO (relaxation + EOS)""" #return pseudo = pdj_data.pseudo("Pb-d-3_r.psp8").as_tmpfile(tmpdir=fwp.workdir) assert pseudo is not None assert pseudo.supports_soc assert not pseudo.dojo_report.exceptions factory = GbrvFactory(pseudo.xc) ecut = 2 #ecut = 6 pawecutdg = 2 * ecut if pseudo.ispaw else None flow = abilab.Flow(workdir=fwp.workdir, manager=fwp.manager) struct_types = [ "fcc", ] # "bcc"] assert pseudo.dojo_report.has_trial("gbrv_fcc", ecut=4) assert not pseudo.dojo_report.has_trial("gbrv_fcc", ecut=ecut) for struct_type in struct_types: work = factory.relax_and_eos_work(pseudo, struct_type, ecut, pawecutdg=pawecutdg, include_soc=True, paral_kgb=tvars.paral_kgb) flow.register_work(work) flow.build_and_pickle_dump(abivalidate=True) fwp.scheduler.add_flow(flow) assert fwp.scheduler.start() == 0 assert not fwp.scheduler.exceptions flow.check_status(show=True) assert all(work.finalized for work in flow) assert flow.all_ok print(pseudo.dojo_report) assert pseudo.dojo_report.has_trial("gbrv_fcc_soc", ecut=ecut) assert not pseudo.dojo_report.exceptions
def itest_gbrv_gga_pawxml_flow(fwp, tvars): """Testing the GBRV flow with GGA and PAW-XML (relaxation + EOS)""" pseudo = pdj_data.pseudo("Si.GGA_PBE-JTH-paw.xml").as_tmpfile( tmpdir=fwp.workdir) assert pseudo is not None assert pseudo.has_dojo_report assert not pseudo.dojo_report.exceptions factory = GbrvFactory(pseudo.xc) ecut = 4 pawecutdg = 2 * ecut if pseudo.ispaw else None flow = abilab.Flow(workdir=fwp.workdir, manager=fwp.manager) struct_types = [ "fcc", ] # "bcc"] assert not pseudo.dojo_report.has_trial("gbrv_fcc", ecut=ecut) for struct_type in struct_types: work = factory.relax_and_eos_work(pseudo, struct_type, ecut, pawecutdg=pawecutdg, paral_kgb=tvars.paral_kgb) flow.register_work(work) flow.build_and_pickle_dump(abivalidate=True) fwp.scheduler.add_flow(flow) assert fwp.scheduler.start() == 0 assert not fwp.scheduler.exceptions flow.check_status(show=True) assert all(work.finalized for work in flow) assert flow.all_ok print(pseudo.dojo_report) assert pseudo.dojo_report.has_trial("gbrv_fcc", ecut=ecut) assert not pseudo.dojo_report.exceptions
def build_flow(pseudo, options): """ Build the flow, returns None if the test has been already performed. """ print(pseudo) if not pseudo.has_dojo_report: raise ValueError("Cannot find dojo_report") if options.soc and not pseudo.supports_soc: raise TypeError( "SOC is on but pseudo does not support spin-orbit coupling") if not options.soc and pseudo.supports_soc and pseudo.path.endswith( "psp8"): cprint( "[STRANGE]: Your psp8 pseudo supports SOC but options.soc is off", "magenta") report = pseudo.dojo_report if options.verbose > 1: print(report) workdir = pseudo.basename + "_DOJO" if options.workdir is None else options.workdir if os.path.exists(workdir): cprint("Directory %s already exists" % workdir, "red") return None flow = abilab.Flow(workdir=workdir, manager=options.manager) extra_abivars = { "mem_test": 0, #"nstep": 100, "paral_kgb": options.paral_kgb } #flow.walknset_vars(extra_abivars) # Build ecut mesh. try: ppgen_ecut = int(report["ppgen_hints"]["high"]["ecut"]) ecut_list = copy.copy(report["ecuts"]) except KeyError: cprint( 'New pseudo without report from the generator, the convergence study is started from 16H', "yellow") #raise NotImplementedError() # TODO #report = DojoReport.from_pseudo(pseudo) report["ppgen_hints"] = {} report["ppgen_hints"]["high"] = {} report["ppgen_hints"]["high"]["ecut"] = 16.0 report["ecuts"] = [16.0, 20.0, 24.0] report.json_write(pseudo.djrepo_path) #pseudo.write_dojo_report(report) ppgen_ecut = int(report["ppgen_hints"]["high"]["ecut"]) ecut_list = copy.copy(report["ecuts"]) try: ecut_hint = int(report["hints"]["normal"]["ecut"]) except KeyError: try: ecut_hint = int(report["ppgen_hints"]["normal"]["ecut"]) except KeyError: ecut_hint = ppgen_ecut #if options.extend: # next_ecut = max(ecut_list) + 2 # ecut_list.append(next_ecut) #if options.new_ecut: # ecut_list.append(options['new-ecut']) add_ecuts = False if add_ecuts: #dense_right = np.linspace(ppgen_ecut, ppgen_ecut + 10, num=6) #dense_left = np.linspace(ppgen_ecut-8, ppgen_ecut, num=4, endpoint=False) #coarse_high = np.linspace(ppgen_ecut + 15, ppgen_ecut + 40, num=4) dense_right = np.arange(ppgen_ecut, ppgen_ecut + 6 * 2, step=2) dense_left = np.arange(max(ppgen_ecut - 6, 2), ppgen_ecut, step=2) coarse_high = np.arange(ppgen_ecut + 15, ppgen_ecut + 35, step=5) ecut_list = list(dense_left) + list(dense_right) + list(coarse_high) # Computation of the deltafactor. if "df" in options.trials or "deltafactor" in options.trials: factory = DeltaFactory(xc=pseudo.xc) dojo_trial = "deltafactor" if not options.soc else "deltafactor_soc" #ecut_list = [75] for ecut in ecut_list: if report.has_trial(dojo_trial, ecut=ecut): cprint( "[%s]: ignoring ecut=%s because it's already in the DOJO_REPORT" % (dojo_trial, ecut), "magenta") continue # Build and register the work. pawecutdg = 2 * ecut if pseudo.ispaw else None work = factory.work_for_pseudo(pseudo, kppa=6750, ecut=ecut, pawecutdg=pawecutdg, include_soc=options.soc, **extra_abivars) flow.register_work(work, workdir='WDF' + str(ecut)) # GBRV tests. if "gbrv" in options.trials: gbrv_factory = GbrvFactory(xc=pseudo.xc) gbrv_structs = ("fcc", "bcc") for struct_type in gbrv_structs: dojo_trial = "gbrv_" + struct_type if options.soc: dojo_trial += "_soc" for ecut in ecut_list: if report.has_trial(dojo_trial, ecut=ecut): cprint( "[gbrv]: ignoring ecut=%s because it's already in the DOJO_REPORT" % ecut, "magenta") continue # Build and register the work. pawecutdg = 2 * ecut if pseudo.ispaw else None work = gbrv_factory.relax_and_eos_work(pseudo, struct_type, ecut=ecut, pawecutdg=pawecutdg, include_soc=options.soc, ntime=50, **extra_abivars) flow.register_work(work, workdir="GBRV_" + struct_type + str(ecut)) # GHOSTS test if "ghosts" in options.trials: assert not options.soc dojo_trial = "ghosts" if not options.soc else "ghosts_soc" ghosts_factory = GhostsFactory(pseudo.xc) ecut = int(report["ppgen_hints"]["high"]["ecut"]) pawecutdg = None if not pseudo.ispaw else int( report["ppgen_hints"]["high"]["pawecutdg"]) #str_ecut = '%.1f' % ecut #print(report["ghosts"].pop(ecut, None)) if report.has_trial(dojo_trial, ecut=ecut): cprint( "[%s]: ignoring ecut=%s because it's already in the DOJO_REPORT" % (dojo_trial, ecut), "magenta") else: # Build and register the work. work = ghosts_factory.work_for_pseudo(pseudo, kppa=2000, maxene=250, ecut=ecut, pawecutdg=pawecutdg, **extra_abivars) if work is not None: flow.register_work(work, workdir='GhostsAt' + str(ecut)) else: cprint( 'Cannot create GhostsAt%s work, factory returned None' % str(ecut), "magenta") # phonons at gamma test. if "phgamma" in options.trials: phg_factory = GammaPhononFactory(pseudo.xc) dojo_trial = "phgamma" if not options.soc else "phgamma_soc" for ecut in ecut_list: if report.has_trial(dojo_trial, ecut=ecut): cprint( "[%s]: ignoring ecut=%s because it's already in the DOJO_REPORT" % (dojo_trial, ecut), "magenta") continue # Build and register the work. pawecutdg = 2 * ecut if pseudo.ispaw else None work = phg_factory.work_for_pseudo(pseudo, kppa=1000, ecut=ecut, pawecutdg=pawecutdg, include_soc=options.soc) if work is not None: flow.register_work(work) else: cprint( 'Cannot create phgamma work for ecut %s, factory returned None' % str(ecut), "magenta") if "raren_relax" in options.trials: nirer_factory = RocksaltRelaxationFactory(pseudo.xc) dojo_trial = "raren_relax" if not options.soc else "raren_relax_soc" l = [] for ecut in ecut_list: if report.has_trial(dojo_trial, ecut=ecut): cprint( "[%s]: ignoring ecut=%s because it's already in the DOJO_REPORT" % (dojo_trial, ecut), "magenta") continue l.append(ecut) ecut_list = l # Build and register the work. pawecutdg = 2 * ecut if pseudo.ispaw else None work = nirer_factory.work_for_pseudo(pseudo, ecut_list, pawecutdg=pawecutdg, include_soc=options.soc) if work is not None: flow.register_work(work) else: cprint('Cannot create nirer work, factory returned None', "magenta") if len(flow) > 0: return flow.allocate() else: # Empty flow since all trials have been already performed. return None