Example #1
0
def afm_input():
    # Fe fcc structure with two atoms per unit cell for test of antiferromagnetic
    # This is the simplest fcc structure compatible with a X point spiral
    structure = abilab.Structure.from_abivars(
        dict(
            natom=2,
            ntypat=1,
            typat=[1, 1],
            znucl=26,
            acell=3 * [6.60],
            rprim=[0.5, -0.5, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0],
            xred=[0.0, 0.0, 0.0, 0.5, 0.0, 0.5],
        ))
    inp = abilab.AbinitInput(structure=structure,
                             pseudos=abidata.pseudos("26fe.pspnc"))

    inp.set_kmesh(ngkpt=[6, 6, 4], shiftk=[0.5, 0.5, 0.5])

    # Antiferromagnetic order
    inp.set_vars(
        nsppol=1,
        nspden=2,
        spinat=[0.0, 0.0, 4.0, 0.0, 0.0, -4.0],
        ecut=18,
        nband=16,
        occopt=3,
        tsmear=0.01,
        tolwfr=1e-7,
        nstep=70,
    )

    return inp
Example #2
0
def tantalum_gsinput(nspinor=2):
    #  Single Ta atom in a big box (BCC), treated with spin-orbit coupling.
    structure = abilab.Structure.from_abivars(
        natom=1,
        ntypat=1,
        typat=[1],
        znucl=73,
        acell=3 * [15.0],
        rprim=[0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5],
        xred=[0.0, 0.0, 0.0])
    inp = abilab.AbinitInput(structure=structure,
                             pseudos=abidata.pseudos("73ta.hghsc"))

    inp.set_kmesh(ngkpt=[1, 1, 1], shiftk=[0.0, 0.0, 0.0])

    inp.set_vars(
        nspinor=nspinor,
        ecut=10,
        ixc=2,
        istwfk=1,
        intxc=1,
        nband=26,
        occopt=7,
        tsmear=0.01,
        toldfe=1e-7,
        nstep=70,
    )

    print(inp)
    return inp
Example #3
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
Example #4
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
Example #5
0
def gs_input(nsppol):
    # Fe normal bcc structure for test of a ferromagnetic calculation
    # The first dataset is without magnetization for comparison
    structure = abilab.Structure.from_abivars(
        dict(natom=1,
             ntypat=1,
             typat=1,
             znucl=26,
             acell=3 * [5.42],
             rprim=[-0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5],
             xred=[0.0, 0.0, 0.0]))
    inp = abilab.AbinitInput(structure, pseudos=abidata.pseudos("26fe.pspnc"))

    inp.set_kmesh(ngkpt=[4, 4, 4], shiftk=[0.5, 0.5, 0.5])

    # Optimization of the lattice parameters
    inp.set_vars(
        nsppol=nsppol,
        ecut=18,
        nband=8,
        occopt=3,
        tsmear=0.01,
        toldfe=1e-6,
        nstep=50,
    )

    if nsppol == 2:
        inp.set_vars(spinat=[0.0, 0.0, 4.0])

    return inp
Example #6
0
def make_input(paw=False):
    """
    Build and return an input file for GS calculations with paral_kgb=1
    """
    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=[1, 1, 1], shiftk=[0, 0, 0])

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

    return inp
Example #7
0
    def test_frohlich_zpr_flow(self):
        """Testing FrohlichZPRFlow"""
        # Read structure from DDB file.
        from abipy import abilab
        ddb_path = abidata.ref_file("refs/mgo_v8t57/mgo_zpr_t57o_DS3_DDB")
        with abilab.abiopen(ddb_path) as ddb:
            structure = ddb.structure

        pseudos = abidata.pseudos("Ca.psp8", "O.psp8")
        scf_input = abilab.AbinitInput(structure=structure, pseudos=pseudos)
        # Set other input variables. These quantities are system-depedent.
        # Here we use parameters similar to https://docs.abinit.org/tests/v8/Input/t57.in
        scf_input.set_vars(
            nband=12,
            nbdbuf=2,
            diemac=6,
            ecut=30,                # Underconverged ecut.
            #ecut=15,
            nstep=100,
            tolvrs=1e-16,
            kptrlatt=[-2,  2,  2,   # In cartesian coordinates, this grid is simple cubic
                       2, -2,  2,
                       2,  2, -2],
        )

        workdir = self.mkdtemp()
        flow = FrohlichZPRFlow.from_scf_input(workdir, scf_input, ddb_node=ddb_path, ndivsm=2, tolwfr=1e-20,
                                              metadata={"mp_id": "mp-149"})
        flow.allocate()
        flow.check_status()
        isok, checks = flow.abivalidate_inputs()
        assert isok
