Remove unused variables, PEP8-ify comments
@@ -316,8 +316,7 @@ def test_thermostated_integrator_hash():
def test_alchemical_langevin_integrator():
- """
- Check that the AlchemicalLangevinSplittingIntegrator, when performing nonequilibrium switching from
+ """Check that the AlchemicalLangevinSplittingIntegrator, when performing nonequilibrium switching from
AlanineDipeptideImplicit to the same with nonbonded forces decoupled and back, results in an approximately
zero free energy difference (using BAR). Up to 6*sigma is tolerated for error.
"""
@@ -341,12 +340,10 @@ def test_alchemical_langevin_integrator():
# Do 100 iterations of each direction
n_iterations = 100
- #instantiate the testsystem
- alanine_dipeptide = testsystems.AlanineDipeptideVacuum()
+ # Instantiate the testsystem
lj = testsystems.LennardJonesCluster()
- #alchemically modify everything:
- n_atoms = lj.system.getNumParticles()
+ # Alchemically modify everything:
alchemical_factory = alchemy.AlchemicalFactory(consistent_exceptions=False)
alchemical_region = alchemy.AlchemicalRegion([1], alchemical_bonds=False, alchemical_angles=False,
alchemical_torsions=False)
@@ -357,7 +354,7 @@ def test_alchemical_langevin_integrator():
alchemical_ctx_forward = openmm.Context(modified_system, alchemical_integrator_forward, platform)
alchemical_ctx_reverse = openmm.Context(modified_system, alchemical_integrator_reverse, platform)
- #get the forward work values:
+ # Get the forward work values:
positions = lj.positions
w_f = numpy.zeros([n_iterations])
for i in range(n_iterations):
@@ -368,7 +365,7 @@ def test_alchemical_langevin_integrator():
print(i)
- #get the reverse work values:
+ # Get the reverse work values:
w_r = numpy.zeros([n_iterations])
for i in range(n_iterations):
w_r[i], eq_positions = run_nonequilibrium_switching(modified_system, positions,
@@ -385,8 +382,7 @@ def test_alchemical_langevin_integrator():
def run_nonequilibrium_switching(system, positions, alchemical_functions, alchemical_integrator, nsteps, alchemical_ctx, direction="forward"):
- """
- Equilibrate and then run some nonequilibrium switching simulations
+ """Equilibrate and then run some nonequilibrium switching simulations
Parameters
----------
@@ -401,22 +397,22 @@ def run_nonequilibrium_switching(system, positions, alchemical_functions, alchem
Work performed by protocol
"""
- #make a ghmc integrator with the default parameters
+ # Make a ghmc integrator with the default parameters
ghmc_integrator = GHMCIntegrator()
gbaoab = GeodesicBAOABIntegrator()
- #use the reference platform, since this is for a test
+ # Use the reference platform, since this is for a test
platform = openmm.Platform.getPlatformByName("Reference")
- #make a context
+ # Make a context
context = openmm.Context(system, gbaoab, platform)
context.setPositions(positions)
- #set the initial alchemical state for the equilibration simulation:
+ # Set the initial alchemical state for the equilibration simulation:
for parameter in alchemical_functions.keys():
context.setParameter(parameter, 0.0) if direction == "forward" else context.setParameter(parameter, 1.0)
- #run some steps to equilibrate
+ # Run some steps to equilibrate
gbaoab.step(100)
eq_positions = context.getState(getPositions=True).getPositions(asNumpy=True)
