Example #1
0
 def step_single(self, step_num, SHOW_MODE=0):
     step_to_go = step_num
     hundredth = step_num / 100
     if step_num <= 0:
         print "step number should be positve integer"
     else:
         while step_to_go > 0:
             # pick a molecule and its new random position and angle
             ind, x, y, theta = self.get_new_conf()
             # get its old position and angle
             x_old, y_old, theta_old = self.mol.conf[ind, :3]
             # compute the energy of the old and new configuration,
             # respectively
             state_old, energy_old = inter_energy(ind, x_old, y_old,
                                                  theta_old, self.mol,
                                                  self.energy_table)
             state_new, energy_new = inter_energy(-1, x, y, theta, self.mol,
                                                  self.energy_table)
             if state_new:
                 p = min(math.exp(-(energy_new - energy_old)), 1)
                 if p > rd.random():
                     # TODO: finish the metropolis part
                     self.mol.update(ind, x, y, theta, 1)
             step_to_go = step_to_go - 1
             if step_to_go % hundredth == 0:
                 if step_to_go != step_num:
                     print "%d / %d done" % (100 - step_to_go / hundredth,
                                             100)
Example #2
0
 def init_single(self):
     self.element_settings = [self.element_num]
     while self.mol.num_init < self.mol.num:
         ind,x,y,theta = self.get_new_conf()
         state, energy = inter_energy(self.mol.num_init,x,y,theta,self.mol,self.energy_table)
         if state:
             self.mol.update(self.mol.num_init,x,y,0)
             self.mol.num_init = self.mol.num_init + 1
             #print x,y,theta,self.mol.conf
             #print state, energy
             #self.show()
         else:
             continue
Example #3
0
 def init_single(self):
     self.element_settings = [self.element_num]
     while self.mol.num_init < self.mol.num:
         ind, x, y, theta = self.get_new_conf()
         state, energy = inter_energy(self.mol.num_init, x, y, theta,
                                      self.mol, self.energy_table)
         if state:
             self.mol.update(self.mol.num_init, x, y, 0)
             self.mol.num_init = self.mol.num_init + 1
             #print x,y,theta,self.mol.conf
             #print state, energy
             #self.show()
         else:
             continue
Example #4
0
 def step_single(self, step_num, SHOW_MODE=0):
     step_to_go = step_num
     hundredth = step_num/100
     if step_num <= 0:
         print "step number should be positve integer"
     else:
         while step_to_go > 0:
             # pick a molecule and its new random position and angle
             ind,x,y,theta = self.get_new_conf()
             # get its old position and angle
             x_old,y_old,theta_old = self.mol.conf[ind,:3]
             # compute the energy of the old and new configuration,
             # respectively
             state_old, energy_old = inter_energy(ind,x_old,y_old,theta_old,self.mol,self.energy_table)
             state_new, energy_new = inter_energy(-1,x,y,theta,self.mol,self.energy_table)
             if state_new:
                 p = min(math.exp(-(energy_new-energy_old)),1)
                 if p > rd.random():
                     # TODO: finish the metropolis part
                     self.mol.update(ind,x,y,theta,1)
             step_to_go = step_to_go - 1
             if step_to_go%hundredth == 0:
                 if step_to_go != step_num:
                     print "%d / %d done" % (100-step_to_go/hundredth,100)