Exemplo n.º 1
0
    def _create_potential(self):
        """construct the potential which will compute the energy and gradient in atomistic (cartesian) coordinates
        
        The bonded (hinged) sides interact with an attractive harmonic potential.  Each atom 
        in the bond has a single interaction partner.
        
        The loosly attractive sides interact with an LJ potential.  These interactions are
        not specific.  Each atom interacts with every other one.
        
        All atoms repel each other with a WCA potential. 
        """
        parser = MolAtomIndexParser(self.aatopology, self.nrigid)
        
        # this is currently only set up for a tetrahedron
        assert self.nrigid == 4
        # do hinges
        harmonic_atoms1 = []
        harmonic_atoms2 = []
        harmonic_atoms1 += parser.get_atom_indices(0, EDGE1_TYPE)
        harmonic_atoms2 += parser.get_atom_indices(1, EDGE1_TYPE)
         
        harmonic_atoms1 += parser.get_atom_indices(0, EDGE2_TYPE)
        harmonic_atoms2 += parser.get_atom_indices(2, EDGE1_TYPE)
        
        harmonic_atoms1 += parser.get_atom_indices(0, EDGE3_TYPE)
        harmonic_atoms2 += parser.get_atom_indices(3, EDGE1_TYPE)
        
        self.harmonic_atoms = np.array(harmonic_atoms1 + harmonic_atoms2, np.integer)

        harmonic_atoms1 = np.array(harmonic_atoms1, dtype=np.integer).ravel()
        harmonic_atoms2 = np.array(harmonic_atoms2, dtype=np.integer).ravel()
        
        
        for i, j in zip(harmonic_atoms1, harmonic_atoms2):
            self.draw_bonds.append((i,j))
        
        # do attractive part
        lj_atoms = []
        lj_atoms += parser.get_atom_indices(1, EDGE2_TYPE)
        lj_atoms += parser.get_atom_indices(1, EDGE3_TYPE)
        lj_atoms += parser.get_atom_indices(2, EDGE2_TYPE)
        lj_atoms += parser.get_atom_indices(2, EDGE3_TYPE)
        lj_atoms += parser.get_atom_indices(3, EDGE2_TYPE)
        lj_atoms += parser.get_atom_indices(3, EDGE3_TYPE)
        lj_atoms = np.array(sorted(lj_atoms)).ravel()
        
        self.lj_atoms = lj_atoms
        
        self.extra_atoms = []
        for i in range(self.nrigid):
            self.extra_atoms += parser.get_atom_indices(i, OTHER_TYPE)
        
        plate_pot = PlatePotential(harmonic_atoms1, harmonic_atoms2, lj_atoms, k=10)
        # wrap it so it can be used with angle axis coordinates
        pot = RBPotentialWrapper(self.aatopology.cpp_topology, plate_pot)
#            self.aasystem.set_cpp_topology(self.pot.topology)
#            raise Exception
        return pot
Exemplo n.º 2
0
    def get_potential(self):
        """construct the rigid body potential"""
        try:
            return self.pot
        except AttributeError:
            # construct the potential which will compute the energy and gradient in atomistic (cartesian) coordinates
            cartesian_potential = LJ()
            # wrap it so it can be used with angle axis coordinates
            self.pot = RBPotentialWrapper(self.aatopology.cpp_topology, cartesian_potential)
#            self.aasystem.set_cpp_topology(self.pot.topology)
            return self.pot
Exemplo n.º 3
0
    def test_to_atomistic2(self):
        x0 = np.array(list(range(self.nrigid * 6)), dtype=float)
        x2 = x0.reshape([-1, 3])
        for p in x2[self.nrigid:, :]:
            p /= np.linalg.norm(p)
        atomistic = self.topology.to_atomistic(x0).flatten()

        from pele.potentials import LJ
        lj = LJ()
        e, g = lj.getEnergyGradient(atomistic.reshape(-1))
        grb = self.topology.transform_gradient(x0, g)
        rbpot = RBPotentialWrapper(self.topology, lj)
        print(rbpot.getEnergy(x0))
Exemplo n.º 4
0
    def test_pot_wrapper(self):
        from pele.angleaxis import _cpp_aa
        from pele.potentials import LJ
        rbpot_cpp = _cpp_aa.RBPotentialWrapper(self.topology, LJ())
        rbpot = RBPotentialWrapper(self.topology, LJ())

        self.assertAlmostEqual(rbpot_cpp.getEnergy(self.x0),
                               rbpot.getEnergy(self.x0), 4)

        e1, grad1 = rbpot_cpp.getEnergyGradient(self.x0)
        e2, grad2 = rbpot.getEnergyGradient(self.x0)
        self.assertAlmostEqual(e1, e2, 4)
        for g1, g2 in zip(grad1, grad2):
            self.assertAlmostEqual(g1, g2, 3)
Exemplo n.º 5
0
    def get_potential(self):
        """construct the rigid body potential"""
        try:
            return self.pot
        except AttributeError:
            # construct the potential which will compute the energy and gradient 
            # in atomistic (cartesian) coordinates
            # NOTE: Currently the LJCut potential only deals with cubic boxes
            cartesian_potential = LJCut(rcut=self.cut, boxvec=self.boxvec)
#            cartesian_potential = LJCutCellLists(rcut=self.cut, boxvec=self.boxvec)
            # wrap it so it can be used with angle axis coordinates
            self.pot = RBPotentialWrapper(self.aatopology.cpp_topology, cartesian_potential)
#            self.aasystem.set_cpp_topology(self.pot.topology)
            return self.pot
Exemplo n.º 6
0
    def setUp(self):
        nrigid = 3
        self.topology = RBTopology()
        self.topology.add_sites([make_otp() for i in range(nrigid)])
        self.topology.finalize_setup()

        cartesian_potential = LJ()
        self.pot = RBPotentialWrapper(self.topology, cartesian_potential)

        self.x0 = _x03
        self.x0 = np.array(self.x0)
        self.e0 = -17.3387670023
        assert nrigid * 6 == self.x0.size

        self.x0atomistic = _x03_atomistic
        self.nrigid = nrigid