Example #8
0
def itest_dilatmxerror_handler(fwp):
    """Test the handler of DilatmxError. The test triggers:

        --- !DilatmxError
        message: |
            Dilatmx has been exceeded too many times (4)
            Restart your calculation from larger lattice vectors and/or a larger dilatmx
        src_file: mover.F90
        src_line: 840
        ...

    in variable cell structural optimizations.
    """
    #if fwp.on_travis:
    pytest.xfail(
        "dilatmxerror_handler is not portable and it's been disabled!")

    structure = abilab.Structure.from_file(abidata.cif_file("si.cif"))
    structure.scale_lattice(structure.volume * 0.8)
    # Perturb the structure (random perturbation of 0.1 Angstrom)
    #structure.perturb(distance=0.1)

    inp = abilab.AbinitInput(structure=structure,
                             pseudos=abidata.pseudos("14si.pspnc"))

    inp.set_vars(
        ecut=4,
        ngkpt=[4, 4, 4],
        shiftk=[0, 0, 0],
        nshiftk=1,
        chksymbreak=0,
        paral_kgb=1,
        optcell=1,
        ionmov=2,
        ecutsm=0.5,
        dilatmx=1.01,
        tolrff=0.02,
        tolmxf=5.0e-5,
        strfact=100,
        ntime=50,
        #ntime=5, To test the restart
    )

    # Create the flow
    flow = flowtk.Flow(fwp.workdir, manager=fwp.manager)
    flow.register_task(inp, task_class=flowtk.RelaxTask)

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

    flow.show_status()
    if not flow.all_ok:
        flow.debug()
        raise RuntimeError()

    task = flow[0][0]
    # Don't check the number of corrections as it's not portable.
    assert len(task.corrections)
    for i in range(task.num_corrections):
        assert task.corrections[i]["event"]["@class"] == "DilatmxError"
Example #9
0
def make_scf_input(ngkpt):
    """
    This function constructs the input file for the GS calculation:
    """
    structure = dict(angdeg=3 * [60.0],
                     acell=3 * [7.1992351952],
                     natom=2,
                     ntypat=2,
                     typat=[1, 2],
                     znucl=[31, 15],
                     xred=[
                         0.0000000000,
                         0.0000000000,
                         0.0000000000,
                         0.2500000000,
                         0.2500000000,
                         0.2500000000,
                     ])

    pseudos = abidata.pseudos("Ga.oncvpsp", "P.psp8")
    gs_inp = abilab.AbinitInput(structure, pseudos=pseudos)

    gs_inp.set_vars(
        nband=8,
        ecut=20.0,  # Too low
        ngkpt=ngkpt,
        nshiftk=1,
        shiftk=[0, 0, 0],
        tolvrs=1.0e-8,
        nstep=150,
        paral_kgb=0,
    )

    return gs_inp
Example #10
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
Example #11
0
def build_abinit_input_from_file(options, **abivars):
    """
    Build and return an AbinitInput instance from filepath.

    abivars are optional variables that will be added to the input.
    """
    from abipy.abio.abivars import AbinitInputFile
    abifile = AbinitInputFile(options.filepath)
    pseudos = get_pseudotable(options)
    jdtset = options.jdtset
    # Get vars from input
    abi_kwargs = abifile.datasets[jdtset - 1].get_vars()
    if abifile.ndtset != 1:
        cprint(
            "# Input file contains %s datasets, will select jdtset index %s:" %
            (abifile.ndtset, jdtset), "yellow")
        abi_kwargs["jdtset"] = jdtset

    # Add input abivars (if any).
    abi_kwargs.update(abivars)

    return abilab.AbinitInput(abifile.structure,
                              pseudos,
                              pseudo_dir=None,
                              comment=None,
                              decorators=None,
                              abi_args=None,
                              abi_kwargs=abi_kwargs,
                              tags=None)
