Esempio n. 1
0
    def test_frames_from_structures(self):
        """Testing frames from structures."""
        mgb2 = abidata.structure_from_ucell("MgB2")
        sic = abidata.structure_from_ucell("SiC")
        alas = abidata.structure_from_ucell("AlAs")
        dfs = frames_from_structures([mgb2, sic, alas], index=None, with_spglib=True, cart_coords=False)

        assert dfs.lattice is not None
        assert dfs.coords is not None
        assert dfs.structures is not None
        formulas = [struct.composition.reduced_formula for struct in dfs.structures]
        assert formulas == ["MgB2", "SiC", "AlAs"]
Esempio n. 2
0
    def test_dataframes_from_structures(self):
        """Testing dataframes from structures."""
        mgb2 = abidata.structure_from_ucell("MgB2")
        sic = abidata.structure_from_ucell("SiC")
        alas = abidata.structure_from_ucell("AlAs")
        dfs = dataframes_from_structures([mgb2, sic, alas], index=None, with_spglib=True, cart_coords=True)
        dfs = dataframes_from_structures([mgb2, sic, alas], index=None, with_spglib=True, cart_coords=False)

        assert dfs.lattice is not None
        assert dfs.coords is not None
        assert dfs.structures is not None
        formulas = [struct.composition.reduced_formula for struct in dfs.structures]
        assert formulas == ["MgB2", "SiC", "AlAs"]
Esempio n. 3
0
def itest_phonon_restart(fwp):
    """Test the restart of phonon calculations with the scheduler."""
    # Crystalline AlAs: computation of the second derivative of the total energy
    structure = abidata.structure_from_ucell("AlAs")

    # List of q-points for the phonon calculation (4,4,4) mesh.
    qpoints = np.reshape([
        0.00000000E+00,  0.00000000E+00,  0.00000000E+00,
        2.50000000E-01,  0.00000000E+00,  0.00000000E+00,
        #5.00000000E-01,  0.00000000E+00,  0.00000000E+00,  # XXX Uncomment this line to test restart from 1DEN
                                                            # Too long --> disabled
    ], (-1, 3))

    # Global variables used both for the GS and the DFPT run.
    global_vars = dict(
        nband=4,
        ecut=3.0,
        ngkpt=[4, 4, 4],
        shiftk=[0, 0, 0],
        tolvrs=1.0e-5,
   )

    multi = abilab.MultiDataset(structure=structure, pseudos=abidata.pseudos("13al.981214.fhi", "33as.pspnc"),
                                ndtset=1 + len(qpoints))

    multi.set_vars(global_vars)

    for i, qpt in enumerate(qpoints):
        # Response-function calculation for phonons.
        multi[i+1].set_vars(
            rfphon=1,        # Will consider phonon-type perturbation.
            nqpt=1,          # One wavevector is to be considered.
            qpt=qpt,         # q-wavevector.
            kptopt=3,
            nstep=5,         # This is to trigger the phonon restart.
        )
        #rfatpol   1 1   # Only the first atom is displaced
        #rfdir   1 0 0   # Along the first reduced coordinate axis
        #kptopt   2      # Automatic generation of k points, taking

                                                           # i == 0 --> restart from WFK
        if i == 1: multi[i+1].set_vars(prtwf=-1, nstep=5)  # Restart with WFK and smart- io.
        if i == 2: multi[i+1].set_vars(prtwf=0, nstep=8)   # Restart from 1DEN. Too long --> disabled.

    all_inps = multi.split_datasets()
    scf_input, ph_inputs = all_inps[0], all_inps[1:]

    flow = flowtk.phonon_flow(fwp.workdir, scf_input, ph_inputs, manager=fwp.manager)
    flow.set_garbage_collector()

    for task in flow.iflat_tasks():
        task.manager.qadapter.max_num_launches = 20

    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

    assert sum(task.num_restarts for task in flow.iflat_tasks()) > 0
Esempio n. 4
0
def make_input(paral_kgb=1, paw=False):
    """Build a template input file for GS calculations with paral_kgb"""
    pseudos = abidata.pseudos("14si.pspnc") if not paw else abidata.pseudos("Si.GGA_PBE-JTH-paw.xml")
    inp = abilab.AbiInput(pseudos=pseudos)

    inp.set_structure(abidata.structure_from_ucell("Si"))
    inp.set_kmesh(ngkpt=[2,2,2], shiftk=[0,0,0])

    # Global variables
    ecut = 10
    inp.set_vars(
        ecut=ecut,
        pawecutdg=ecut*4,
        nsppol=1,
        nband=20,
        paral_kgb=paral_kgb,
        npkpt=1,
        npband=1,
        npfft=1,
        #
        istwfk="*1",
        timopt=-1,
        chksymbreak=0,
        prtwf=0,
        prtden=0,
        tolvrs=1e-10,
        nstep=50,
    )

    return inp
Esempio n. 5
0
def build_flow(options):
    # 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(sys.argv[0]).replace(".py", "").replace("run_","flow_")

    flow = flowtk.Flow(options.workdir, manager=options.manager)

    pseudos = abidata.pseudos("14si.pspnc")

    # Get the unperturbed structure.
    base_structure = abidata.structure_from_ucell("Si")

    etas = [-.001, 0, +.001]
    ph_displ = np.reshape(np.zeros(3*len(base_structure)), (-1,3))
    ph_displ[0,:] = [+1, 0, 0]
    ph_displ[1,:] = [-1, 0, 0]

    # Build new structures by displacing atoms according to the phonon displacement
    # ph_displ (in cartesian coordinates). The Displacement is normalized so that
    # the maximum atomic diplacement is 1 Angstrom and then multiplied by eta.
    modifier = abilab.StructureModifier(base_structure)

    displaced_structures = modifier.displace(ph_displ, etas, frac_coords=False)

    # Generate the different shifts to average
    ndiv = 2
    shift1D = np.arange(1,2*ndiv+1,2)/(2*ndiv)
    all_shifts = [[x,y,z] for x in shift1D for y in shift1D for z in shift1D]
    all_shifts = [[0, 0, 0]]

    for structure, eta in zip(displaced_structures, etas):
        for shift in all_shifts:
            flow.register_work(raman_work(structure, pseudos, shift))

    return flow
Esempio n. 6
0
def make_scf_input(ecut=10, ngkpt=(8, 8, 8)):
    """
    This function constructs an `AbinitInput` for performing a
    GS-SCF calculation in crystalline AlAs.

    Args:
        ecut: cutoff energy in Ha.
        ngkpt: 3 integers specifying the k-mesh for the electrons.

    Return:
        `AbinitInput` object
    """
    # Initialize the AlAs structure from an internal database. Use the pseudos shipped with AbiPy.
    gs_inp = abilab.AbinitInput(structure=abidata.structure_from_ucell("AlAs"),
                                pseudos=abidata.pseudos("13al.981214.fhi", "33as.pspnc"))

    # Set the value of the Abinit variables needed for GS runs.
    gs_inp.set_vars(
        nband=4,
        ecut=ecut,
        ngkpt=ngkpt,
        nshiftk=1,
        shiftk=[0.0, 0.0, 0.0],
        ixc=7,
        nstep=500,
        iscf=7,
        diemac=5.0,
        toldfe=1.0e-22,
        nbdbuf=0,
        kptopt=1,
    )

    gs_inp.set_mnemonics(True)
    return gs_inp
Esempio n. 7
0
def make_input(paw=False):
    """
    Build and return an input file for GS calculations with paral_kgb=1
    """
    pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc")
              #if not paw else
              #abidata.pseudos("Si.GGA_PBE-JTH-paw.xml")
    structure = abidata.structure_from_ucell("SiO2-alpha")

    inp = abilab.AbinitInput(structure, pseudos)
    inp.set_kmesh(ngkpt=[4, 4, 4], shiftk=[0,0,0.5])

    # Global variables
    ecut = 40
    inp.set_vars(
        ecut=ecut,
        pawecutdg=ecut*4 if paw else None,
        nsppol=1,
        nband=32,
        paral_kgb=1,
        kptopt=3,
        istwfk="*1",
        timopt=-1,
        chksymbreak=0,
        nsym=1,
        prtwf=0,
        prtden=0,
        tolvrs=1e-8,
        nstep=20,
    )

    return inp
Esempio n. 8
0
def build_flow(options):
    # 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_")

    structure = abidata.structure_from_ucell("MgB2")

    # Get pseudos from a table.
    table = abilab.PseudoTable(abidata.pseudos("12mg.pspnc", "5b.pspnc"))
    pseudos = table.get_pseudos_for_structure(structure)

    nval = structure.num_valence_electrons(pseudos)
    #print(nval)

    flow = flowtk.Flow(workdir=options.workdir)

    scf_work = flowtk.Work()
    ngkpt_list = [[4, 4, 4], [8, 8, 8], [12, 12, 12]]
    tsmear_list = [0.01, 0.02, 0.04]
    for ngkpt in ngkpt_list:
        for tsmear in tsmear_list:
            scf_input = make_scf_input(structure, ngkpt, tsmear, pseudos)
            scf_work.register_scf_task(scf_input)
    flow.register_work(scf_work)

    # This call uses the information reported in the GS task to
    # compute all the independent atomic perturbations corresponding to a [4, 4, 4] q-mesh.
    for scf_task in scf_work:
        ph_work = flowtk.PhononWork.from_scf_task(scf_task, qpoints=[4, 4, 4], is_ngqpt=True)
        flow.register_work(ph_work)

    return flow.allocate(use_smartio=True)
