Skip to content

Incorrect AnionCorrections obtained using MaterialsProject2020Compatibility for ComputedEntry with sulfur having positive oxidation state. #4538

Description

@dembart

Python version

Python 3.11.13

Pymatgen version

2025.10.7

Operating system version

OSX

Current behavior

I get AnionCorrections for S6+ species (it is cation) when I create ComputedEntry from scratch and apply corrections using MaterialsProject2020Compatibility.

from pymatgen.core import Composition 
from pymatgen.entries.computed_entries import ComputedEntry
from pymatgen.entries.compatibility import MaterialsProject2020Compatibility

comp = Composition.from_dict({"Li1+": 4, "Cs1+": 4, "S6+":4, "O2-": 16})
energy = -160.3371 # uncorrected energy for mp-6597

entry = ComputedEntry(composition = comp, energy = energy)
entry.parameters = {"run_type": "GGA"}

compat = MaterialsProject2020Compatibility(check_potcar=False, correct_peroxide=True)
compat.process_entry(entry, on_error="raise")
print(entry)
None ComputedEntry - Cs4 Li4 S4 O16 (CsLiSO4)
Energy (Uncorrected)     = -160.3371 eV (-5.7263  eV/atom)
Correction               = -13.0040  eV (-0.4644  eV/atom)
Energy (Final)           = -173.3411 eV (-6.1908  eV/atom)
Energy Adjustments:
  MP2020 anion correction (S): -2.0120   eV (-0.0719  eV/atom)
  MP2020 anion correction (oxide): -10.9920  eV (-0.3926  eV/atom)
Parameters:
  run_type               = GGA
Data:
  oxidation_states       = {'Li': 1.0, 'Cs': 1.0, 'S': 6.0, 'O': -2.0}

However, when I retrieve this record using mp_api, everything appears correct.

with MPRester(api_key) as mp_rester:
    entry = mp_rester.get_entries(['mp-6597'], additional_criteria={'thermo_types': ['GGA_GGA+U']})
print(entry[0])
Retrieving ThermoDoc documents: 100%|██████████| 1/1 [00:00<00:00, 19328.59it/s]
mp-6597-GGA ComputedStructureEntry - Cs4 Li4 S4 O16 (CsLiSO4)
Energy (Uncorrected)     = -160.3371 eV (-5.7263  eV/atom)
Correction               = -10.9920  eV (-0.3926  eV/atom)
Energy (Final)           = -171.3291 eV (-6.1189  eV/atom)
Energy Adjustments:
  MP2020 anion correction (oxide): -10.9920  eV (-0.3926  eV/atom)
Parameters:
  potcar_spec            = [{'titel': 'PAW_PBE Cs_sv 08Apr2002', 'hash': '096b53a7d80cc0086976bcda50d536e5', 'summary_stats': None}, {'titel': 'PAW_PBE Li_sv 23Jan2001', 'hash': '4799bab014a83a07c654d7196c8ecfa9', 'summary_stats': None}, {'titel': 'PAW_PBE S 17Jan2003', 'hash': 'd368db6899d8839859bbee4811a42a88', 'summary_stats': None}, {'titel': 'PAW_PBE O 08Apr2002', 'hash': '7a25bc5b9a5393f46600a4939d357982', 'summary_stats': None}]
  run_type               = GGA
  is_hubbard             = False
  hubbards               = None
Data:
  oxide_type             = oxide
  aspherical             = True
  last_updated           = 2024-11-21 20:38:24.276956+00:00
  task_id                = mp-1393723
  material_id            = mp-6597
  oxidation_states       = {'Cs': 1.0, 'Li': 1.0, 'S': 6.0, 'O': -2.0}
  license                = BY-C
  run_type               = GGA

Expected Behavior

No anion corrections for sulfur having positive oxidation state.

Minimal example

from pymatgen.core import Composition 
from pymatgen.entries.computed_entries import ComputedEntry
from pymatgen.entries.compatibility import MaterialsProject2020Compatibility

comp = Composition.from_dict({"Li1+": 4, "Cs1+": 4, "S6+":4, "O2-": 16})
energy = -160.3371 # uncorrected energy for mp-6597

entry = ComputedEntry(composition = comp, energy = energy)
entry.parameters = {"run_type": "GGA"}

compat = MaterialsProject2020Compatibility(check_potcar=False, correct_peroxide=True)
compat.process_entry(entry, on_error="raise")
print(entry.energy)

Relevant files to reproduce this bug

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions