@@ -1243,6 +1243,44 @@ def nscf_from_gsinput(gs_input, kppa=None, nband=None, accuracy="normal",
12431243
12441244 return nscf_input
12451245
1246+ def wfq_nscf_from_gsinput (gs_input , qpt , kppa = None , nband = None , accuracy = "high" ,
1247+ shift_mode = "Monkhorst-Pack" ) -> AbinitInput :
1248+ """
1249+ Return an |AbinitInput| object to perform a NSCF calculation on a K+Q grid from a GS SCF input.
1250+
1251+ Args:
1252+ gs_input: the |AbinitInput| that was used to calculated the charge density.
1253+ qpt: q-point used to shift the k grid.
1254+ kppa: defines the kpt sampling used for the NSCF run. If None the kpoint sampling and
1255+ shifts will be the same as in the SCF input.
1256+ nband: the number of bands to be used for the calculation. If None it will be
1257+ automatically generated.
1258+ accuracy: accuracy of the calculation.
1259+ shift_mode: the mode to be used for the shifts. Options are "Gamma", "Monkhorst-Pack",
1260+ "Symmetric", "OneSymmetric". See ShiftMode object for more details. Only used if kppa
1261+ is not None.
1262+
1263+ Return: |AbinitInput|
1264+ """
1265+ # create a copy to avoid messing with the previous input
1266+ wfq_input = gs_input .deepcopy ()
1267+ wfq_input .pop_irdvars ()
1268+
1269+ if kppa is not None :
1270+ shift_mode = ShiftMode .from_object (shift_mode )
1271+ shifts = _get_shifts (shift_mode , gs_input .structure )
1272+ dos_ksampling = aobj .KSampling .automatic_density (wfq_input .structure , kppa , chksymbreak = 0 , shifts = shifts )
1273+ wfq_input .set_vars (dos_ksampling .to_abivars ())
1274+
1275+ if nband is None :
1276+ nband = _find_nscf_nband_from_gsinput (gs_input )
1277+
1278+ wfq_input .set_vars (qpt = qpt , nband = nband , iscf = - 2 , nqpt = 1 , kptopt = 3 )
1279+ wfq_input .set_vars (_stopping_criterion ("nscf" , accuracy ))
1280+
1281+ return wfq_input
1282+
1283+
12461284
12471285def dos_from_gsinput (gs_input , kppa = None , nband = None , accuracy = "normal" , dos_method = "tetra" ,
12481286 projection = "l" , shift_mode = "Monkhorst-Pack" ) -> AbinitInput :
@@ -1352,10 +1390,9 @@ def hybrid_scf_input(gs_input: AbinitInput,
13521390
13531391def scf_for_phonons (structure , pseudos , kppa = None , ecut = None , pawecutdg = None , nband = None , accuracy = "normal" ,
13541392 spin_mode = "polarized" , smearing = "fermi_dirac:0.1 eV" , charge = 0.0 , scf_algorithm = None ,
1355- shift_mode = "Symmetric" ) -> AbinitInput :
1393+ shift_mode = "Symmetric" , nbdbuf = 4 ) -> AbinitInput :
13561394
13571395 # add the band for nbdbuf, if needed
1358- nbdbuf = 4
13591396 if nband is not None :
13601397 nband += nbdbuf
13611398
@@ -1364,7 +1401,7 @@ def scf_for_phonons(structure, pseudos, kppa=None, ecut=None, pawecutdg=None, nb
13641401 scf_algorithm = scf_algorithm , shift_mode = shift_mode )
13651402
13661403 # with no bands set and no smearing the minimum number of bands plus some nbdbuf
1367- if nband is None and smearing is None :
1404+ if nband is None and ( smearing is None or smearing == "nosmearing" ) :
13681405 nval = structure .num_valence_electrons (pseudos )
13691406 nval -= abiinput ['charge' ]
13701407 nband = int (round (nval / 2 ) + nbdbuf )
@@ -1453,6 +1490,32 @@ def dtepert_from_gsinput(gs_input, dte_pert, manager=None) -> AbinitInput:
14531490 return dte_inp
14541491
14551492
1493+
1494+ def phononpert_from_gsinput (gs_input , phonon_pert , phonon_tol = None , manager = None ) -> AbinitInput :
1495+ """
1496+ Returns an |AbinitInput| to perform a phonon perturbation calculation for a specific perturbation based on a ground state |AbinitInput|.
1497+
1498+ Args:
1499+ gs_input: an |AbinitInput| representing a ground state calculation, likely the SCF performed to get the WFK.
1500+ phonon_pert: dict with the Abinit variables defining the perturbation
1501+ Example: {'idir': 1, 'ipert': 1, 'qpt': [0.0, 0.0, 0.0]},
1502+ phonon_tol: dict with a single ABINIT tolerance variable (e.g. ``{'tolvrs': 1.0e-10}``)
1503+ used to control the convergence of the DFPT calculation.
1504+ If ``None``, a default of ``{'tolvrs': 1.0e-10}`` is used.
1505+ manager: |TaskManager| of the task. If None, the manager is initialized from the config file.
1506+ """
1507+ gs_input = gs_input .deepcopy ()
1508+ gs_input .pop_irdvars ()
1509+ gs_input .pop_vars (['autoparal' , 'npfft' ])
1510+
1511+ if phonon_tol is None :
1512+ phonon_tol = {"tolvrs" : 1.0e-10 }
1513+
1514+ phonon_inp = gs_input .make_phpert_input (perturbation = phonon_pert , tolerance = phonon_tol , manager = manager )
1515+
1516+ return phonon_inp
1517+
1518+
14561519def dte_from_gsinput (gs_input , use_phonons = True , ph_tol = None , ddk_tol = None , dde_tol = None ,
14571520 skip_dte_permutations = False , manager = None ) -> MultiDataset :
14581521 """
0 commit comments