Esempio n. 9
0
def make_input(paw=False):
    """
    Build and return an input file for GS calculations with paral_kgb=1
    """
    pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc") if not paw else \
              abidata.pseudos("Si.GGA_PBE-JTH-paw.xml", "o.paw")

    structure = abidata.structure_from_ucell("SiO2-alpha")

    inp = abilab.AbinitInput(structure, pseudos)
    inp.set_kmesh(ngkpt=[1, 1, 1], shiftk=[0, 0, 0])

    # Global variables
    ecut = 24
    inp.set_vars(
        ecut=ecut,
        pawecutdg=ecut * 2 if paw else None,
        paral_kgb=1,
        nsppol=1,
        nband=28,
        npkpt=1,
        npband=1,
        npfft=1,
        fftalg=112,
        #istwfk="*1",
        timopt=-1,
        chksymbreak=0,
        prtwf=0,
        prtden=0,
        tolvrs=1e-8,
        nstep=10,
    )

    return inp
Esempio n. 10
0
def get_gsinput_alas_ngkpt(ngkpt, usepaw=0, as_task=False):
    """
    Build and return a GS input file for AlAs or a Task if `as_task`
    """
    if usepaw != 0: raise NotImplementedError("PAW")
    pseudos = abidata.pseudos("13al.981214.fhi", "33as.pspnc")
    structure = abidata.structure_from_ucell("AlAs")

    from abipy.abio.inputs import AbinitInput
    scf_input = AbinitInput(structure, pseudos=pseudos)

    scf_input.set_vars(
        nband=5,
        ecut=8.0,
        ngkpt=ngkpt,
        nshiftk=1,
        shiftk=[0, 0, 0],
        tolvrs=1.0e-6,
        diemac=12.0,
    )

    if not as_task:
        return scf_input
    else:
        from abipy.flowtk.tasks import ScfTask
        return ScfTask(scf_input)
Esempio n. 11
0
def make_scf_nscf_inputs(nsppol):
    inp = abilab.AbiInput(pseudos=data.pseudos("26fe.pspnc"), ndtset=2)

    # Fe normal bcc structure for test of a ferromagnetic calculation
    structure = data.structure_from_ucell("Fe-fm")
    inp.set_structure(structure)

    # Global variables
    global_vars = dict(nsppol=nsppol,
                       ecut=18,
                       nband=8,
                       occopt=3,
                       tsmear=0.01,
                    )
    if nsppol == 2:
        global_vars.update(spinat=[0.0, 0.0, 4.0])

    inp.set_variables(**global_vars)

    # Dataset 1 (GS run)
    inp[1].set_kmesh(ngkpt=[4,4,4], shiftk=[0.5,0.5,0.5])
    inp[1].set_variables(tolvrs=1e-6)

    # Dataset 2 (NSCF run)
    inp[2].set_kpath(ndivsm=4)
    inp[2].set_variables(tolwfr=1e-8)
    
    # Generate two input files for the GS and the NSCF run 
    scf_input, nscf_input = inp.split_datasets()

    return scf_input, nscf_input
def build_flow(options):
    # 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_")

    structure = abidata.structure_from_ucell("MgB2")

    # Get pseudos from a table.
    table = abilab.PseudoTable(abidata.pseudos("12mg.pspnc", "5b.pspnc"))
    pseudos = table.get_pseudos_for_structure(structure)

    flow = flowtk.Flow(workdir=options.workdir)

    # Build work of GS task. Each gs_task uses different (ngkpt, tsmear) values
    # and represent the starting point of the phonon works.
    scf_work = flowtk.Work()
    ngkpt_list = [[4, 4, 4], [8, 8, 8]] #, [12, 12, 12]]
    tsmear_list = [0.01, 0.02] # , 0.04]
    for ngkpt in ngkpt_list:
        for tsmear in tsmear_list:
            scf_input = make_scf_input(structure, ngkpt, tsmear, pseudos)
            scf_work.register_scf_task(scf_input)
    flow.register_work(scf_work)

    # This call uses the information reported in the GS task to
    # compute all the independent atomic perturbations corresponding to a [2, 2, 2] q-mesh.
    # For each GS task, construct a phonon work that will inherit (ngkpt, tsmear) from scf_task.
    for scf_task in scf_work:
        ph_work = flowtk.PhononWork.from_scf_task(scf_task, qpoints=[2, 2, 2], is_ngqpt=True)
        flow.register_work(ph_work)

    return flow.allocate(use_smartio=True)
Esempio n. 13
0
def make_scf_input(ecut=10, ngkpt=(8, 8, 8)):
    """
    This function constructs an `AbinitInput` for performing a
    GS-SCF calculation in crystalline AlAs.

    Args:
        ecut: cutoff energy in Ha.
        ngkpt: 3 integers specifying the k-mesh for the electrons.

    Return:
        `AbinitInput` object
    """
    # Initialize the AlAs structure from an internal database. Use the pseudos shipped with AbiPy.
    gs_inp = abilab.AbinitInput(structure=abidata.structure_from_ucell("AlAs"),
                                pseudos=abidata.pseudos(
                                    "13al.981214.fhi", "33as.pspnc"))

    # Set the value of the Abinit variables needed for GS runs.
    gs_inp.set_vars(
        nband=4,
        ecut=ecut,
        ngkpt=ngkpt,
        nshiftk=1,
        shiftk=[0.0, 0.0, 0.0],
        ixc=7,
        nstep=500,
        iscf=7,
        diemac=5.0,
        toldfe=1.0e-22,
        nbdbuf=0,
        kptopt=1,
    )

    gs_inp.set_mnemonics(True)
    return gs_inp
Esempio n. 14
0
def build_flow(options):
    # 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(sys.argv[0]).replace(
            ".py", "").replace("run_", "flow_")

    # Init structure from internal database.
    structure = abidata.structure_from_ucell("MgB2")

    # Our pseudopotentials.
    pseudos = abilab.PseudoTable(["Mg-low.psp8", "B.psp8"])

    flow = flowtk.Flow(workdir=options.workdir)

    # Build work of GS task. Each gs_task uses different (ngkpt, tsmear) values
    # and represent the starting point of the phonon works.
    ngkpt = [12, 12, 12]
    tsmear = 0.02
    scf_input, nscf_input = make_scf_nscf_inputs(structure, ngkpt, tsmear,
                                                 pseudos)

    gs_work = flowtk.Work()
    scf_task = gs_work.register_scf_task(scf_input)
    nscf_task = gs_work.register_nscf_task(nscf_input, deps={scf_task: "DEN"})
    flow.register_work(gs_work)

    # This call uses the information reported in the GS task to
    # compute all the independent atomic perturbations corresponding to a [6, 6, 6] q-mesh.
    ph_work = flowtk.PhononWork.from_scf_task(scf_task,
                                              qpoints=[4, 4, 4],
                                              is_ngqpt=True)
    flow.register_work(ph_work)

    return flow.allocate(use_smartio=True)
Esempio n. 15
0
def make_inputs(paral_kgb=1):
    """
    Returns a tuple of 4 input files for SCF, NSCF, SCR, SIGMA calculations.
    These files are then used as templates for the convergence study
    wrt ecuteps and the number of bands in W.
    """
    structure = abidata.structure_from_ucell("SiC")
    pseudos = abidata.pseudos("14si.pspnc", "6c.pspnc")
    ecut = 12

    global_vars = dict(
        ecut=ecut,
        istwfk="*1",
        paral_kgb=paral_kgb,
        gwpara=2
    )

    ecuteps = 4
    ngkpt = [4, 4, 4]
    shiftk = [0, 0, 0]

    inp = abilab.AbiInput(pseudos=pseudos, ndtset=4)

    inp.set_structure(structure)
    inp.set_vars(**global_vars)
    inp.set_kmesh(ngkpt=ngkpt, shiftk=shiftk)

    inp[1].set_vars(
        nband=10,
        tolvrs=1.e-8,
    )

    inp[2].set_vars(
        nband=25,
        tolwfr=1.e-8,
        iscf=-2
    )

    inp[3].set_vars(
        optdriver=3,
        ecutwfn=ecut,
        nband=20,
        symchi=1,
        inclvkb=0,
        ecuteps=ecuteps,
    )
        
    inp[4].set_vars(
        optdriver=4,
        nband=20,
        ecutwfn=ecut,
        ecutsigx=ecut,
        #ecutsigx=(4*ecut), ! This is problematic
        symsigma=1,
        ecuteps=ecuteps,
        )

    inp[4].set_kptgw(kptgw=[[0,0,0], [0.5, 0, 0]], bdgw=[1, 8])

    return inp.split_datasets()
