Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ceriottm committed Apr 20, 2024
1 parent f110482 commit 9965a3d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
25 changes: 13 additions & 12 deletions ipi/engine/forcefields.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ def evaluate(self, r):
r["status"] = "Done"
r["t_finished"] = time.time()


class FFPlumed(FFEval):
"""Direct PLUMED interface
Expand Down Expand Up @@ -719,21 +720,21 @@ def __init__(
self.plumedrestart = True
self.plumed.cmd("setRestart", 1)
self.plumed.cmd("init")
ipi_name = lambda name : "ipi_"+name.replace(".","_")

ipi_name = lambda name: "ipi_" + name.replace(".", "_")

Check warning on line 724 in ipi/engine/forcefields.py

View workflow job for this annotation

GitHub Actions / lint

F841 local variable 'ipi_name' is assigned to but never used
self.plumed_data = {}
for x in plumedextras:
rank = np.zeros( 1, dtype=np.int_ )
self.plumed.cmd(f"getDataRank {x}", rank )
if rank[0]>1:
rank = np.zeros(1, dtype=np.int_)
self.plumed.cmd(f"getDataRank {x}", rank)
if rank[0] > 1:
raise ValueError("Cannot retrieve varibles with rank > 1")
shape = np.zeros( rank[0], dtype=np.int_ )
if shape[0]>1:
raise ValueError("Cannot retrieve varibles with size > 1")
self.plumed.cmd(f"getDataShape {x}", shape )
shape = np.zeros(rank[0], dtype=np.int_)
if shape[0] > 1:
raise ValueError("Cannot retrieve varibles with size > 1")
self.plumed.cmd(f"getDataShape {x}", shape)
self.plumed_data[x] = np.zeros(shape, dtype=np.double)
self.plumed.cmd(f"setMemoryForData {x}", self.plumed_data[x] )
self.plumed.cmd(f"setMemoryForData {x}", self.plumed_data[x])

self.charges = dstrip(myatoms.q) * 0.0
self.masses = dstrip(myatoms.m)
self.lastq = np.zeros(3 * self.natoms)
Expand Down Expand Up @@ -775,7 +776,7 @@ def evaluate(self, r):
self.plumed.cmd("setVirial", vir)
self.plumed.cmd("prepareCalc")
self.plumed.cmd("performCalcNoUpdate")

bias = np.zeros(1, float)
self.plumed.cmd("getBias", bias)
v = bias[0]
Expand Down
2 changes: 1 addition & 1 deletion ipi/engine/forces.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ def extra_combine(self):

re = {}
for k in range(self.nforces):
# combines the extras from the different force components
# combines the extras from the different force components
for e, v in self.mforces[k].extras.items():
if e in self.mforces[k].force_extras:
# extras that are tagged as force_extras are treated exactly as if they were an energy/force/stress
Expand Down
9 changes: 6 additions & 3 deletions ipi/inputs/forcefields.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,11 @@ class InputFFPlumed(InputForceField):
),
"plumedextras": (
InputArray,
{"dtype": str, "default": input_default(factory=np.zeros, args=(0, str)),
"help": "List of variables defined in the PLUMED input, that should be transferred to i-PI as `extras` fields." },
{
"dtype": str,
"default": input_default(factory=np.zeros, args=(0, str)),
"help": "List of variables defined in the PLUMED input, that should be transferred to i-PI as `extras` fields.",
},
),
}

Expand Down Expand Up @@ -563,7 +566,7 @@ def fetch(self):
plumeddat=self.plumeddat.fetch(),
plumedstep=self.plumedstep.fetch(),
plumedextras=self.plumedextras.fetch(),
init_file=self.file.fetch(),
init_file=self.file.fetch(),
)


Expand Down

0 comments on commit 9965a3d

Please sign in to comment.