Exemplo n.º 1
0
 def setUp(self):
     a = Vector(1.5, 0.3, 0.)
     b = Vector(-0.1, 0.8, 0.2)
     c = Vector(0., -0.2, 1.1)
     self.universe = ParallelepipedicPeriodicUniverse((a, b, c))
     for i in range(100):
         p = self.universe.boxToRealCoordinates(randomPointInBox(1.))
         self.universe.addObject(Atom('C', position=p))
Exemplo n.º 2
0
 def setUp(self):
     a = Vector(1.5, 0.3, 0.)
     b = Vector(-0.1, 0.8, 0.2)
     c = Vector(0., -0.2, 1.1)
     self.universe = ParallelepipedicPeriodicUniverse((a, b, c))
     for i in range(100):
         p = self.universe.boxToRealCoordinates(randomPointInBox(1.))
         self.universe.addObject(Atom('C', position = p))
Exemplo n.º 3
0
 def test_boxCoordinates1(self):
     for i in range(500):
         p = randomPointInBox(5.)
         pt = self.universe.realToBoxCoordinates(p)
         self.assert_(
             (self.universe.boxToRealCoordinates(pt) - p).length() < 1.e-14)
         pt = self.universe.boxToRealCoordinates(p)
         self.assert_(
             (self.universe.realToBoxCoordinates(pt) - p).length() < 1.e-14)
Exemplo n.º 4
0
 def test_boxCoordinates1(self):
     for i in range(500):
         p = randomPointInBox(5.)
         pt = self.universe.realToBoxCoordinates(p)
         self.assert_((self.universe.boxToRealCoordinates(pt)-p).length()
                      < 1.e-14)
         pt = self.universe.boxToRealCoordinates(p)
         self.assert_((self.universe.realToBoxCoordinates(pt)-p).length()
                      < 1.e-14)
Exemplo n.º 5
0
 def test_coordinateFold(self):
     for i in range(500):
         self.universe.translateBy(randomPointInBox(0.5))
         self.universe.foldCoordinatesIntoBox()
         for atom in self.universe.atomList():
             rb = self.universe.realToBoxCoordinates(atom.position())
             self.assert_(rb[0] >= -0.5)
             self.assert_(rb[1] >= -0.5)
             self.assert_(rb[2] >= -0.5)
             self.assert_(rb[0] <= 0.5)
             self.assert_(rb[1] <= 0.5)
             self.assert_(rb[2] <= 0.5)
         cconf = self.universe.contiguousObjectConfiguration(
             self.universe.objectList())
         for o in self.universe:
             for bu in o.bondedUnits():
                 for bond in bu.bonds:
                     l = (bond.a1.position(cconf) -
                          bond.a2.position(cconf)).length()
                     self.assert_(l < 0.16)
Exemplo n.º 6
0
 def test_coordinateFold(self):
     for i in range(500):
         self.universe.translateBy(randomPointInBox(0.5))
         self.universe.foldCoordinatesIntoBox()
         for atom in self.universe.atomList():
             rb = self.universe.realToBoxCoordinates(atom.position())
             self.assert_(rb[0] >= -0.5)
             self.assert_(rb[1] >= -0.5)
             self.assert_(rb[2] >= -0.5)
             self.assert_(rb[0] <= 0.5)
             self.assert_(rb[1] <= 0.5)
             self.assert_(rb[2] <= 0.5)
         cconf = self.universe.contiguousObjectConfiguration(
                                                 self.universe.objectList())
         for o in self.universe:
             for bu in o.bondedUnits():
                 for bond in bu.bonds:
                     l = (bond.a1.position(cconf)
                          - bond.a2.position(cconf)).length()
                     self.assert_(l < 0.16)
Exemplo n.º 7
0
# Calculate the size of the box
density = 1.*Units.g/(Units.cm)**3
number_density = density/Molecule('water').mass()
real_size = (n_molecules/number_density)**(1./3.)

# Create the universe with a larger initial size
current_size = 5.*real_size
world = CubicPeriodicUniverse(current_size,
                              Amber94ForceField(1.2*Units.nm,
                                                {'method': 'ewald'}))

# Add solvent molecules at random positions, avoiding the neighbourhood
# of previously placed molecules
excluded_regions = []
for i in range(n_molecules):
    m = Molecule('water', position = randomPointInBox(current_size))
    while 1:
        s = m.boundingSphere()
        collision = 0
        for region in excluded_regions:
            if s.intersectWith(region) is not None:
                collision = 1
                break
        if not collision:
            break
        m.translateTo(randomPointInBox(current_size))
    world.addObject(m)
    excluded_regions.append(s)

# Reduce energy
minimizer = SteepestDescentMinimizer(world, step_size = 0.05*Units.Ang)
Exemplo n.º 8
0
 def setUp(self):
     self.universe = OrthorhombicPeriodicUniverse((1.5, 0.8, 1.1))
     for i in range(100):
         p = self.universe.boxToRealCoordinates(randomPointInBox(1.))
         self.universe.addObject(Atom('C', position = p))
Exemplo n.º 9
0
 def setUp(self):
     self.universe = InfiniteUniverse()
     for i in range(100):
         p = randomPointInBox(1.)
         self.universe.addObject(Atom('C', position = p))
Exemplo n.º 10
0
# Calculate the size of the box
density = 1. * Units.g / (Units.cm)**3
number_density = density / Molecule('water').mass()
real_size = (n_molecules / number_density)**(1. / 3.)

# Create the universe with a larger initial size
current_size = 5. * real_size
world = CubicPeriodicUniverse(
    current_size, Amber94ForceField(1.2 * Units.nm, {'method': 'ewald'}))

# Add solvent molecules at random positions, avoiding the neighbourhood
# of previously placed molecules
excluded_regions = []
for i in range(n_molecules):
    m = Molecule('water', position=randomPointInBox(current_size))
    while 1:
        s = m.boundingSphere()
        collision = 0
        for region in excluded_regions:
            if s.intersectWith(region) is not None:
                collision = 1
                break
        if not collision:
            break
        m.translateTo(randomPointInBox(current_size))
    world.addObject(m)
    excluded_regions.append(s)

# Reduce energy
minimizer = SteepestDescentMinimizer(world, step_size=0.05 * Units.Ang)
Exemplo n.º 11
0
 def setUp(self):
     self.universe = OrthorhombicPeriodicUniverse((1.5, 0.8, 1.1))
     for i in range(100):
         p = self.universe.boxToRealCoordinates(randomPointInBox(1.))
         self.universe.addObject(Atom('C', position=p))
Exemplo n.º 12
0
 def setUp(self):
     self.universe = InfiniteUniverse()
     for i in range(100):
         p = randomPointInBox(1.)
         self.universe.addObject(Atom('C', position=p))