Example #1
0
 def __init__(self, lattice, model, chain_list = None, first_structure = None):
     self.lattice = lattice
     self.model = model
     self.step=0
     if first_structure is None:
         self.best_structure = random_avoid(self.model.natoms, self.lattice, model = model, chain_list = chain_list)
     else:
         self.best_structure =first_structure
     self.best_energy = self.model.calculate_energy(self.best_structure)
Example #2
0
 def __init__(self, lattice, model, chain_list = None, first_structure = None, temperature = 1.0):
     self.lattice = lattice
     self.model = model
     if first_structure is None:
         self.last_structure = random_avoid(self.model.natoms, self.lattice, model = model, chain_list = chain_list)
     else:
         self.last_structure = first_structure
     self.model.calculate_energy(self.last_structure)
     self.best_structure = self.last_structure
     self.best_energy = self.best_structure.energy
     self.mover = Reptate()
     self.step = 0
     if temperature > 0:
         self.rt = float(temperature)
     else:
         raise ValueError("temperature must be > 0")
Example #3
0
 def run(self, steps):
     '''Perform a simple random search.
     
     Parameters
     ----------
     steps: number of structures to generate
     
     Returns
     -------
     the best structure found
     '''
     for self.step in range (self.step +1, self.step + steps + 1):
         structure=random_avoid(self.model.natoms, self.lattice, model = self.model)
         energy = self.model.calculate_energy(structure)
         structure.energy = energy
         if energy < self.best_energy:
             self.best_energy=energy
             self.best_structure = structure
     return self.best_structure
Example #4
0
 def test_multidomain(self):
     structure=random_avoid(20, CubicLattice(), chain_list=[10,10])
     self.assertEqual(0,len(structure.overlap_map))
     self.assertEqual(2,structure.num_chains)
Example #5
0
 def test_trapping(self):
     structure=random_avoid(150, SquareLattice())
     self.assertEqual(0,len(structure.overlap_map))
Example #6
0
 def test_avoid(self):
     structure=random_avoid(100, CubicLattice())
     self.assertEqual(0,len(structure.overlap_map))
     self.assertEqual(1,structure.num_chains)
Example #7
0
 def test_multidomain(self):
     structure=random_avoid(20, CubicLattice(), chain_list=[10,10])
     self.assertIsNotNone(plot_3d(structure))
     self.assertIsNotNone(plot_contact_map(structure))
Example #8
0
 def test_3d(self):
     structure=random_avoid(150, CubicLattice())
     self.assertIsNotNone(plot_3d(structure))
Example #9
0
 def test_2d(self):
     structure=random_avoid(100, SquareLattice())
     self.assertIsNotNone(plot_2d(structure))
     self.assertIsNotNone(plot_contact_map(structure))