Esempio n. 16
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_") 

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

    # Create the work for the band structure calculation.
    structure = abidata.structure_from_ucell("NiO")
    pseudos = abidata.pseudos("28ni.paw", "8o.2.paw")

    # The code below set up the parameters for the LDA+U calculation in NiO.
    #usepawu   1
    #lpawu   2 -1
    #upawu  8.0 0.0 eV
    #jpawu  0.8 0.0 eV
    usepawu = 1
    u_values = [5.0, 8.0]

    for u in u_values:
        # Apply U-J on Ni only.
        luj_params = abilab.LdauParams(usepawu, structure)
        luj_params.luj_for_symbol("Ni", l=2, u=u, j=0.1*u, unit="eV")

        scf_input, nscf_input, dos_input = make_scf_nscf_dos_inputs(structure, pseudos, luj_params)
                                                                       
        work = abilab.BandStructureWork(scf_input, nscf_input, dos_inputs=dos_input)
        flow.register_work(work)

    return flow
Esempio n. 17
0
def make_input(paw=False):
    """Build a template input file for GS calculations with k-point parallelism """
    pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc") if not paw else \
              abidata.pseudos("Si.GGA_PBE-JTH-paw.xml", "o.paw")
    structure = abidata.structure_from_ucell("SiO2-alpha")

    inp = abilab.AbinitInput(structure, pseudos)
    inp.set_kmesh(ngkpt=[1,1,1], shiftk=[0,0,0])

    # Global variables
    ecut = 24
    inp.set_vars(
        ecut=ecut,
        pawecutdg=ecut*2 if paw else None,
        nsppol=1,
        nband=28,
        paral_kgb=0,
        #istwfk="*1",
        #fftalg=312,
        timopt=-1,
        chksymbreak=0,
        prtwf=0,
        prtden=0,
        tolvrs=1e-10,
    )

    return inp
Esempio n. 18
0
def make_input():
    """Build a template input file for GS calculations with k-point parallelism """
    pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc")

    structure = abidata.structure_from_ucell("SiO2-alpha")
    #structure.make_supercell([3,3,3])

    inp = abilab.AbinitInput(structure, pseudos)
    inp.set_kmesh(ngkpt=[4, 4, 4], shiftk=[0, 0, 0])

    # Global variables
    ecut = 24
    inp.set_vars(
        ecut=ecut,
        nsppol=1,
        nband=28,
        paral_kgb=0,
        istwfk="*1",
        timopt=-1,
        chksymbreak=0,
        chkprim=0,
        maxnsym=2400,
        prtwf=0,
        prtden=0,
        tolvrs=1e-8,
    )

    return inp
Esempio n. 19
0
def make_scf_nscf_inputs(nsppol, paral_kgb=1):
    """
    Generate two input files for the GS and the NSCF run for given `nsppol`.
    """
    # Fe normal bcc structure for test of a ferromagnetic calculation
    multi = abilab.MultiDataset(structure=data.structure_from_ucell("Fe-fm"),
                                pseudos=data.pseudos("26fe.pspnc"), ndtset=2)

    # Global variables
    global_vars = dict(
        nsppol=nsppol,
        ecut=18,
        nband=8,
        occopt=3,
        tsmear=0.01,
        paral_kgb=paral_kgb,
    )
    if nsppol == 2:
        global_vars.update(spinat=[0.0, 0.0, 4.0])

    multi.set_vars(global_vars)

    # Dataset 1 (GS run)
    multi[0].set_kmesh(ngkpt=[4,4,4], shiftk=[0.5,0.5,0.5])
    multi[0].set_vars(tolvrs=1e-6)

    # Dataset 2 (NSCF run)
    multi[1].set_kpath(ndivsm=4)
    multi[1].set_vars(tolwfr=1e-8)

    # Generate two input files for the GS and the NSCF run
    scf_input, nscf_input = multi.split_datasets()

    return scf_input, nscf_input
Esempio n. 20
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_") 

    flow = abilab.Flow(workdir, manager=options.manager)

    # Create the work for the band structure calculation.
    structure = abidata.structure_from_ucell("NiO")
    pseudos = abidata.pseudos("28ni.paw", "8o.2.paw")

    # The code below set up the parameters for the LDA+U calculation in NiO.
    #usepawu   1
    #lpawu   2 -1
    #upawu  8.0 0.0 eV
    #jpawu  0.8 0.0 eV
    usepawu = 1
    u_values = [5.0, 8.0]

    for u in u_values:
        # Apply U-J on Ni only.
        luj_params = abilab.LdauParams(usepawu, structure)
        luj_params.luj_for_symbol("Ni", l=2, u=u, j=0.1*u, unit="eV")

        scf_input, nscf_input, dos_input = make_scf_nscf_dos_inputs(structure, pseudos, luj_params)
                                                                       
        work = abilab.BandStructureWork(scf_input, nscf_input, dos_inputs=dos_input)
        flow.register_work(work)

    return flow
def build_flow(options):
    # 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(sys.argv[0]).replace(
            ".py", "").replace("run_", "flow_")

    structure = abidata.structure_from_ucell("MgB2")

    # Get pseudos from a table.
    table = abilab.PseudoTable(abidata.pseudos("12mg.pspnc", "5b.pspnc"))
    pseudos = table.get_pseudos_for_structure(structure)

    flow = flowtk.Flow(workdir=options.workdir)

    # Build work of GS task. Each gs_task uses different (ngkpt, tsmear) values
    # and represent the starting point of the phonon works.
    scf_work = flowtk.Work()
    ngkpt_list = [[4, 4, 4], [8, 8, 8]]  #, [12, 12, 12]]
    tsmear_list = [0.01, 0.02]  # , 0.04]
    for ngkpt in ngkpt_list:
        for tsmear in tsmear_list:
            scf_input = make_scf_input(structure, ngkpt, tsmear, pseudos)
            scf_work.register_scf_task(scf_input)
    flow.register_work(scf_work)

    # This call uses the information reported in the GS task to
    # compute all the independent atomic perturbations corresponding to a [2, 2, 2] q-mesh.
    # For each GS task, construct a phonon work that will inherit (ngkpt, tsmear) from scf_task.
    for scf_task in scf_work:
        ph_work = flowtk.PhononWork.from_scf_task(scf_task,
                                                  qpoints=[2, 2, 2],
                                                  is_ngqpt=True)
        flow.register_work(ph_work)

    return flow.allocate(use_smartio=True)
Esempio n. 22
0
def build_flow(options):
    # 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_")

    flow = flowtk.Flow(options.workdir, manager=options.manager)

    pseudos = abidata.pseudos("14si.pspnc")

    # Get the unperturbed structure.
    base_structure = abidata.structure_from_ucell("Si")

    etas = [-.001, 0, +.001]
    ph_displ = np.reshape(np.zeros(3*len(base_structure)), (-1,3))
    ph_displ[0,:] = [+1, 0, 0]
    ph_displ[1,:] = [-1, 0, 0]

    # Build new structures by displacing atoms according to the phonon displacement
    # ph_displ (in cartesian coordinates). The Displacement is normalized so that
    # the maximum atomic diplacement is 1 Angstrom and then multiplied by eta.
    modifier = abilab.StructureModifier(base_structure)

    displaced_structures = modifier.displace(ph_displ, etas, frac_coords=False)

    # Generate the different shifts to average
    ndiv = 2
    shift1D = np.arange(1,2*ndiv+1,2)/(2*ndiv)
    all_shifts = [[x,y,z] for x in shift1D for y in shift1D for z in shift1D]
    all_shifts = [[0, 0, 0]]

    for structure, eta in zip(displaced_structures, etas):
        for shift in all_shifts:
            flow.register_work(raman_work(structure, pseudos, shift))

    return flow
Esempio n. 23
0
def make_input(paw=False):
    """Build a template for GS calculations with k-point parallelism"""
    pseudos = abidata.pseudos("14si.pspnc") if not paw else abidata.pseudos(
        "Si.GGA_PBE-JTH-paw.xml")
    structure = abidata.structure_from_ucell("Si")

    inp = abilab.AbinitInput(structure, pseudos)
    inp.set_kmesh(ngkpt=[12, 12, 12], shiftk=[0, 0, 0])

    # Global variables
    ecut = 40
    inp.set_vars(
        ecut=ecut,
        pawecutdg=ecut * 4 if paw else None,
        nsppol=2,
        nband=40,
        paral_kgb=0,
        #istwfk="*1",
        timopt=-1,
        chksymbreak=0,
        prtwf=0,
        prtden=0,
        tolvrs=1e-10,
    )

    return inp
Esempio n. 24
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_")

    #pseudos = abidata.pseudos("12mg.pspnc", "5b.pspnc")
    structure = abidata.structure_from_ucell("MgB2")

    # Get pseudos from a table.
    table = abilab.PseudoTable(abidata.pseudos("12mg.pspnc", "5b.pspnc"))
    pseudos = table.get_pseudos_for_structure(structure)

    nval = structure.num_valence_electrons(pseudos)
    #print(nval)

    inputs = make_scf_nscf_inputs(structure, pseudos)
    scf_input, nscf_input, dos_inputs = inputs[0], inputs[1], inputs[2:]
    #print(scf_input.pseudos)

    return abilab.bandstructure_flow(workdir,
                                     scf_input,
                                     nscf_input,
                                     dos_inputs=dos_inputs,
                                     manager=options.manager)
