Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert to Yb_2 on pre-PBE_54 input sets #2972

Merged
merged 12 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pymatgen/analysis/tests/test_interface_reactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ def setUp(self):
norm=True,
use_hull_energy=False,
)
with pytest.raises(Exception) as context1:
with pytest.raises(Exception) as exc_info:
_ = InterfacialReactivity(Composition("Li2O2"), Composition("Li"), pd=self.gpd, norm=True)
assert (
str(context1.exception) == "Please use the GrandPotentialInterfacialReactivity "
"class for interfacial reactions with open elements!"
)
with pytest.raises(Exception) as context2:
assert (
str(exc_info.value) == "Please use the GrandPotentialInterfacialReactivity "
"class for interfacial reactions with open elements!"
)
with pytest.raises(Exception) as exc_info:
_ = GrandPotentialInterfacialReactivity(
Composition("O2"),
Composition("Mn"),
Expand All @@ -160,7 +160,7 @@ def setUp(self):
norm=False,
include_no_mixing_energy=True,
)
assert str(context2.exception) == "Please provide non-grand phase diagram to compute no_mixing_energy!"
assert str(exc_info.value) == "Please provide non-grand phase diagram to compute no_mixing_energy!"

self.ir = [ir_0, ir_1, ir_2, ir_3, ir_4, ir_5, ir_6, ir_7, ir_8, ir_9, ir_10, ir_11, ir_12]

Expand Down
10 changes: 5 additions & 5 deletions pymatgen/analysis/transition_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

from __future__ import annotations

import glob
import os
from glob import glob

import numpy as np
from monty.json import MSONable, jsanitize
Expand Down Expand Up @@ -254,14 +254,14 @@ def from_dir(cls, root_dir, relaxation_dirs=None, **kwargs):
terminal_dirs.append([os.path.join(root_dir, d) for d in ["initial", "final"]])

for i, d in neb_dirs:
outcar = glob.glob(os.path.join(d, "OUTCAR*"))
contcar = glob.glob(os.path.join(d, "CONTCAR*"))
poscar = glob.glob(os.path.join(d, "POSCAR*"))
outcar = glob(os.path.join(d, "OUTCAR*"))
contcar = glob(os.path.join(d, "CONTCAR*"))
poscar = glob(os.path.join(d, "POSCAR*"))
terminal = i in [0, neb_dirs[-1][0]]
if terminal:
for ds in terminal_dirs:
od = ds[0] if i == 0 else ds[1]
outcar = glob.glob(os.path.join(od, "OUTCAR*"))
outcar = glob(os.path.join(od, "OUTCAR*"))
if outcar:
outcar = sorted(outcar)
outcars.append(Outcar(outcar[-1]))
Expand Down
21 changes: 9 additions & 12 deletions pymatgen/apps/borg/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from __future__ import annotations

import abc
import glob
import json
import logging
import os
import warnings
from glob import glob

