Skip to content

Fix run-type ranking in ThermoDoc.from_entries (GGA(+U) reported over r2SCAN) - #1545

Open
kavanase wants to merge 1 commit into
materialsproject:mainfrom
kavanase:fix/thermo-doc-run-type-ranking
Open

kavanase wants to merge 1 commit into
materialsproject:mainfrom
kavanase:fix/thermo-doc-run-type-ranking

Conversation

@kavanase

@kavanase kavanase commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

ThermoDoc.from_entries picks the entry to use for a material using entry_quality_scores = {"GGA": 1, "GGA+U": 2, "SCAN": 3, "r2SCAN": 4} (i.e. RunType values), but looked the scores up with entry.data["run_type"]. In MP's corrected entries that field holds BlessedCalcs field names (GGA, GGA_U, R2SCAN; the legacy corrected-entries builder sets it from the MaterialsDoc.entries keys, and the new one compares it to "R2SCAN"), so GGA+U and r2SCAN entries scored 0 and GGA entries 1:

  • GGA vs r2SCAN: GGA wins outright.
  • GGA+U vs r2SCAN: a 0-0 tie, then LASPH (set on both), then total energy, so the larger cell wins, which
    in each case is the GGA+U one.

This only matters when a material has more than one entry, i.e. when the GGA(+U)/r2SCAN mixing scheme keeps
both its GGA(+U) and r2SCAN entries. The thermo doc, and so the summary doc and website, then reports the
GGA(+U) entry. It is also why rutile TiO2 (mp-2657) showed 0.0436 eV/atom (its GGA entry) rather than 0.0095
(r2SCAN) before DB 2026.09.28.

This PR uses entry.parameters["run_type"] instead, which holds the actual RunType values, and which
from_entries already uses for energy_type and the entries keys. The r2SCAN key has mismatched since
26be1b9 (Sep 2024, "R2SCAN" -> "r2SCAN"), and GGA+U since BlessedCalcs (#880).

Effect on current data (DB 2026.09.28) (with help from Claude)

Rebuilding thermo docs from MP's served phase diagrams with and without this change, the only docs that
change are those of materials with two entries, all now reporting their r2SCAN entry (EaH in eV/atom):

material system before (as served) after
mp-19311 (V2CoO6) Co-O-V GGA+U, 0.0421, unstable r2SCAN, 0.0000, stable
mp-1095283 (PAuO4) Au-O-P GGA, 0.0072, unstable r2SCAN, 0.0000, stable
mp-23724 (KHCO3) C-H-K-O GGA, 0.0153 r2SCAN, 0.0001
mp-626716 (KHO) H-K-O GGA, 0.0032 r2SCAN, 0.0004
mp-1039605 (Ce2Mg) Ce-Mg GGA, 0.0523 r2SCAN, 0.0338
mp-726023 (NClO) Cl-N-O GGA, 0.1684 r2SCAN, 0.1638
mp-7858 (MgUO4) Mg-O-U GGA, 0.0001 r2SCAN, 0.0001
mp-1039397 Ca-Mg GGA, 0.0352 r2SCAN, 0.0369
mp-768486 O-S-Sb GGA, 0.0076 r2SCAN, 0.0178
mp-550206 (CoO2) Co-O GGA+U, 0.0067 r2SCAN, 0.1169

Materials with a single entry don't change. In GGA_GGA+U docs, a material with both a GGA and a GGA+U entry
now reports the GGA+U one, as the scores intend; the one case found (in ~87k docs sampled) is mp-15590
(Sr2Nb2O7), whose "GGA+U" entry has no U values and the same energy, so only energy_type and provenance
change.

Not fixed here: why these materials have two entries in the mixed phase diagrams, which is down to the
mixing scheme's structure grouping in pymatgen (MaterialsProjectDFTMixingScheme).

Contributor Checklist

- [ ] I have broken down my PR scope into the following TODO tasks
~~ - [ ] task 1~~
~~ - [ ] task 2~~

  • I have run the tests locally and they passed.
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

@tsmathis

Copy link
Copy Markdown
Collaborator

Thanks for pointing this out @kavanase

@codecov-commenter

codecov-commenter commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.38%. Comparing base (075ff68) to head (77bb90d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1545      +/-   ##
==========================================
+ Coverage   85.37%   85.38%   +0.01%     
==========================================
  Files         216      216              
  Lines       17793    17793              
==========================================
+ Hits        15190    15192       +2     
+ Misses       2603     2601       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants