Skip to content

Commit

Permalink
Linter
Browse files Browse the repository at this point in the history
  • Loading branch information
ceriottm committed Sep 26, 2024
1 parent 8cef823 commit bd9b949
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
4 changes: 2 additions & 2 deletions ipi/engine/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def array_pbc(self, pos):
system box.
"""

s = dstrip(pos).copy().reshape(-1,3)
s = dstrip(pos).copy().reshape(-1, 3)

s = np.dot(dstrip(self.ih), s.T)
s = s - np.round(s)
Expand Down Expand Up @@ -145,7 +145,7 @@ def __init__(self, h=None):
Args:
h: Optional array giving the initial lattice vector matrix. The
reference cell matrix is set equal to this.
reference cell matrix is set equal to this.
"""

if h is None:
Expand Down
35 changes: 20 additions & 15 deletions ipi/engine/forcefields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,28 +1422,29 @@ def queue(self, atoms, cell, reqid=-1):
R_random = np.eye(3)

for R, w in self._rotations:
R = R@R_random
R = R @ R_random
rot_atoms = atoms.clone()
# NB we need generic cell orientation
rot_cell = GenericCell(R@dstrip(cell.h).copy())
rot_atoms.q[:] = (dstrip(rot_atoms.q).reshape(-1,3)@R.T).flatten()
rot_cell = GenericCell(R @ dstrip(cell.h).copy())
rot_atoms.q[:] = (dstrip(rot_atoms.q).reshape(-1, 3) @ R.T).flatten()
rots.append((R, w))

ffh.append(super(FFRotations, self).queue(rot_atoms, rot_cell, reqid))

if self.inversion:
# also add a "flipped cell" to the evaluation list
R = R*-1
rot_cell = GenericCell(R@dstrip(cell.h).copy())
R = R * -1
rot_cell = GenericCell(R @ dstrip(cell.h).copy())
rot_atoms = atoms.clone()
rot_atoms.q[:] = (dstrip(rot_atoms.q).reshape(-1,3)@R.T).flatten()
rot_atoms.q[:] = (dstrip(rot_atoms.q).reshape(-1, 3) @ R.T).flatten()
ffh.append(super(FFRotations, self).queue(rot_atoms, rot_cell, reqid))


# creates the request with the help of the base class,
# making sure it already contains a handle to the list of FF
# requests
req = ForceField.queue(self, atoms, cell, reqid, template=dict(ff_handles=ffh, rots=rots))
req = ForceField.queue(
self, atoms, cell, reqid, template=dict(ff_handles=ffh, rots=rots)
)
req["status"] = "Running"
req["t_dispatched"] = time.time()
return req
Expand Down Expand Up @@ -1479,8 +1480,8 @@ def gather(self, r):
for ff_r, (R, w) in zip(rot_handles, rots):
pots.append(ff_r["result"][0])
# must rotate forces and virial back into the original reference frame
frcs.append((ff_r["result"][1].reshape(-1,3)@R).flatten())
virs.append((R.T@ff_r["result"][2]@R))
frcs.append((ff_r["result"][1].reshape(-1, 3) @ R).flatten())
virs.append((R.T @ ff_r["result"][2] @ R))
xtrs.append(ff_r["result"][3])
quad_w.append(w)

Expand All @@ -1490,15 +1491,19 @@ def gather(self, r):
virs = np.array(virs).reshape(-1, 3, 3)

# Computes the mean energetics (using the quadrature weights)
mean_pot = np.mean(pots*quad_w, axis=0)/quad_w.mean()
mean_frc = np.mean(frcs*quad_w[:,np.newaxis], axis=0)/quad_w.mean()
mean_vir = np.mean(virs*quad_w[:,np.newaxis,np.newaxis], axis=0)/quad_w.mean()
mean_pot = np.mean(pots * quad_w, axis=0) / quad_w.mean()
mean_frc = np.mean(frcs * quad_w[:, np.newaxis], axis=0) / quad_w.mean()
mean_vir = (
np.mean(virs * quad_w[:, np.newaxis, np.newaxis], axis=0) / quad_w.mean()
)

# Sets the output of the committee model.
r["result"][0] = mean_pot
r["result"][1] = mean_frc
r["result"][2] = mean_vir
r["result"][3] = {"o3grid_pots":pots} # this is the list of potentials on a grid, for monitoring
r["result"][3] = {
"o3grid_pots": pots
} # this is the list of potentials on a grid, for monitoring

# "dissolve" the extras dictionaries into a list
for k in xtrs[0].keys():
Expand Down
2 changes: 1 addition & 1 deletion ipi/utils/mathtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def roots_legendre(L):


def get_rotation_quadrature(L):
if L==1:
if L == 1:
# returns the identity (for some reason this algo below generates a different rotation)
return [(np.eye(3), 2.0)]
quads = []
Expand Down

0 comments on commit bd9b949

Please sign in to comment.