def get_gsinput_si(usepaw=0, as_task=False): # Build GS input file. pseudos = abidata.pseudos("14si.pspnc") if usepaw == 0 else data.pseudos("Si.GGA_PBE-JTH-paw.xml") #silicon = abilab.Structure.zincblende(5.431, ["Si", "Si"], units="ang") silicon = abidata.cif_file("si.cif") from abipy.abio.inputs import AbinitInput scf_input = AbinitInput(silicon, pseudos) ecut = 6 scf_input.set_vars( ecut=ecut, pawecutdg=40, nband=6, paral_kgb=0, iomode=3, toldfe=1e-9, ) if usepaw: scf_input.set_vars(pawecutdg=4 * ecut) # K-point sampling (shifted) scf_input.set_autokmesh(nksmall=4) if not as_task: return scf_input else: from abipy.flowtk.tasks import ScfTask return ScfTask(scf_input)
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)
def get_gsinput_si(usepaw=0, as_task=False): """ Build and return a GS input file for silicon or a Task if `as_task` """ pseudos = abidata.pseudos( "14si.pspnc") if usepaw == 0 else abidata.pseudos( "Si.GGA_PBE-JTH-paw.xml") silicon = abidata.cif_file("si.cif") from abipy.abio.inputs import AbinitInput scf_input = AbinitInput(silicon, pseudos) ecut = 6 scf_input.set_vars( ecut=ecut, nband=6, paral_kgb=0, iomode=3, toldfe=1e-9, ) if usepaw: scf_input.set_vars(pawecutdg=4 * ecut) # K-point sampling (shifted) scf_input.set_autokmesh(nksmall=4) if not as_task: return scf_input else: from abipy.flowtk.tasks import ScfTask return ScfTask(scf_input)
def scf_input(structure, pseudos, kppa=None, ecut=None, pawecutdg=None, nband=None, accuracy="normal", spin_mode="polarized", smearing="fermi_dirac:0.1 eV", charge=0.0, scf_algorithm=None, shift_mode="Monkhorst-Pack"): structure = Structure.as_structure(structure) abinit_input = AbinitInput(structure, pseudos) # Set the cutoff energies. abinit_input.set_vars(_find_ecut_pawecutdg(ecut, pawecutdg, abinit_input.pseudos)) # SCF calculation. kppa = _DEFAULTS.get("kppa") if kppa is None else kppa shifts = (0.5, 0.5, 0.5) if shift_mode[0].lower() == "m" else (0.0, 0.0, 0.0) scf_ksampling = aobj.KSampling.automatic_density(structure, kppa, chksymbreak=0, shifts=shifts) scf_electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm=scf_algorithm, charge=charge, nband=nband, fband=None) if spin_mode=="polarized": abinit_input.set_autospinat() if scf_electrons.nband is None: scf_electrons.nband = _find_scf_nband(structure, abinit_input.pseudos, scf_electrons,abinit_input.get('spinat', None)) abinit_input.set_vars(scf_ksampling.to_abivars()) abinit_input.set_vars(scf_electrons.to_abivars()) abinit_input.set_vars(_stopping_criterion("scf", accuracy)) return abinit_input
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)
def scf_phonons_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): """ Returns a :class:`AbinitInput` for performing phonon calculations. GS input + the input files for the phonon 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. """ # 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) gs_inp.set_vars(ksampling.to_abivars()) gs_inp.set_vars(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) # i.e. the same parameters used for the k-mesh in gs_inp. qpoints = gs_inp.abiget_ibz(ngkpt=(4,4,4), shiftk=(0,0,0), kptopt=1).points #print("get_ibz qpoints:", qpoints) # Build the input files for the q-points in the IBZ. ph_inputs = MultiDataset(gs_inp.structure, pseudos=gs_inp.pseudos, ndtset=len(qpoints)) for ph_inp, qpt in zip(ph_inputs, qpoints): # Response-function calculation for phonons. ph_inp.set_vars( rfphon=1, # Will consider phonon-type perturbation nqpt=1, # One wavevector is to be considered qpt=qpt, # This wavevector is q=0 (Gamma) tolwfr=1.0e-20, kptopt=3, # One could used symmetries for Gamma. ) #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 irred_perts = ph_inp.abiget_irred_phperts() #for pert in irred_perts: # #print(pert) # # TODO this will work for phonons, but not for the other types of perturbations. # ph_inp = q_inp.deepcopy() # rfdir = 3 * [0] # rfdir[pert.idir -1] = 1 # ph_inp.set_vars( # rfdir=rfdir, # rfatpol=[pert.ipert, pert.ipert] # ) # ph_inputs.append(ph_inp) # Split input into gs_inp and ph_inputs all_inps = [gs_inp] all_inps.extend(ph_inputs.split_datasets()) return all_inps
def scf_phonons_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): """ Returns a :class:`AbinitInput` for performing phonon calculations. GS input + the input files for the phonon 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. """ # 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) gs_inp.set_vars(ksampling.to_abivars()) gs_inp.set_vars(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) # i.e. the same parameters used for the k-mesh in gs_inp. qpoints = gs_inp.abiget_ibz(ngkpt=(4, 4, 4), shiftk=(0, 0, 0), kptopt=1).points #print("get_ibz qpoints:", qpoints) # Build the input files for the q-points in the IBZ. ph_inputs = MultiDataset(gs_inp.structure, pseudos=gs_inp.pseudos, ndtset=len(qpoints)) for ph_inp, qpt in zip(ph_inputs, qpoints): # Response-function calculation for phonons. ph_inp.set_vars( rfphon=1, # Will consider phonon-type perturbation nqpt=1, # One wavevector is to be considered qpt=qpt, # This wavevector is q=0 (Gamma) tolwfr=1.0e-20, kptopt=3, # One could used symmetries for Gamma. ) #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 irred_perts = ph_inp.abiget_irred_phperts() #for pert in irred_perts: # #print(pert) # # TODO this will work for phonons, but not for the other types of perturbations. # ph_inp = q_inp.deepcopy() # rfdir = 3 * [0] # rfdir[pert.idir -1] = 1 # ph_inp.set_vars( # rfdir=rfdir, # rfatpol=[pert.ipert, pert.ipert] # ) # ph_inputs.append(ph_inp) # Split input into gs_inp and ph_inputs all_inps = [gs_inp] all_inps.extend(ph_inputs.split_datasets()) return all_inps