Esempio n. 25
0
def make_scf_nscf_inputs(nsppol, paral_kgb=1):
    """
    Generate two input files for the GS and the NSCF run for given `nsppol`.
    """
    # Fe normal bcc structure for test of a ferromagnetic calculation
    multi = abilab.MultiDataset(structure=data.structure_from_ucell("Fe-fm"),
                                pseudos=data.pseudos("26fe.pspnc"), ndtset=2)

    # Global variables
    global_vars = dict(
        nsppol=nsppol,
        ecut=18,
        nband=8,
        occopt=3,
        tsmear=0.01,
        paral_kgb=paral_kgb,
    )
    if nsppol == 2:
        global_vars.update(spinat=[0.0, 0.0, 4.0])

    multi.set_vars(global_vars)

    # Dataset 1 (GS run)
    multi[0].set_kmesh(ngkpt=[4,4,4], shiftk=[0.5,0.5,0.5])
    multi[0].set_vars(tolvrs=1e-6)

    # Dataset 2 (NSCF run)
    multi[1].set_kpath(ndivsm=4)
    multi[1].set_vars(tolwfr=1e-8)

    # Generate two input files for the GS and the NSCF run
    scf_input, nscf_input = multi.split_datasets()

    return scf_input, nscf_input
Esempio n. 26
0
def make_input():
    """Build a template input file for GS calculations with k-point parallelism """
    pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc")

    structure = abidata.structure_from_ucell("SiO2-alpha")
    #structure.make_supercell([3,3,3])

    inp = abilab.AbinitInput(structure, pseudos)
    inp.set_kmesh(ngkpt=[4,4,4], shiftk=[0,0,0])

    # Global variables
    ecut = 24
    inp.set_vars(
        ecut=ecut,
        nsppol=1,
        nband=28,
        paral_kgb=0,
        istwfk="*1",
        timopt=-1,
        chksymbreak=0,
        chkprim=0,
        maxnsym=2400,
        prtwf=0,
        prtden=0,
        tolvrs=1e-8,
    )

    return inp
Esempio n. 27
0
def make_inputs(paral_kgb=1):
    """
    Returns a tuple of 4 input files for SCF, NSCF, SCR, SIGMA calculations.
    These files are then used as templates for the convergence study
    wrt ecuteps and the number of bands in W.
    """
    multi = abilab.MultiDataset(abidata.structure_from_ucell("SiC"),
                                pseudos=abidata.pseudos(
                                    "14si.pspnc", "6c.pspnc"),
                                ndtset=4)

    ecut = 12
    global_vars = dict(
        ecut=ecut,
        istwfk="*1",
        paral_kgb=paral_kgb,
        gwpara=2,
        iomode=1,
    )

    ecuteps = 4
    ngkpt = [4, 4, 4]
    shiftk = [0, 0, 0]

    multi.set_vars(global_vars)
    multi.set_kmesh(ngkpt=ngkpt, shiftk=shiftk)

    # SCF
    multi[0].set_vars(
        nband=10,
        tolvrs=1.e-8,
    )

    # NSCF
    multi[1].set_vars(nband=25, tolwfr=1.e-8, iscf=-2)

    # SCR
    multi[2].set_vars(
        optdriver=3,
        ecutwfn=ecut,
        nband=20,
        symchi=1,
        inclvkb=0,
        ecuteps=ecuteps,
    )

    # SIGMA
    multi[3].set_vars(
        optdriver=4,
        nband=20,
        ecutwfn=ecut,
        ecutsigx=ecut,
        #ecutsigx=(4*ecut), ! This is problematic
        symsigma=1,
        ecuteps=ecuteps,
    )

    multi[3].set_kptgw(kptgw=[[0, 0, 0], [0.5, 0, 0]], bdgw=[1, 8])

    return multi.split_datasets()
Esempio n. 28
0
    def test_base(self):
        """Testing ScalarField."""
        structure = abidata.structure_from_ucell("Si")
        nspinor, nsppol, nspden = 1, 1, 1
        xyz_shape = (2, 3, 4)
        datar = np.zeros((nsppol, ) + xyz_shape)

        field = ScalarField(nspinor,
                            nsppol,
                            nspden,
                            datar,
                            structure,
                            iorder="c")

        print(field)
        assert field.datar.ndim == 4
        assert len(field) == nsppol
        assert field.shape == datar.shape
        assert field.nx == 2 and field.ny == 3 and field.nz == 4
        assert field.is_collinear

        #assert field.datar_xyz.ndim == 4
        #assert field.datar_xyz.shape[-3:], xyz_shape)

        field.export(self.get_tmpname(text=True, suffix=".xsf"))
Esempio n. 29
0
def make_template():
    """Build a template input file for GS calculations with paral_kgb"""
    inp = abilab.AbiInput(pseudos=data.pseudos("14si.pspnc"))
    inp.set_structure(data.structure_from_ucell("Si"))

    # GS run with paral_kgb
    inp.set_kmesh(ngkpt=[1,1,1], shiftk=[0,0,0])

    # Global variables
    global_vars = dict(ecut=20,
                       nsppol=1,
                       nband=20,
                       paral_kgb=1,
                       npkpt=1,
                       npband=1,
                       npfft=1,
                       #
                       istwfk="*1",
                       timopt=-1,
                       chksymbreak=0,
                       prtwf=0,
                       prtden=0,
                       tolvrs=1e-8,
                       nstep=10,
                       )
    inp.set_variables(**global_vars)

    return inp
Esempio n. 30
0
def make_scf_input(ecut=2, ngkpt=(4, 4, 4)):
    """
    This function constructs an `AbinitInput` for performing a 
    GS-SCF calculation in crystalline AlAs.

    Args:
        ecut: cutoff energy in Ha.
        ngkpt: 3 integers specifying the k-mesh for the electrons.

    Return:
        `AbinitInput` object 
    """
    # Initialize the AlAs structure from an internal database. Use the pseudos shipped with AbiPy.
    gs_inp = abilab.AbinitInput(structure=abidata.structure_from_ucell("AlAs"),
                                pseudos=abidata.pseudos("13al.981214.fhi", "33as.pspnc"))
    
    # Set the value of the Abinit variables needed for GS runs.
    gs_inp.set_vars(
        nband=4,       
        ecut=ecut,         
        ngkpt=ngkpt,
        nshiftk=4,
        shiftk=[0.0, 0.0, 0.5,   # This gives the usual fcc Monkhorst-Pack grid
                0.0, 0.5, 0.0,
                0.5, 0.0, 0.0,
                0.5, 0.5, 0.5],
        ixc=1,
        nstep=25,
        diemac=9.0,
        tolvrs=1.0e-10,
    )
    
    gs_inp.set_mnemonics(True)
    return gs_inp
Esempio n. 31
0
def make_template(paral_kgb=1, paw=False):
    """Build a template input file for GS calculations with paral_kgb"""
    pseudos = abidata.pseudos("14si.pspnc") if not paw else abidata.pseudos(
        "Si.GGA_PBE-JTH-paw.xml")
    inp = abilab.AbiInput(pseudos=pseudos, ndtset=1)
    inp.set_structure(abidata.structure_from_ucell("Si"))

    # GS run with paral_kgb
    inp.set_kmesh(ngkpt=[1, 1, 1], shiftk=[0, 0, 0])

    # Global variables
    ecut = 20
    global_vars = dict(
        ecut=ecut,
        pawecutdg=ecut * 4,
        nsppol=1,
        nband=20,
        paral_kgb=paral_kgb,
        npkpt=1,
        npband=1,
        npfft=1,
        fftalg=112,
        #
        istwfk="*1",
        timopt=-1,
        chksymbreak=0,
        prtwf=0,
        prtden=0,
        tolvrs=1e-8,
        nstep=10,
    )
    inp.set_variables(**global_vars)
    return inp
Esempio n. 32
0
def make_scf_input(paral_kgb=0):
    """
    This function constructs the input files for the phonon calculation:
    GS input + the input files for the phonon calculation.
    """
    # Crystalline AlAs: computation of the second derivative of the total energy
    structure = abidata.structure_from_ucell("AlAs")
    pseudos = abidata.pseudos("13al.981214.fhi", "33as.pspnc")
    gs_inp = abilab.AbinitInput(structure, pseudos=pseudos)

    gs_inp.set_vars(
        nband=4,
        ecut=2.0,
        ngkpt=[4, 4, 4],
        nshiftk=4,
        shiftk=[0.0, 0.0, 0.5,   # This gives the usual fcc Monkhorst-Pack grid
                0.0, 0.5, 0.0,
                0.5, 0.0, 0.0,
                0.5, 0.5, 0.5],
        #shiftk=[0, 0, 0],
        paral_kgb=paral_kgb,
        tolvrs=1.0e-10,
        ixc=1,
        diemac=9.0,
        iomode=3,
    )

    return gs_inp
