Ejemplo n.º 1
0
def quenchCrystal(coords, pot, **kwargs):
    ''' Special quench routine for crystals which makes sure that the final structure is a reduced cell '''
    coords, E, rms, calls = mylbfgs(coords, pot, **kwargs)
    #while(GMIN.reduceCell(coords)):
    if(GMIN.reduceCell(coords)):
        #print "Reduced cell, redo minimization"
        coords, E, rms, callsn = mylbfgs(coords, pot, **kwargs)
        calls+=callsn
    return coords, E, rms, calls
Ejemplo n.º 2
0
 def takeStep(self, coords, **kwargs):
     ''' takeStep routine to generate random cell '''        
     ca = self.coordsadapter        
     ca.updateCoords(coords)
     
     atomistic = np.zeros(3*GMIN.getNAtoms())
     valid_configuration = False
     for i in xrange(50):
         volumeTarget = self.expand_current*lattice.volume(ca.lattice)
          
         # random box
         ca.lattice[[0,3,5]] = 1.0 + self.expand * np.random.random(3)  
         ca.lattice[[1,2,4]] = self.shear * np.random.random(3)
         
         if(self.volume != None):
             volumeTarget = self.volume[0] + (self.volume[1] - self.volume[0]) * np.random.random()
                     
         vol = lattice.volume(ca.lattice)
         ca.lattice[:] = ca.lattice * (volumeTarget / vol)**(1.0/3.0)
         GMIN.reduceCell(coords)
         
         for i in xrange(50):# first choose random positions and rotations
             for i in xrange(GMIN.getNRigidBody()):
                 ca.posRigid[i] = np.random.random()
                 ca.rotRigid[i] = rotations.random_aa()
     
             if self.overlap is None:
                 return
         
         
             GMIN.toAtomistic(atomistic, coords)
             if not crystals.has_overlap(atomistic, self.overlap):
                 return
                         
         print "Could generate valid configuration for current box, choose new box"
     raise Exception("GenRandomCrystal: failed to generate a non-overlapping configuration")