Skip to content

Commit

Permalink
Make it pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
litman90 committed May 12, 2024
1 parent 08678cd commit a3395e0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
10 changes: 7 additions & 3 deletions ipi/engine/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,13 @@ def init_stage1(self, simul):
"""

if simul.beads.nbeads == 0:
fpos = fmom = fmass = flab = fcell = (
False # we don't have an explicitly defined beads object yet
)
fpos = (
fmom
) = (
fmass
) = (
flab
) = fcell = False # we don't have an explicitly defined beads object yet
else:
fpos = fmom = fmass = flab = fcell = True

Expand Down
18 changes: 9 additions & 9 deletions ipi/engine/motion/geop.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ def step(self, step=None):

# Restore dimensionality of d and invhessian
self.d[:, self.gm.fixatoms_mask] = masked_d
self.invhessian[np.ix_(self.gm.fixatoms_mask, self.gm.fixatoms_mask)] = (
masked_invhessian
)
self.invhessian[
np.ix_(self.gm.fixatoms_mask, self.gm.fixatoms_mask)
] = masked_invhessian

else:
fdf0 = (self.old_u, -self.old_f)
Expand Down Expand Up @@ -576,9 +576,9 @@ def step(self, step=None):
)

# Restore dimensionality of the hessian
self.hessian[np.ix_(self.gm.fixatoms_mask, self.gm.fixatoms_mask)] = (
masked_hessian
)
self.hessian[
np.ix_(self.gm.fixatoms_mask, self.gm.fixatoms_mask)
] = masked_hessian
else:
# Make one step. ( A step is finished when a movement is accepted)
BFGSTRM(
Expand Down Expand Up @@ -794,9 +794,9 @@ def step(self, step=None):
)

# Restore dimensionality of the invhessian
self.invhessian[np.ix_(self.gm.fixatoms_mask, self.gm.fixatoms_mask)] = (
masked_invhessian
)
self.invhessian[
np.ix_(self.gm.fixatoms_mask, self.gm.fixatoms_mask)
] = masked_invhessian

else:
fdf0 = (self.old_u, -self.old_f)
Expand Down
10 changes: 5 additions & 5 deletions ipi/engine/motion/instanton.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def evaluate(self):
e = self.pot.copy()
g = -self.f.copy()

e = e * (self.coef[1:,0] + self.coef[:-1,0]) / 2
e = e * (self.coef[1:, 0] + self.coef[:-1, 0]) / 2
g = g * (self.coef[1:] + self.coef[:-1]) / 2
return e, g

Expand Down Expand Up @@ -670,7 +670,7 @@ def evaluate(self):
e += e_friction
g += g_friction

e = e * (self.coef[1:,0] + self.coef[:-1,0]) / 2
e = e * (self.coef[1:, 0] + self.coef[:-1, 0]) / 2
g = g * (self.coef[1:] + self.coef[:-1]) / 2

return e, g
Expand Down Expand Up @@ -865,10 +865,10 @@ class Mapper(object):
It also handles fixatoms"""

def __init__(self):
"""Initializes object for Mapper.
"""Initializes object for Mapper.
This class is inteded to combine several mappers and provide
the actual Mapper that will be used by the optimizers."""

self.sm = SpringMapper()
self.gm = PesMapper()

Expand Down Expand Up @@ -1758,7 +1758,7 @@ def step(self, step=None):
h_up_band[-1, :] += -np.ones(h_up_band.shape[1]) * lamb
d_x = alpha * invmul_banded(h_up_band, f)
else:
h_test = (h_test - np.eye(h_test.shape[0]) * lamb)
h_test = h_test - np.eye(h_test.shape[0]) * lamb
d_x = alpha * np.linalg.solve(h_test, f)

d_x.shape = self.fix.fixbeads.q.shape
Expand Down
4 changes: 3 additions & 1 deletion ipi/interfaces/sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,9 @@ def dispatch_free_client(self, fc, match_ids="any", send_threads=[]):
# makes sure the request is marked as running and the client included in the jobs list
fc.locked = fc.lastreq is r["id"]

r["offset"] = (
r[
"offset"
] = (
self.offset
) # transmits with the request an offset value for the energy (typically zero)

Expand Down
11 changes: 8 additions & 3 deletions ipi/utils/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ def read_output(filename):
match = header_pattern.match(line)
if match:
# Extracting matched groups
col_type, start_col, end_col, property_name, units, description = (
match.groups()
)
(
col_type,
start_col,
end_col,
property_name,
units,
description,
) = match.groups()
col_info = f"{start_col}-{end_col}" if end_col else start_col
properties[col_info] = {
"name": property_name,
Expand Down
4 changes: 3 additions & 1 deletion tools/py/energy_ppi.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ def totalEnergy(prefix, temp, ss=0):
rc[:] - q[j, i * 3 : i * 3 + 3], f[j, i * 3 : i * 3 + 3]
)

ePA *= 0.5 * nbeads * (Constants.kb * temperature) ** 2 / Constants.hbar**2
ePA *= (
0.5 * nbeads * (Constants.kb * temperature) ** 2 / Constants.hbar**2
)
ePA += 0.5 * nbeads * (3 * natoms) * Constants.kb * temperature + U
f2ePA = f2 * ePA
eVir /= 2.0 * nbeads
Expand Down

0 comments on commit a3395e0

Please sign in to comment.