Esempio n. 33
0
def make_inputs(tvars):
    """Constrcut the input files."""
    structure = abidata.structure_from_ucell("GaAs")

    inp = abilab.AbiInput(pseudos=abidata.pseudos("31ga.pspnc", "33as.pspnc"), ndtset=5)
    inp.set_structure(structure)

    # Global variables
    kmesh = dict(ngkpt=[4, 4, 4],
                 nshiftk=4,
                 shiftk=[[0.5, 0.5, 0.5],
                         [0.5, 0.0, 0.0],
                         [0.0, 0.5, 0.0],
                         [0.0, 0.0, 0.5]])

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

    global_vars.update(kmesh)

    inp.set_variables(**global_vars)

    # Dataset 1 (GS run)
    inp[1].set_variables(
        tolvrs=1e-6,
        nband=4)

    # NSCF run with large number of bands, and points in the the full BZ
    inp[2].set_variables(
        iscf=-2,
        nband=20,
        nstep=25,
        kptopt=1,
        tolwfr=1.e-8)
        #kptopt=3)

    # Fourth dataset: ddk response function along axis 1
    # Fifth dataset: ddk response function along axis 2
    # Sixth dataset: ddk response function along axis 3
    for idir in range(3):
        rfdir = 3 * [0]
        rfdir[idir] = 1

        inp[3+idir].set_variables(
            iscf=-3,
            nband=20,
            nstep=1,
            nline=0,
            prtwf=3,
            kptopt=3,
            nqpt=1,
            qpt=[0.0, 0.0, 0.0],
            rfdir=rfdir,
            rfelfd=2,
            tolwfr=1.e-9,
        )

    # scf_inp, nscf_inp, ddk1, ddk2, ddk3
    return inp.split_datasets()
Esempio n. 34
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_") 

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

    flow = abilab.Flow(workdir, manager)

    pseudos = data.pseudos("14si.pspnc", "6c.pspnc")
    structure = data.structure_from_ucell("SiC")

    global_vars = dict(
        chksymbreak=0,
        ecut=20,
        paral_kgb=0,
    )

    ngkpt = [4,4,4]
    shiftk = [[0.5,0.5,0.5],
              [0.5,0.0,0.0],
              [0.0,0.5,0.0],
              [0.0,0.0,0.5]]


    inp = abilab.AbiInput(pseudos=pseudos, ndtset=2)
    inp.set_structure(structure)
    inp.set_vars(**global_vars)

    relax_inp, nscf_inp = inp[1:]

    relax_inp.set_kmesh(ngkpt=ngkpt, shiftk=shiftk)
    relax_inp.set_vars(
        toldff=1e-6,
        tolmxf=1e-5,
        strfact=100,
        ecutsm=0.5,
        dilatmx=1.15,
        ntime=100,
        ionmov=2,
        optcell=1,
    )

    nscf_inp.set_kpath(ndivsm=20)
    nscf_inp.tolwfr = 1e-22

    relax_inp, nscf_inp = inp.split_datasets()

    # Initialize the work.
    relax_task = flow.register_task(relax_inp, task_class=abilab.RelaxTask)

    #work = RelaxWork(self, ion_input, ioncell_input, workdir=None, manager=None):

    nscf_task = flow.register_task(nscf_inp, deps={relax_task: "DEN"}, task_class=abilab.NscfTask)

    return flow.allocate()
Esempio n. 35
0
def itest_phonon_restart(fwp):
    """Test the restart of phonon calculations with the scheduler."""
    # Crystalline AlAs: computation of the second derivative of the total energy
    structure = abidata.structure_from_ucell("AlAs")

    # List of q-points for the phonon calculation (4,4,4) mesh.
    qpoints = np.reshape([
             0.00000000E+00,  0.00000000E+00,  0.00000000E+00,
             2.50000000E-01,  0.00000000E+00,  0.00000000E+00,
             #5.00000000E-01,  0.00000000E+00,  0.00000000E+00,  # XXX Uncomment this line to test restart from 1DEN
                                                                 # Too long --> disabled
            ], (-1, 3))

    # Global variables used both for the GS and the DFPT run.
    global_vars = dict(nband=4,
                       ecut=3.0,
                       ngkpt=[4, 4, 4],
                       shiftk=[0, 0, 0],
                       tolvrs=1.0e-5,
                    )

    multi = abilab.MultiDataset(structure=structure, pseudos=abidata.pseudos("13al.981214.fhi", "33as.pspnc"), 
                                ndtset=1+len(qpoints))

    multi.set_vars(global_vars)

    for i, qpt in enumerate(qpoints):
        # Response-function calculation for phonons.
        multi[i+1].set_vars(
            rfphon=1,        # Will consider phonon-type perturbation.
            nqpt=1,          # One wavevector is to be considered.
            qpt=qpt,         # q-wavevector.
            kptopt=3,
            nstep=5,         # This is to trigger the phonon restart.
        )
        #rfatpol   1 1   # Only the first atom is displaced
        #rfdir   1 0 0   # Along the first reduced coordinate axis
        #kptopt   2      # Automatic generation of k points, taking

                                                           # i == 0 --> restart from WFK
        if i == 1: multi[i+1].set_vars(prtwf=-1, nstep=5)  # Restart with WFK and smart- io.
        if i == 2: multi[i+1].set_vars(prtwf=0, nstep=8)   # Restart from 1DEN. Too long --> disabled.

    all_inps = multi.split_datasets()
    scf_input, ph_inputs = all_inps[0], all_inps[1:]

    flow = abilab.phonon_flow(fwp.workdir, scf_input, ph_inputs, manager=fwp.manager)
    flow.set_garbage_collector()

    for task in flow.iflat_tasks():
        task.manager.qadapter.max_num_launches = 20

    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

    assert sum(task.num_restarts for task in flow.iflat_tasks()) > 0
Esempio n. 36
0
def make_inputs(paw=False):
    pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc") if not paw else \
              abidata.pseudos("Si.GGA_PBE-JTH-paw.xml", "o.paw")

    structure = abidata.structure_from_ucell("SiO2-alpha")

    multi = abilab.MultiDataset(structure, pseudos=pseudos, ndtset=4)

    ecut = 24
    multi.set_vars(
        ecut=ecut,
        pawecutdg=ecut * 2 if paw else None,
        paral_kgb=0,
        istwfk="*1",
        timopt=-1,
    )

    multi.set_kmesh(ngkpt=[4, 4, 3], shiftk=[0.0, 0.0, 0.0])

    gs, nscf, scr, sigma = multi.split_datasets()

    # Dataset 1 (GS run)
    gs.set_vars(
        tolvrs=1e-6,
        nband=28,
    )

    # Dataset 2 (NSCF run)
    nscf.set_vars(
        iscf=-2,
        tolwfr=1e-4,
        nband=600,
        nbdbuf=200,
    )

    # Dataset3: Calculation of the screening.
    scr.set_vars(
        optdriver=3,
        gwpara=2,
        nband=25,
        ecutwfn=ecut,
        symchi=1,
        inclvkb=0,
        ecuteps=6.0,
    )

    # Dataset4: Calculation of the Self-Energy matrix elements (GW corrections)
    sigma.set_vars(
        optdriver=4,
        gwpara=2,
        ecutwfn=ecut,
        ecuteps=6.0,
        ecutsigx=ecut,
        symsigma=1,
        gw_qprange=1,
    )

    return gs, nscf, scr, sigma
Esempio n. 37
0
def build_flow(options):
    # Set 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_")

    structure = abidata.structure_from_ucell("GaAs")
    pseudos = abidata.pseudos("Ga-low_r.psp8", "As_r.psp8")
    num_electrons = structure.num_valence_electrons(pseudos)
    #print("num_electrons:", num_electrons)

    # Usa same shifts in all tasks.
    ngkpt = [4, 4, 4]
    shiftk= [
        [0.5, 0.5, 0.5],
        [0.5, 0.0, 0.0],
        [0.0, 0.5, 0.0],
        [0.0, 0.0, 0.5],
    ]

    # NSCF run on k-path with large number of bands
    kptbounds = [
        [0.5, 0.0, 0.0],  # L point
        [0.0, 0.0, 0.0],  # Gamma point
        [0.0, 0.5, 0.5],  # X point
    ]

    # Initialize the flow.
    flow = flowtk.Flow(options.workdir, manager=options.manager)

    for nspinor in [1, 2]:
        # Multi will contain two datasets (GS + NSCF) for the given nspinor.
        multi = abilab.MultiDataset(structure=structure, pseudos=pseudos, ndtset=2)

        # Global variables.
        multi.set_vars(
            ecut=20,
            nspinor=nspinor,
            nspden=1 if nspinor == 1 else 4,
            so_psp="*0" if nspinor == 1 else "*1",   # Important!
            #paral_kgb=1,
        )

        nband_occ = num_electrons // 2 if nspinor == 1 else num_electrons
        #print(nband_occ)

        # Dataset 1 (GS run)
        multi[0].set_vars(tolvrs=1e-8, nband=nband_occ + 4)
        multi[0].set_kmesh(ngkpt=ngkpt, shiftk=shiftk, kptopt=1 if nspinor == 1 else 4)

        multi[1].set_vars(iscf=-2, nband=nband_occ + 4, tolwfr=1.e-12)
        multi[1].set_kpath(ndivsm=10, kptbounds=kptbounds)

        # Get the SCF and the NSCF input.
        scf_input, nscf_input = multi.split_datasets()

        flow.register_work(flowtk.BandStructureWork(scf_input, nscf_input))

    return flow
