@@ -200,14 +200,8 @@ def get_correction(self, entry) -> ufloat:
200
200
Correction.
201
201
"""
202
202
comp = entry .composition
203
-
204
- correction = ufloat (0.0 , 0.0 )
205
-
206
203
# set error to 0 because old MPCompatibility doesn't have errors
207
-
208
- # only correct GGA or GGA+U entries
209
- if entry .parameters .get ("run_type" ) not in ("GGA" , "GGA+U" ):
210
- return ufloat (0.0 , 0.0 )
204
+ correction = ufloat (0.0 , 0.0 )
211
205
212
206
rform = entry .composition .reduced_formula
213
207
if rform in self .cpd_energies :
@@ -252,10 +246,6 @@ def get_correction(self, entry) -> ufloat:
252
246
253
247
correction = ufloat (0.0 , 0.0 )
254
248
255
- # only correct GGA or GGA+U entries
256
- if entry .parameters .get ("run_type" ) not in ("GGA" , "GGA+U" ):
257
- return ufloat (0.0 , 0.0 )
258
-
259
249
# Check for sulfide corrections
260
250
if Element ("S" ) in comp :
261
251
sf_type = "sulfide"
@@ -351,10 +341,6 @@ def get_correction(self, entry) -> ufloat:
351
341
rform = comp .reduced_formula
352
342
cpd_energies = self .cpd_energies
353
343
354
- # only correct GGA or GGA+U entries
355
- if entry .parameters .get ("run_type" ) not in ("GGA" , "GGA+U" ):
356
- return ufloat (0.0 , 0.0 )
357
-
358
344
correction = ufloat (0.0 , 0.0 )
359
345
360
346
if rform in cpd_energies :
@@ -465,22 +451,13 @@ def get_correction(self, entry) -> ufloat:
465
451
Returns:
466
452
Correction, Uncertainty.
467
453
"""
468
- if entry .parameters .get ("run_type" ) not in ("GGA" , "GGA+U" ):
469
- raise CompatibilityError (
470
- f"Entry { entry .entry_id } has invalid run type { entry .parameters .get ('run_type' )} . Discarding."
471
- )
472
-
473
454
calc_u = entry .parameters .get ("hubbards" ) or defaultdict (int )
474
455
comp = entry .composition
475
456
476
457
elements = sorted ((el for el in comp .elements if comp [el ] > 0 ), key = lambda el : el .X )
477
458
most_electroneg = elements [- 1 ].symbol
478
459
correction = ufloat (0.0 , 0.0 )
479
460
480
- # only correct GGA or GGA+U entries
481
- if entry .parameters .get ("run_type" ) not in ("GGA" , "GGA+U" ):
482
- return ufloat (0.0 , 0.0 )
483
-
484
461
u_corr = self .u_corrections .get (most_electroneg , {})
485
462
u_settings = self .u_settings .get (most_electroneg , {})
486
463
u_errors = self .u_errors .get (most_electroneg , defaultdict (float ))
@@ -653,17 +630,30 @@ class CorrectionsList(Compatibility):
653
630
MITCompatibility subclasses instead.
654
631
"""
655
632
656
- def __init__ (self , corrections : Sequence [Correction ]):
633
+ def __init__ (self , corrections : Sequence [Correction ], run_types : list [ str ] | None = None ):
657
634
"""
658
635
Args:
659
636
corrections (list[Correction]): Correction objects to apply.
637
+ run_types: Valid DFT run_types for this correction scheme. Entries with run_type
638
+ other than those in this list will be excluded from the list returned
639
+ by process_entries. The default value captures both GGA and GGA+U run types
640
+ historically used by the Materials Project, for example in.
660
641
"""
642
+ if run_types is None :
643
+ run_types = ["GGA" , "GGA+U" , "PBE" , "PBE+U" ]
661
644
self .corrections = corrections
645
+ self .run_types = run_types
662
646
super ().__init__ ()
663
647
664
648
def get_adjustments (self , entry : AnyComputedEntry ) -> list [EnergyAdjustment ]:
665
649
"""Get the list of energy adjustments to be applied to an entry."""
666
650
adjustment_list = []
651
+ if entry .parameters .get ("run_type" ) not in self .run_types :
652
+ raise CompatibilityError (
653
+ f"Entry { entry .entry_id } has invalid run type { entry .parameters .get ('run_type' )} . "
654
+ f"Must be GGA or GGA+U. Discarding."
655
+ )
656
+
667
657
corrections , uncertainties = self .get_corrections_dict (entry )
668
658
669
659
for k , v in corrections .items ():
0 commit comments