def test_site_distance_squared(self): print("\ntest site distance squared") c0 = np.zeros(3) c1 = np.ones(3) p0 = self.p0.copy() p1 = p0 + 1 site = make_otp() d2 = site.distance_squared(c0, p0, c1, p1) d2p = _sitedist(c1 - c0, p0, p1, site.S, site.W, site.cog) self.assertAlmostEqual(d2, 10.9548367929, 5)
def test_site_distance_squared(self): print("\ntest site distance squared") c0 = np.zeros(3) c1 = np.ones(3) p0 = self.p0.copy() p1 = p0 + 1 site = make_otp() d2 = site.distance_squared(c0, p0, c1, p1) d2p = _sitedist(c1-c0, p0, p1, site.S, site.W, site.cog) self.assertAlmostEqual(d2, 10.9548367929, 5)
def test_site_to_atomistic(self): rf = make_otp() p = np.array([1., 2, 3]) p /= np.linalg.norm(p) com = np.array([4., 5, 6]) print("otp to atomistic") print(rf.to_atomistic(com, p)) print("otp transform grad") g = np.array(list(range(9)), dtype=float).reshape([-1, 3]) print(g.reshape(-1)) print(rf.transform_grad(p, g))
def make_atom_indices_cpp_topology(self, atom_indices=None): sites = [make_otp() for _ in xrange(self.nrigid)] if atom_indices is None: atom_indices = np.array(range(self.nrigid * 3), dtype=int) np.random.shuffle(atom_indices) i = 0 for site in sites: site.atom_indices = atom_indices[i:i + site.get_natoms()].copy() i += site.get_natoms() topology = RBTopology() topology.add_sites(sites) topology.finalize_setup(use_cpp=False) return topology, atom_indices
def test_site_to_atomistic(self): rf = make_otp() p = np.array([1., 2, 3]) p /= np.linalg.norm(p) com = np.array([4., 5, 6]) print("otp to atomistic") print(rf.to_atomistic(com, p)) print("otp transform grad") g = np.array(list(range(9)), dtype=float).reshape([-1,3]) print(g.reshape(-1)) print(rf.transform_grad(p, g))
def make_atom_indices_cpp_topology(self, atom_indices=None): sites = [make_otp() for _ in xrange(self.nrigid)] if atom_indices is None: atom_indices = np.array(range(self.nrigid*3), dtype=int) np.random.shuffle(atom_indices) i = 0 for site in sites: site.atom_indices = atom_indices[i:i+site.get_natoms()].copy() i += site.get_natoms() topology = RBTopology() topology.add_sites(sites) topology.finalize_setup(use_cpp=False) return topology, atom_indices
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
def make_normal_cpp_topology(self): sites = [make_otp() for _ in xrange(self.nrigid)] normal_topology = RBTopology() normal_topology.add_sites(sites) normal_topology.finalize_setup() return normal_topology