Esempio n. 38
0
def build_flow(options):
    # Set 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(sys.argv[0]).replace(".py", "").replace("run_", "flow_")

    structure = abidata.structure_from_ucell("GaAs")
    pseudos = abidata.pseudos("Ga-low_r.psp8", "As_r.psp8")
    num_electrons = structure.num_valence_electrons(pseudos)
    #print("num_electrons:", num_electrons)

    # Usa same shifts in all tasks.
    ngkpt = [4, 4, 4]
    shiftk = [
        [0.5, 0.5, 0.5],
        [0.5, 0.0, 0.0],
        [0.0, 0.5, 0.0],
        [0.0, 0.0, 0.5],
    ]

    # NSCF run on k-path with large number of bands
    kptbounds = [
        [0.5, 0.0, 0.0],  # L point
        [0.0, 0.0, 0.0],  # Gamma point
        [0.0, 0.5, 0.5],  # X point
    ]

    # Initialize the flow.
    flow = flowtk.Flow(options.workdir, manager=options.manager)

    for nspinor in [1, 2]:
        # Multi will contain two datasets (GS + NSCF) for the given nspinor.
        multi = abilab.MultiDataset(structure=structure, pseudos=pseudos, ndtset=2)

        # Global variables.
        multi.set_vars(
            ecut=20,
            nspinor=nspinor,
            nspden=1 if nspinor == 1 else 4,
            so_psp="*0" if nspinor == 1 else "*1",   # Important!
            #paral_kgb=1,
        )

        nband_occ = num_electrons // 2 if nspinor == 1 else num_electrons
        #print(nband_occ)

        # Dataset 1 (GS run)
        multi[0].set_vars(tolvrs=1e-8, nband=nband_occ + 4)
        multi[0].set_kmesh(ngkpt=ngkpt, shiftk=shiftk, kptopt=1 if nspinor == 1 else 4)

        multi[1].set_vars(iscf=-2, nband=nband_occ + 4, tolwfr=1.e-12)
        multi[1].set_kpath(ndivsm=10, kptbounds=kptbounds)

        # Get the SCF and the NSCF input.
        scf_input, nscf_input = multi.split_datasets()

        flow.register_work(flowtk.BandStructureWork(scf_input, nscf_input))

    return flow
Esempio n. 39
0
    def test_utils(self):
        """Test utilities for the generation of Abinit inputs."""
        # Test as_structure and from/to abivars
        si = Structure.as_structure(abidata.cif_file("si.cif"))
        assert si.formula == "Si2"
        assert si.abi_spacegroup is None and not si.has_abi_spacegroup

        if self.has_matplotlib():
            si.show_bz(show=False)

        assert si is Structure.as_structure(si)
        assert si == Structure.as_structure(si.to_abivars())
        assert si == Structure.from_abivars(si.to_abivars())
        assert len(si.abi_string)
        assert si.reciprocal_lattice == si.lattice.reciprocal_lattice
        #si.si_kptbounds()
        #si.calc_ksampling(nksmall=10)
        #si.calc_ngkpt(nksmall=10)
        #si.calc_shiftk()

        si = Structure.from_material_id("mp-149", api_key="8pkvwRLQSCVbW2Fe")
        assert si.formula == "Si2"

        mgb2 = abidata.structure_from_ucell("MgB2")
        if self.has_ase():
            mgb2.abi_primitive()
        # FIXME: This is buggy
        #print(mgb2.get_sorted_mgb2())
        #assert [site.species_string for site in mgb2.get_sorted_structure()] == ["B", "B", "Mg"]
        mgb2.abi_sanitize()
        mgb2.get_conventional_standard_structure()
        assert len(mgb2.abi_string)
        assert len(mgb2.spglib_summary(verbose=10))
        #print(structure.__repr_html__())

        self.serialize_with_pickle(mgb2)

        pseudos = abidata.pseudos("12mg.pspnc", "5b.pspnc")
        assert mgb2.num_valence_electrons(pseudos) == 8
        assert mgb2.valence_electrons_per_atom(pseudos) == [2, 3, 3]
        self.assert_equal(mgb2.calc_shiftk() , [[0.0, 0.0, 0.5]])

        #bmol = Structure.boxed_molecule(pseudos, cart_coords=[[0, 0, 0], [5, 5, 5]])
        #self.assert_almost_equal(bmol.volume, (10 * bohr_to_ang) ** 3)
        #batom = Structure.boxed_atom(abidata.pseudo("12mg.pspnc"), cart_coords=[1, 2, 3], acell=(10, 20, 30))
        #assert isinstance(batom, Structure)
        #assert len(batom.cart_coords) == 1 and np.all(batom.cart_coords[0] == [1, 2, 3])

        #bcc = Structure.bcc(a=10, species, primitive)
        #fcc = Structure.bcc(a=10, species, primitive)
        #rock = Structure.rocksalt(a=10, species)
        #perov = Structure.ABO3(a=10, species)

        # Test notebook generation.
        if self.has_nbformat():
            mgb2.write_notebook(nbpath=self.get_tmpname(text=True))
Esempio n. 40
0
def make_inputs(paw=False):
    pseudos = abidata.pseudos("14si.pspnc", "8o.pspnc") if not paw else \
              abidata.pseudos("Si.GGA_PBE-JTH-paw.xml", "o.paw")

    structure = abidata.structure_from_ucell("SiO2-alpha")

    multi = abilab.MultiDataset(structure, pseudos=pseudos, ndtset=4)

    ecut = 24
    multi.set_vars(
        ecut=ecut,
        pawecutdg=ecut*2 if paw else None,
        paral_kgb=0,
        istwfk="*1",
        timopt=-1,
    )


    multi.set_kmesh(ngkpt=[4,4,3], shiftk=[0.0, 0.0, 0.0])

    gs, nscf, scr, sigma = multi.split_datasets()

    # Dataset 1 (GS run)
    gs.set_vars(tolvrs=1e-6,
                nband=28,)

    # Dataset 2 (NSCF run)
    nscf.set_vars(iscf=-2,
                  tolwfr=1e-4,
                  nband=600,
                  nbdbuf=200,
                  )

    # Dataset3: Calculation of the screening.
    scr.set_vars(
        optdriver=3,
        gwpara=2,
        nband=25,
        ecutwfn=ecut,
        symchi=1,
        inclvkb=0,
        ecuteps=6.0,
    )

    # Dataset4: Calculation of the Self-Energy matrix elements (GW corrections)
    sigma.set_vars(
        optdriver=4,
        gwpara=2,
        ecutwfn=ecut,
        ecuteps=6.0,
        ecutsigx=ecut,
        symsigma=1,
        gw_qprange=1,
    )

    return gs, nscf, scr, sigma
Esempio n. 41
0
def make_inputs(tvars):
    """Constrcut the input files."""
    structure = abidata.structure_from_ucell("GaAs")

    multi = abilab.MultiDataset(structure, pseudos=abidata.pseudos("31ga.pspnc", "33as.pspnc"), ndtset=5)

    # Global variables
    kmesh = dict(ngkpt=[4, 4, 4],
                 nshiftk=4,
                 shiftk=[[0.5, 0.5, 0.5],
                         [0.5, 0.0, 0.0],
                         [0.0, 0.5, 0.0],
                         [0.0, 0.0, 0.5]])

    global_vars = dict(ecut=2, paral_kgb=tvars.paral_kgb)
    global_vars.update(kmesh)

    multi.set_vars(global_vars)

    # Dataset 1 (GS run)
    multi[0].set_vars(
        tolvrs=1e-6,
        nband=4)

    # NSCF run with large number of bands, and points in the the full BZ
    multi[1].set_vars(
        iscf=-2,
        nband=20,
        nstep=25,
        kptopt=1,
        tolwfr=1.e-8)
        #kptopt=3)

    # Fourth dataset: ddk response function along axis 1
    # Fifth dataset: ddk response function along axis 2
    # Sixth dataset: ddk response function along axis 3
    for idir in range(3):
        rfdir = 3 * [0]
        rfdir[idir] = 1

        multi[2+idir].set_vars(
            iscf=-3,
            nband=20,
            nstep=1,
            nline=0,
            prtwf=3,
            kptopt=3,
            nqpt=1,
            qpt=[0.0, 0.0, 0.0],
            rfdir=rfdir,
            rfelfd=2,
            tolwfr=1.e-9,
        )

    # scf_inp, nscf_inp, ddk1, ddk2, ddk3
    return multi.split_datasets()
