Esempio n. 1
0
def build_flow(options):
    structure = abilab.Structure.from_file(abidata.cif_file("si.cif"))

    scf_kppa = 40
    nscf_nband = 6
    ndivsm = 5
    #dos_ngkpt = [4,4,4]
    #dos_shiftk = [0.1, 0.2, 0.3]

    extra_abivars = dict(
        ecut=6, 
        timopt=-1,
        accesswff=3, 
        istwfk="*1",
    )

    # 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_") 

    # Instantiate the TaskManager.
    manager = abilab.TaskManager.from_user_config() if not options.manager else \
              abilab.TaskManager.from_file(options.manager)

    # Initialize the flow.
    # FIXME  Abistructure is not pickleable with protocol -1
    flow = abilab.AbinitFlow(workdir=workdir, manager=manager, pickle_protocol=0)

    work = bandstructure(structure, abidata.pseudos("14si.pspnc"), scf_kppa, nscf_nband, ndivsm, 
                         spin_mode="unpolarized", smearing=None, **extra_abivars)

    flow.register_work(work)
    return flow.allocate()
Esempio n. 2
0
def make_flow(workdir="tmp_ht_si_ebands"):
    structure = AbiStructure.asabistructure(data.cif_file("si.cif"))

    scf_kppa = 40
    nscf_nband = 6
    ndivsm = 5
    #dos_ngkpt = [4,4,4]
    #dos_shiftk = [0.1, 0.2, 0.3]

    extra_abivars = dict(
        ecut=6, 
        timopt=-1,
        accesswff=3, 
        istwfk="*1",
    )

    manager = abilab.TaskManager.from_user_config()

    # Initialize the flow.
    # FIXME  Abistructure is not pickleable with protocol -1
    flow = abilab.AbinitFlow(workdir=workdir, manager=manager, pickle_protocol=0)

    work = bandstructure(structure, data.pseudos("14si.pspnc"), scf_kppa, nscf_nband, ndivsm, 
                         spin_mode="unpolarized", smearing=None, **extra_abivars)

    flow.register_work(work)
    return flow.allocate()
Esempio n. 3
0
def itest_htc_bandstructure(fwp, tvars):
    """Test band-structure calculations done with the HTC interface."""
    structure = abilab.Structure.from_file(abidata.cif_file("si.cif"))

    scf_kppa = 20
    nscf_nband = 6
    ndivsm = 5
    dos_kppa = 40
    # TODO: Add this options because I don't like the kppa approach
    # I had to use it because it was the approach used in VaspIO
    #dos_ngkpt = [4,4,4]
    #dos_shiftk = [0.1, 0.2, 0.3]

    extra_abivars = dict(
        ecut=2,
        paral_kgb=tvars.paral_kgb,
    )

    # Initialize the flow.
    flow = abilab.AbinitFlow(workdir=fwp.workdir, manager=fwp.manager)

    work = bandstructure(structure, abidata.pseudos("14si.pspnc"), scf_kppa, nscf_nband, ndivsm,
                         spin_mode="unpolarized", smearing=None, dos_kppa=dos_kppa, **extra_abivars)

    flow.register_work(work)
    flow.allocate()
    flow.build_and_pickle_dump()

    fwp.scheduler.add_flow(flow)
    fwp.scheduler.start()
    assert fwp.scheduler.num_excs == 0
    assert fwp.scheduler.nlaunch == 3

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

    # Test if GSR files are produced and are readable.
    for i, task in enumerate(work):
        gsr_path = task.outdir.list_filepaths(wildcard="*GSR.nc")[0]
        gsr = abilab.abiopen(gsr_path)
        print(gsr)
        assert gsr.nsppol == 1
        assert gsr.structure == structure
        ebands = gsr.ebands

        # TODO: This does not work yet because GSR files do not contain
        # enough info to understand if we have a path or a mesh.
        #if i == 2:
            # Bandstructure case
            #assert ebands.has_bzpath
            #with pytest.raises(ebands.Error):
            #    ebands.get_edos()

        if i == 3:
            # DOS case
            assert ebands.has_bzmesh
            gsr.bands.get_edos()