Exemple #1
0
 def default_parameters(cls):
     result = Parameters()
     result.number1 = 6
     result.number2 = 6
     result.distance = 0.5
     result.bond_type = BOND_SINGLE
     return result
Exemple #2
0
 def fn():
     context.application.model.file_open("test/input/core_objects.zml")
     context.application.main.toggle_selection(context.application.model.universe.children[3], on=True)
     parameters = Parameters()
     parameters.translation = Translation([2.0, 4.1, -1.0])
     TranslateDialog = context.application.plugins.get_action("TranslateDialog")
     assert TranslateDialog.analyze_selection(parameters)
     TranslateDialog(parameters)
Exemple #3
0
 def fn():
     context.application.model.file_open("test/input/core_objects.zml")
     context.application.main.toggle_selection(context.application.model.universe.children[3], on=True)
     parameters = Parameters()
     parameters.rotation = Rotation.from_properties(1.0, numpy.array([0.1, 1.4, 0.3]), False)
     RotateDialog = context.application.plugins.get_action("RotateDialog")
     assert RotateDialog.analyze_selection(parameters)
     RotateDialog(parameters)
Exemple #4
0
 def free_optimize(self, springs):
     context.application.main.select_nodes(springs)
     OptimizeSprings = context.application.plugins.get_action("OptimizeSprings")
     parameters = Parameters()
     parameters.allow_rotation = True
     parameters.update_interval = 0.4
     parameters.update_steps = 1
     OptimizeSprings(parameters)
Exemple #5
0
 def fn():
     context.application.model.file_open("test/input/periodic.zml")
     parameters = Parameters()
     parameters.repetitions_b = 2
     parameters.repetitions_c = 3
     SuperCell = context.application.plugins.get_action("SuperCell")
     assert SuperCell.analyze_selection(parameters)
     SuperCell(parameters)
Exemple #6
0
 def free_optimize(self, springs):
     context.application.main.select_nodes(springs)
     OptimizeSprings = context.application.plugins.get_action(
         "OptimizeSprings")
     parameters = Parameters()
     parameters.allow_rotation = True
     parameters.update_interval = 0.4
     parameters.update_steps = 1
     OptimizeSprings(parameters)
Exemple #7
0
 def fn():
     context.application.model.file_open("test/input/core_objects.zml")
     context.application.main.toggle_selection(context.application.model.universe.children[3], on=True)
     parameters = Parameters()
     parameters.center = numpy.array([1.0, 0.2, -0.9], float)
     parameters.normal = numpy.array([2.0, 4.1, -1.0], float)
     ReflectionDialog = context.application.plugins.get_action("ReflectionDialog")
     assert ReflectionDialog.analyze_selection(parameters)
     ReflectionDialog(parameters)
Exemple #8
0
 def fn():
     context.application.model.file_open("test/input/core_objects.zml")
     context.application.main.toggle_selection(context.application.model.universe.children[3], on=True)
     context.application.cache.drag_destination = context.application.model.universe.children[2].children[0]
     DropTarget = context.application.plugins.get_action("DropTarget")
     parameters = Parameters()
     parameters.child_index = -1
     assert DropTarget.analyze_selection(parameters)
     DropTarget(parameters)
Exemple #9
0
 def fn():
     context.application.model.file_open("test/input/core_objects.zml")
     context.application.main.toggle_selection(context.application.model.folder.children[0], on=True)
     context.application.cache.drag_destination = context.application.model.folder
     parameters = Parameters()
     parameters.child_index = 2
     MoveNon3DObjects = context.application.plugins.get_action("MoveNon3DObjects")
     assert MoveNon3DObjects.analyze_selection(parameters)
     MoveNon3DObjects(parameters)
Exemple #10
0
 def execute_drag(self, destination, child_index):
     parameters = Parameters()
     context.application.cache.drag_destination = destination
     parameters.child_index = child_index
     for drag_action in self.drag_actions:
         if drag_action.cached_analyze_selection(parameters=parameters):
             drag_action(parameters=parameters)
             return True
     return False
Exemple #11
0
 def default_parameters(cls):
     result = Parameters()
     universe = context.application.model.universe
     if universe.cell.active[0]:
         result.interval_a = numpy.array([0.0, universe.repetitions[0]], float)
     if universe.cell.active[1]:
         result.interval_b = numpy.array([0.0, universe.repetitions[1]], float)
     if universe.cell.active[2]:
         result.interval_c = numpy.array([0.0, universe.repetitions[2]], float)
     return result
