Skip to content

Commit 724bfc7

Browse files
committed
Merge branch 'master' into pass-kwargs-to-structure-to-method
2 parents dbf34e8 + 195f19e commit 724bfc7

File tree

6 files changed

+31
-25
lines changed

6 files changed

+31
-25
lines changed

src/pymatgen/analysis/local_env.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3745,23 +3745,23 @@ def get_nn_info(self, structure: Structure, n: int):
37453745

37463746
if self.use_fictive_radius:
37473747
# calculate fictive ionic radii
3748-
fictive_radii = [_get_fictive_ionic_radius(site, neighbor) for neighbor in neighbors]
3748+
fict_ionic_radii = [_get_fictive_ionic_radius(site, neighbor) for neighbor in neighbors]
37493749
else:
37503750
# just use the bond distance
3751-
fictive_radii = [neighbor.nn_distance for neighbor in neighbors]
3751+
fict_ionic_radii = [neighbor.nn_distance for neighbor in neighbors]
37523752

37533753
# calculate mean fictive ionic radius
3754-
mefir = _get_mean_fictive_ionic_radius(fictive_radii)
3754+
mefir = _get_mean_fictive_ionic_radius(fict_ionic_radii)
37553755

37563756
# iteratively solve MEFIR; follows equation 4 in Hoppe's EconN paper
37573757
prev_mefir = float("inf")
37583758
while abs(prev_mefir - mefir) > 1e-4:
37593759
# this is guaranteed to converge
37603760
prev_mefir = mefir
3761-
mefir = _get_mean_fictive_ionic_radius(fictive_radii, minimum_fir=mefir)
3761+
mefir = _get_mean_fictive_ionic_radius(fict_ionic_radii, minimum_fir=mefir)
37623762

37633763
siw = []
3764-
for nn, fir in zip(neighbors, fictive_radii, strict=True):
3764+
for nn, fir in zip(neighbors, fict_ionic_radii, strict=True):
37653765
if nn.nn_distance < self.cutoff:
37663766
w = math.exp(1 - (fir / mefir) ** 6)
37673767
if w > self.tol:

src/pymatgen/electronic_structure/dos.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ def get_interpolated_gap(
107107
energies = self.x
108108
below_fermi = [i for i in range(len(energies)) if energies[i] < self.efermi and tdos[i] > tol]
109109
above_fermi = [i for i in range(len(energies)) if energies[i] > self.efermi and tdos[i] > tol]
110+
if not below_fermi or not above_fermi:
111+
return 0.0, self.efermi, self.efermi
112+
110113
vbm_start = max(below_fermi)
111114
cbm_start = min(above_fermi)
112-
if vbm_start == cbm_start:
115+
if vbm_start in [cbm_start, cbm_start - 1]:
113116
return 0.0, self.efermi, self.efermi
114117

115118
# Interpolate between adjacent values
@@ -311,7 +314,7 @@ def get_interpolated_gap(
311314

312315
vbm_start = max(below_fermi)
313316
cbm_start = min(above_fermi)
314-
if vbm_start == cbm_start:
317+
if vbm_start in [cbm_start, cbm_start - 1]:
315318
return 0.0, self.efermi, self.efermi
316319

317320
# Interpolate between adjacent values

src/pymatgen/io/vasp/sets.py

+12-16
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,8 @@ def kpoints_updates(self) -> Kpoints:
26632663

26642664

26652665
class NEBSet(VaspInputSet):
2666-
"""Write NEB inputs.
2666+
"""An input set for NEB calculations. These are based on NEB parameters that have been extensively tested by the
2667+
Materials Virtual Lab.
26672668
26682669
Note that EDIFF is not on a per atom basis for this input set.
26692670
"""
@@ -2695,11 +2696,19 @@ def __init__(
26952696

26962697
# NEB specific defaults
26972698
defaults = {
2699+
"EDIFF": 5e-5,
2700+
"EDIFFG": -0.02,
26982701
"IMAGES": len(structures) - 2,
2699-
"IBRION": 1,
27002702
"ISYM": 0,
2703+
"ISIF": 2,
27012704
"LCHARG": False,
27022705
"LDAU": False,
2706+
"LORBIT": 0,
2707+
"NSW": 200,
2708+
"ALGO": "Normal",
2709+
"IBRION": 3,
2710+
"IOPT": 1,
2711+
"POTIM": 0,
27032712
}
27042713
self._config_dict["INCAR"].update(defaults)
27052714
self.parent_set = parent_set
@@ -2799,24 +2808,11 @@ def __init__(self, structures: list[Structure], **kwargs) -> None:
27992808
"""
28002809
user_incar_settings = kwargs.get("user_incar_settings", {})
28012810

2802-
# CI-NEB settings
2811+
# Additional CI-NEB settings
28032812
defaults = {
2804-
"EDIFF": 5e-5,
2805-
"EDIFFG": -0.02,
2806-
"IBRION": 3,
28072813
"ICHAIN": 0,
2808-
"IOPT": 1,
2809-
"ISIF": 2,
2810-
"ISMEAR": 0,
2811-
"ISPIN": 2,
2812-
"LCHARG": False,
28132814
"LCLIMB": True,
2814-
"LDAU": False,
2815-
"LORBIT": 0,
2816-
"NSW": 200,
2817-
"POTIM": 0,
28182815
"SPRING": -5,
2819-
"ALGO": "Normal",
28202816
}
28212817
if user_incar_settings != {}:
28222818
defaults.update(user_incar_settings)

src/pymatgen/util/coord.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def get_linear_interpolated_value(x_values: ArrayLike, y_values: ArrayLike, x: f
135135
"""
136136
arr = np.array(sorted(zip(x_values, y_values, strict=True), key=lambda d: d[0]))
137137

138-
indices = np.where(arr[:, 0] >= x)[0]
138+
indices = np.where(arr[:, 0] > x)[0]
139139

140140
if len(indices) == 0 or indices[0] == 0:
141141
raise ValueError(f"{x=} is out of range of provided x_values ({min(x_values)}, {max(x_values)})")

tests/io/vasp/test_sets.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,9 @@ def test_incar(self):
13421342
incar = self.vis.incar
13431343
assert "LDAUU" not in incar
13441344
assert incar["EDIFF"] == approx(0.00005)
1345-
assert self.vis_MIT.incar["EDIFF"] == approx(0.00001)
1345+
assert self.vis_MIT.incar["EDIFF"] == approx(0.00005)
1346+
assert incar["NSW"] == 200
1347+
assert incar["IBRION"] == 3
13461348
assert "LCLIMB" in self.vis_cineb.incar
13471349

13481350
def test_kpoints(self):

tests/util/test_coord.py

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def test_get_linear_interpolated_value(self):
1919
with pytest.raises(ValueError, match=r"x=6 is out of range of provided x_values \(0, 5\)"):
2020
coord.get_linear_interpolated_value(x_vals, y_vals, 6)
2121

22+
# test when x is equal to first value in x_vals (previously broke, fixed in #4299):
23+
assert coord.get_linear_interpolated_value(x_vals, y_vals, 0) == approx(3)
24+
with pytest.raises(ValueError, match=r"x=-0.5 is out of range of provided x_values \(0, 5\)"):
25+
coord.get_linear_interpolated_value(x_vals, y_vals, -0.5)
26+
2227
def test_in_coord_list(self):
2328
coords = [[0, 0, 0], [0.5, 0.5, 0.5]]
2429
test_coord = [0.1, 0.1, 0.1]

0 commit comments

Comments
 (0)