Created
March 15, 2017 19:27
-
-
Save maxentile/f2fca9f7f3be21776d68c3c1655c9478 to your computer and use it in GitHub Desktop.
Converts an OpenMM CustomIntegrator into a readable list of computation steps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from openmmtools.integrators import GHMCIntegrator, GradientDescentMinimizationIntegrator | |
integrators = [GHMCIntegrator(), GradientDescentMinimizationIntegrator()] | |
step_type_dict = { | |
0 : "{target} <- {expr}", | |
1: "{target} <- {expr}", | |
2: "{target} <- sum({expr})", | |
3: "constrain positions", | |
4: "constrain velocities", | |
5: "allow forces to update the context state", | |
6: "if:", | |
7: "while:", | |
8: "end" | |
} | |
for integrator in integrators: | |
scheme = integrator.__class__.__name__ | |
readable_lines = [] | |
for i in range(integrator.getNumComputations()): | |
step_type, target, expr = integrator.getComputationStep(i) | |
readable_line = step_type_dict[step_type].format(target=target, expr=expr) | |
readable_lines.append(readable_line + "\n") | |
print(readable_line) | |
# Save pretty-printed results to .txt | |
with open("{}.txt".format(scheme), "w") as f: | |
f.writelines(readable_lines) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment