Skip to content

Commit 9509bd1

Browse files
Meg OsatoMeg Osato
authored andcommitted
add lines to debug simulation
1 parent be31895 commit 9509bd1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

blues/simulation.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@ def _stepNCMC(self, nstepsNC, moveStep, move_engine=None):
10931093
lastStep = nstepsNC - 1
10941094
for step in range(int(nstepsNC)):
10951095
try:
1096+
prevstate = self._ncmc_sim.context.getState(getEnergy=True, getPositions=True, enforcePeriodicBox=True)
10961097
if not step:
10971098
print("Calling beforeMove()")
10981099
self._ncmc_sim.context = move_engine.selected_move.beforeMove(self._ncmc_sim.context)
@@ -1107,7 +1108,16 @@ def _stepNCMC(self, nstepsNC, moveStep, move_engine=None):
11071108
state = self._ncmc_sim.context.getState(getEnergy=True, getPositions=True)
11081109

11091110
#print("STEPPPPP:", step)
1110-
#state = self._ncmc_sim.context.getState(getEnergy=True, getPositions=True, enforcePeriodicBox=True)
1111+
current_state = self._ncmc_sim.context.getState(getEnergy=True, getPositions=True, enforcePeriodicBox=True)
1112+
positions = state.getPositions(asNumpy=True)
1113+
positions = positions.value_in_unit(nanometer)
1114+
has_nan = np.isnan(pos).any()
1115+
if has_nan:
1116+
with open(f"output_{step}.pdb", "w") as f:
1117+
prevpositions = prevstate.getPositions(asNumpy=True)
1118+
PDBFile.writeFile(self._ncmc_sim.topology, positions, f, keepIds=True)
1119+
1120+
11111121
#print(" PE:", state.getPotentialEnergy())
11121122
#print(" KE:", state.getKineticEnergy())
11131123
energies.append(self._print_energy_contributions(self._ncmc_sim))

0 commit comments

Comments
 (0)