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