Пример #1
0
    def fn():
        context.application.model.file_open("test/input/silica_layer.zml")
        parameters = Parameters()
        parameters.interval_a = numpy.array([0.0, 3.0], float)
        parameters.interval_b = numpy.array([0.0, 3.0], float)
        UnitCellToCluster = context.application.plugins.get_action("UnitCellToCluster")
        assert UnitCellToCluster.analyze_selection(parameters)
        UnitCellToCluster(parameters)
        crd_cluster = [node.transformation.t for node in context.application.model.universe.children]

        context.application.model.file_open("test/input/silica_layer.zml")
        parameters = Parameters()
        parameters.repetitions_a = 3
        parameters.repetitions_b = 3
        SuperCell = context.application.plugins.get_action("SuperCell")
        assert SuperCell.analyze_selection(parameters)
        SuperCell(parameters)
        crd_super = [node.transformation.t for node in context.application.model.universe.children]

        # check that the number of atoms is the same
        assert len(crd_super) == len(crd_cluster)
        # check if the coordinates match
        for c_super in crd_super:
            for i in xrange(len(crd_cluster)):
                c_cluster = crd_cluster[i]
                delta = c_cluster - c_super
                delta = context.application.model.universe.shortest_vector(delta)
                if numpy.linalg.norm(delta) < 1e-3:
                    del crd_cluster[i]
                    break
        assert len(crd_cluster) == 0
Пример #2
0
 def default_parameters(cls):
     result = Parameters()
     universe = context.application.model.universe
     if universe.cell.active[0]:
         result.repetitions_a = universe.repetitions[0]
     if universe.cell.active[1]:
         result.repetitions_b = universe.repetitions[1]
     if universe.cell.active[2]:
         result.repetitions_c = universe.repetitions[2]
     return result
Пример #3
0
 def default_parameters(cls):
     result = Parameters()
     universe = context.application.model.universe
     if universe.cell.active[0]:
         result.repetitions_a = universe.repetitions[0]
     if universe.cell.active[1]:
         result.repetitions_b = universe.repetitions[1]
     if universe.cell.active[2]:
         result.repetitions_c = universe.repetitions[2]
     return result
Пример #4
0
 def fn():
     context.application.model.file_open("test/input/silica_layer.zml")
     AutoConnectPhysical = context.application.plugins.get_action("AutoConnectPhysical")
     assert AutoConnectPhysical.analyze_selection()
     AutoConnectPhysical()
     parameters = Parameters()
     parameters.repetitions_a = 2
     parameters.repetitions_b = 3
     SuperCell = context.application.plugins.get_action("SuperCell")
     assert SuperCell.analyze_selection(parameters)
     SuperCell(parameters)
     Bond = context.application.plugins.get_node("Bond")
     for node in context.application.model.universe.children:
         if isinstance(node, Bond):
             node.calc_vector_dimensions()
             assert node.length < 4.0
Пример #5
0
 def fn():
     context.application.model.file_open("test/input/silica_layer.zml")
     parameters = Parameters()
     parameters.repetitions_a = 2
     parameters.repetitions_b = 3
     SuperCell = context.application.plugins.get_action("SuperCell")
     assert SuperCell.analyze_selection(parameters)
     SuperCell(parameters)
     crd_before = [node.transformation.t for node in context.application.model.universe.children]
     WrapCellContents = context.application.plugins.get_action("WrapCellContents")
     assert WrapCellContents.analyze_selection()
     WrapCellContents()
     # coordinates should not be changed
     crd_after = [node.transformation.t for node in context.application.model.universe.children]
     for i in xrange(len(crd_after)):
         assert abs(crd_before[i][0] - crd_after[i][0]) < 1e-5
         assert abs(crd_before[i][1] - crd_after[i][1]) < 1e-5
         assert abs(crd_before[i][2] - crd_after[i][2]) < 1e-5