def setUp(self): self.test_transformations = [] for i in xrange(20): test_transformation = Complete() test_transformation.set_rotation_properties(random.random()*math.pi*2, numpy.random.uniform(-3, 3, 3), random.sample([True, False], 1)[0]) test_transformation.t = numpy.random.uniform(-3, 3, 3) self.test_transformations.append(test_transformation)
def setUp(self): self.test_transformations = [] for i in xrange(20): test_transformation = Complete() test_transformation.set_rotation_properties( random.random() * math.pi * 2, numpy.random.uniform(-3, 3, 3), random.sample([True, False], 1)[0]) test_transformation.t = numpy.random.uniform(-3, 3, 3) self.test_transformations.append(test_transformation)
def do_test(self, coordinates, masses, expected_is): reference = MolecularDescriptorTV1(coordinates, masses) self.assert_(reference.inversion_symmetric == expected_is) for counter in xrange(3): transformation = Complete() transformation.set_rotation_properties( random.uniform(0, 2 * math.pi), numpy.random.uniform(-1, 1, (3, )), False, ) transformation.t = numpy.random.uniform(-5, 5, (3, )) new_coordinates = numpy.array([ transformation.vector_apply(coordinate) for coordinate in coordinates ], float) new_descriptor = MolecularDescriptorTV1(new_coordinates, masses) self.assert_(reference.compare_structure(new_descriptor)) self.assert_(not reference.compare_global_rotation(new_descriptor)) self.assert_( not reference.compare_global_translation(new_descriptor))
def do_test(self, coordinates, masses, expected_is): reference = MolecularDescriptorTV1(coordinates, masses) self.assert_(reference.inversion_symmetric == expected_is) for counter in xrange(3): transformation = Complete() transformation.set_rotation_properties( random.uniform(0, 2*math.pi), numpy.random.uniform(-1, 1, (3,)), False, ) transformation.t = numpy.random.uniform(-5, 5, (3,)) new_coordinates = numpy.array([ transformation.vector_apply(coordinate) for coordinate in coordinates ], float) new_descriptor = MolecularDescriptorTV1(new_coordinates, masses) self.assert_(reference.compare_structure(new_descriptor)) self.assert_(not reference.compare_global_rotation(new_descriptor)) self.assert_(not reference.compare_global_translation(new_descriptor))
def do(self): cache = context.application.cache for node in cache.nodes: transformation = Complete() translated_children = [] for child in node.children: if isinstance(child, GLTransformationMixin) and isinstance(child.transformation, Translation): if child.get_fixed(): translated_children = [] break translated_children.append(child) if len(translated_children) == 0: continue mass, com = compute_center_of_mass(yield_particles(node)) if mass == 0.0: continue transformation.t = com tensor = compute_inertia_tensor(yield_particles(node), com) transformation.r = default_rotation_matrix(tensor) CenterAlignBase.do(self, node, translated_children, transformation)