def test_dihedral_ethene(): mol = Molecule.from_file("input/ethene.xyz") c = mol.coordinates.copy() assert abs(ic.dihed_cos([c[2], c[0], c[3], c[5]])[0] - 1.0) < 1e-5 assert abs(ic.dihed_angle([c[2], c[0], c[3], c[5]])[0]) < 1e-5 for i in xrange(1000): angle = np.random.uniform(-np.pi, np.pi) radius = np.random.uniform(0, 5*angstrom) offset = np.random.uniform(0, 5*angstrom) c[5] = [ offset, -radius*np.cos(angle), -radius*np.sin(angle), ] assert abs(ic.dihed_cos([c[2], c[0], c[3], c[5]])[0] - np.cos(angle)) < 1e-5 assert abs(ic.dihed_angle([c[2], c[0], c[3], c[5]])[0] - angle) < 1e-5
def test_dihedral_ethene(self): mol = XYZFile("input/ethene.xyz").get_molecule() c = mol.coordinates.copy() self.assertAlmostEqual(ic.dihed_cos(c[2], c[0], c[3], c[5])[0], 1.0) self.assertAlmostEqual(ic.dihed_angle(c[2], c[0], c[3], c[5])[0], 0.0) for i in xrange(1000): angle = numpy.random.uniform(-numpy.pi, numpy.pi) radius = numpy.random.uniform(0, 5*angstrom) offset = numpy.random.uniform(0, 5*angstrom) c[5] = [ offset, -radius*numpy.cos(angle), radius*numpy.sin(angle), ] self.assertAlmostEqual(ic.dihed_cos(c[2], c[0], c[3], c[5])[0], numpy.cos(angle)) self.assertAlmostEqual(ic.dihed_angle(c[2], c[0], c[3], c[5])[0], angle)
def test_dihedral_ethene(): mol = Molecule.from_file(context.get_fn("test/ethene.xyz")) c = mol.coordinates.copy() assert abs(ic.dihed_cos([c[2], c[0], c[3], c[5]])[0] - 1.0) < 1e-5 assert abs(ic.dihed_angle([c[2], c[0], c[3], c[5]])[0]) < 1e-5 for i in xrange(1000): angle = np.random.uniform(-np.pi, np.pi) radius = np.random.uniform(0, 5 * angstrom) offset = np.random.uniform(0, 5 * angstrom) c[5] = [ offset, -radius * np.cos(angle), -radius * np.sin(angle), ] assert abs(ic.dihed_cos([c[2], c[0], c[3], c[5]])[0] - np.cos(angle)) < 1e-5 assert abs(ic.dihed_angle([c[2], c[0], c[3], c[5]])[0] - angle) < 1e-5
def test_dihedral_ethene(): mol = Molecule.from_file( pkg_resources.resource_filename(__name__, "../data/test/ethene.xyz")) c = mol.coordinates.copy() assert abs(ic.dihed_cos([c[2], c[0], c[3], c[5]])[0] - 1.0) < 1e-5 assert abs(ic.dihed_angle([c[2], c[0], c[3], c[5]])[0]) < 1e-5 for i in range(1000): angle = np.random.uniform(-np.pi, np.pi) radius = np.random.uniform(0, 5 * angstrom) offset = np.random.uniform(0, 5 * angstrom) c[5] = [ offset, -radius * np.cos(angle), -radius * np.sin(angle), ] assert abs(ic.dihed_cos([c[2], c[0], c[3], c[5]])[0] - np.cos(angle)) < 1e-5 assert abs(ic.dihed_angle([c[2], c[0], c[3], c[5]])[0] - angle) < 1e-5