Esempio n. 1
0
    def do(self):
        universe = context.application.cache.node
        # first make sure the cell is right handed
        if numpy.linalg.det(universe.cell) < 0 and universe.cell_active.sum() == 3:
            new_cell = universe.cell.copy()
            temp = new_cell[:,0].copy()
            new_cell[:,0] = new_cell[:,1]
            new_cell[:,1] = temp
            primitive.SetProperty(universe, "cell", new_cell)

        # then rotate the unit cell box to the normalized frame:
        rotation = Rotation()
        rotation.r = numpy.array(universe.calc_align_rotation_matrix())
        new_cell = numpy.dot(rotation.r, universe.cell)
        old_cell_active = universe.cell_active.copy()
        universe.cell_active = numpy.array([False, False, False])
        primitive.SetProperty(universe, "cell", new_cell)
        for child in context.application.cache.transformed_children:
            primitive.Transform(child, rotation)
        universe.cell_active = old_cell_active
        primitive.SetProperty(universe, "cell", new_cell)
Esempio n. 2
0
 def do(self):
     cache = context.application.cache
     rotation = Rotation()
     rotation.r = copy.deepcopy(cache.node.transformation.r)
     CenterAlignBase.do(self, cache.parent, cache.transformed_neighbors, rotation)