예제 #1
0
파일: itest_gw.py 프로젝트: zbwang/abipy
def itest_g0w0qptdm_flow(fwp, tvars):
    """Integration test for G0W0WithQptdmFlow."""
    scf, nscf, scr, sig = make_g0w0_inputs(ngkpt=[2, 2, 2], tvars=tvars)

    flow = flowtk.G0W0WithQptdmFlow(fwp.workdir,
                                    scf,
                                    nscf,
                                    scr,
                                    sig,
                                    manager=fwp.manager)

    # Enable garbage collector at the flow level.
    # Note that here we have tp use this policy because tasks are created dynamically
    #flow.set_garbage_collector(policy="task")
    flow.set_garbage_collector(policy="flow")

    assert len(flow) == 3
    bands_work = flow[0]
    scr_work = flow[1]
    sigma_work = flow[2]

    assert scr_work.depends_on(bands_work.nscf_task)
    assert not scr_work.depends_on(bands_work.scf_task)

    for sigma_task in sigma_work:
        #print("sigma_task.deps", sigma_task.deps)
        assert sigma_task.depends_on(bands_work.nscf_task)
        assert not sigma_task.depends_on(bands_work.scf_task)
        assert sigma_task.depends_on(scr_work)

    flow.build_and_pickle_dump(abivalidate=True)
    flow.show_dependencies()
    # This call is needed to connect the node and enable
    # the callbacks, otherwise the scheduler enters a deadlock.
    flow.connect_signals()

    # Run the flow.
    fwp.scheduler.add_flow(flow)
    assert fwp.scheduler.start() == 0
    assert not fwp.scheduler.exceptions

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

    # Test set_garbage_collector
    # The WFK|SCR file should have been removed because we call set_garbage_collector
    #assert not scf_task.outdir.has_abiext("WFK")
    #assert not nscf_task.outdir.has_abiext("WFK")
    #assert not scr_task.outdir.has_abiext("SCR")
    #assert not scr_task.outdir.has_abiext("SUS")

    # The SCR file produced by scr_work should have been removed
    assert not scr_work.outdir.has_abiext("SCR")

    #assert flow.validate_json_schema()

    flow.finalize()
예제 #2
0
def build_flow(options):
    """
    Construct the flow for G0W0 calculations.
    The calculation of the SCR file is split into nqptdm independent calculations.
    Partial SCR files are then merged with mrgddb before starting the sigma run.
    """
    # Working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_")
    if not options.workdir:
        options.workdir = os.path.basename(__file__).replace(".py", "").replace("run_", "flow_")

    # Build the input files for GS, NSCF, SCR and SIGMA runs.
    gs, nscf, scr_input, sigma_input = all_inputs()

    # Construct the flow.
    return flowtk.G0W0WithQptdmFlow(options.workdir, gs, nscf, scr_input, sigma_input,
                                    manager=options.manager)