33from __future__ import annotations
44
55import logging
6+ import warnings
67from copy import deepcopy
78from dataclasses import dataclass , field
89from typing import TYPE_CHECKING , Any
2223logger = logging .getLogger (__name__ )
2324
2425
26+ def _emit_magmom_warning () -> None :
27+ warnings .warn (
28+ "Removing the MAGMOM tag is not recommended generally, "
29+ "but is permitted to allow for previous behavior in atomate2. "
30+ "See https://vasp.at/wiki/MAGMOM to understand how "
31+ "magnetic initialization is affected by MAGMOM, CHGCAR, and WAVECAR." ,
32+ stacklevel = 2 ,
33+ )
34+
35+
2536@dataclass
2637class RelaxSetGenerator (VaspInputGenerator ):
2738 """Class to generate VASP relaxation input sets."""
@@ -170,6 +181,10 @@ class NonSCFSetGenerator(VaspInputGenerator):
170181 nbands_factor
171182 Multiplicative factor for NBANDS when starting from a previous calculation.
172183 Choose a higher number if you are doing an LOPTICS calculation.
184+ remove_magmoms
185+ Whether to remove the MAGMOM tag from a previous calculation and
186+ use the initialization of the set. NOT RECOMMENDED. Included to allow for
187+ backwards compatible behavior.
173188 **kwargs
174189 Other keyword arguments that will be passed to :obj:`VaspInputGenerator`.
175190 """
@@ -182,6 +197,7 @@ class NonSCFSetGenerator(VaspInputGenerator):
182197 optics : bool = False
183198 nbands_factor : float = 1.2
184199 auto_ispin : bool = True
200+ remove_magmoms : bool = False
185201
186202 def __post_init__ (self ) -> None :
187203 """Ensure mode is set correctly."""
@@ -259,7 +275,9 @@ def incar_updates(self) -> dict:
259275 # underestimates, so set it explicitly
260276 updates .update (LOPTICS = True , LREAL = False , CSHIFT = 1e-5 , NEDOS = 2000 )
261277
262- updates ["MAGMOM" ] = None
278+ if self .remove_magmoms :
279+ _emit_magmom_warning ()
280+ updates ["MAGMOM" ] = None
263281
264282 return updates
265283
@@ -419,6 +437,10 @@ class HSEBSSetGenerator(VaspInputGenerator):
419437 Choose a higher number if you are doing an LOPTICS calculation.
420438 added_kpoints
421439 A list of kpoints in fractional coordinates to add as zero-weighted points.
440+ remove_magmoms
441+ Whether to remove the MAGMOM tag from a previous calculation and
442+ use the initialization of the set. NOT RECOMMENDED. Included to allow for
443+ backwards compatible behavior.
422444 **kwargs
423445 Other keyword arguments that will be passed to :obj:`VaspInputGenerator`.
424446 """
@@ -432,6 +454,7 @@ class HSEBSSetGenerator(VaspInputGenerator):
432454 nbands_factor : float = 1.2
433455 added_kpoints : list [Vector3D ] = field (default_factory = list )
434456 auto_ispin : bool = True
457+ remove_magmoms : bool = False
435458
436459 def __post_init__ (self ) -> None :
437460 """Ensure mode is set correctly."""
@@ -520,7 +543,9 @@ def incar_updates(self) -> dict:
520543 # LREAL not supported with LOPTICS
521544 updates .update (LOPTICS = True , LREAL = False , CSHIFT = 1e-5 )
522545
523- updates ["MAGMOM" ] = None
546+ if self .remove_magmoms :
547+ _emit_magmom_warning ()
548+ updates ["MAGMOM" ] = None
524549
525550 return updates
526551
0 commit comments