Exemple #12
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
Exemple #13
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
Exemple #14
0
 def fn():
     context.application.model.file_open("test/input/lau.zml")
     context.application.main.select_nodes([context.application.model.universe])
     parameters = Parameters()
     parameters.number1 = 14
     parameters.number2 = 14
     parameters.distance = 6.0
     parameters.bond_type = BOND_SINGLE
     AutoConnectParameters = context.application.plugins.get_action("AutoConnectParameters")
     assert AutoConnectParameters.analyze_selection(parameters)
     AutoConnectParameters(parameters)
Exemple #15
0
 def fn():
     context.application.model.file_open("test/input/core_objects.zml")
     context.application.main.toggle_selection(context.application.model.universe, on=True)
     ScaleUnitCell = context.application.plugins.get_action("ScaleUnitCell")
     assert ScaleUnitCell.analyze_selection()
     parameters = Parameters()
     parameters.matrix = numpy.array([
         [1.0, 0.0, 0.0],
         [0.0, 2.0, 0.0],
         [0.0, 0.0, 3.0],
     ])
     ScaleUnitCell(parameters)
Exemple #16
0
    def fn():
        context.application.model.file_open("test/input/precursor.zml")
        context.application.main.select_nodes([context.application.model.universe])

        parameters = Parameters()
        parameters.filter_atom1 = Expression()
        parameters.filter_bond12 = Expression()
        parameters.filter_atom2 = Expression()

        DistributionBondLengths = context.application.plugins.get_action("DistributionBondLengths")
        assert DistributionBondLengths.analyze_selection(parameters)
        DistributionBondLengths(parameters)
Exemple #17
0
 def default_parameters(cls):
     result = Parameters()
     universe = context.application.model.universe
     if universe.cell.active[0]:
         result.interval_a = numpy.array([0.0, universe.repetitions[0]],
                                         float)
     if universe.cell.active[1]:
         result.interval_b = numpy.array([0.0, universe.repetitions[1]],
                                         float)
     if universe.cell.active[2]:
         result.interval_c = numpy.array([0.0, universe.repetitions[2]],
                                         float)
     return result
Exemple #18
0
 def default_parameters(cls):
     result = Parameters()
     result.filter_atom1 = Expression()
     result.filter_bond12 = Expression()
     result.filter_atom2 = Expression()
     result.filter_bond23 = Expression()
     result.filter_atom3 = Expression()
     result.filter_bond34 = Expression()
     result.filter_atom4 = Expression()
     return result
Exemple #19
0
    def fn():
        context.application.model.file_open("test/input/springs.zml")
        context.application.main.select_nodes(
            context.application.model.universe.children[7:9][::-1] +
            context.application.model.universe.children[2:6][::-1])
        parameters = Parameters()
        parameters.allow_rotation = True
        parameters.update_interval = 0.4
        parameters.update_steps = 1

        OptimizeSprings = context.application.plugins.get_action(
            "OptimizeSprings")
        assert OptimizeSprings.analyze_selection(parameters)
        OptimizeSprings(parameters)
Exemple #20
0
    def fn():
        context.application.model.file_open("test/input/springs.zml")
        context.application.main.select_nodes(
            context.application.model.universe.children[7:9][::-1] +
            context.application.model.universe.children[2:6][::-1]
        )
        parameters = Parameters()
        parameters.allow_rotation = True
        parameters.update_interval = 0.4
        parameters.update_steps = 1

        OptimizeSprings = context.application.plugins.get_action("OptimizeSprings")
        assert OptimizeSprings.analyze_selection(parameters)
        OptimizeSprings(parameters)
Exemple #21
0
    def fn():
        context.application.model.file_open("test/input/precursor.zml")
        context.application.main.select_nodes(
            [context.application.model.universe])

        parameters = Parameters()
        parameters.filter_atom1 = Expression()
        parameters.filter_bond12 = Expression()
        parameters.filter_atom2 = Expression()

        DistributionBondLengths = context.application.plugins.get_action(
            "DistributionBondLengths")
        assert DistributionBondLengths.analyze_selection(parameters)
        DistributionBondLengths(parameters)
Exemple #22
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
Exemple #23
0
    def fn():
        context.application.model.file_open("test/input/tpa.zml")
        universe = context.application.model.universe
        context.application.main.select_nodes([universe] + universe.children)
        parameters = Parameters()
        parameters.number1 = 6
        parameters.number2 = 6
        parameters.distance = 3.0
        parameters.bond_type = BOND_SINGLE
        AutoConnectParameters = context.application.plugins.get_action("AutoConnectParameters")
        assert AutoConnectParameters.analyze_selection(parameters)
        AutoConnectParameters(parameters)

        Bond = context.application.plugins.get_node("Bond")
        num_bonds = sum(isinstance(node,Bond) for node in universe.children)
        assert num_bonds == 2*4
Exemple #24
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
Exemple #25
0
 def default_parameters(cls):
     result = Parameters()
     result.n = 5
     result.m = 1
     result.flat = False
     result.max_length = 50 * angstrom
     result.max_error = 0.01 * angstrom
     result.tube_length = Undefined(50 * angstrom)
     return result