Example #12
0
def ion_relaxation(tvars, ntime=50):
    structure = abilab.Structure.from_file(abidata.cif_file("si.cif"))

    # Perturb the structure (random perturbation of 0.1 Angstrom)
    structure.perturb(distance=0.02)

    global_vars = dict(
        ecut=6,
        ngkpt=[2, 2, 2],
        shiftk=[0, 0, 0],
        nshiftk=1,
        chksymbreak=0,
        paral_kgb=tvars.paral_kgb,
    )

    inp = abilab.AbinitInput(structure, pseudos=abidata.pseudos("14si.pspnc"))

    # Global variables
    inp.set_vars(global_vars)

    # Dataset 1 (Atom Relaxation)
    #inp[1].set_vars(
    # FIXME here there's a bug
    inp.set_vars(
        optcell=0,
        ionmov=2,
        tolrff=0.02,
        tolmxf=5.0e-5,
        ntime=ntime,
        #dilatmx=1.05, # FIXME: abinit crashes if I don't use this
    )

    return inp
Example #13
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
Example #14
0
def gs_input(ecut, pawecutdg, acell_ang=3.567):
    # tpaw1_2.in
    # Input for PAW1 tutorial
    # Diamond at experimental volume
    structure = abilab.Structure.from_abivars(
        natom=2,
        ntypat=1,
        typat=2 * [1],
        znucl=6,
        acell=3 * [abilab.Length(acell_ang, "ang").to("bohr")],
        rprim=[0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0],
        xred=[0.0, 0.0, 0.0, 1 / 4, 1 / 4, 1 / 4],
    )
    inp = abilab.AbinitInput(structure=structure,
                             pseudos=abidata.pseudos("6c.lda.atompaw"))

    # Optimization of the lattice parameters
    inp.set_vars(
        ecut=ecut,
        pawecutdg=pawecutdg,
        ecutsm=0.5,
        nband=6,
        tolvrs=1e-10,
        nstep=20,
    )

    inp.set_autokmesh(nksmall=6)  # ngkpt=[6, 6, 6], shiftk=[0.5, 0.5, 0.5])

    return inp
Example #15
0
def build_flow(options):
    """
    Create a `Flow` for phonon calculations with phonopy:
    """
    # 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_")

    # Initialize structure and pseudos
    structure = abilab.Structure.from_file(abidata.cif_file("si.cif"))
    pseudos = abidata.pseudos("14si.pspnc")

    # Build input for GS calculation.
    gsinp = abilab.AbinitInput(structure, pseudos)
    gsinp.set_vars(ecut=8, nband=4, toldff=1.e-6)

    # This gives ngkpt = 4x4x4 with 4 shifts for the initial unit cell.
    # The k-point sampling will be rescaled when we build the supercell in PhonopyWork.
    gsinp.set_autokmesh(nksmall=4)

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

    # Use a 2x2x2 supercell to compute phonons with phonopy
    work = PhonopyGruneisenWork.from_gs_input(gsinp,
                                              voldelta=0.01,
                                              scdims=[2, 2, 2])
    flow.register_work(work)

    return flow
Example #16
0
    def add_eos_tasks(self):
        """
        Read the optimized structure from the netcdf file and add to self a new
        a new list of `ScfTask` for the computation of the EOS with the GBRV setup.
        """
        self.history.info("Building EOS tasks")

        # Get the relaxed structure.
        self.relaxed_structure = relaxed_structure = self.relax_task.get_final_structure()

        # GBRV use nine points from -1% to 1% of the initial guess and fitting the results to a parabola.
        # Note that it's not clear to me if they change the volume or the lattice parameter!
        self.volumes = relaxed_structure.volume * np.arange(99, 101.25, 0.25) / 100.

        for vol in self.volumes:
            new_lattice = relaxed_structure.lattice.scale(vol)
            new_structure = Structure(new_lattice, relaxed_structure.species, relaxed_structure.frac_coords)

            scf_input = abilab.AbinitInput(new_structure, self.pseudos)

            scf_input.set_vars(self.extra_abivars.copy())
            scf_input.add_abiobjects(self.ksampling, self.spin_mode, self.smearing)
            # Use toldfe instead of tolvrs
            scf_input.pop_tolerances()
            scf_input.set_vars(toldfe=1e-10)

            # Register new task
            self.register_scf_task(scf_input)

        # Allocate new tasks and update the pickle database.
        self.flow.allocate()
        self.flow.build_and_pickle_dump()
