Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Mar 8, 2024
1 parent 1dadefd commit daa0bb0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
36 changes: 18 additions & 18 deletions pymatgen/analysis/piezo_sensitivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def get_rand_IST(self, max_force=1):
max_force (float): maximum born effective charge value
Return:
InternalStrainTensor object
InternalStrainTensor
"""
n_atoms = len(self.structure)
IST = np.zeros((n_atoms, 3, 3, 3))
Expand Down Expand Up @@ -352,7 +352,7 @@ def get_FCM_operations(self, eigtol=1e-5, opstol=1e-5):

def get_unstable_FCM(self, max_force=1):
"""
Generate an unsymmeterized force constant matrix.
Generate an unsymmetrized force constant matrix.
Args:
max_charge (float): maximum born effective charge value
Expand Down Expand Up @@ -411,10 +411,10 @@ def get_unstable_FCM(self, max_force=1):

def get_symmetrized_FCM(self, unsymmetrized_fcm, max_force=1):
"""
Generate a symmeterized force constant matrix from an unsymmeterized matrix.
Generate a symmetrized force constant matrix from an unsymmetrized matrix.
Args:
unsymmetrized_fcm (numpy array): unsymmeterized force constant matrix
unsymmetrized_fcm (numpy array): unsymmetrized force constant matrix
max_charge (float): maximum born effective charge value
Return:
Expand Down Expand Up @@ -469,12 +469,12 @@ def get_symmetrized_FCM(self, unsymmetrized_fcm, max_force=1):

def get_stable_FCM(self, fcm, fcmasum=10):
"""
Generate a symmeterized force constant matrix that obeys the objects symmetry
Generate a symmetrized force constant matrix that obeys the objects symmetry
constraints, has no unstable modes and also obeys the acoustic sum rule through an
iterative procedure.
Args:
fcm (numpy array): unsymmeterized force constant matrix
fcm (numpy array): unsymmetrized force constant matrix
fcmasum (int): number of iterations to attempt to obey the acoustic sum
rule
Expand All @@ -484,28 +484,28 @@ def get_stable_FCM(self, fcm, fcmasum=10):
check = 0
count = 0
while check == 0:
# if resymmetrizing brings back unstable modes 20 times, the method breaks
# if re-symmetrizing brings back unstable modes 20 times, the method breaks
if count > 20:
check = 1
break

eigs, vecs = np.linalg.eig(fcm)

maxeig = np.max(-1 * eigs)
eigsort = np.argsort(np.abs(eigs))
for i in range(3, len(eigs)):
if eigs[eigsort[i]] > 1e-6:
eigs[eigsort[i]] = -1 * maxeig * np.random.rand()
max_eig = np.max(-1 * eigs)
eig_sort = np.argsort(np.abs(eigs))
for idx in range(3, len(eigs)):
if eigs[eig_sort[idx]] > 1e-6:
eigs[eig_sort[idx]] = -1 * max_eig * np.random.rand()
diag = np.real(np.eye(len(fcm)) * eigs)

fcm = np.real(np.matmul(np.matmul(vecs, diag), vecs.T))
fcm = self.get_symmetrized_FCM(fcm)
fcm = self.get_asum_FCM(fcm)
eigs, vecs = np.linalg.eig(fcm)
unstable_modes = 0
eigsort = np.argsort(np.abs(eigs))
for i in range(3, len(eigs)):
if eigs[eigsort[i]] > 1e-6:
eig_sort = np.argsort(np.abs(eigs))
for idx in range(3, len(eigs)):
if eigs[eig_sort[idx]] > 1e-6:
unstable_modes = 1
if unstable_modes == 1:
count = count + 1
Expand All @@ -518,11 +518,11 @@ def get_stable_FCM(self, fcm, fcmasum=10):

def get_asum_FCM(self, fcm: np.ndarray, numiter: int = 15):
"""
Generate a symmeterized force constant matrix that obeys the objects symmetry
Generate a symmetrized force constant matrix that obeys the objects symmetry
constraints and obeys the acoustic sum rule through an iterative procedure.
Args:
fcm (numpy array): 3Nx3N unsymmeterized force constant matrix
fcm (numpy array): 3Nx3N unsymmetrized force constant matrix
numiter (int): number of iterations to attempt to obey the acoustic sum
rule
Expand Down Expand Up @@ -608,7 +608,7 @@ def get_asum_FCM(self, fcm: np.ndarray, numiter: int = 15):
@requires(Phonopy, "phonopy not installed!")
def get_rand_FCM(self, asum=15, force=10):
"""
Generate a symmeterized force constant matrix from an unsymmeterized matrix
Generate a symmetrized force constant matrix from an unsymmetrized matrix
that has no unstable modes and also obeys the acoustic sum rule through an
iterative procedure.
Expand Down
14 changes: 7 additions & 7 deletions pymatgen/analysis/structure_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,16 @@ def solid_angle(center, coords):
float: The solid angle.
"""
origin = np.array(center)
r = [np.array(c) - origin for c in coords]
r.append(r[0])
n = [np.cross(r[i + 1], r[i]) for i in range(len(r) - 1)]
n.append(np.cross(r[1], r[0]))
radii = [np.array(c) - origin for c in coords]
radii.append(radii[0])
n = [np.cross(radii[i + 1], radii[i]) for i in range(len(radii) - 1)]
n.append(np.cross(radii[1], radii[0]))
vals = []
for i in range(len(n) - 1):
v = -np.dot(n[i], n[i + 1]) / (np.linalg.norm(n[i]) * np.linalg.norm(n[i + 1]))
vals.append(acos(np.clip(v, -1, 1)))
phi = sum(vals)
return phi + (3 - len(r)) * pi
return phi + (3 - len(radii)) * pi


def get_max_bond_lengths(structure, el_radius_updates=None):
Expand All @@ -380,14 +380,14 @@ def get_max_bond_lengths(structure, el_radius_updates=None):
dict[(Element1, Element2)], float]: The two elements are ordered by Z.
"""
# jmc = JMolCoordFinder(el_radius_updates)
jmnn = JmolNN(el_radius_updates=el_radius_updates)
jm_nn = JmolNN(el_radius_updates=el_radius_updates)

bonds_lens = {}
els = sorted(structure.elements, key=lambda x: x.Z)

for i1, el1 in enumerate(els):
for i2 in range(len(els) - i1):
bonds_lens[el1, els[i1 + i2]] = jmnn.get_max_bond_distance(el1.symbol, els[i1 + i2].symbol)
bonds_lens[el1, els[i1 + i2]] = jm_nn.get_max_bond_distance(el1.symbol, els[i1 + i2].symbol)

return bonds_lens

Expand Down

0 comments on commit daa0bb0

Please sign in to comment.