Skip to content

Commit 27726d3

Browse files
committed
minor cleanup
1 parent afdb335 commit 27726d3

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

mp_api/client/core/_oxygen_evolution.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Compute the oxygen evolution of a phase."""
2+
23
from __future__ import annotations
34

45
import json
@@ -16,6 +17,8 @@
1617
from scipy.interpolate import make_splrep, splev
1718

1819
DEFAULT_CACHE_FILE = Path(__file__).absolute().parent / "JANAF_O2_data.json"
20+
# O2 partial pressure at ambient conditions, in MPa
21+
O2_PARTIAL_PRESSURE = 0.21 * atm * 1e-6
1922

2023

2124
class OxygenEvolution:
@@ -30,17 +33,15 @@ class OxygenEvolution:
3033

3134
def __init__(
3235
self,
33-
cache_file: Path | None = DEFAULT_CACHE_FILE,
36+
cache_file: Path = DEFAULT_CACHE_FILE,
3437
):
3538
self._spline_pars = None
3639
self.cache_file = cache_file
3740

3841
def get_chempot_temp_data(
3942
self,
4043
nist_url: str = "https://janaf.nist.gov/tables/O-029.txt",
41-
ref_p: float = 0.21
42-
* atm
43-
* 1e-6, # O2 partial pressure at ambient conditions, in MPa
44+
ref_p: float = O2_PARTIAL_PRESSURE,
4445
meas_p: float = 0.1, # The reference pressure reported in JANAF, 0.1 MPa
4546
) -> tuple[np.ndarray, np.ndarray]:
4647
"""Get the approximate relationship between the O2 chemical potential and temperature.
@@ -67,7 +68,7 @@ def get_chempot_temp_data(
6768
"""
6869
if self.cache_file and self.cache_file.exists():
6970
data = json.loads(self.cache_file.read_text())
70-
return tuple(np.array(data[k]) for k in ("temperature", "mu-mu_0K"))
71+
return tuple(np.array(data[k]) for k in ("temperature", "mu-mu_0K")) # type: ignore
7172

7273
response = requests.get(nist_url)
7374

@@ -176,7 +177,7 @@ def get_oxygen_evolution_from_phase_diagram(
176177
c * scale for c in entry["reaction"]._coeffs
177178
]
178179

179-
oxy_evo_data = {
180+
oxy_evo_data: dict = {
180181
formula: {
181182
k: [data[idx][k] for idx in range(len(data))]
182183
for k in (
@@ -196,9 +197,8 @@ def get_oxygen_evolution_from_phase_diagram(
196197
oxy_evo_data[formula]["evolution"],
197198
oxy_evo_data[formula]["reaction"],
198199
) = self.stairstep(*(data[k] for k in ("mu", "evolution", "reaction")))
199-
oxy_evo_data[formula][
200-
"evolution"
201-
] *= -0.5 # This is the normalization convention we adopt for MP
200+
# This is the normalization convention we adopt for MP
201+
oxy_evo_data[formula]["evolution"] *= -0.5
202202
oxy_evo_data[formula]["temperature"] = self.mu_to_temp_spline(
203203
data["mu"] - mu_0K
204204
)

0 commit comments

Comments
 (0)