def exchange(self): if self._oddeven == 0: self._oddeven = 1 else: self._oddeven = 0 energies = self._multisystem.runAnalysisPotential() temperatures = self._multisystem.runAnalysisTemperature() nparts = self._multisystem.runAnalysisNPart() print "energies = ", energies print "temperatures = ", temperatures for i in range(len(energies) / 2): m = 2 * i + self._oddeven n = m + 1 if n < len(energies): metro = self._RNG.random() t1 = temperatures[m] t2 = temperatures[n] e1 = energies[m] e2 = energies[n] n1 = nparts[m] n2 = nparts[n] delta = (1 / t2 - 1 / t1) * (e1 / n1 - e2 / n2) if delta <= 0: exyesno = 'yes' else: if exp(-delta) > metro: exyesno = 'yes' else: exyesno = 'no' print "systems %i and %i: dE=%10.5f random=%10.5f ==> exchange: %s" % ( m, n, delta, metro, exyesno) if exyesno == 'yes': # exchange temperature of system[n] <--> system[m] pmi.activate(self._comm[n]) self._multisystem.beginSystemDefinition() self._thermostat[n].temperature = t1 pmi.deactivate(self._comm[n]) pmi.activate(self._comm[m]) self._multisystem.beginSystemDefinition() self._thermostat[m].temperature = t2 pmi.deactivate(self._comm[m])
def exchange(self): if self._oddeven == 0: self._oddeven = 1 else: self._oddeven = 0; energies = self._multisystem.runAnalysisPotential() temperatures = self._multisystem.runAnalysisTemperature() nparts = self._multisystem.runAnalysisNPart() print "energies = ", energies print "temperatures = ", temperatures for i in range(len(energies)/2): m = 2 * i + self._oddeven n = m + 1 if n<len(energies): metro = self._RNG.random() t1 = temperatures[m] t2 = temperatures[n] e1 = energies[m] e2 = energies[n] n1 = nparts[m] n2 = nparts[n] delta = (1/t2-1/t1)*(e1/n1-e2/n2) if delta <= 0: exyesno = 'yes' else: if exp(-delta) > metro: exyesno = 'yes' else: exyesno = 'no' print "systems %i and %i: dE=%10.5f random=%10.5f ==> exchange: %s" % (m, n, delta, metro, exyesno) if exyesno=='yes': # exchange temperature of system[n] <--> system[m] pmi.activate(self._comm[n]) self._multisystem.beginSystemDefinition() self._thermostat[n].temperature = t1 pmi.deactivate(self._comm[n]) pmi.activate(self._comm[m]) self._multisystem.beginSystemDefinition() self._thermostat[m].temperature = t2 pmi.deactivate(self._comm[m])
def endDefiningSystem(self,n): if not (n in range(0,self._nsystems)): print("ERROR: System number must be between 0 and ",self._nsystems) else: pmi.deactivate(self._comm[n])
def endDefiningSystem(self,n): if not (n in range(0,self._nsystems)): print "ERROR: System number must be between 0 and ",self._nsystems else: pmi.deactivate(self._comm[n])