Esempio n. 42
0
def make_scf_nscf_bse_inputs(ngkpt=(6, 6, 6), ecut=6, ecuteps=3, mdf_epsinf=12.0, soenergy="0.8 eV"):
    """
    Build and returns three `AbinitInput` objects to perform a 
    GS-SCF + GS-NSCF + BSE calculation with the model dielectric function.

    Args:
        ngkpt: Three integers giving the number of divisions for the k-mesh.
        ecut: Cutoff energy for the wavefunctions.
        ecuteps: Cutoff energy for the screened interation W_{GG'}.
        mdf_epsinf: Static limit of the macroscopic dielectric functions. 
            Used to build the model dielectric function.
        soenergy: Scissors operator energy (used to open the initial KS gap).
    """
    multi = abilab.MultiDataset(
        structure=abidata.structure_from_ucell("Si"), pseudos=abidata.pseudos("14si.pspnc"), ndtset=3
    )
    multi.set_mnemonics(True)

    # Variables common to the three datasets.
    multi.set_vars(ecut=ecut, nband=8, istwfk="*1", diemac=12.0)

    # SCF run to get the density.
    multi[0].set_vars(tolvrs=1e-8)
    multi[0].set_kmesh(ngkpt=ngkpt, shiftk=(0, 0, 0))

    # NSCF run on a randomly shifted k-mesh (improve the converge of optical properties)
    multi[1].set_vars(iscf=-2, nband=15, tolwfr=1e-8, chksymbreak=0)  # Skip the check on the k-mesh.

    # This shift breaks the symmetry of the k-mesh.
    multi[1].set_kmesh(ngkpt=ngkpt, shiftk=(0.11, 0.21, 0.31))

    # BSE run with Haydock iterative method (only resonant + W + v)
    multi[2].set_vars(
        optdriver=99,  # BS calculation
        chksymbreak=0,  # To skip the check on the k-mesh.
        bs_calctype=1,  # L0 is contstructed with KS orbitals and energies.
        soenergy=soenergy,  # Scissors operator used to correct the KS band structure.
        bs_exchange_term=1,  # Exchange term included.
        bs_coulomb_term=21,  # Coulomb term with model dielectric function.
        mdf_epsinf=mdf_epsinf,  # Parameter for the model dielectric function.
        bs_coupling=0,  # Tamm-Dancoff approximation.
        bs_loband=2,  # Lowest band included in the calculation
        nband=6,  # Highest band included in the calculation
        bs_freq_mesh="0 6 0.02 eV",  # Frequency mesh for the dielectric function
        bs_algorithm=2,  # Use Haydock method.
        zcut="0.15 eV",  # Complex shift to avoid divergences in the continued fraction.
        ecutwfn=ecut,  # Cutoff for the wavefunction.
        ecuteps=ecuteps,  # Cutoff for W and /bare v.
        inclvkb=2,  # The commutator for the optical limit is correctly evaluated.
    )

    # Same shift as the one used in the previous dataset.
    multi[2].set_kmesh(ngkpt=ngkpt, shiftk=(0.11, 0.21, 0.31))

    scf_input, nscf_input, bse_input = multi.split_datasets()
    return scf_input, nscf_input, bse_input
Esempio n. 43
0
    def test_dfpt_methods(self):
        """Testing DFPT methods."""
        gs_inp = AbinitInput(structure=abidata.structure_from_ucell("AlAs"),
                             pseudos=abidata.pseudos("13al.981214.fhi", "33as.pspnc"))

        gs_inp.set_vars(
            nband=4,             
            ecut=2,         
            ngkpt=[4, 4, 4],
            nshiftk=4,
            shiftk=[0.0, 0.0, 0.5,   # This gives the usual fcc Monkhorst-Pack grid
                    0.0, 0.5, 0.0,
                    0.5, 0.0, 0.0,
                    0.5, 0.5, 0.5],
            #shiftk=[0, 0, 0],
            paral_kgb=1,
            nstep=25,
            tolvrs=1.0e-10,
        )

        ################
        # Phonon methods
        ################
        with self.assertRaises(gs_inp.Error):
            ddk_inputs = gs_inp.make_ddk_inputs(tolerance={"tolfoo": 1e10})

        phg_inputs = gs_inp.make_ph_inputs_qpoint(qpt=(0, 0, 0), tolerance=None)
        print("phonon inputs at Gamma\n", phg_inputs)
        assert len(phg_inputs) == 2
        assert np.all(phg_inputs[0]["rfatpol"] == [1, 1])
        assert np.all(phg_inputs[1]["rfatpol"] == [2, 2])
        assert all(np.all(inp["rfdir"] == [1, 0, 0] for inp in phg_inputs))
        assert all(np.all(inp["kptopt"] == 2 for inp in phg_inputs))

        if self.has_abinit():
            # Validate
            vs = phg_inputs.abivalidate()
            assert all(v.retcode == 0 for v in vs)

        #############
        # DDK methods
        #############
        with self.assertRaises(gs_inp.Error):
            ddk_inputs = gs_inp.make_ddk_inputs(tolerance={"tolvrs": 1e10})

        ddk_inputs = gs_inp.make_ddk_inputs(tolerance=None)
        print("DDK inputs\n", ddk_inputs)
        assert len(ddk_inputs) == 3
        assert all(inp["iscf"] == -3 for inp in ddk_inputs)
        assert all(inp["rfelfd"] == 2 for inp in ddk_inputs)

        if self.has_abinit():
            # Validate
            vs = ddk_inputs.abivalidate()
            assert all(v.retcode == 0 for v in vs)
Esempio n. 44
0
def make_inputs(ngkpt=(4,4,4), ecut=8, ecuteps=2):
    """
    """
    inp = abilab.AbiInput(pseudos=abidata.pseudos("14si.pspnc"), ndtset=3)
    #inp.set_structure(abidata.cif_file("si.cif"))
    inp.set_structure(abidata.structure_from_ucell("Si"))

    inp.set_variables(
        ecut=ecut, 
        nband=8,
        istwfk="*1",
        diemac=12.0,
        paral_kgb=1,
    )

    inp[1].set_variables(tolvrs=1e-8)
    #inp[1].set_autokmesh(nksmall=min(ngkpt))
    inp[1].set_kmesh(ngkpt=ngkpt, shiftk=(0, 0, 0))

    inp[2].set_variables(
        iscf=-2,
        nband=15,
        tolwfr=1e-8,
        chksymbreak=0,               # To skip the check on the k-mesh.
    )

    # This shift breaks the symmetry of the k-mesh.
    inp[2].set_kmesh(ngkpt=ngkpt, shiftk=(0.11,0.21,0.31))

    # BSE run with Haydock iterative method (only resonant + W + v)
    inp[3].set_variables(
        optdriver=99,               # BS calculation
        chksymbreak=0,              # To skip the check on the k-mesh.
        bs_calctype=1,              # L0 is contstructed with KS orbitals and energies.
        soenergy="0.8 eV",          # Scissors operator used to correct the KS band structure.
        bs_exchange_term=1,         # Exchange term included.
        bs_coulomb_term=21,         # Coulomb term with model dielectric function.
        mdf_epsinf=12.0,            # Parameter for the model dielectric function.
        bs_coupling=0,              # Tamm-Dancoff approximation.
        bs_loband=3,
        nband=6,
        #bs_freq_mesh=0 6 0.02 eV,  # Frequency mesh.
        bs_algorithm=2,             # Haydock method.
        #bs_haydock_niter=200       # Max number of iterations for the Haydock method.
        #bs_haydock_tol=0.05 0,     # Tolerance for the iterative method.
        zcut="0.15 eV",             # complex shift to avoid divergences in the continued fraction.
        ecutwfn=ecut,               # Cutoff for the wavefunction.
        ecuteps=ecuteps,            # Cutoff for W and /bare v used to calculate the BS matrix elements.
        inclvkb=2,                  # The commutator for the optical limit is correctly evaluated.
    )

    inp[3].set_kmesh(ngkpt=ngkpt, shiftk=(0.11,0.21,0.31))

    scf_input, nscf_input, bse_input = inp.split_datasets()
    return scf_input, nscf_input, bse_input
Esempio n. 45
0
    def test_utils(self):
        """Test utilities for the generation of Abinit inputs."""
        structure = data.structure_from_ucell("MgB2")

        self.serialize_with_pickle(structure)

        pseudos = data.pseudos("12mg.pspnc", "05b.soft_tm")
        nval = structure.calc_nvalence(pseudos)
        self.assertTrue(nval == 12)
        shiftk = structure.calc_shiftk()
        self.assert_equal(shiftk, [[0.0, 0.0, 0.5]])
Esempio n. 46
0
    def test_utils(self):
        """Test utilities for the generation of Abinit inputs."""
        structure = data.structure_from_ucell("MgB2")

        self.serialize_with_pickle(structure)

        pseudos = data.pseudos("12mg.pspnc", "5b.pspnc")
        nval = structure.num_valence_electrons(pseudos)
        self.assertEqual(nval, 8)
        shiftk = structure.calc_shiftk()
        self.assert_equal(shiftk, [[0.0, 0.0, 0.5]])
Esempio n. 47
0
    def test_utils(self):
        """Test utilities for the generation of Abinit inputs."""
        structure = data.structure_from_ucell("MgB2")
        structure.abi_sanitize()
        print(structure.abi_string)

        self.serialize_with_pickle(structure)

        pseudos = data.pseudos("12mg.pspnc", "5b.pspnc")
        nval = structure.num_valence_electrons(pseudos)
        self.assertEqual(nval, 8)
        self.assert_equal(structure.calc_shiftk(), [[0.0, 0.0, 0.5]])
