def test_central(verbose=False): testsys = System(system) moves = RigidBodyMC(waters) moves.setReflectionSphere(Vector(0), radius) if verbose: print("Performing 5000 moves 10 times...") PDB().write(testsys.molecules(), "test_central0000.pdb") for i in range(1,11): moves.move(testsys, 5000, False) if verbose: PDB().write(testsys.molecules(), "test_central%0004d.pdb" % i) # the reflection sphere should ensure that none of the # water molecules diffuse outside the sphere mols = testsys.molecules() for molnum in mols.molNums(): mol = mols[molnum] dist = mol.evaluate().center().length() if verbose: print("%s : %s A" % (molnum.value(), dist)) assert( dist <= radius.value() )
def test_local(verbose = False): testsys = System(system) moves = RigidBodyMC(waters) local_radius = 1 * angstrom if verbose: print("Setting local reflection spheres...") for molnum in waters.molNums(): center = waters[molnum].evaluate().center() moves.setReflectionSphere(molnum, center, local_radius) if verbose: print("%s : %s == %s, %s == %s" % (molnum.value(), \ center, moves.reflectionSphereCenter(molnum), \ local_radius.value(), moves.reflectionSphereRadius(molnum).value())) assert( moves.reflectionSphereCenter(molnum) == center ) assert( moves.reflectionSphereRadius(molnum) == local_radius ) if verbose: print("Performing 5000 moves 10 times...") PDB().write(testsys.molecules(), "test_local0000.pdb") for i in range(1,11): moves.move(testsys, 5000, False) if verbose: PDB().write(testsys.molecules(), "test_local%0004d.pdb" % i) # the reflection sphere should ensure that none of the # water molecules diffuse outside the sphere mols = testsys.molecules() for molnum in mols.molNums(): mol = mols[molnum] oldmol = waters[molnum] dist = Vector.distance( mol.evaluate().center(), oldmol.evaluate().center() ) if verbose: print("%s : %s A" % (molnum.value(), dist)) assert( dist <= local_radius.value() )
solvent.add(molecules) titrator.setMoleculeGroup(solvent) system.add(cljff) system.add(solvent) system.setProperty("space", space) print("Initialising the ions...") titrator.applyTo(system) print("Randomising the location of ions...") titrator.randomiseCharge(3) titrator.applyTo(system) print("System is ready for simulation :-)") PDB().write(system.molecules(), "test0000.pdb") move = TitrationMove() move.setTemperature(25 * celsius) moves = WeightedMoves() moves.add(move, 1) move = RigidBodyMC(solvent) moves.add(move, 1) print("Start: %s" % system.energies()) for i in range(1, 11): system = moves.move(system, 1000, False) print("%5d: %s" % (i, system.energies()))
ms = t.elapsed() print("Parameterised all of the water molecules (in %d ms)!" % ms) system = System() system.add(cljff) print("Initial energy = %s" % system.energy()) mc = RigidBodyMC(free_mols) sync_mc = RigidBodyMC(sync_mols) sync_mc.setSynchronisedTranslation(True) sync_mc.setSynchronisedRotation(True) nodes = Cluster.getNode() this_thread = nodes.borrowThisThread() moves = WeightedMoves() moves.add(mc, 2) moves.add(sync_mc, 1) for i in range(0,10): print(i+1) node = nodes.getNode() sim = Simulation.run(node, system, moves, 1000) system = sim.system() moves = sim.moves() PDB().write(system.molecules(), "test%003d.pdb" % (i+1))
move.setMaximumRotation(5 * degrees) # We now group all of the moves to be performed into a single Moves # object. In this case, a WeightedMoves will draw moves randomly # according to their weight moves = WeightedMoves() moves.add( move, 1 ) # Lets perform 100 moves. The moves are performed on a copy of 'system', # with the updated version of 'system' after the moves returned by this # function print("Running 100 moves...") new_system = moves.move(system, 100, True) # Now lets run a simulation, writing out a PDB trajectory PDB().write(system.molecules(), "output000.pdb") print(system.energies()) # Here we run 10 blocks of 1000 moves, printing out the # energies and a PDB of the coordinates after each block for i in range(1,11): system = moves.move(system, 1000, True) print("%d: %s" % (i, system.energies())) PDB().write(system.molecules(), "output%003d.pdb" % i) # Finally, we print out information about how many moves # were accepted and rejected. print("Move information:") print(moves)
mol = mol.edit().rename("SB2").commit() mol = protoms.parameterise(mol, ProtoMS.SOLUTE) perturbations = mol.property("perturbations") print(perturbations) print(perturbations.requiredSymbols()) print(perturbations.requiredProperties()) lam = perturbations.symbols().Lambda() system = System() solute = MoleculeGroup("solute", mol) system.add(solute) system.setConstant(lam, 0.0) system.add( PerturbationConstraint(solute) ) print(system.constraintsSatisfied()) for i in range(0,101,10): system.setConstant(lam, 0.01 * i) PDB().write(system.molecules(), "test_%003d.pdb" % i)
rb_moves.setTemperature(temperature) # create volume moves to change the box size vol_moves = VolumeMove(mols) vol_moves.setMaximumVolumeChange( mols.nMolecules() * 0.1 * angstrom3 ) vol_moves.setTemperature(temperature) vol_moves.setPressure(pressure) # group these two moves together moves = WeightedMoves() moves.add( rb_moves, mols.nMolecules() ) moves.add( vol_moves, 1 ) # print the initial energy and coordinates print("0: %s" % system.energy()) PDB().write(system.molecules(), "output000000.pdb") # now run the simulation in blocks of 1000 moves nmoves = 0 while nmoves < num_moves: system = moves.move(system, 1000, False) nmoves += 1000 # print out the energy and coordinates every 1000 moves print("%s %s" % (nmoves, system.energy())) print(moves) PDB().write(system.molecules(), "output%000006d.pdb" % nmoves) print("Complete!")
solvent_move.setMaximumRotation(5 * degrees) solute_move = RigidBodyMC(solute) solute_move.setMaximumTranslation(0.2 * angstrom) solute_move.setMaximumRotation(5 * degrees) moves = WeightedMoves() moves.add(solvent_move, 100) moves.add(solute_move, 1) for i in range(1, 11): system = moves.move(system, 5000, False) #system = moves.move(system, 50, False) print("Step %d of 10: Energy = %s" % (i, system.energy())) PDB().write(system.molecules(), "test_equil_%0004d.pdb" % i) print("Equilibration complete") print("Adding energy monitors...") identity_points = [] for atom in identity_atoms: identity_points.append(AtomPoint( solute.moleculeAt(0).atom(AtomName(atom)))) idassigner = IDAssigner(identity_points, solvent) nrgmon0 = EnergyMonitor(solute, solvent) nrgmon1 = EnergyMonitor(solute, idassigner)
print("Final energy = %s" % system.energy()) system.mustNowRecalculateFromScratch() print("Are we sure? = %s" % system.energy()) mc = sim.moves().moves()[0] print("nAccepted() == %d, nRejected() == %d (%f %%)" % (mc.nAccepted(), \ mc.nRejected(), 100 * mc.acceptanceRatio())) print("Took %d ms" % ms) #mc.setSynchronisedTranslation(True) #mc.setSynchronisedRotation(True) #moves = SameMoves(mc) for i in range(0, 10): print(i + 1) #node = nodes.getNode() #sim = Simulation.run(node, system, moves, 1) #system = sim.system() #moves = sim.moves() system = moves.move(system, 1000, False) print(moves) PDB().write(system.molecules(), "test%003d.pdb" % (i + 1))
mcmove.add(intra_mcmove) mcmove.add(inter_mcmove) do_mc = False hmcmove = HybridMC(salt, 4*femtosecond, 20) do_hmc = True do_hmc = False print(system.property("space")) print("\nMove 0") print(system.energy()) print(mdmove.kineticEnergy()) print(system.energy() + mdmove.kineticEnergy()) PDB().write(system.molecules(), "test%0004d.pdb" % 0) if do_mc: for i in range(1,1000): system = mcmove.move(system, 20, False) print(i, system.energy()) PDB().write(system.molecules(), "test%0004d.pdb" % i) elif do_hmc: for i in range(1,1000): hmcmove.move(system, 1) print(i, system.energy()) PDB().write(system.molecules(), "test%0004d.pdb" % i)
solvent_move.setMaximumRotation( 5 * degrees ) solute_move = RigidBodyMC( solute ) solute_move.setMaximumTranslation( 0.2 * angstrom ) solute_move.setMaximumRotation( 5 * degrees ) moves = WeightedMoves() moves.add( solvent_move, 100 ) moves.add( solute_move, 1 ) for i in range(1,11): system = moves.move(system, 5000, False ) #system = moves.move(system, 50, False) print("Step %d of 10: Energy = %s" % (i, system.energy())) PDB().write(system.molecules(), "test_equil_%0004d.pdb" % i) print("Equilibration complete") print("Adding energy monitors...") identity_points = [] for atom in identity_atoms: identity_points.append( AtomPoint( solute.moleculeAt(0).atom(AtomName(atom)) ) ) idassigner = IDAssigner(identity_points, solvent) nrgmon0 = EnergyMonitor(solute, solvent) nrgmon1 = EnergyMonitor(solute, idassigner)
rb_moves.setTemperature(temperature) # create volume moves to change the box size vol_moves = VolumeMove(mols) vol_moves.setMaximumVolumeChange(mols.nMolecules() * 0.1 * angstrom3) vol_moves.setTemperature(temperature) vol_moves.setPressure(pressure) # group these two moves together moves = WeightedMoves() moves.add(rb_moves, mols.nMolecules()) moves.add(vol_moves, 1) # print the initial energy and coordinates print("0: %s" % system.energy()) PDB().write(system.molecules(), "output000000.pdb") # now run the simulation in blocks of 1000 moves nmoves = 0 while nmoves < num_moves: system = moves.move(system, 1000, False) nmoves += 1000 # print out the energy and coordinates every 1000 moves print("%s %s" % (nmoves, system.energy())) print(moves) PDB().write(system.molecules(), "output%000006d.pdb" % nmoves) print("Complete!")
print((grid_system.energies())) print((exp_system.energies())) print(("\nGrid energy equals: %s. Explicit energy equals: %s." % \ (grid_system.energy(), exp_system.energy()))) diff = grid_system.energy() - exp_system.energy() print(("The difference is %s\n" % diff)) rbmc = RigidBodyMC(swapwaters) rbmc.setReflectionSphere(center_point, 7.5*angstrom) moves = SameMoves(rbmc) PDB().write(grid_system.molecules(), "test0000.pdb") t = QTime() for i in range(1,11): print("Moving the system...") t.start() grid_system = moves.move(grid_system, 1000, False) ms = t.elapsed() print(("Moves complete! Took %d ms" % ms)) print(("GRID: ",grid_system.energies())) exp_system.update( grid_system.molecules() ) print(("EXPT: ",exp_system.energies())) print(("\nGrid energy equals: %s. Explicit energy equals: %s." % \ (grid_system.energy(), exp_system.energy())))
move.setMaximumTranslation(0.5 * angstrom) move.setMaximumRotation(5 * degrees) # We now group all of the moves to be performed into a single Moves # object. In this case, a WeightedMoves will draw moves randomly # according to their weight moves = WeightedMoves() moves.add(move, 1) # Lets perform 100 moves. The moves are performed on a copy of 'system', # with the updated version of 'system' after the moves returned by this # function print("Running 100 moves...") new_system = moves.move(system, 100, True) # Now lets run a simulation, writing out a PDB trajectory PDB().write(system.molecules(), "output000.pdb") print(system.energies()) # Here we run 10 blocks of 1000 moves, printing out the # energies and a PDB of the coordinates after each block for i in range(1, 11): system = moves.move(system, 1000, True) print("%d: %s" % (i, system.energies())) PDB().write(system.molecules(), "output%003d.pdb" % i) # Finally, we print out information about how many moves # were accepted and rejected. print("Move information:") print(moves)