def build_flow(options): # Path of the pseudopotential to test. #pseudo = data.pseudo("14si.pspnc") pseudo = data.pseudo("Si.GGA_PBE-JTH-paw.xml") # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_") workdir = options.workdir if not options.workdir: workdir = os.path.basename(__file__).replace(".py", "").replace("run_", "flow_") # Initialize the flow. flow = abilab.Flow(workdir=workdir, manager=options.manager, remove=options.remove) # Build the workflow for the computation of the deltafactor. # The calculation is done with the parameters and the cif files # used in the original paper. We only have to specify # the cutoff energy ecut (Ha) for the pseudopotential. # The workflow will produce a pdf file with the equation of state # and a file deltafactor.txt with the final results in the # outdir directory DELTAFACTOR/work_0/outdir. factory = DeltaFactory() kppa = 6750 # Use this to have the official k-point sampling kppa = 50 # this value is for testing purpose. ecut = 8 pawecutdg = ecut * 2 if pseudo.ispaw else None work = factory.work_for_pseudo(pseudo, accuracy="normal", kppa=kppa, ecut=ecut, pawecutdg=pawecutdg, toldfe=1.e-8, smearing="fermi_dirac:0.0005") # Register the workflow. flow.register_work(work) return flow
def itest_deltafactor_gga_pawxml(fwp, tvars): """ Testing the flow used for the computation of the deltafactor with PAW and GGA XC. """ # Path of the pseudopotential to test. 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 flow = abilab.Flow(workdir=fwp.workdir, manager=fwp.manager) # Build the workflow for the computation of the deltafactor. # The workflow will produce a pdf file with the equation of state # and a file deltafactor.txt with the final results in the # outdir directory DELTAFACTOR/work_0/outdir. kppa = 20 # this value is for testing purpose (6570 is the correct one) ecut = 2 pawecutdg = ecut * 2 if pseudo.ispaw else None assert not pseudo.dojo_report.has_trial("deltafactor", ecut=ecut) work = DeltaFactory(pseudo.xc).work_for_pseudo(pseudo, kppa=kppa, ecut=ecut, pawecutdg=pawecutdg, include_soc=False, paral_kgb=tvars.paral_kgb) # Register the workflow. flow.register_work(work) flow.build_and_pickle_dump(abivalidate=True) for task in flow[0]: task.start_and_wait() flow.check_status(show=True) assert flow.all_ok assert all(work.finalized for work in flow) results = flow[0].get_results() #20.453 ang^3 88.545 GPa 4.31 20.8658081501 336.680999051 GPa -35.681897152 #delta Equation of State: deltafactor_polyfit #Minimum volume = 20.87 Ang^3 #modulus = 2.10 eV/Ang^3 = 336.68 GPa, b1 = -35.68 #Deltafactor = 15.681 meV assert pseudo.dojo_report.has_trial("deltafactor", ecut=ecut) assert not pseudo.dojo_report.exceptions
def itest_deltafactor_gga_ncsoc(fwp, tvars): """ Testing the flow used for the computation of the deltafactor with GGA and NC+SOC. """ # return # Path of the pseudopotential to test. pseudo = pdj_data.pseudo("Pb-d-3_r.psp8").as_tmpfile(tmpdir=fwp.workdir) assert pseudo.has_dojo_report assert pseudo.supports_soc assert not pseudo.dojo_report.exceptions flow = abilab.Flow(workdir=fwp.workdir, manager=fwp.manager) # Build the workflow for the computation of the deltafactor. # The workflow will produce a pdf file with the equation of state # and a file deltafactor.txt with the final results in the # outdir directory DELTAFACTOR/work_0/outdir. kppa = 40 # this value is for testing purpose (6570 is the correct one) ecut = 8 pawecutdg = ecut * 2 if pseudo.ispaw else None assert pseudo.dojo_report.has_trial("deltafactor", ecut=12) assert not pseudo.dojo_report.has_trial("deltafactor_soc", ecut=ecut) work = DeltaFactory(pseudo.xc).work_for_pseudo(pseudo, kppa=kppa, ecut=ecut, pawecutdg=pawecutdg, include_soc=True, paral_kgb=tvars.paral_kgb) # Register the workflow. flow.register_work(work) flow.build_and_pickle_dump(abivalidate=True) for task in flow[0]: task.start_and_wait() flow.check_status(show=True) assert flow.all_ok assert all(work.finalized for work in flow) results = flow[0].get_results() assert pseudo.dojo_report.has_trial("deltafactor_soc", ecut=ecut) assert not pseudo.dojo_report.exceptions
def itest_deltafactor(fwp, tvars): """Test the flow used for the computation of the deltafactor.""" # Path of the pseudopotential to test. pseudo = abidata.pseudo("Si.GGA_PBE-JTH-paw.xml") flow = abilab.Flow(workdir=fwp.workdir, manager=fwp.manager) # Build the workflow for the computation of the deltafactor. # The workflow will produce a pdf file with the equation of state # and a file deltafactor.txt with the final results in the # outdir directory DELTAFACTOR/work_0/outdir. kppa = 20 # this value is for testing purpose (6570 is the correct one) ecut = 2 pawecutdg = ecut * 2 if pseudo.ispaw else None work = DeltaFactory().work_for_pseudo(pseudo, kppa=kppa, ecut=ecut, pawecutdg=pawecutdg, paral_kgb=tvars.paral_kgb) # Register the workflow. flow.register_work(work) flow.allocate() flow.build_and_pickle_dump() for task in flow[0]: task.start_and_wait() flow.check_status() flow.show_status() assert flow.all_ok assert all(work.finalized for work in flow) results = flow[0].get_results()
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