from monty.io import zopen
from monty.json import MSONable
Expand Down Expand Up @@ -118,9 +118,9 @@ def assimilate(self, path):
"""
files = os.listdir(path)
if "relax1" in files and "relax2" in files:
filepath = glob.glob(os.path.join(path, "relax2", "vasprun.xml*"))[0]
filepath = glob(os.path.join(path, "relax2", "vasprun.xml*"))[0]
else:
vasprun_files = glob.glob(os.path.join(path, "vasprun.xml*"))
vasprun_files = glob(os.path.join(path, "vasprun.xml*"))
filepath = None
if len(vasprun_files) == 1:
filepath = vasprun_files[0]
Expand Down Expand Up @@ -159,11 +159,8 @@ def get_valid_paths(self, path):
(not parent.endswith("/relax1"))
and (not parent.endswith("/relax2"))
and (
len(glob.glob(os.path.join(parent, "vasprun.xml*"))) > 0
or (
len(glob.glob(os.path.join(parent, "POSCAR*"))) > 0
and len(glob.glob(os.path.join(parent, "OSZICAR*"))) > 0
)
len(glob(os.path.join(parent, "vasprun.xml*"))) > 0
or (len(glob(os.path.join(parent, "POSCAR*"))) > 0 and len(glob(os.path.join(parent, "OSZICAR*"))) > 0)
)
):
return [parent]
Expand Down Expand Up @@ -233,13 +230,13 @@ def assimilate(self, path):
if "relax1" in files and "relax2" in files:
for filename in ("INCAR", "POTCAR", "POSCAR"):
search_str = os.path.join(path, "relax1", filename + "*")
files_to_parse[filename] = glob.glob(search_str)[0]
files_to_parse[filename] = glob(search_str)[0]
for filename in ("CONTCAR", "OSZICAR"):
search_str = os.path.join(path, "relax2", filename + "*")
files_to_parse[filename] = glob.glob(search_str)[-1]
files_to_parse[filename] = glob(search_str)[-1]
else:
for filename in filenames:
files = sorted(glob.glob(os.path.join(path, filename + "*")))
files = sorted(glob(os.path.join(path, filename + "*")))
if len(files) == 1 or filename in ("INCAR", "POTCAR") or len(files) == 1 and filename == "DYNMAT":
files_to_parse[filename] = files[0]
elif len(files) > 1:
Expand Down Expand Up @@ -440,7 +437,7 @@ def _get_transformation_history(path):
"""
Checks for a transformations.json* file and returns the history.
"""
trans_json = glob.glob(os.path.join(path, "transformations.json*"))
trans_json = glob(os.path.join(path, "transformations.json*"))
if trans_json:
try:
with zopen(trans_json[0]) as f:
Expand Down
10 changes: 4 additions & 6 deletions pymatgen/cli/pmg_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

from __future__ import annotations

import glob
import os
import shutil
import subprocess
from argparse import Namespace
from glob import glob
from typing import Literal
from urllib.request import urlretrieve

Expand All @@ -31,17 +31,15 @@ def setup_cp2k_data(cp2k_data_dirs: list[str]) -> None:
raise SystemExit(0)
print("Generating pymatgen resource directory for CP2K...")

import glob

from monty.json import jsanitize
from ruamel import yaml

from pymatgen.core import Element
from pymatgen.io.cp2k.inputs import GaussianTypeOrbitalBasisSet, GthPotential
from pymatgen.io.cp2k.utils import chunk

basis_files = glob.glob(os.path.join(data_dir, "*BASIS*"))
potential_files = glob.glob(os.path.join(data_dir, "*POTENTIAL*"))
basis_files = glob(os.path.join(data_dir, "*BASIS*"))
potential_files = glob(os.path.join(data_dir, "*POTENTIAL*"))

settings: dict[str, dict] = {str(el): {"potentials": {}, "basis_sets": {}} for el in Element}

Expand Down Expand Up @@ -141,7 +139,7 @@ def setup_potcars(potcar_dirs: list[str]):
basename = os.path.basename(parent)
basename = name_mappings.get(basename, basename)
for subdir in subdirs:
filenames = glob.glob(os.path.join(parent, subdir, "POTCAR*"))
filenames = glob(os.path.join(parent, subdir, "POTCAR*"))
if len(filenames) > 0:
try:
base_dir = os.path.join(target_dir, basename)
Expand Down
6 changes: 3 additions & 3 deletions pymatgen/command_line/bader_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

from __future__ import annotations

import glob
import os
import shutil
import subprocess
import warnings
from glob import glob
from shutil import which

import numpy as np
Expand Down Expand Up @@ -418,7 +418,7 @@ def from_path(cls, path, suffix=""):

def _get_filepath(filename):
name_pattern = filename + suffix + "*" if filename != "POTCAR" else filename + "*"
paths = glob.glob(os.path.join(path, name_pattern))
paths = glob(os.path.join(path, name_pattern))
fpath = None
if len(paths) >= 1:
# using reverse=True because, if multiple files are present,
Expand Down Expand Up @@ -478,7 +478,7 @@ def bader_analysis_from_path(path, suffix=""):
"""

def _get_filepath(filename, warning, path=path, suffix=suffix):
paths = glob.glob(os.path.join(path, filename + suffix + "*"))
paths = glob(os.path.join(path, filename + suffix + "*"))
if not paths:
warnings.warn(warning)
return None
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/command_line/chargemol_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
"""
from __future__ import annotations

import glob
import os
import shutil
import subprocess
import warnings
from glob import glob
from shutil import which

import numpy as np
Expand Down Expand Up @@ -155,7 +155,7 @@ def _get_filepath(path, filename, suffix=""):
(str): Absolute path to the file.
"""
name_pattern = f"{filename}{suffix}*" if filename != "POTCAR" else f"{filename}*"
paths = glob.glob(os.path.join(path, name_pattern))
paths = glob(os.path.join(path, name_pattern))
fpath = None
if len(paths) >= 1:
# using reverse=True because, if multiple files are present,
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/command_line/critic2_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@

