示例#1
0
def itest_oneshot_phonon_work(fwp):
    """
    Test build_oneshot_phononwork i.e. computation of the phonon frequencies
    for all modes in a single task.
    """
    all_inps = scf_ph_inputs()

    # SCF + one-shot for the first 2 qpoints.
    scf_input, ph_inputs = all_inps[0], all_inps[1:3]

    from pymatgen.io.abinit.works import build_oneshot_phononwork
    flow = abilab.Flow(fwp.workdir)

    # rfdir and rfatpol are missing!
    with pytest.raises(ValueError):
        phon_work = build_oneshot_phononwork(scf_input, ph_inputs)
    for phinp in ph_inputs:
        phinp.set_vars(rfdir=[1, 1, 1])

    with pytest.raises(ValueError):
        phon_work = build_oneshot_phononwork(scf_input, ph_inputs)
    for phinp in ph_inputs:
        phinp.set_vars(rfatpol=[1, len(phinp.structure)])

    # Now ph_inputs is ok
    phon_work = build_oneshot_phononwork(scf_input, ph_inputs)
    flow.register_work(phon_work)

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

    flow.check_status(show=True, verbose=1)
    assert all(work.finalized for work in flow)
    assert flow.all_ok

    # Read phonons from main output file.
    phonons_list = phon_work.read_phonons()
    assert len(phonons_list) == 2

    ph0, ph1 = phonons_list[0], phonons_list[1]
    assert ph0.qpt == [0, 0, 0]
    assert ph1.qpt == [2.50000000E-01, 0.00000000E+00, 0.00000000E+00]
    assert len(ph0.freqs) == 3 * len(scf_input.structure)
    assert len(ph1.freqs) == 3 * len(scf_input.structure)
    nptu.assert_almost_equal(ph0.freqs.to("Ha"), [
        -1.219120E-05, -1.201501E-05, -1.198453E-05, 1.577646E-03,
        1.577647E-03, 1.577647E-03
    ])
    nptu.assert_almost_equal(ph1.freqs.to("Ha"), [
        2.644207E-04, 2.644236E-04, 6.420904E-04, 1.532696E-03, 1.532697E-03,
        1.707196E-03
    ])
示例#2
0
def build_flow(options):
    """
    Create an `AbinitFlow` for phonon calculations:

        1) One workflow for the GS run.

        2) nqpt workflows for phonon calculations. Each workflow contains 
           nirred tasks where nirred is the number of irreducible phonon perturbations
           for that particular q-point.
    """
    # 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_")

    all_inps = scf_ph_inputs()
    scf_input, ph_inputs = all_inps[0], all_inps[1:]

    flow = abilab.Flow(workdir, manager=options.manager, remove=options.remove)
    from pymatgen.io.abinit.works import build_oneshot_phononwork
    work = build_oneshot_phononwork(scf_input, ph_inputs)
    flow.register_work(work)

    return flow
示例#3
0
def itest_oneshot_phonon_work(fwp):
    """
    Test build_oneshot_phononwork i.e. computation of the phonon frequencies
    for all modes in a single task.
    """
    all_inps = scf_ph_inputs()

    # SCF + one-shot for the first 2 qpoints.
    scf_input, ph_inputs = all_inps[0], all_inps[1:3]

    from pymatgen.io.abinit.works import build_oneshot_phononwork
    flow = abilab.Flow(fwp.workdir)

    # rfdir and rfatpol are missing!
    with pytest.raises(ValueError):
        phon_work = build_oneshot_phononwork(scf_input, ph_inputs)
    for phinp in ph_inputs: phinp.set_vars(rfdir=[1, 1, 1])

    with pytest.raises(ValueError):
        phon_work = build_oneshot_phononwork(scf_input, ph_inputs)
    for phinp in ph_inputs: phinp.set_vars(rfatpol=[1, len(phinp.structure)])

    # Now ph_inputs is ok
    phon_work = build_oneshot_phononwork(scf_input, ph_inputs)
    flow.register_work(phon_work)

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

    flow.check_status(show=True, verbose=1)
    assert all(work.finalized for work in flow)
    assert flow.all_ok
    
    # Read phonons from main output file.
    phonons_list = phon_work.read_phonons()
    assert len(phonons_list) == 2

    ph0, ph1 = phonons_list[0], phonons_list[1]
    assert ph0.qpt == [0, 0, 0]
    assert ph1.qpt == [2.50000000E-01,  0.00000000E+00,  0.00000000E+00]
    assert len(ph0.freqs) == 3 * len(scf_input.structure)
    assert len(ph1.freqs) == 3 * len(scf_input.structure)
    nptu.assert_almost_equal(ph0.freqs.to("Ha"), 
        [-1.219120E-05, -1.201501E-05, -1.198453E-05,  1.577646E-03,  1.577647E-03, 1.577647E-03])
    nptu.assert_almost_equal(ph1.freqs.to("Ha"), 
        [2.644207E-04, 2.644236E-04, 6.420904E-04, 1.532696E-03, 1.532697E-03, 1.707196E-03])
def build_flow(options):
    """
    Create an `AbinitFlow` for phonon calculations:

        1) One workflow for the GS run.

        2) nqpt workflows for phonon calculations. Each workflow contains 
           nirred tasks where nirred is the number of irreducible phonon perturbations
           for that particular q-point.
    """
    # 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_") 

    all_inps = scf_ph_inputs()
    scf_input, ph_inputs = all_inps[0], all_inps[1:]

    flow = abilab.Flow(workdir, manager=options.manager, remove=options.remove)
    from pymatgen.io.abinit.works import build_oneshot_phononwork
    work = build_oneshot_phononwork(scf_input, ph_inputs)
    flow.register_work(work)

    return flow