Skip to content

[Breaking] Update "electron affinities" in periodic_table.json#4344

Merged
shyuep merged 9 commits intomaterialsproject:masterfrom
DanielYang59:update-pt-elec-affinity-wiki
Apr 20, 2025
Merged

[Breaking] Update "electron affinities" in periodic_table.json#4344
shyuep merged 9 commits intomaterialsproject:masterfrom
DanielYang59:update-pt-elec-affinity-wiki

Conversation

@DanielYang59
Copy link
Contributor

@DanielYang59 DanielYang59 commented Apr 1, 2025

Summary

Looks like some data entries from Wikipedia changed quite dramatically (some are just flucations), not sure if we want to update them?

def add_electron_affinities():
"""Update the periodic table data file with electron affinities."""
req = requests.get("https://wikipedia.org/wiki/Electron_affinity_(data_page)", timeout=60)

@DanielYang59 DanielYang59 marked this pull request as ready for review April 1, 2025 12:36
@shyuep
Copy link
Member

shyuep commented Apr 1, 2025

This one we need to be careful about. I am unclear where the old values come from. I believe it is the official Pauling definition. It might be old but it is what people have been using all this while. This can potentially cause havoc since MP uses the electronegativity in generating the formula.

@DanielYang59
Copy link
Contributor Author

Yes can never be too careful when changing such core data recordings, looks like to me it might came from the same source (wikipedia) as used in the PR (not sure if wikipedia updated its recording at some point?):

@requires(BeautifulSoup, "BeautifulSoup must be installed to use this method.")
def add_electron_affinities():
"""Update the periodic table data file with electron affinities."""
req = requests.get("https://wikipedia.org/wiki/Electron_affinity_(data_page)", timeout=60)
soup = BeautifulSoup(req.text, "html.parser")

@shyuep
Copy link
Member

shyuep commented Apr 1, 2025

Maybe a quick check would be to query for all MP formulas, rerun the Compositiion parsing and reduced formula nad compare the results? If there are no changes to formulas, we can potentially consider it. But again, this is something often used. E.g., matminer uses it as a feature in some instances.

@DanielYang59 DanielYang59 marked this pull request as draft April 1, 2025 16:39
@DanielYang59
Copy link
Contributor Author

DanielYang59 commented Apr 1, 2025

Just to make sure we're on the same page, this PR tries to update the "electron affinity" not the "electronegativity" (X):

@property
def electron_affinity(self) -> float:
"""The amount of energy released when an electron is attached to a neutral atom."""
return self._data["Electron affinity"]

@property
def X(self) -> float:
"""Pauling electronegativity of element. Note that if an element does not
have an Pauling electronegativity, a NaN float is returned.
"""
if X := self._data.get("X"):
return X
warnings.warn(
f"No Pauling electronegativity for {self.symbol}. Setting to NaN. This has no physical meaning, "
"and is mainly done to avoid errors caused by the code expecting a float.",
stacklevel=2,
)
return float("NaN")

And indeed Composition uses X to sort the formula:

@property
def formula(self) -> str:
"""A formula string, with elements sorted by electronegativity,
e.g. Li4 Fe4 P4 O16.
"""
sym_amt = self.get_el_amt_dict()
syms = sorted(sym_amt, key=lambda sym: get_el_sp(sym).X)
formula = [f"{s}{formula_double_format(sym_amt[s], ignore_ones=False)}" for s in syms]
return " ".join(formula)

And AFAIK there's no places across pymatgen accessing this property:
image

And I didn't see any place in matminer trying to use it either

@DanielYang59 DanielYang59 marked this pull request as ready for review April 1, 2025 20:30
@shyuep
Copy link
Member

shyuep commented Apr 2, 2025

Ah my bad... I thought it was the electronegativity. Electron affinity is much less problematic since I don't think there are any critical use of it in normal operations.

@DanielYang59
Copy link
Contributor Author

No worries at all, never hurt to double check in any case :)

@shyuep shyuep merged commit 1ce269f into materialsproject:master Apr 20, 2025
43 checks passed
@DanielYang59 DanielYang59 deleted the update-pt-elec-affinity-wiki branch April 20, 2025 19:38
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.

2 participants