from __future__ import annotations

import glob
import logging
import os
import subprocess
import warnings
from enum import Enum
from glob import glob
from shutil import which

import numpy as np
Expand Down Expand Up @@ -322,7 +322,7 @@ def get_filepath(filename, warning, path, suffix):
path: Path to search
suffix: Suffixes to search.
"""
paths = glob.glob(os.path.join(path, filename + suffix + "*"))
paths = glob(os.path.join(path, filename + suffix + "*"))
if not paths:
warnings.warn(warning)
return None
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/command_line/enumlib_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
from __future__ import annotations

import fractions
import glob
import itertools
import logging
import math
import re
import subprocess
from glob import glob
from shutil import which
from threading import Timer

Expand Down Expand Up @@ -364,7 +364,7 @@ def _get_structures(self, num_structs):
ordered_structure = None # to fix pylint E0601
inv_org_latt = None

for file in glob.glob("vasp.*"):
for file in glob("vasp.*"):
with open(file) as f:
data = f.read()
data = re.sub(r"scale factor", "1", data)
Expand Down
28 changes: 13 additions & 15 deletions pymatgen/core/tests/test_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_get_lll_reduced_lattice(self):
lattice = Lattice([1.0, 1, 1, -1.0, 0, 2, 3.0, 5, 6])
reduced_latt = lattice.get_lll_reduced_lattice()

expected_ans = Lattice(np.array([0.0, 1.0, 0.0, 1.0, 0.0, 1.0, -2.0, 0.0, 1.0]).reshape((3, 3)))
expected_ans = Lattice([0.0, 1.0, 0.0, 1.0, 0.0, 1.0, -2.0, 0.0, 1.0]).reshape((3, 3))
assert round(abs(np.linalg.det(np.linalg.solve(expected_ans.matrix, reduced_latt.matrix)) - 1), 7) == 0
self.assertArrayAlmostEqual(sorted(reduced_latt.abc), sorted(expected_ans.abc))
assert round(abs(reduced_latt.volume - lattice.volume), 7) == 0
Expand All @@ -201,19 +201,17 @@ def test_get_lll_reduced_lattice(self):
14.253000,
]
expected_ans = Lattice(
np.array(
[
-4.298850,
2.481942,
0.000000,
2.865900,
4.963884,
0.000000,
0.000000,
0.000000,
14.253000,
]
)
[
-4.298850,
2.481942,
0.000000,
2.865900,
4.963884,
0.000000,
0.000000,
0.000000,
14.253000,
]
)
reduced_latt = Lattice(latt).get_lll_reduced_lattice()
assert round(abs(np.linalg.det(np.linalg.solve(expected_ans.matrix, reduced_latt.matrix)) - 1), 7) == 0
Expand Down Expand Up @@ -481,7 +479,7 @@ def test_get_distance_and_image_strict(self):
for _ in range(10):
lengths = [np.random.randint(1, 100) for i in range(3)]
lattice = [np.random.rand(3) * lengths[i] for i in range(3)]
lattice = Lattice(np.array(lattice))
lattice = Lattice(lattice)

f1 = np.random.rand(3)
f2 = np.random.rand(3)
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/core/tests/test_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_distance_and_image(self):
assert round(abs(distance - 19.461500456028563), 5) == 0
# Test that old and new distance algo give the same ans for
# "standard lattices"
lattice = Lattice(np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]))
lattice = Lattice([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
site1 = PeriodicSite("Fe", np.array([0.01, 0.02, 0.03]), lattice)
site2 = PeriodicSite("Fe", np.array([0.99, 0.98, 0.97]), lattice)
assert round(abs(get_distance_and_image_old(site1, site2)[0] - site1.distance_and_image(site2)[0]), 7) == 0
Expand Down
40 changes: 20 additions & 20 deletions pymatgen/io/cp2k/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

from __future__ import annotations

import glob
import logging
import os
import re
import warnings
from glob import glob
from itertools import chain

import numpy as np
Expand Down Expand Up @@ -246,31 +246,31 @@ def parse_files(self):
Identify files present in the directory with the cp2k output file. Looks for trajectories,
dos, and cubes
"""
self.filenames["DOS"] = glob.glob(os.path.join(self.dir, "*.dos*"))
pdos = glob.glob(os.path.join(self.dir, "*pdos*"))
self.filenames["DOS"] = glob(os.path.join(self.dir, "*.dos*"))
pdos = glob(os.path.join(self.dir, "*pdos*"))
self.filenames["PDOS"] = []
self.filenames["LDOS"] = []
for p in pdos:
if "list" in p.split("/")[-1]:
self.filenames["LDOS"].append(p)
else:
self.filenames["PDOS"].append(p)
self.filenames["band_structure"] = glob.glob(os.path.join(self.dir, "*BAND.bs*"))
self.filenames["trajectory"] = glob.glob(os.path.join(self.dir, "*pos*.xyz*"))
self.filenames["forces"] = glob.glob(os.path.join(self.dir, "*frc*.xyz*"))
self.filenames["stress"] = glob.glob(os.path.join(self.dir, "*stress*"))
self.filenames["cell"] = glob.glob(os.path.join(self.dir, "*.cell*"))
self.filenames["ener"] = glob.glob(os.path.join(self.dir, "*.ener*"))
self.filenames["electron_density"] = glob.glob(os.path.join(self.dir, "*ELECTRON_DENSITY*.cube*"))
self.filenames["spin_density"] = glob.glob(os.path.join(self.dir, "*SPIN_DENSITY*.cube*"))
self.filenames["v_hartree"] = glob.glob(os.path.join(self.dir, "*hartree*.cube*"))
self.filenames["hyperfine_tensor"] = glob.glob(os.path.join(self.dir, "*HYPERFINE*eprhyp*"))
self.filenames["g_tensor"] = glob.glob(os.path.join(self.dir, "*GTENSOR*data*"))
self.filenames["spinspin_tensor"] = glob.glob(os.path.join(self.dir, "*K*data*"))
self.filenames["chi_tensor"] = glob.glob(os.path.join(self.dir, "*CHI*data*"))
self.filenames["nmr_shift"] = glob.glob(os.path.join(self.dir, "*SHIFT*data*"))
self.filenames["raman"] = glob.glob(os.path.join(self.dir, "*raman*data*"))
restart = glob.glob(os.path.join(self.dir, "*restart*"))
self.filenames["band_structure"] = glob(os.path.join(self.dir, "*BAND.bs*"))
self.filenames["trajectory"] = glob(os.path.join(self.dir, "*pos*.xyz*"))
self.filenames["forces"] = glob(os.path.join(self.dir, "*frc*.xyz*"))
self.filenames["stress"] = glob(os.path.join(self.dir, "*stress*"))
self.filenames["cell"] = glob(os.path.join(self.dir, "*.cell*"))
self.filenames["ener"] = glob(os.path.join(self.dir, "*.ener*"))
self.filenames["electron_density"] = glob(os.path.join(self.dir, "*ELECTRON_DENSITY*.cube*"))
self.filenames["spin_density"] = glob(os.path.join(self.dir, "*SPIN_DENSITY*.cube*"))
self.filenames["v_hartree"] = glob(os.path.join(self.dir, "*hartree*.cube*"))
self.filenames["hyperfine_tensor"] = glob(os.path.join(self.dir, "*HYPERFINE*eprhyp*"))
self.filenames["g_tensor"] = glob(os.path.join(self.dir, "*GTENSOR*data*"))
self.filenames["spinspin_tensor"] = glob(os.path.join(self.dir, "*K*data*"))
self.filenames["chi_tensor"] = glob(os.path.join(self.dir, "*CHI*data*"))
self.filenames["nmr_shift"] = glob(os.path.join(self.dir, "*SHIFT*data*"))
self.filenames["raman"] = glob(os.path.join(self.dir, "*raman*data*"))
restart = glob(os.path.join(self.dir, "*restart*"))
self.filenames["restart.bak"] = []
self.filenames["restart"] = []
for r in restart:
Expand All @@ -279,7 +279,7 @@ def parse_files(self):
else:
self.filenames["restart"].append(r)

wfn = glob.glob(os.path.join(self.dir, "*.wfn*")) + glob.glob(os.path.join(self.dir, "*.kp*"))
wfn = glob(os.path.join(self.dir, "*.wfn*")) + glob(os.path.join(self.dir, "*.kp*"))
self.filenames["wfn.bak"] = []
for w in wfn:
if "bak" in w.split("/")[-1]:
Expand Down
Loading