Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/ase-3.22.1
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep authored Feb 4, 2022
2 parents 4be6a13 + 3acbecd commit 3c960d7
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions pymatgen/analysis/diffusion/aimd/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_labels(points, centroids):
"""
dists = all_distances(points, centroids)
min_dists = np.min(dists, axis=1)
return np.where(dists == min_dists[:, None])[1], np.sum(min_dists ** 2)
return np.where(dists == min_dists[:, None])[1], np.sum(min_dists**2)

@staticmethod
def get_centroids(points, labels, k, centroids):
Expand Down Expand Up @@ -149,7 +149,7 @@ def get_labels(self, points, centroids):
"""
dists = self.lattice.get_all_distances(points, centroids)
min_dists = np.min(dists, axis=1)
return np.where(dists == min_dists[:, None])[1], np.sum(min_dists ** 2)
return np.where(dists == min_dists[:, None])[1], np.sum(min_dists**2)

def get_centroids(self, points, labels, k, centroids):
"""
Expand Down
2 changes: 1 addition & 1 deletion pymatgen/analysis/diffusion/aimd/pathway.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def to_chgcar(self, filename="CHGCAR.vasp"):
"""

count = 1
VolinAu = self.structure.lattice.volume / 0.5291772083 ** 3
VolinAu = self.structure.lattice.volume / 0.5291772083**3
symbols = self.structure.symbol_set
natoms = [str(int(self.structure.composition[symbol])) for symbol in symbols]
init_fcoords = np.array(self.structure.frac_coords)
Expand Down
8 changes: 4 additions & 4 deletions pymatgen/analysis/diffusion/aimd/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(
images = images.reshape((len(r) ** 3, 3))

# Find the zero image vector
zd = np.sum(images ** 2, axis=1)
zd = np.sum(images**2, axis=1)
indx0 = np.argmin(zd)

for s in structures:
Expand All @@ -95,7 +95,7 @@ def __init__(
for fcoords, ref_fcoords, latt in zip(fcoords_list, ref_fcoords_list, lattices):
dcf = fcoords[:, None, None, :] + images[None, None, :, :] - ref_fcoords[None, :, None, :]
dcc = latt.get_cartesian_coords(dcf)
d2 = np.sum(dcc ** 2, axis=3)
d2 = np.sum(dcc**2, axis=3)
dists = [
d2[u, v, j] ** 0.5
for u in range(len(indices))
Expand Down Expand Up @@ -356,7 +356,7 @@ def __init__(
for i, j in natoms.items():
self.density[s_index][i] = j / self.structures[s_index].volume

self.volumes = 4.0 * np.pi * self.r ** 2 * self.dr
self.volumes = 4.0 * np.pi * self.r**2 * self.dr
self.volumes[self.volumes < 1e-8] = 1e8 # avoid divide by zero
self.n_structures = len(self.structures)
self.sigma = ceil(sigma / self.dr)
Expand Down Expand Up @@ -468,7 +468,7 @@ def get_coordination_number(self, ref_species, species, is_average=True):
if isinstance(species, str):
species = [species]
density = [sum(i[j] for j in species) for i in self.density]
cn = [np.cumsum(rdf * density[i] * 4.0 * np.pi * self.r ** 2 * self.dr) for i, rdf in enumerate(all_rdf)]
cn = [np.cumsum(rdf * density[i] * 4.0 * np.pi * self.r**2 * self.dr) for i, rdf in enumerate(all_rdf)]
if is_average:
cn = np.mean(cn, axis=0)
return self.r, cn
Expand Down
8 changes: 4 additions & 4 deletions pymatgen/analysis/diffusion/aimd/van_hove.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def __init__(
ref_ions = [] # type: ArrayLike

# auxiliary factor for 4*\pi*r^2
aux_factor = 4.0 * np.pi * interval ** 2
aux_factor[0] = np.pi * dr ** 2
aux_factor = 4.0 * np.pi * interval**2
aux_factor[0] = np.pi * dr**2

for i, ss in enumerate(diffusion_analyzer.get_drift_corrected_structures()):
all_fcoords = np.array(ss.frac_coords)
Expand Down Expand Up @@ -158,7 +158,7 @@ def __init__(
images = images.reshape((len(r) ** 3, 3))

# find the zero image vector
zd = np.sum(images ** 2, axis=1)
zd = np.sum(images**2, axis=1)
indx0 = np.argmin(zd)

for it in range(reduced_nt):
Expand All @@ -172,7 +172,7 @@ def __init__(
- ref_ions[it1, None, :, None, :]
)
dcc = lattice.get_cartesian_coords(dcf)
d2 = np.sum(dcc ** 2, axis=3)
d2 = np.sum(dcc**2, axis=3)
dists = [
d2[u, v, j] ** 0.5
for u in range(len(indices))
Expand Down
6 changes: 3 additions & 3 deletions pymatgen/analysis/diffusion/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def __init__(
dcomponents = dc[:, n:, :] - dc[:, :-n, :]

# Get msd
sq_disp = dx ** 2
sq_disp = dx**2
sq_disp_ions[:, i] = np.average(np.sum(sq_disp, axis=2), axis=1)
msd[i] = np.average(sq_disp_ions[:, i][indices])

Expand Down Expand Up @@ -335,7 +335,7 @@ def weighted_lstsq(a, b):
# Drift and displacement information.
self.drift = drift
self.corrected_displacements = dc
self.max_ion_displacements = np.max(np.sum(dc ** 2, axis=-1) ** 0.5, axis=1)
self.max_ion_displacements = np.max(np.sum(dc**2, axis=-1) ** 0.5, axis=1)
self.max_framework_displacement = np.max(self.max_ion_displacements[framework_indices])
self.msd = msd
self.mscd = mscd
Expand Down Expand Up @@ -802,7 +802,7 @@ def get_conversion_factor(structure, species, temperature):
n = structure.composition[species]

vol = structure.volume * 1e-24 # units cm^3
return 1000 * n / (vol * const.N_A) * z ** 2 * (const.N_A * const.e) ** 2 / (const.R * temperature)
return 1000 * n / (vol * const.N_A) * z**2 * (const.N_A * const.e) ** 2 / (const.R * temperature)


def _get_vasprun(args):
Expand Down
4 changes: 2 additions & 2 deletions pymatgen/analysis/diffusion/neb/pathfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, structures):
weights = np.zeros_like(target_dists, dtype=np.float64)
for ni in range(nimages):
avg_dist = (target_dists[ni] + structures[ni + 1].distance_matrix) / 2.0
weights[ni] = 1.0 / (avg_dist ** 4 + np.eye(natoms, dtype=np.float64) * 1e-8)
weights[ni] = 1.0 / (avg_dist**4 + np.eye(natoms, dtype=np.float64) * 1e-8)

for ni, i in itertools.product(range(nimages + 2), range(natoms)):
frac_coords = structures[ni][i].frac_coords
Expand Down Expand Up @@ -255,7 +255,7 @@ def get_unit_vector(vec):
Args:
vec: Vector.
"""
return vec / np.sqrt(np.sum(vec ** 2))
return vec / np.sqrt(np.sum(vec**2))

def _get_total_forces(self, x, true_forces, spring_const):
"""
Expand Down
4 changes: 2 additions & 2 deletions requirements-ci.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest==6.2.5
pytest==7.0.0
pytest-cov==3.0.0
coveralls==3.3.1
mypy==0.931
Expand All @@ -7,4 +7,4 @@ flake8==4.0.1
pylint==2.12.2
black==22.1.0
treon==0.1.3
maggma==0.29.0
maggma==0.39.1

0 comments on commit 3c960d7

Please sign in to comment.