Exemple #26
0
 def fn():
     context.application.model.file_open("test/input/sod.zml")
     parameters = Parameters()
     parameters.interval_b = numpy.array([-0.5, 2.5], float)
     parameters.interval_c = numpy.array([-1.5, 1.5], float)
     UnitCellToCluster = context.application.plugins.get_action("UnitCellToCluster")
     assert UnitCellToCluster.analyze_selection(parameters)
     UnitCellToCluster(parameters)
     # check the bond lengths
     Bond = context.application.plugins.get_node("Bond")
     universe = context.application.model.universe
     for bond in context.application.model.universe.children:
         if isinstance(bond, Bond):
             delta = bond.children[0].target.transformation.t - bond.children[1].target.transformation.t
             delta = universe.shortest_vector(delta)
             distance = numpy.linalg.norm(delta)
             assert distance < 4.0
Exemple #27
0
 def default_parameters(cls):
     result = Parameters()
     result.filter_atom1 = Expression()
     result.filter_bond12 = Expression()
     result.filter_atom2 = Expression()
     result.filter_bond23 = Expression()
     result.filter_atom3 = Expression()
     result.filter_bond34 = Expression()
     result.filter_atom4 = Expression()
     return result
Exemple #28
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
Exemple #29
0
 def fn():
     context.application.model.file_open("test/input/silica_layer.zml")
     parameters = Parameters()
     parameters.n = 10
     parameters.m = 4
     parameters.flat = False
     parameters.max_length = 300 * angstrom
     parameters.max_error = 0.01 * angstrom
     parameters.tube_length = Undefined(0.01 * angstrom)
     CreateTube = context.application.plugins.get_action("CreateTube")
     assert CreateTube.analyze_selection(parameters)
     CreateTube(parameters)
Exemple #30
0
    def fn():
        context.application.model.file_open("test/input/tpa.xyz")
        Atom = context.application.plugins.get_node("Atom")
        for child in context.application.model.universe.children[::-1]:
            if isinstance(child, Atom) and child.number == 1:
                context.application.model.universe.children.remove(child)
        context.application.main.select_nodes([context.application.model.universe])
        AutoConnectPhysical = context.application.plugins.get_action("AutoConnectPhysical")
        assert AutoConnectPhysical.analyze_selection()
        AutoConnectPhysical()

        parameters = Parameters()
        parameters.num_hydrogens = 2
        parameters.valence_angle = 1.9093

        context.application.main.select_nodes([context.application.model.universe.children[1]])
        SaturateHydrogensManual = context.application.plugins.get_action("SaturateHydrogensManual")
        assert SaturateHydrogensManual.analyze_selection(parameters)
        SaturateHydrogensManual(parameters)
Exemple #31
0
 def default_parameters(cls):
     result = Parameters()
     result.n = 5
     result.m = 1
     result.flat = False
     result.max_length = 50*angstrom
     result.max_error = 0.01*angstrom
     result.tube_length = Undefined(50*angstrom)
     return result
Exemple #32
0
 def fn():
     FileNew = context.application.plugins.get_action("FileNew")
     FileNew()
     context.application.main.select_nodes([context.application.model.folder])
     AddFolder = context.application.plugins.get_action("AddFolder")
     assert AddFolder.analyze_selection()
     AddFolder()
     context.application.main.select_nodes([context.application.model.folder])
     AddNotes = context.application.plugins.get_action("AddNotes")
     assert AddNotes.analyze_selection()
     AddNotes()
     context.application.main.select_nodes([context.application.model.folder])
     SelectChildrenByExpression = context.application.plugins.get_action("SelectChildrenByExpression")
     parameters = Parameters()
     parameters.recursive = SelectChildrenByExpression.SELECT_PLAIN
     parameters.expression = Expression("isinstance(node, Folder)")
     assert SelectChildrenByExpression.analyze_selection(parameters)
     SelectChildrenByExpression(parameters)
     assert context.application.model.folder.children[0].selected
     assert not context.application.model.folder.children[1].selected
Exemple #33
0
 def default_parameters(cls):
     result = Parameters()
     result.number1 = 6
     result.number2 = 6
     result.distance = 0.5
     result.bond_type = BOND_SINGLE
     return result
Exemple #34
0
 def fn():
     context.application.model.file_open("test/input/silica_layer.zml")
     parameters = Parameters()
     parameters.n = 10
     parameters.m = 4
     parameters.flat = False
     parameters.max_length = 300*angstrom
     parameters.max_error = 0.01*angstrom
     parameters.tube_length = Undefined(0.01*angstrom)
     CreateTube = context.application.plugins.get_action("CreateTube")
     assert CreateTube.analyze_selection(parameters)
     CreateTube(parameters)
