def _get_integrator(self, thermostat): assert thermostat in [None, "Nose", "Langevin" ], "Wrong thermostat: " + str(thermostat) if thermostat is None: return VelocityVerletIntegrator(self._universe, delta_t=self._dt) elif thermostat == "Nose": self._universe.thermostat = NoseThermostat(self._temperature) return VelocityVerletIntegrator(self._universe, delta_t=self._dt) elif thermostat == "Langevin": return self._get_Langevin_integrator()
def _get_integrators(self, thermostat): if thermostat is None: return [ VelocityVerletIntegrator(universe, delta_t=self._time_step) for universe in self._universes ] elif thermostat == "Nose": for universe in self._universes: universe.thermostat = NoseThermostat(self._temperature) return [ VelocityVerletIntegrator(universe, delta_t=self._time_step) for universe in self._universes ] elif thermostat == "Langevin": return [ self._get_Langevin_integrator(universe) for universe in self._universes ] else: raise Exception("Unknown thermostat " + thermostat)
print("Solvent molecules have been added, now shrinking universe...") # Shrink the universe back to its original size, thereby compressing # the solvent to its real density. MMTK.Solvation.shrinkUniverse(universe, temperature, 'solvation.nc') print("Universe has been compressed, now equilibrating...") # Set a better force field and add thermostat and barostat. # # Note: For efficiency, optimized Ewald parameters should be used # in a real application. The barostat relaxation time must be # adjusted to the system size; it should be chosen smaller than # for a realistic simulation in order to reach the final # volume faster. universe.setForceField(Amber94ForceField(1.4, {'method': 'ewald'})) universe.thermostat = NoseThermostat(temperature) universe.barostat = AndersenBarostat(pressure, 0.1*Units.ps) # Create an integrator and a trajectory. integrator = VelocityVerletIntegrator(universe, delta_t=1.*Units.fs) trajectory = Trajectory(universe, "equilibration.nc", "w", "Equilibration (NPT ensemble)") # Start an NPT integration with periodic rescaling of velocities # and resetting of the barostat. The number of steps required to # reach a stable volume depends strongly on the system! output_actions = [TrajectoryOutput(trajectory, ('configuration', 'energy', 'thermodynamic', 'time', 'auxiliary'), 0, None, 100), LogOutput("equilibration.log", ('time', 'energy'),