Skip to content

Commit 3a754c1

Browse files
committed
fix pmg paper readme badge
add NthOrderElasticTensor types
1 parent 746e173 commit 3a754c1

File tree

5 files changed

+32
-36
lines changed

5 files changed

+32
-36
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ height="70">
1313
[![PyPI Downloads](https://img.shields.io/pypi/dm/pymatgen?logo=pypi&logoColor=white&color=blue&label=PyPI)](https://pypi.org/project/pymatgen)
1414
[![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/pymatgen?logo=condaforge&color=blue&label=Conda)](https://anaconda.org/conda-forge/pymatgen)
1515
[![Requires Python 3.9+](https://img.shields.io/badge/Python-3.9+-blue.svg?logo=python&logoColor=white)](https://python.org/downloads)
16-
[![arXiv](https://img.shields.io/badge/J.ComMatSci-2012.10.028-blue)](https://doi.org/10.1016/j.commatsci.2012.10.028)
16+
[![Paper](https://img.shields.io/badge/J.ComMatSci-2012.10.028-blue?logo=elsevier&logoColor=white)](https://doi.org/10.1016/j.commatsci.2012.10.028)
1717

1818
</h4>
1919

dev_scripts/potcar_scrambler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def scramble_single_potcar(self, potcar: PotcarSingle):
9393
return scrambled_potcar_str
9494

9595
def to_file(self, filename: str):
96-
with zopen(filename, "wt") as f:
97-
f.write(self.scrambled_potcars_str)
96+
with zopen(filename, "wt") as file:
97+
file.write(self.scrambled_potcars_str)
9898

9999
@classmethod
100100
def from_file(cls, input_filename: str, output_filename: str | None = None):

docs/index.md

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pymatgen/analysis/elasticity/elastic.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ def snyder_total(self, structure: Structure) -> float:
320320

321321
@raise_if_unphysical
322322
def clarke_thermalcond(self, structure: Structure) -> float:
323-
"""
324-
Calculates Clarke's thermal conductivity (in SI units).
323+
"""Calculates Clarke's thermal conductivity.
325324
326325
Args:
327326
structure: pymatgen structure object
@@ -339,8 +338,7 @@ def clarke_thermalcond(self, structure: Structure) -> float:
339338

340339
@raise_if_unphysical
341340
def cahill_thermalcond(self, structure: Structure) -> float:
342-
"""
343-
Calculates Cahill's thermal conductivity (in SI units).
341+
"""Calculate Cahill's thermal conductivity.
344342
345343
Args:
346344
structure: pymatgen structure object
@@ -354,12 +352,11 @@ def cahill_thermalcond(self, structure: Structure) -> float:
354352

355353
@due.dcite(
356354
Doi("10.1039/C7EE03256K"),
357-
description="Minimum thermal conductivity in the context of diffuson-mediated thermal transport",
355+
description="Minimum thermal conductivity in the context of diffusion-mediated thermal transport",
358356
)
359357
@raise_if_unphysical
360358
def agne_diffusive_thermalcond(self, structure: Structure) -> float:
361-
"""
362-
Calculates Agne's diffusive thermal conductivity (in SI units).
359+
"""Calculates Agne's diffusive thermal conductivity.
363360
364361
Please cite the original authors if using this method
365362
M. T. Agne, R. Hanus, G. J. Snyder, Energy Environ. Sci. 2018, 11, 609-616.
@@ -397,23 +394,23 @@ def debye_temperature(self, structure: Structure) -> float:
397394
return 1.05457e-34 / 1.38065e-23 * vm * (6 * np.pi**2 / v0) ** (1 / 3)
398395

399396
@property
400-
def universal_anisotropy(self):
397+
def universal_anisotropy(self) -> float:
401398
"""Returns the universal anisotropy value."""
402399
return 5 * self.g_voigt / self.g_reuss + self.k_voigt / self.k_reuss - 6.0
403400

404401
@property
405-
def homogeneous_poisson(self):
402+
def homogeneous_poisson(self) -> float:
406403
"""Returns the homogeneous poisson ratio."""
407404
return (1 - 2 / 3 * self.g_vrh / self.k_vrh) / (2 + 2 / 3 * self.g_vrh / self.k_vrh)
408405

409-
def green_kristoffel(self, u):
406+
def green_kristoffel(self, u) -> float:
410407
"""Returns the Green-Kristoffel tensor for a second-order tensor."""
411408
return self.einsum_sequence([u, u], "ijkl,i,l")
412409

413410
@property
414411
def property_dict(self):
415412
"""Returns a dictionary of properties derived from the elastic tensor."""
416-
props = [
413+
props = (
417414
"k_voigt",
418415
"k_reuss",
419416
"k_vrh",
@@ -423,7 +420,7 @@ def property_dict(self):
423420
"universal_anisotropy",
424421
"homogeneous_poisson",
425422
"y_mod",
426-
]
423+
)
427424
return {prop: getattr(self, prop) for prop in props}
428425

429426
def get_structure_property_dict(
@@ -441,7 +438,7 @@ def get_structure_property_dict(
441438
ignore_errors (bool): if set to true, will set problem properties
442439
that depend on a physical tensor to None, defaults to False
443440
"""
444-
s_props = [
441+
s_props = (
445442
"trans_v",
446443
"long_v",
447444
"snyder_ac",
@@ -450,7 +447,7 @@ def get_structure_property_dict(
450447
"clarke_thermalcond",
451448
"cahill_thermalcond",
452449
"debye_temperature",
453-
]
450+
)
454451
sp_dict: dict[str, float | Structure | None]
455452
if ignore_errors and (self.k_vrh < 0 or self.g_vrh < 0):
456453
sp_dict = {prop: None for prop in s_props}
@@ -514,8 +511,8 @@ def from_independent_strains(cls, strains, stresses, eq_stress=None, vasp=False,
514511
c_ij[ii, jj] = np.polyfit(strains[:, ii], stresses[:, jj], 1)[0]
515512
if vasp:
516513
c_ij *= -0.1 # Convert units/sign convention of vasp stress tensor
517-
c = cls.from_voigt(c_ij)
518-
return c.zeroed(tol)
514+
instance = cls.from_voigt(c_ij)
515+
return instance.zeroed(tol)
519516

520517

521518
class ComplianceTensor(Tensor):

tests/io/test_template_input.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,39 @@
1010

1111
class TestTemplateInputGen(PymatgenTest):
1212
def test_write_inputs(self):
13-
tis = TemplateInputGen().get_input_set(
13+
input_set = TemplateInputGen().get_input_set(
1414
template=f"{TEST_FILES_DIR}/template_input_file.txt",
1515
variables={"TEMPERATURE": 298},
1616
filename="hello_world.in",
1717
)
18-
tis.write_input(self.tmp_path)
19-
with open(os.path.join(self.tmp_path, "hello_world.in")) as f:
20-
assert "298" in f.read()
18+
input_set.write_input(self.tmp_path)
19+
with open(os.path.join(self.tmp_path, "hello_world.in")) as file:
20+
assert "298" in file.read()
2121

2222
with pytest.raises(FileNotFoundError, match="No such file or directory:"):
23-
tis.write_input(os.path.join(self.tmp_path, "temp"), make_dir=False)
23+
input_set.write_input(os.path.join(self.tmp_path, "temp"), make_dir=False)
2424

25-
tis.write_input(os.path.join(self.tmp_path, "temp"), make_dir=True)
25+
input_set.write_input(os.path.join(self.tmp_path, "temp"), make_dir=True)
2626

27-
tis = TemplateInputGen().get_input_set(
27+
input_set = TemplateInputGen().get_input_set(
2828
template=f"{TEST_FILES_DIR}/template_input_file.txt",
2929
variables={"TEMPERATURE": 400},
3030
filename="hello_world.in",
3131
)
3232

3333
# test len, iter, getitem
34-
assert len(tis.inputs) == 1
35-
assert len(list(tis.inputs)) == 1
36-
assert isinstance(tis.inputs["hello_world.in"], str)
34+
assert len(input_set.inputs) == 1
35+
assert len(list(input_set.inputs)) == 1
36+
assert isinstance(input_set.inputs["hello_world.in"], str)
3737

3838
with pytest.raises(FileExistsError, match="hello_world.in"):
39-
tis.write_input(self.tmp_path, overwrite=False)
39+
input_set.write_input(self.tmp_path, overwrite=False)
4040

41-
tis.write_input(self.tmp_path, overwrite=True)
41+
input_set.write_input(self.tmp_path, overwrite=True)
4242

43-
with open(os.path.join(self.tmp_path, "hello_world.in")) as f:
44-
assert "400" in f.read()
43+
with open(os.path.join(self.tmp_path, "hello_world.in")) as file:
44+
assert "400" in file.read()
4545

46-
tis.write_input(self.tmp_path, zip_inputs=True)
46+
input_set.write_input(self.tmp_path, zip_inputs=True)
4747

4848
assert "InputSet.zip" in list(os.listdir(self.tmp_path))

0 commit comments

Comments
 (0)