@@ -343,6 +343,16 @@ class DictSet(VaspInputSet):
343
343
SIGMA=0.2; if the system is an insulator, then ISMEAR=-5 (tetrahedron
344
344
smearing). Note, this only works when generating the input set from a
345
345
previous VASP directory.
346
+ auto_ispin (bool) = False:
347
+ If generating input set from a previous calculation, this controls whether
348
+ to disable magnetisation (ISPIN = 1) if the absolute value of all magnetic
349
+ moments are less than 0.02.
350
+ auto_lreal (bool) = False:
351
+ If True, automatically use the VASP recommended LREAL based on cell size.
352
+ auto_metal_kpoints
353
+ If true and the system is metallic, try and use ``reciprocal_density_metal``
354
+ instead of ``reciprocal_density`` for metallic systems. Note, this only works
355
+ if the bandgap is not None.
346
356
bandgap_tol (float): Tolerance for determining if a system is metallic when
347
357
KSPACING is set to "auto". If the bandgap is less than this value, the
348
358
system is considered metallic. Defaults to 1e-4 (eV).
@@ -373,6 +383,9 @@ class DictSet(VaspInputSet):
373
383
validate_magmom : bool = True
374
384
inherit_incar : bool | list [str ] = False
375
385
auto_ismear : bool = False
386
+ auto_ispin : bool = False
387
+ auto_lreal : bool = False
388
+ auto_metal_kpoints : bool = False
376
389
bandgap_tol : float = 1e-4
377
390
bandgap : float | None = None
378
391
prev_incar : str | dict | None = None
@@ -405,9 +418,9 @@ def __post_init__(self):
405
418
406
419
if self .vdw :
407
420
vdw_par = loadfn (MODULE_DIR / "vdW_parameters.yaml" )
408
- try :
409
- self ._config_dict ["INCAR" ].update (vdw_par [ self . vdw ] )
410
- except KeyError :
421
+ if vdw_param := vdw_par . get ( self . vdw ) :
422
+ self ._config_dict ["INCAR" ].update (vdw_param )
423
+ else :
411
424
raise KeyError (
412
425
f"Invalid or unsupported van-der-Waals functional. Supported functionals are { ', ' .join (vdw_par )} ."
413
426
)
@@ -721,6 +734,9 @@ def incar(self) -> Incar:
721
734
else :
722
735
auto_updates .update (ISMEAR = - 5 , SIGMA = 0.05 ) # insulator
723
736
737
+ if self .auto_lreal :
738
+ auto_updates .update (LREAL = _get_recommended_lreal (structure ))
739
+
724
740
kpoints = self .kpoints
725
741
if kpoints is not None :
726
742
# unset KSPACING as we are using a KPOINTS file
@@ -759,14 +775,13 @@ def incar(self) -> Incar:
759
775
and incar .get ("NSW" , 0 ) > 0
760
776
and (ismear < 0 or (ismear == 0 and sigma > 0.05 ))
761
777
):
762
- ismear_docs = "https://www.vasp.at/wiki/index.php/ISMEAR"
763
778
msg = ""
764
779
if ismear < 0 :
765
780
msg = f"Relaxation of likely metal with ISMEAR < 0 ({ ismear } )."
766
781
elif ismear == 0 and sigma > 0.05 :
767
782
msg = f"ISMEAR = 0 with a small SIGMA ({ sigma } ) detected."
768
783
warnings .warn (
769
- f"{ msg } See VASP recommendations on ISMEAR for metals ({ ismear_docs } )." ,
784
+ f"{ msg } See VASP recommendations on ISMEAR for metals (" "https://www.vasp.at/wiki/index.php/ISMEAR )." ,
770
785
BadInputSetWarning ,
771
786
stacklevel = 1 ,
772
787
)
@@ -3058,6 +3073,11 @@ def _get_ispin(vasprun: Vasprun | None, outcar: Outcar | None) -> int:
3058
3073
return 2
3059
3074
3060
3075
3076
+ def _get_recommended_lreal (structure : Structure ) -> str | bool :
3077
+ """Get recommended LREAL flag based on the structure."""
3078
+ return "Auto" if structure .num_sites > 16 else False
3079
+
3080
+
3061
3081
def _combine_kpoints (* kpoints_objects : Kpoints ) -> Kpoints :
3062
3082
"""Combine multiple Kpoints objects."""
3063
3083
_labels : list [list [str ]] = []
0 commit comments