Skip to content

Commit 0bd9909

Browse files
author
Aaron Kaplan
committed
sync w main
2 parents 85e672f + 1d1c8f8 commit 0bd9909

6 files changed

Lines changed: 187 additions & 39 deletions

mp_api/client/mprester.py

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from typing import TYPE_CHECKING
88

99
from emmet.core.electronic_structure import BSPathType
10-
from emmet.core.mpid import MPID
10+
from emmet.core.mpid import MPID, AlphaID
1111
from emmet.core.settings import EmmetSettings
1212
from emmet.core.tasks import TaskDoc
1313
from emmet.core.thermo import ThermoType
@@ -1700,3 +1700,78 @@ def get_stability(
17001700
}
17011701
for idx, entry in enumerate(entries)
17021702
]
1703+
1704+
def get_oxygen_evolution(
1705+
self,
1706+
material_id: str | MPID | AlphaID,
1707+
working_ion: str | Element,
1708+
thermo_type: str | ThermoType = ThermoType.GGA_GGA_U,
1709+
):
1710+
working_ion = Element(working_ion)
1711+
formatted_mpid = AlphaID(material_id).string
1712+
electrode_docs = self.materials.insertion_electrodes.search(
1713+
battery_ids=[f"{formatted_mpid}_{working_ion.value}"],
1714+
fields=["chemsys", "electrode_object", "framework"],
1715+
)
1716+
if len(electrode_docs) == 0:
1717+
raise ValueError(
1718+
"No available insertion electrode data with MPID = "
1719+
f"{formatted_mpid} and working ion {working_ion.value}"
1720+
)
1721+
if Element.O not in {
1722+
Element(ele) for ele in electrode_docs[0].chemsys.split("-")
1723+
}:
1724+
raise ValueError(
1725+
f"No oxygen in the host framework {electrode_docs[0].framework}"
1726+
)
1727+
1728+
inserted_chemsys = "-".join(
1729+
sorted({working_ion.value, *electrode_docs[0].chemsys.split("-")})
1730+
)
1731+
unique_composition = {
1732+
entry.composition
1733+
for entry in electrode_docs[0].electrode_object.get_all_entries()
1734+
}
1735+
1736+
phase_diagram = self.materials.thermo.get_phase_diagram_from_chemsys(
1737+
inserted_chemsys,
1738+
thermo_type=ThermoType(thermo_type),
1739+
)
1740+
1741+
by_dict = {
1742+
composition.formula: [
1743+
{
1744+
k: profile[v]
1745+
for k, v in {
1746+
"mu": "chempot",
1747+
"reaction": "reaction",
1748+
"evolution": "evolution",
1749+
}.items()
1750+
}
1751+
for profile in phase_diagram.get_element_profile("O", composition)
1752+
]
1753+
for composition in unique_composition
1754+
}
1755+
1756+
target_comp = Composition({"O": 1})
1757+
for formula, data in by_dict.items():
1758+
for idx, entry in enumerate(data):
1759+
# Normalize all reactions to have integer coefficients
1760+
scale = entry["reaction"].normalized_repr_and_factor()[1]
1761+
by_dict[formula][idx]["reaction"]._coeffs = [
1762+
c * scale for c in entry["reaction"]._coeffs
1763+
]
1764+
1765+
by_dict[formula][idx]["O2_produced"] = (
1766+
entry["reaction"].get_coeff(target_comp)
1767+
if target_comp in entry["reaction"].products
1768+
else 0
1769+
)
1770+
1771+
return {
1772+
formula: {
1773+
k: [data[idx][k] for idx in range(len(data))]
1774+
for k in ("mu", "reaction", "evolution", "O2_produced")
1775+
}
1776+
for formula, data in by_dict.items()
1777+
}

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ authors = [
99
]
1010
description = "API Client for the Materials Project"
1111
readme = "README.md"
12-
requires-python = ">=3.9"
12+
requires-python = ">=3.10"
1313
license = { text = "modified BSD" }
1414
classifiers = [
1515
"Programming Language :: Python :: 3",
@@ -20,19 +20,18 @@ classifiers = [
2020
"Topic :: Scientific/Engineering",
2121
]
2222
dependencies = [
23-
"setuptools",
2423
"msgpack",
2524
"pymatgen>=2022.3.7,!=2024.2.20",
2625
"typing-extensions>=3.7.4.1",
2726
"requests>=2.23.0",
2827
"monty>=2024.12.10",
29-
"emmet-core>=0.84.10rc1",
28+
"emmet-core>=0.84.6rc0,<0.85",
3029
"smart_open",
3130
]
3231
dynamic = ["version"]
3332

3433
[project.optional-dependencies]
35-
all = ["emmet-core[all]>=0.84.10rc1", "custodian", "mpcontribs-client", "boto3"]
34+
all = ["emmet-core[all]>=0.84.6rc0,<0.85", "custodian", "mpcontribs-client", "boto3"]
3635
test = [
3736
"pre-commit",
3837
"pytest",

requirements/requirements-ubuntu-latest_py3.11.txt

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,36 @@
66
#
77
annotated-types==0.7.0
88
# via pydantic
9+
attrs==25.3.0
10+
# via
11+
# jsonlines
12+
# jsonschema
13+
# referencing
14+
bcrypt==5.0.0
15+
# via paramiko
916
bibtexparser==1.4.3
1017
# via pymatgen
11-
blake3==1.0.6
12-
# via emmet-core
18+
boto3==1.40.40
19+
# via maggma
20+
botocore==1.40.40
21+
# via
22+
# boto3
23+
# s3transfer
1324
certifi==2025.8.3
1425
# via requests
1526
charset-normalizer==3.4.3
1627
# via requests
1728
contourpy==1.3.3
1829
# via matplotlib
30+
cryptography==46.0.1
31+
# via paramiko
1932
cycler==0.12.1
2033
# via matplotlib
21-
emmet-core==0.84.10rc2
34+
dnspython==2.8.0
35+
# via
36+
# maggma
37+
# pymongo
38+
emmet-core==0.84.10
2239
# via mp-api (pyproject.toml)
2340
fonttools==4.60.0
2441
# via matplotlib
@@ -78,7 +95,7 @@ pydantic==2.11.9
7895
# pymatgen-io-validation
7996
pydantic-core==2.33.2
8097
# via pydantic
81-
pydantic-settings==2.10.1
98+
pydantic-settings==2.11.0
8299
# via
83100
# emmet-core
84101
# pymatgen-io-validation
@@ -89,6 +106,10 @@ pymatgen==2025.6.14
89106
# pymatgen-io-validation
90107
pymatgen-io-validation==0.1.2
91108
# via emmet-core
109+
pymongo==4.10.1
110+
# via maggma
111+
pynacl==1.6.0
112+
# via paramiko
92113
pyparsing==3.2.5
93114
# via
94115
# bibtexparser
@@ -100,8 +121,10 @@ python-dateutil==2.9.0.post0
100121
python-dotenv==1.1.1
101122
# via pydantic-settings
102123
pytz==2025.2
103-
# via pandas
104-
pyyaml==6.0.2
124+
# via
125+
# mongomock
126+
# pandas
127+
pyyaml==6.0.3
105128
# via pybtex
106129
requests==2.32.5
107130
# via
@@ -112,7 +135,7 @@ ruamel-yaml==0.18.15
112135
# via
113136
# monty
114137
# pymatgen
115-
ruamel-yaml-clib==0.2.13
138+
ruamel-yaml-clib==0.2.14
116139
# via ruamel-yaml
117140
scipy==1.16.2
118141
# via pymatgen

requirements/requirements-ubuntu-latest_py3.11_extras.txt

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,19 @@ attrs==25.3.0
2020
# referencing
2121
babel==2.17.0
2222
# via sphinx
23+
bcrypt==5.0.0
24+
# via paramiko
2325
bibtexparser==1.4.3
2426
# via pymatgen
2527
blake3==1.0.6
2628
# via emmet-core
2729
boltons==25.0.0
2830
# via mpcontribs-client
29-
boto3==1.40.35
30-
# via mp-api (pyproject.toml)
31-
botocore==1.40.35
31+
boto3==1.40.40
32+
# via
33+
# maggma
34+
# mp-api (pyproject.toml)
35+
botocore==1.40.40
3236
# via
3337
# boto3
3438
# s3transfer
@@ -48,6 +52,8 @@ contourpy==1.3.3
4852
# via matplotlib
4953
coverage[toml]==7.10.7
5054
# via pytest-cov
55+
cryptography==46.0.1
56+
# via paramiko
5157
custodian==2025.8.13
5258
# via mp-api (pyproject.toml)
5359
cycler==0.12.1
@@ -62,7 +68,7 @@ dnspython==2.8.0
6268
# pymongo
6369
docutils==0.21.2
6470
# via sphinx
65-
emmet-core[all]==0.85.0rc0
71+
emmet-core[all]==0.84.10
6672
# via mp-api (pyproject.toml)
6773
execnet==2.1.1
6874
# via pytest-xdist
@@ -285,7 +291,7 @@ pydantic==2.11.9
285291
# pymatgen-io-validation
286292
pydantic-core==2.33.2
287293
# via pydantic
288-
pydantic-settings==2.10.1
294+
pydantic-settings==2.11.0
289295
# via
290296
# emmet-core
291297
# pymatgen-io-validation
@@ -323,6 +329,8 @@ pymongo==4.15.1
323329
# via
324330
# matminer
325331
# mpcontribs-client
332+
pynacl==1.6.0
333+
# via paramiko
326334
pyparsing==3.2.5
327335
# via
328336
# bibtexparser
@@ -356,7 +364,7 @@ pytz==2025.2
356364
# via
357365
# bravado-core
358366
# pandas
359-
pyyaml==6.0.2
367+
pyyaml==6.0.3
360368
# via
361369
# bravado
362370
# bravado-core
@@ -399,7 +407,7 @@ ruamel-yaml==0.18.15
399407
# monty
400408
# pymatgen
401409
# robocrys
402-
ruamel-yaml-clib==0.2.13
410+
ruamel-yaml-clib==0.2.14
403411
# via ruamel-yaml
404412
s3transfer==0.14.0
405413
# via boto3
@@ -420,9 +428,11 @@ seekpath==2.1.0
420428
# via emmet-core
421429
semantic-version==2.10.0
422430
# via mpcontribs-client
423-
shapely==2.1.1
431+
sentinels==1.1.1
432+
# via mongomock
433+
shapely==2.1.2
424434
# via pymatgen-analysis-alloys
425-
simplejson==3.20.1
435+
simplejson==3.20.2
426436
# via
427437
# bravado
428438
# bravado-core
@@ -469,7 +479,11 @@ sympy==1.14.0
469479
tabulate==0.9.0
470480
# via pymatgen
471481
threadpoolctl==3.6.0
472-
# via scikit-learn
482+
# via
483+
# mdanalysis
484+
# scikit-learn
485+
tidynamics==1.1.2
486+
# via transport-analysis
473487
tifffile==2025.9.20
474488
# via scikit-image
475489
tqdm==4.67.1

requirements/requirements-ubuntu-latest_py3.12.txt

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,36 @@
66
#
77
annotated-types==0.7.0
88
# via pydantic
9+
attrs==25.3.0
10+
# via
11+
# jsonlines
12+
# jsonschema
13+
# referencing
14+
bcrypt==5.0.0
15+
# via paramiko
916
bibtexparser==1.4.3
1017
# via pymatgen
11-
blake3==1.0.6
12-
# via emmet-core
18+
boto3==1.40.40
19+
# via maggma
20+
botocore==1.40.40
21+
# via
22+
# boto3
23+
# s3transfer
1324
certifi==2025.8.3
1425
# via requests
1526
charset-normalizer==3.4.3
1627
# via requests
1728
contourpy==1.3.3
1829
# via matplotlib
30+
cryptography==46.0.1
31+
# via paramiko
1932
cycler==0.12.1
2033
# via matplotlib
21-
emmet-core==0.84.10rc2
34+
dnspython==2.8.0
35+
# via
36+
# maggma
37+
# pymongo
38+
emmet-core==0.84.10
2239
# via mp-api (pyproject.toml)
2340
fonttools==4.60.0
2441
# via matplotlib
@@ -78,7 +95,7 @@ pydantic==2.11.9
7895
# pymatgen-io-validation
7996
pydantic-core==2.33.2
8097
# via pydantic
81-
pydantic-settings==2.10.1
98+
pydantic-settings==2.11.0
8299
# via
83100
# emmet-core
84101
# pymatgen-io-validation
@@ -89,6 +106,10 @@ pymatgen==2025.6.14
89106
# pymatgen-io-validation
90107
pymatgen-io-validation==0.1.2
91108
# via emmet-core
109+
pymongo==4.10.1
110+
# via maggma
111+
pynacl==1.6.0
112+
# via paramiko
92113
pyparsing==3.2.5
93114
# via
94115
# bibtexparser
@@ -100,8 +121,10 @@ python-dateutil==2.9.0.post0
100121
python-dotenv==1.1.1
101122
# via pydantic-settings
102123
pytz==2025.2
103-
# via pandas
104-
pyyaml==6.0.2
124+
# via
125+
# mongomock
126+
# pandas
127+
pyyaml==6.0.3
105128
# via pybtex
106129
requests==2.32.5
107130
# via
@@ -112,7 +135,7 @@ ruamel-yaml==0.18.15
112135
# via
113136
# monty
114137
# pymatgen
115-
ruamel-yaml-clib==0.2.13
138+
ruamel-yaml-clib==0.2.14
116139
# via ruamel-yaml
117140
scipy==1.16.2
118141
# via pymatgen

0 commit comments

Comments
 (0)