Beispiel #1
0
def itest_relaxation_with_restart_from_den(fwp, tvars):
    """Test structural relaxations with automatic restart from DEN files."""
    # Build the flow
    flow = abilab.Flow(fwp.workdir, manager=fwp.manager)

    # Use small value for ntime to trigger restart, then disable the output of the WFK file.
    ion_input, ioncell_input = make_ion_ioncell_inputs(tvars,
                                                       dilatmx=1.1,
                                                       ntime=3)
    ion_input.set_vars(prtwf=0)
    ioncell_input.set_vars(prtwf=0)

    relax_work = abilab.RelaxWork(ion_input, ioncell_input)
    flow.register_work(relax_work)

    assert flow.make_scheduler().start() == 0
    flow.show_status()

    assert all(work.finalized for work in flow)
    assert flow.all_ok

    # we should have (0, 1) restarts and no WFK file in outdir.
    for i, task in enumerate(relax_work):
        assert task.status == task.S_OK
        assert task.num_restarts == i
        assert task.num_corrections == 0
        assert not task.outdir.has_abiext("WFK")

    if has_matplotlib:
        assert relax_work.plot_ion_relaxation(show=False) is not None
        assert relax_work.plot_ioncell_relaxation(show=False) is not None

    flow.rmtree()
Beispiel #2
0
def build_flow(options):
    # 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_") 

    # Create the flow
    flow = abilab.Flow(workdir, manager=options.manager, remove=options.remove)

    # Create a relaxation work and add it to the flow.
    ion_inp, ioncell_inp = make_ion_ioncell_inputs()

    relax_work = abilab.RelaxWork(ion_inp, ioncell_inp)
    flow.register_work(relax_work)

    #bands_work = abilab.BandStructureWork(scf_input, nscf_input)
    bands_work = abilab.Work()
    deps = {relax_work[-1]: "@structure"}
    deps = {relax_work[-1]: ["DEN", "@structure"]}  # --> This is not possible because the file ext is changed!
    #deps = {relax_work[-1]: ["WFK", "@structure"]} # --> This triggers an infamous bug in abinit

    bands_work.register_relax_task(ioncell_inp, deps=deps)
    flow.register_work(bands_work)

    return flow
Beispiel #3
0
    def test_ion_ioncell_relax_input(self):
        """Testing ion_ioncell_relax_input factory."""
        multi = ion_ioncell_relax_input(self.si_structure,
                                        self.si_pseudo,
                                        kppa=10,
                                        ecut=2)
        #scf_kppa, scf_nband #accuracy="normal", spin_mode="polarized",
        #smearing="fermi_dirac:0.1 eV", charge=0.0, scf_algorithm=None)

        ion_inp, ioncell_inp = multi.split_datasets()

        flow = abilab.Flow.temporary_flow()
        flow.register_work(abilab.RelaxWork(ion_inp, ioncell_inp))
        assert flow.build_and_pickle_dump(abivalidate=True) == 0
Beispiel #4
0
    def test_ion_ioncell_relax_input(self):
        """Testing ioncell_relax_input factory."""
        inp = ion_ioncell_relax_input(self.si_structure,
                                      self.si_pseudo,
                                      kppa=10,
                                      ecut=2)
        #scf_kppa, scf_nband #accuracy="normal", spin_mode="polarized",
        #smearing="fermi_dirac:0.1 eV", charge=0.0, scf_algorithm=None)

        self.validate_inp(inp)
        ion_inp, ioncell_inp = inp.split_datasets()

        #return
        flow = abilab.Flow("flow_ion_ioncell_relax_input")
        flow.register_work(abilab.RelaxWork(ion_inp, ioncell_inp))
        flow.allocate()
Beispiel #5
0
def main(options):
    #structure = abidata.structure_from_ucell("MgB2")
    #pseudos = abilab.PseudoTable(abidata.pseudos("12mg.pspnc", "5b.pspnc"))

    structure = abidata.structure_from_ucell("NiO")
    pseudos = abidata.pseudos("28ni.paw", "8o.2.paw")

    inp = ion_ioncell_relax_input(structure, pseudos, ecut=8, pawecutdg=12)

    inp.chkprim = 0
    ion_inp, ioncell_inp = inp.split_datasets()

    # Create the flow
    flow = abilab.Flow("flow_debug_relax")

    relax_work = abilab.RelaxWork(ion_inp, ioncell_inp)
    flow.register_work(relax_work)
    return flow.allocate()
Beispiel #6
0
def build_flow(options):
    # 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_")

    # Create the flow
    flow = abilab.Flow(workdir, manager=options.manager, remove=options.remove)

    paral_kgb = 1
    #paral_kgb = 0  # This one is OK

    # Create a relaxation work and add it to the flow.
    ion_inp, ioncell_inp = make_ion_ioncell_inputs(paral_kgb=paral_kgb)

    relax_work = abilab.RelaxWork(ion_inp, ioncell_inp)
    flow.register_work(relax_work)

    scf_inp, nscf_inp = make_scf_nscf_inputs(paral_kgb=paral_kgb)

    bands_work = abilab.BandStructureWork(scf_inp, nscf_inp)

    # The scf task in bands work restarts from the DEN file of the last task in relax_work
    if paral_kgb == 0:
        # cg works fine if we restart from the WFK
        bands_work.scf_task.add_deps({relax_work[-1]: "WFK"})
    else:
        # --> This triggers an infamous bug in abinit
        bands_work.scf_task.add_deps({relax_work[-1]: "WFK"})

        # --> This is ok if we used fourier_interp to change the FFT mesh.
        #bands_work.scf_task.add_deps({relax_work[-1]: "DEN"})

    # All task in bands_work will fetch the relaxed structure from the last task in relax_work
    for task in bands_work:
        task.add_deps({relax_work[-1]: "@structure"})

    flow.register_work(bands_work)
    flow.allocate()
    flow.use_smartio()
    flow.set_garbage_collector()

    return flow