Esempio n. 48
0
def build_flow(options):
    """
    Create a `Flow` for phonon calculations:

        1) One workflow for the GS run.
        2) nqpt works for phonon calculations. Each work 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_")
    if not options.workdir:
        options.workdir = os.path.basename(__file__).replace(".py", "").replace("run_", "flow_")

    flow = flowtk.Flow(workdir=options.workdir)

    # This function constructs the input files for the phonon calculation:
    # GS input + the input files for the phonon calculation.
    pseudos = abidata.pseudos("14si.pspnc")
    structure = abidata.structure_from_ucell("Si")

    gs_inp = abilab.AbinitInput(structure, pseudos=pseudos)

    # List of q-points for the phonon calculation.
    #qpoints = np.reshape(qpoints, (-1, 3))

    # Global variables used both for the GS and the DFPT run.
    gs_inp.set_vars(
        nband=4,
        ecut=2.0,
        ngkpt=[4, 4, 4],
        nshiftk=4,
        shiftk=[0.0, 0.0, 0.5,   # This gives the usual fcc Monkhorst-Pack grid
                0.0, 0.5, 0.0,
                0.5, 0.0, 0.0,
                0.5, 0.5, 0.5],
        #shiftk=[0, 0, 0],
        paral_kgb=0,
        diemac=12.0,
        iomode=3,
        tolvrs=1.0e-18,
    )

    # Get the qpoints in the IBZ. Note that here we use a q-mesh with ngkpt=(4,4,4) and shiftk=(0,0,0)
    qpoints = gs_inp.abiget_ibz(ngkpt=(4, 4, 4), shiftk=(0, 0, 0)).points

    # Build input for GS calculation and register the first work.
    #work0 = flow.register_scf_task(scf_input)
    #ph_work = flowtk.PhononWork.from_scf_task(work0[0], qpoints=qpoints, is_ngqpt=True)
    #flow.register_work(ph_work)

    ph_inputs = abilab.MultiDataset(structure, pseudos=pseudos, ndtset=len(qpoints))

    return flow
Esempio n. 49
0
def relax_flow(workdir="tmp_sic_relax"):

    manager = abilab.TaskManager.simple_mpi(mpi_ncpus=1)
                                                         
    flow = abilab.AbinitFlow(workdir, manager)

    pseudos = data.pseudos("14si.pspnc", "6c.pspnc")
    structure = data.structure_from_ucell("SiC")

    global_vars = dict(
        chksymbreak=0,
        ecut = 20
    )

    ngkpt = [4,4,4]
    shiftk = [[0.5,0.5,0.5],
              [0.5,0.0,0.0],
              [0.0,0.5,0.0],
              [0.0,0.0,0.5]]


    inp = abilab.AbiInput(pseudos=pseudos, ndtset=2)
    inp.set_structure(structure)
    inp.set_variables(**global_vars)

    relax_inp, nscf_inp = inp[1:]

    relax_inp.set_kmesh(ngkpt=ngkpt, shiftk=shiftk)
    relax_inp.set_variables(
        toldff=1e-6,
        tolmxf=1e-5,
        strfact=100,
        ecutsm=0.5,
        dilatmx=1.15,
        ntime=100,
        ionmov=2,
        optcell=1,
    )

    nscf_inp.set_kpath(ndivsm=20)
    nscf_inp.tolwfr = 1e-22

    relax_inp, nscf_inp = inp.split_datasets()

    # Initialize the workflow.
    relax_task = flow.register_task(relax_inp, task_class=abilab.RelaxTask)

    #work = RelaxWorkflow(self, ion_input, ioncell_input, workdir=None, manager=None):

    nscf_task = flow.register_task(nscf_inp, deps={relax_task: "DEN"}, task_class=abilab.NscfTask)

    return flow.allocate()
Esempio n. 50
0
def scf_ph_inputs(tvars=None):
    """
    This function constructs the input files for the phonon calculation:
    GS input + the input files for the phonon calculation.
    """
    # Crystalline AlAs: computation of the second derivative of the total energy
    structure = abidata.structure_from_ucell("AlAs")

    # List of q-points for the phonon calculation (4,4,4) mesh.
    qpoints = [
             0.00000000E+00,  0.00000000E+00,  0.00000000E+00,
             2.50000000E-01,  0.00000000E+00,  0.00000000E+00,
             5.00000000E-01,  0.00000000E+00,  0.00000000E+00,
             2.50000000E-01,  2.50000000E-01,  0.00000000E+00,
             5.00000000E-01,  2.50000000E-01,  0.00000000E+00,
            -2.50000000E-01,  2.50000000E-01,  0.00000000E+00,
             5.00000000E-01,  5.00000000E-01,  0.00000000E+00,
            -2.50000000E-01,  5.00000000E-01,  2.50000000E-01,
            ]

    qpoints = np.reshape(qpoints, (-1,3))

    # Global variables used both for the GS and the DFPT run.
    global_vars = dict(nband=4,
                       ecut=3.0,
                       ngkpt=[4, 4, 4],
                       shiftk=[0, 0, 0],
                       tolvrs=1.0e-6,
                       paral_kgb=0 if tvars is None else tvars.paral_kgb,
                    )

    multi = abilab.MultiDataset(structure=structure, pseudos=abidata.pseudos("13al.981214.fhi", "33as.pspnc"), 
                              ndtset=1+len(qpoints))

    multi.set_vars(global_vars)

    for i, qpt in enumerate(qpoints):
        # Response-function calculation for phonons.
        multi[i+1].set_vars(
            nstep=20,
            rfphon=1,        # Will consider phonon-type perturbation
            nqpt=1,          # One wavevector is to be considered
            qpt=qpt,         # This wavevector is q=0 (Gamma)
            kptopt=3,
            )

            #rfatpol   1 1   # Only the first atom is displaced
            #rfdir   1 0 0   # Along the first reduced coordinate axis
            #kptopt   2      # Automatic generation of k points, taking

    # Split input into gs_inp and ph_inputs
    return multi.split_datasets()
Esempio n. 51
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_")

    flow = flowtk.Flow(workdir, manager=options.manager, remove=options.remove)

    pseudos = data.pseudos("14si.pspnc", "6c.pspnc")
    structure = data.structure_from_ucell("SiC")

    global_vars = dict(
        chksymbreak=0,
        ecut=20,
        paral_kgb=0,
        iomode=3,
    )

    ngkpt = [4, 4, 4]
    shiftk = [[0.5, 0.5, 0.5], [0.5, 0.0, 0.0], [0.0, 0.5, 0.0],
              [0.0, 0.0, 0.5]]

    multi = abilab.MultiDataset(structure, pseudos=pseudos, ndtset=2)
    multi.set_vars(global_vars)

    relax_inp, nscf_inp = multi.split_datasets()

    relax_inp.set_kmesh(ngkpt=ngkpt, shiftk=shiftk)
    relax_inp.set_vars(
        toldff=1e-6,
        tolmxf=1e-5,
        strfact=100,
        ecutsm=0.5,
        dilatmx=1.15,
        ntime=100,
        ionmov=2,
        optcell=1,
    )

    nscf_inp.set_kpath(ndivsm=20)
    nscf_inp.tolwfr = 1e-22

    # Initialize the work.
    relax_task = flow.register_task(relax_inp, task_class=flowtk.RelaxTask)

    #work = RelaxWork(self, ion_input, ioncell_input, workdir=None, manager=None):
    #nscf_task = flow.register_task(nscf_inp, deps={relax_task: "DEN"}, task_class=flowtk.NscfTask)

    return flow
Esempio n. 52
0
    def test_utils(self):
        """Test utilities for the generation of Abinit inputs."""
        structure = data.structure_from_ucell("MgB2")
        structure.abi_sanitize()
        structure.get_conventional_standard_structure()
        print(structure.abi_string)
        #print(structure._repr_html_())

        self.serialize_with_pickle(structure)

        pseudos = data.pseudos("12mg.pspnc", "5b.pspnc")
        nval = structure.num_valence_electrons(pseudos)
        self.assertEqual(nval, 8)
        self.assert_equal(structure.calc_shiftk() , [[0.0, 0.0, 0.5]])
Esempio n. 53
0
    def setUp(self):
        # Si ebands
        si_structure = abilab.Structure.from_file(abidata.cif_file("si.cif"))
        self.si_ebands = ebands_input(si_structure, abidata.pseudos("14si.pspnc"), ecut=2, kppa=10)

        # Reference input string. Used to test if decorators do not change the initial Input.
        self.si_ebands_inpstr = str(self.si_ebands)

        # NiO bands with PAW
        nio_structure = abidata.structure_from_ucell("NiO")
        self.nio_ebands = ebands_input(nio_structure, abidata.pseudos("28ni.paw", "8o.2.paw"),
                                       ecut=2, pawecutdg=4, kppa=10)

        self.nio_ebands_inpstr = str(self.nio_ebands)
Esempio n. 54
0
    def test_input_errors(self):
        """Testing typical AbinitInput Error"""
        si_structure = abilab.Structure.from_file(abidata.cif_file("si.cif"))

        # Ambiguous list of pseudos.
        with self.assertRaises(AbinitInput.Error):
            AbinitInput(si_structure, pseudos=abidata.pseudos("14si.pspnc", "Si.oncvpsp"))

        # Pseudos do not match structure.
        with self.assertRaises(AbinitInput.Error):
            AbinitInput(si_structure, pseudos=abidata.pseudos("13al.981214.fhi"))

        # Negative triple product.
        with self.assertRaises(AbinitInput.Error):
            s = abidata.structure_from_ucell("Al-negative-volume")
            AbinitInput(s, pseudos=abidata.pseudos("13al.981214.fhi"))