Skip to content

Commit

Permalink
Merge branch 'master' into symmetrized_structure_as_dict_monsable
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Feb 25, 2025
2 parents c740b75 + 195f19e commit 41c9784
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/pymatgen/analysis/local_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -3745,23 +3745,23 @@ def get_nn_info(self, structure: Structure, n: int):

if self.use_fictive_radius:
# calculate fictive ionic radii
firs = [_get_fictive_ionic_radius(site, neighbor) for neighbor in neighbors]
fict_ionic_radii = [_get_fictive_ionic_radius(site, neighbor) for neighbor in neighbors]
else:
# just use the bond distance
firs = [neighbor.nn_distance for neighbor in neighbors]
fict_ionic_radii = [neighbor.nn_distance for neighbor in neighbors]

# calculate mean fictive ionic radius
mefir = _get_mean_fictive_ionic_radius(firs)
mefir = _get_mean_fictive_ionic_radius(fict_ionic_radii)

# iteratively solve MEFIR; follows equation 4 in Hoppe's EconN paper
prev_mefir = float("inf")
while abs(prev_mefir - mefir) > 1e-4:
# this is guaranteed to converge
prev_mefir = mefir
mefir = _get_mean_fictive_ionic_radius(firs, minimum_fir=mefir)
mefir = _get_mean_fictive_ionic_radius(fict_ionic_radii, minimum_fir=mefir)

siw = []
for nn, fir in zip(neighbors, firs, strict=True):
for nn, fir in zip(neighbors, fict_ionic_radii, strict=True):
if nn.nn_distance < self.cutoff:
w = math.exp(1 - (fir / mefir) ** 6)
if w > self.tol:
Expand Down
7 changes: 5 additions & 2 deletions src/pymatgen/electronic_structure/dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ def get_interpolated_gap(
energies = self.x
below_fermi = [i for i in range(len(energies)) if energies[i] < self.efermi and tdos[i] > tol]
above_fermi = [i for i in range(len(energies)) if energies[i] > self.efermi and tdos[i] > tol]
if not below_fermi or not above_fermi:
return 0.0, self.efermi, self.efermi

vbm_start = max(below_fermi)
cbm_start = min(above_fermi)
if vbm_start == cbm_start:
if vbm_start in [cbm_start, cbm_start - 1]:
return 0.0, self.efermi, self.efermi

# Interpolate between adjacent values
Expand Down Expand Up @@ -311,7 +314,7 @@ def get_interpolated_gap(

vbm_start = max(below_fermi)
cbm_start = min(above_fermi)
if vbm_start == cbm_start:
if vbm_start in [cbm_start, cbm_start - 1]:
return 0.0, self.efermi, self.efermi

# Interpolate between adjacent values
Expand Down
28 changes: 12 additions & 16 deletions src/pymatgen/io/vasp/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,8 @@ def kpoints_updates(self) -> Kpoints:


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

# NEB specific defaults
defaults = {
"EDIFF": 5e-5,
"EDIFFG": -0.02,
"IMAGES": len(structures) - 2,
"IBRION": 1,
"ISYM": 0,
"ISIF": 2,
"LCHARG": False,
"LDAU": False,
"LORBIT": 0,
"NSW": 200,
"ALGO": "Normal",
"IBRION": 3,
"IOPT": 1,
"POTIM": 0,
}
self._config_dict["INCAR"].update(defaults)
self.parent_set = parent_set
Expand Down Expand Up @@ -2799,24 +2808,11 @@ def __init__(self, structures: list[Structure], **kwargs) -> None:
"""
user_incar_settings = kwargs.get("user_incar_settings", {})

# CI-NEB settings
# Additional CI-NEB settings
defaults = {
"EDIFF": 5e-5,
"EDIFFG": -0.02,
"IBRION": 3,
"ICHAIN": 0,
"IOPT": 1,
"ISIF": 2,
"ISMEAR": 0,
"ISPIN": 2,
"LCHARG": False,
"LCLIMB": True,
"LDAU": False,
"LORBIT": 0,
"NSW": 200,
"POTIM": 0,
"SPRING": -5,
"ALGO": "Normal",
}
if user_incar_settings != {}:
defaults.update(user_incar_settings)
Expand Down
2 changes: 1 addition & 1 deletion src/pymatgen/util/coord.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def get_linear_interpolated_value(x_values: ArrayLike, y_values: ArrayLike, x: f
"""
arr = np.array(sorted(zip(x_values, y_values, strict=True), key=lambda d: d[0]))

indices = np.where(arr[:, 0] >= x)[0]
indices = np.where(arr[:, 0] > x)[0]

if len(indices) == 0 or indices[0] == 0:
raise ValueError(f"{x=} is out of range of provided x_values ({min(x_values)}, {max(x_values)})")
Expand Down
4 changes: 3 additions & 1 deletion tests/io/vasp/test_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,9 @@ def test_incar(self):
incar = self.vis.incar
assert "LDAUU" not in incar
assert incar["EDIFF"] == approx(0.00005)
assert self.vis_MIT.incar["EDIFF"] == approx(0.00001)
assert self.vis_MIT.incar["EDIFF"] == approx(0.00005)
assert incar["NSW"] == 200
assert incar["IBRION"] == 3
assert "LCLIMB" in self.vis_cineb.incar

def test_kpoints(self):
Expand Down
5 changes: 5 additions & 0 deletions tests/util/test_coord.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def test_get_linear_interpolated_value(self):
with pytest.raises(ValueError, match=r"x=6 is out of range of provided x_values \(0, 5\)"):
coord.get_linear_interpolated_value(x_vals, y_vals, 6)

# test when x is equal to first value in x_vals (previously broke, fixed in #4299):
assert coord.get_linear_interpolated_value(x_vals, y_vals, 0) == approx(3)
with pytest.raises(ValueError, match=r"x=-0.5 is out of range of provided x_values \(0, 5\)"):
coord.get_linear_interpolated_value(x_vals, y_vals, -0.5)

def test_in_coord_list(self):
coords = [[0, 0, 0], [0.5, 0.5, 0.5]]
test_coord = [0.1, 0.1, 0.1]
Expand Down

0 comments on commit 41c9784

Please sign in to comment.