Serve the pre-built PD for property_data / conventional_unit_cell queries - #1126
Open
kavanase wants to merge 1 commit into
Open
Serve the pre-built PD for property_data / conventional_unit_cell queries#1126kavanase wants to merge 1 commit into
kavanase wants to merge 1 commit into
Conversation
…it_cell queries (with the additions/corrections applied afterwards); plus fixes and a test
Contributor
Author
|
Test failure seems unrelated to this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #1104 / #1121.
get_entries_in_chemsysserves MP's pre-built (website) phase diagram for the default mixedGGA_GGA+U_R2SCANthermo type, which guarantees every entry shares one energy scale. That was gated onnot (property_data or conventional_unit_cell): requesting either flag instead fell through to re-applyingMaterialsProjectDFTMixingSchemelocally, which is slower (two downloads plus a local re-mix), drops entries the scheme cannot place, can anchor on a different hull than MP serves, and is nondeterministic across processes (materialsproject/pymatgen#3113) -- (I'll be suggesting a separate fix for that issue topymatgen).The result was that the same chemical system returned three different answers depending on which flags you passed. For Si-O:
get_entries_in_chemsys("Si-O")... property_data=["energy_above_hull"]... conventional_unit_cell=TrueNow the served phase diagram is used in all three cases and decorated afterwards:
property_datafields are fetched with a singlematerials.thermo.searchand merged intoentry.data, andconventional_unit_cellreshaping is applied to the returned entries.Bug fix:
conventional_unit_cellmis-scaled the r2SCAN mixing correctionPreviously,
get_entriesreshaped entries by mutating the raw thermo doc dicts, scaling the energy, the composition, and anyn_atoms-bearing energy adjustment. AConstantEnergyAdjustment— how the GGA(+U)/r2SCAN mixing correction is stored — has non_atoms, so it alone stayed at its primitive-cell (no conventional) value while everything around it scaled, silently shifting corrected energies.On
get_entries("H-O", additional_criteria={"thermo_types": ["GGA_GGA+U_R2SCAN"]}, conventional_unit_cell=True), 6 of the 11 reshaped entries came back wrong:The magnitudes are exactly
correction_per_atom x (ratio - 1) / ratio, i.e. entirely explained by the unscaled constant adjustment. Reshaping now goes through one helper,_get_conventional_cell_entry, which scales adjustments with pymatgen's ownEnergyAdjustment.normalize— correct for constant, composition and temperature adjustments alike, which avoids these mismatches.This affects
get_entries,get_entry_by_material_idandget_entries_in_chemsys.Changes
get_entries_in_chemsys: drop theproperty_data/conventional_unit_cellgate; attachproperty_datato the served entries post-hoc with onethermo.searchcall.get_entries: build theComputedStructureEntryfirst, then reshape the object via the shared helper.Tests
test_get_entries_in_chemsys_decorated_served_pd: asserts the plain,property_dataandconventional_unit_cellcalls return the same served entry set on the same energy scale.test_get_entriesnow also asserts the corrected energy per atom. The existing assertion used the uncorrected energy, which was scaled correctly (while corrected was now).Checklist
ruff.mypy.duecredit@due.dcitedecorators to reference relevant papers by DOI (example)