示例#1
0
def phonons_from_gsinput(gs_inp, ph_ngqpt=None, with_ddk=True, with_dde=True, with_bec=False, ph_tol=None, ddk_tol=None,
                         dde_tol=None):
    """
    Returns a :class:`AbinitInput` for performing phonon calculations.
    GS input + the input files for the phonon calculation.
    """

    gs_inp = gs_inp.deepcopy()

    gs_inp.pop_irdvars()

    if with_dde:
        with_ddk = True

    if with_bec:
        with_ddk = True
        with_dde = False

    multi = []

    if ph_ngqpt is None:
        ph_ngqpt = np.array(gs_inp["ngkpt"])

    qpoints = gs_inp.abiget_ibz(ngkpt=ph_ngqpt, shiftk=(0,0,0), kptopt=1).points


    # Build the input files for the q-points in the IBZ.
    # Response-function calculation for phonons.
    for qpt in qpoints:
        if np.allclose(qpt, 0):
            if with_ddk:
                multi_ddk = gs_inp.make_ddk_inputs(ddk_tol)
                multi_ddk.add_tags(DDK)
                multi.extend(multi_ddk)
            if with_dde:
                multi_dde = gs_inp.make_dde_inputs(dde_tol)
                multi_dde.add_tags(DDE)
                multi.extend(multi_dde)
            elif with_bec:
                multi_bec = gs_inp.make_bec_inputs(ph_tol)
                multi_bec.add_tags(BEC)
                multi.extend(multi_bec)
                continue

        multi_ph_q = gs_inp.make_ph_inputs_qpoint(qpt, ph_tol)
        multi_ph_q.add_tags(PH_Q_PERT)
        multi.extend(multi_ph_q)

    multi = MultiDataset.from_inputs(multi)
    multi.add_tags(PHONON)

    #FIXME for the time being there could be problems in mergeddb if the kpoints grid is gamma centered or if
    # if the grid is odd. Remove when mergeddb is fixed
    multi.set_vars(kptopt=3)

    return multi
示例#2
0
文件: factories.py 项目: kidaa/abipy
def phonons_from_gsinput(gs_inp, ph_ngqpt=None, with_ddk=True, with_dde=True, with_bec=False, ph_tol=None, ddk_tol=None,
                         dde_tol=None):
    """
    Returns a :class:`AbinitInput` for performing phonon calculations.
    GS input + the input files for the phonon calculation.
    """

    if with_dde:
        with_ddk = True

    if with_bec:
        with_ddk = True
        with_dde = False

    if ph_ngqpt is None:
        qpoints = gs_inp.abiget_ibz().points
    else:
        qpoints = gs_inp.abiget_ibz(ngkpt=ph_ngqpt, shiftk=(0,0,0), kptopt=1).points

    # Build the input files for the q-points in the IBZ.
    # Response-function calculation for phonons.
    multi = []
    for qpt in qpoints:
        if np.allclose(qpt, 0):
            if with_ddk:
                multi_ddk = gs_inp.make_ddk_inputs(ddk_tol)
                multi_ddk.add_tags(DDK)
                multi.extend(multi_ddk)
            if with_dde:
                multi_dde = gs_inp.make_dde_inputs(dde_tol)
                multi_dde.add_tags(DDE)
                multi.extend(multi_dde)
            elif with_bec:
                multi_bec = gs_inp.make_bec_inputs(ph_tol)
                multi_bec.add_tags(BEC)
                multi.extend(multi_bec)
                continue

        multi_ph_q = gs_inp.make_ph_inputs_qpoint(qpt, ph_tol)
        multi_ph_q.add_tags(PH_Q_PERT)
        multi.extend(multi_ph_q)

    multi = MultiDataset.from_inputs(multi)
    multi.add_tags(PHONON)

    return multi
示例#3
0
def scf_piezo_elastic_inputs(structure, pseudos, kppa, ecut=None, pawecutdg=None, scf_nband=None,
                             accuracy="normal", spin_mode="polarized",
                             smearing="fermi_dirac:0.1 eV", charge=0.0, scf_algorithm=None, ddk_tol=None, rf_tol=None):

    """
    Returns a :class:`AbinitInput` for performing elastic and piezoelectric constants calculations.
    GS input + the input files for the elastic and piezoelectric constants calculation.

    Args:
        structure: :class:`Structure` object.
        pseudos: List of filenames or list of :class:`Pseudo` objects or :class:`PseudoTable` object.
        kppa: Defines the sampling used for the SCF run.
        ecut: cutoff energy in Ha (if None, ecut is initialized from the pseudos according to accuracy)
        pawecutdg: cutoff energy in Ha for PAW double-grid (if None, pawecutdg is initialized from the
            pseudos according to accuracy)
        scf_nband: Number of bands for SCF run. If scf_nband is None, nband is automatically initialized
            from the list of pseudos, the structure and the smearing option.
        accuracy: Accuracy of the calculation.
        spin_mode: Spin polarization.
        smearing: Smearing technique.
        charge: Electronic charge added to the unit cell.
        scf_algorithm: Algorithm used for solving of the SCF cycle.
        ddk_tol
    """
    # Build the input file for the GS run.
    gs_inp = AbinitInput(structure=structure, pseudos=pseudos)

    # Set the cutoff energies.
    gs_inp.set_vars(_find_ecut_pawecutdg(ecut, pawecutdg, gs_inp.pseudos))

    ksampling = aobj.KSampling.automatic_density(gs_inp.structure, kppa, chksymbreak=0, shifts=(0.0, 0.0, 0.0))
    gs_inp.set_vars(ksampling.to_abivars())
    gs_inp.set_vars(tolvrs=1.0e-18)

    scf_electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm=scf_algorithm,
                                   charge=charge, nband=None, fband=None)

    if scf_electrons.nband is None:
        scf_electrons.nband = _find_scf_nband(structure, gs_inp.pseudos, scf_electrons)
    gs_inp.set_vars(scf_electrons.to_abivars())

    all_inps = [gs_inp]

    # Add the ddk input
    ddk_inp = gs_inp.deepcopy()

    ddk_inp.set_vars(
                rfelfd=2,             # Activate the calculation of the d/dk perturbation
                rfdir=(1,1,1),        # All directions
                nqpt=1,               # One wavevector is to be considered
                qpt=(0, 0, 0),        # q-wavevector.
                kptopt=2,             # Take into account time-reversal symmetry.
                iscf=-3,              # The d/dk perturbation must be treated in a non-self-consistent way
            )
    if ddk_tol is None:
        ddk_tol = {"tolwfr": 1.0e-20}

    if len(ddk_tol) != 1 or any(k not in _tolerances for k in ddk_tol):
        raise ValueError("Invalid tolerance: {}".format(ddk_tol))
    ddk_inp.pop_tolerances()
    ddk_inp.set_vars(ddk_tol)

    ddk_inp.add_tags(DDK)
    all_inps.append(ddk_inp)

    # Add the Response Function calculation
    rf_inp = gs_inp.deepcopy()

    rf_inp.set_vars(rfphon=1,                          # Atomic displacement perturbation
                    rfatpol=(1,len(gs_inp.structure)), # Perturbation of all atoms
                    rfstrs=3,                          # Do the strain perturbations
                    rfdir=(1,1,1),                     # All directions
                    nqpt=1,                            # One wavevector is to be considered
                    qpt=(0, 0, 0),                     # q-wavevector.
                    kptopt=2,                          # Take into account time-reversal symmetry.
                    iscf=7,                            # The d/dk perturbation must be treated in a non-self-consistent way
                    )

    if rf_tol is None:
        rf_tol = {"tolvrs": 1.0e-12}

    if len(rf_tol) != 1 or any(k not in _tolerances for k in rf_tol):
        raise ValueError("Invalid tolerance: {}".format(rf_tol))
    rf_inp.pop_tolerances()
    rf_inp.set_vars(rf_tol)

    rf_inp.add_tags([DFPT, STRAIN])
    all_inps.append(rf_inp)

    return MultiDataset.from_inputs(all_inps)