Exemple #35
0
    def fn():
        context.application.model.file_open("test/input/tpa.xyz")
        Atom = context.application.plugins.get_node("Atom")
        for child in context.application.model.universe.children[::-1]:
            if isinstance(child, Atom) and child.number == 1:
                context.application.model.universe.children.remove(child)
        context.application.main.select_nodes(
            [context.application.model.universe])
        AutoConnectPhysical = context.application.plugins.get_action(
            "AutoConnectPhysical")
        assert AutoConnectPhysical.analyze_selection()
        AutoConnectPhysical()

        parameters = Parameters()
        parameters.num_hydrogens = 2
        parameters.valence_angle = 1.9093

        context.application.main.select_nodes(
            [context.application.model.universe.children[1]])
        SaturateHydrogensManual = context.application.plugins.get_action(
            "SaturateHydrogensManual")
        assert SaturateHydrogensManual.analyze_selection(parameters)
        SaturateHydrogensManual(parameters)
Exemple #36
0
 def fn():
     context.application.model.file_open("test/input/lau.zml")
     context.application.main.select_nodes(
         [context.application.model.universe])
     parameters = Parameters()
     parameters.number1 = 14
     parameters.number2 = 14
     parameters.distance = 6.0
     parameters.bond_type = BOND_SINGLE
     AutoConnectParameters = context.application.plugins.get_action(
         "AutoConnectParameters")
     assert AutoConnectParameters.analyze_selection(parameters)
     AutoConnectParameters(parameters)
Exemple #37
0
    def fn():
        context.application.model.file_open("test/input/tpa.zml")
        universe = context.application.model.universe
        context.application.main.select_nodes([universe] + universe.children)
        parameters = Parameters()
        parameters.number1 = 6
        parameters.number2 = 6
        parameters.distance = 3.0
        parameters.bond_type = BOND_SINGLE
        AutoConnectParameters = context.application.plugins.get_action(
            "AutoConnectParameters")
        assert AutoConnectParameters.analyze_selection(parameters)
        AutoConnectParameters(parameters)

        Bond = context.application.plugins.get_node("Bond")
        num_bonds = sum(isinstance(node, Bond) for node in universe.children)
        assert num_bonds == 2 * 4
Exemple #38
0
 def default_parameters(cls):
     result = Parameters()
     result.matrix = context.application.model.universe.cell.matrix.copy()
     return result
Exemple #39
0
 def default_parameters(cls):
     result = Parameters()
     result.expression = Expression()
     result.recursive = cls.SELECT_PLAIN
     return result
Exemple #40
0
    def default_parameters(cls):
        rotation2 = Rotation.from_properties(0.0, [1, 0, 0], False)

        result = Parameters()
        result.connect_description1 = (Expression("True"),
                                       Expression("node.get_radius()"))
        result.repulse_description1 = (Expression("True"),
                                       Expression("node.get_radius()"))
        result.connect_description2 = (Expression("True"),
                                       Expression("node.get_radius()"))
        result.repulse_description2 = (Expression("True"),
                                       Expression("node.get_radius()"))
        result.action_radius = 7 * angstrom
        result.distance_tolerance = 0.1 * angstrom
        result.hit_tolerance = 0.1 * angstrom
        result.allow_inversions = True
        result.minimum_triangle_size = 0.1 * angstrom
        result.rotation_tolerance = 0.05
        result.rotation2 = Undefined(rotation2)
        return result
Exemple #41
0
 def default_parameters(cls):
     result = Parameters()
     result.num_hydrogens = 2
     result.valence_angle = 109.4 * deg
     return result
Exemple #42
0
 def default_parameters(cls):
     result = Parameters()
     result.matrix = context.application.model.universe.cell.matrix.copy()
     return result
Exemple #43
0
 def default_parameters(cls):
     result = Parameters()
     result.center = numpy.zeros(3, float)
     result.normal = numpy.zeros(3, float)
     return result
Exemple #44
0
 def default_parameters(cls):
     result = Parameters()
     result.allow_rotation = True
     result.update_interval = 0.4
     result.update_steps = 1
     return result
Exemple #45
0
 def default_parameters(cls):
     result = Parameters()
     result.center = Translation.identity()
     result.rotation = Rotation.identity()
     return result
Exemple #46
0
 def default_parameters(cls):
     result = Parameters()
     result.translation = Translation.identity()
     return result
Exemple #47
0
 def default_parameters(cls):
     result = Parameters()
     result.center = numpy.zeros(3, float)
     result.normal = numpy.zeros(3, float)
     return result
Exemple #48
0
 def default_parameters(cls):
     result = Parameters()
     result.expression = Expression()
     result.recursive = cls.SELECT_PLAIN
     return result