Example #17
0
def make_scf_input(paral_kgb=0):
    """
    This function constructs the input file for the GS 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=[2, 2, 2],
        nshiftk=1,
        shiftk=[0, 0, 0],
        #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],
        paral_kgb=paral_kgb,
        tolvrs=1.0e-10,
        diemac=9.0,
    )

    return gs_inp
Example #18
0
def itest_tolsymerror_handler(fwp):
    """
    Test the handler of TolSymError. The test triggers:

        --- !TolSymError
        message: |
            Could not find the point group
        src_file: symptgroup.F90
        src_line: 236
        ...

    at the level of the symmetry finder and autoparal fails
    because it cannot find the parallel configurations.
    """
    structure = dict(
        acell=(1.0, 1.0, 1.0),
        xred=[
            1.0001907690, 1.0040151117, 0.0099335191, 0.2501907744,
            0.2540150788, 0.2599335332
        ],
        rprim=[
            -6.2733366562, 0.0000000000, -3.6219126071, -6.2733366562,
            0.0000000000, 3.6219126071, -4.1822244376, 5.9145585205,
            0.0000000000
        ],
        typat=(1, 1),
        ntypat=1,
        znucl=14,
        natom=2,
    )

    inp = abilab.AbinitInput(structure=structure,
                             pseudos=abidata.pseudos("14si.pspnc"))

    inp.set_vars(
        ntime=5,
        tolrff=0.02,
        shiftk=[0, 0, 0],
        ngkpt=(4, 4, 4),
        chksymbreak=0,
        ecut=4,
        tolmxf=5e-05,
        nshiftk=1,
    )

    flow = flowtk.Flow(workdir=fwp.workdir, manager=fwp.manager)
    flow.register_task(inp, task_class=flowtk.RelaxTask)

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

    flow.show_status()
    if not flow.all_ok:
        flow.debug()
        raise RuntimeError()

    task = flow[0][0]
    assert len(task.corrections) == 1
    assert task.corrections[0]["event"]["@class"] == "TolSymError"
Example #19
0
    def __init__(self, a_guess, struct_type, pseudo, ecut_list=None, pawecutdg=None, ngkpt=(8, 8, 8),
                 spin_mode="unpolarized", include_soc=False, tolvrs=1.e-10, smearing="fermi_dirac:0.001 Ha",
                 ecutsm=0.05, chksymbreak=0, workdir=None, manager=None):
        """
        Build a :class:`Work` for the computation of the relaxed lattice parameter.

        Args:
            structure_type: fcc, bcc
            pseudo: :class:`Pseudo` object.
            ecut_list: Cutoff energy in Hartree
            ngkpt: MP divisions.
            spin_mode: Spin polarization mode.
            toldfe: Tolerance on the energy (Ha)
            smearing: Smearing technique.
            workdir: String specifing the working directory.
            manager: :class:`TaskManager` responsible for the submission of the tasks.
        """
        super(RelaxWithGbrvParamsWork, self).__init__(workdir=workdir, manager=manager)
        self_pseudo = pseudo
        self.include_soc = include_soc
        self.struct_type = struct_type

        if struct_type == "bcc":
            structure = Structure.bcc(a_guess, species=[pseudo.symbol])
        elif struct_type == "fcc":
            structure = Structure.fcc(a_guess, species=[pseudo.symbol])

        # Set extra_abivars.
        extra_abivars = dict(
            pawecutdg=pawecutdg,
            tolvrs=tolvrs,
            prtwf=-1,
            fband=3.0,
            nstep=100,
            ntime=50,
            ecutsm=ecutsm,
            dilatmx=1.1,
        )

        self.ecut_list = ecut_list
        smearing = Smearing.as_smearing(smearing)

        # Kpoint sampling: shiftk depends on struct_type
        shiftk = {"fcc": [0, 0, 0], "bcc": [0.5, 0.5, 0.5]}.get(struct_type)
        spin_mode = SpinMode.as_spinmode(spin_mode)
        ksampling = KSampling.monkhorst(ngkpt, chksymbreak=chksymbreak, shiftk=shiftk,
                                        use_time_reversal=spin_mode.nspinor==1)
        relax_algo = RelaxationMethod.atoms_and_cell()

        inp = abilab.AbinitInput(structure, pseudo)
        inp.add_abiobjects(ksampling, relax_algo, spin_mode, smearing)
        inp.set_vars(extra_abivars)

        # Register structure relaxation task.
        for ecut in self.ecut_list:
            self.relax_task = self.register_relax_task(inp.new_with_vars(ecut=ecut))
Example #20
0
def make_scf_input(ngkpt=(4, 4, 4)):
    """
    This function constructs the input file for the GS calculation of
    AlAs in hypothetical wurzite (hexagonal) structure.
    In principle, the stucture should be relaxed before starting the calculation,
    here we use the *unrelaxed* geometry of the official tutorial.

    Args:
        ngkpt: K-mesh used both in the GS and in the DFPT part.
    """

    # Initialize structure. Use enough significant digits
    # so that Abinit will recognize the correct spacegroup
    # (Hexagonal and rhombohedral lattices are a bit problematic).
    structure = abilab.Structure.from_abivars(
        acell=[7.5389648144E+00, 7.5389648144E+00, 1.2277795374E+01],
        natom=4,
        ntypat=2,
        rprim=[
            np.sqrt(0.75), 0.5, 0.0, -np.sqrt(0.75), 0.5, 0.0, 0.0, 0.0, 1.0
        ],
        typat=[1, 1, 2, 2],
        xred=[
            1 / 3, 2 / 3, 0, 2 / 3, 1 / 3, 1 / 2, 1 / 3, 2 / 3,
            3.7608588373E-01, 2 / 3, 1 / 3, 8.7608588373E-01
        ],
        znucl=[13, 33],
    )

    pseudos = abidata.pseudos("13al.pspnc", "33as.pspnc")
    gs_inp = abilab.AbinitInput(structure, pseudos=pseudos)

    # Set other important variables (consistent with tutorial)
    # All the other DFPT runs will inherit these parameters.
    gs_inp.set_vars(
        nband=8,
        ecut=6.0,
        ecutsm=0.5,  # Important when performing structural optimization
        # with variable cell. All DFPT calculations should use
        # the same value to be consistent.
        ngkpt=ngkpt,
        nshiftk=1,
        shiftk=[0.0, 0.0, 0.5
                ],  # This choice preserves the hexagonal symmetry of the grid.
        diemac=9.0,
        nstep=40,
        paral_kgb=0,
        tolvrs=1.0e-18,
    )

    return gs_inp
Example #21
0
def gs_input(x=0.7, ecut=10, acell=(10, 10, 10)):
    """
    This function builds an AbinitInput object to compute the total energy
    of the H2 molecule in a big box.

    Args:
        x: Position of the first Hydrogen along the x-axis in Cartesian coordinates.
           The second Hydrogen is located at [-x, 0, 0]
        ecut: Cutoff energy in Ha.
        acell: Lengths of the primitive vectors (in Bohr)

    Returns:
        AbinitInput object.
    """
    # Build structure from dictionary with input variables.
    structure = abilab.Structure.from_abivars(
        ntypat=1,  # There is only one type of atom.
        znucl=1,  # Atomic numbers of the type(s) of atom.
        natom=2,  # There are two atoms.
        typat=(1, 1),  # They both are of type 1, that is, Hydrogen.
        xcart=[
            -x,
            0.0,
            0.0,  # Cartesian coordinates of atom 1, in Bohr.
            +x,
            0.0,
            0.0
        ],  # second atom.
        acell=acell,  # Lengths of the primitive vectors (in Bohr).
        rprim=[1, 0, 0, 0, 1, 0, 0, 0,
               1]  # Orthogonal primitive vectors (default).
    )

    # Build AbinitInput from structure and pseudo(s) taken from AbiPy package.
    inp = abilab.AbinitInput(structure=structure,
                             pseudos=abidata.pseudos("01h.pspgth"))

    # Set value of other variables.
    inp.set_vars(ecut=ecut,
                 nband=1,
                 diemac=2.0,
                 toldfe=1e-6,
                 prtwf=-1,
                 iomode=3)

    # Define k-point sampling.
    inp.set_kmesh(ngkpt=(1, 1, 1), shiftk=(0, 0, 0))

    return inp
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_")

    # Get structure from DDB file.
    ddb_path = abidata.ref_file("refs/mgo_v8t57/mgo_zpr_t57o_DS3_DDB")
    with abilab.abiopen(ddb_path) as ddb:
        structure = ddb.structure

    # Build SCF input using structure from DDB file.
    pseudos = abidata.pseudos("Ca.psp8", "O.psp8")
    scf_input = abilab.AbinitInput(structure=structure, pseudos=pseudos)

    # Set other input variables. These quantities are system-depedent.
    # Here we use parameters similar to https://docs.abinit.org/tests/v8/Input/t57.in
    scf_input.set_vars(
        nband=12,
        nbdbuf=2,
        diemac=6,
        ecut=30,  # Underconverged ecut.
        #ecut=15,
        nstep=100,
        tolvrs=1e-16,
        kptrlatt=[
            -2,
            2,
            2,  # In cartesian coordinates, this grid is simple cubic
            2,
            -2,
            2,
            2,
            2,
            -2
        ],
    )

    # Build the flow to detect band edges, compute effective masses and finally obtain an estimate for the ZPR
    # BECS/phonons/eps_inf are taken from ddb_node.
    from abipy.flowtk.effmass_works import FrohlichZPRFlow
    flow = FrohlichZPRFlow.from_scf_input(options.workdir,
                                          scf_input,
                                          ddb_node=ddb_path,
                                          ndivsm=2,
                                          tolwfr=1e-14,
                                          manager=options.manager)
    return flow
Example #23
0
def make_nscf_input(structure,
                    pseudos,
                    ngkpt=(2, 2, 2),
                    shiftk=(0, 0, 0),
                    **variables):
    """Build and return NSCF input given the structure and pseudopotentials"""
    scf_inp = abilab.AbinitInput(structure, pseudos=pseudos)

    # Global variables
    scf_inp.set_vars(**variables)

    # Dataset 1 (GS run)
    scf_inp.set_kmesh(ngkpt=ngkpt, shiftk=shiftk)
    scf_inp.set_vars(iscf=-2)

    return scf_inp
Example #24
0
def make_scf_input(ngkpt):
    """
    This function constructs the input file for the GS calculation:
    """
    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=6,
        ecut=6.0,
        ngkpt=ngkpt,
        nshiftk=1,
        shiftk=[0, 0, 0],
        tolvrs=1.0e-10,
    )

    return gs_inp
Example #25
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:
        if os.getenv("READTHEDOCS", False): __file__ = os.path.join(os.getcwd(), "run_sic_relax.py")
        options.workdir = os.path.basename(__file__).replace(".py", "").replace("run_", "flow_")

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

    # Initialize the input
    relax_inp = abilab.AbinitInput(structure, pseudos=pseudos)

    # Set variables
    relax_inp.set_vars(
        ecut=20,
        paral_kgb=1,
        iomode=3,
        # Relaxation part
        ionmov=2,
        optcell=1,
        strfact=100,
        ecutsm=0.5,       # Important!
        dilatmx=1.15,     # Important!
        toldff=1e-6,
        tolmxf=1e-5,
        ntime=100,
    )

    # K-points sampling
    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]
    ]
    relax_inp.set_kmesh(ngkpt=[4, 4, 4], shiftk=shiftk)

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

    # Register the task.
    flow.register_relax_task(relax_inp)

    return flow
Example #26
0
def make_scf_input(structure, ngkpt, tsmear, pseudos, paral_kgb=1):
    """return GS input."""

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

    # Global variables
    scf_inp.set_vars(
        ecut=35,
        nband=8,
        occopt=4,    # Marzari smearing
        tsmear=tsmear,
        paral_kgb=paral_kgb,
   )

    # Dataset 1 (GS run)
    scf_inp.set_kmesh(ngkpt=ngkpt, shiftk=structure.calc_shiftk())
    scf_inp.set_vars(tolvrs=1e-10)

    return scf_inp
def make_scf_input(structure, ngkpt, tsmear, pseudos, paral_kgb=1):
    """Build and return Ground-state input for MgB2 given ngkpt and tsmear."""

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

    # Global variables
    scf_inp.set_vars(
        ecut=10,
        nband=8,
        occopt=4,    # Marzari smearing
        tsmear=tsmear,
        paral_kgb=paral_kgb,
   )

    # Dataset 1 (GS run)
    scf_inp.set_kmesh(ngkpt=ngkpt, shiftk=structure.calc_shiftk())
    scf_inp.set_vars(tolvrs=1e-10)

    return scf_inp
Example #28
0
def make_scf_input(usepaw=0, nspinor=1):
    """Returns input for GS-SCF calculation."""
    if nspinor == 1:
        pseudos = abidata.pseudos(
            "14si.pspnc") if usepaw == 0 else abidata.pseudos(
                "Si.GGA_PBE-JTH-paw.xml")
    else:
        pseudos = abidata.pseudos(
            "Si_r.psp8") if usepaw == 0 else abidata.pseudos(
                "Si.GGA_PBE-JTH-paw.xml")

    # https://docs.abinit.org/tests/v7/Input/t82.in
    structure = dict(
        ntypat=1,
        natom=2,
        typat=[1, 1],
        znucl=14,
        #acell=3 * [10.26310667319252],
        acell=3 * [10.2073557],  # 5.4015 Ang
        rprim=[[0.0, 0.5, 0.5], [0.5, 0.0, 0.5], [0.5, 0.5, 0.0]],
        xred=[[0.0, 0.0, 0.0], [0.25, 0.25, 0.25]],
    )

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

    # Global variables
    nband = 8 if nspinor == 1 else 16
    scf_input.set_vars(
        ecut=8,
        nband=nband,
        nspinor=nspinor,
        nstep=100,
        tolvrs=1e-8,
    )

    if scf_input.ispaw:
        scf_input.set_vars(pawecutdg=2 * scf_input["ecut"])

    # Set k-mesh
    scf_input.set_kmesh(ngkpt=[8, 8, 8], shiftk=[0, 0, 0])

    return scf_input
Example #29
0
def make_scf_input(usepaw=0):
    """Returns the GS input file"""
    # Here we use parameters similar to https://docs.abinit.org/tests/v8/Input/t57.in
    pseudos = abidata.pseudos("Ca.psp8", "O.psp8")

    structure = dict(
        acell=3 * [9.136],
        xred=[
            0.0000000000, 0.0000000000, 0.0000000000, 0.5000000000,
            0.5000000000, 0.5000000000
        ],
        rprim=[0, 0.5, 0.5, 0.5, 0, 0.5, 0.5, 0.5, 0],
        typat=[1, 2],
        natom=2,
        ntypat=2,
        znucl=[20, 8],
    )

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

    scf_input.set_vars(
        nband=10,
        nbdbuf=2,
        diemac=6,
        #ecut=30,               # Underconverged ecut.
        ecut=15,
        nstep=100,
        tolvrs=1e-6,
        kptrlatt=[
            -2,
            2,
            2,  # In cartesian coordinates, this grid is simple cubic
            2,
            -2,
            2,
            2,
            2,
            -2
        ],
    )

    return scf_input
Example #30
0
def gs_input(structure, pseudos, ksamp):

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

    inp.set_vars(**global_vars)

    inp.set_vars(
        tolvrs=1e-16,
        nband=2 * len(structure),  # 2 bands / atoms
        nstep=500,
        kptopt=1,
        iscf=5,
    )

    vars_ksamp = ksamp.to_abivars()
    vars_ksamp.pop("#comment", None)

    inp.set_vars(**vars_ksamp)

    return inp