コード例 #1
0
ファイル: KMCConfigurationTest.py プロジェクト: PytLab/KMCLib
    def notestTypesBucketFormat(self):
        """ Test that the configuration accepts the bucket input format. """
        # Define the unit cell.
        unit_cell = KMCUnitCell(cell_vectors=numpy.array([[2.1,0.0,0.0],
                                                          [0.0,1.0,0.0],
                                                          [0.0,0.0,1.0]]),
                                basis_points=[[0.0,0.0,0.0]])

        # And a lattice.
        lattice = KMCLattice(unit_cell=unit_cell,
                             repetitions=(10,1,1),
                             periodic=(True,False,False))

        # Populate the lattice with types.
        types = [(2,"A"),
                 "B",
                 ["B", "B", "A"],
                 ["B", (2,"A")],
                 "B",
                 "empty",
                 [(3,"A")],
                 [(1,"B"), "A"],
                 [(2,"A")],
                 "empty"]

        # Setup the configuration.
        config = KMCConfiguration(lattice=lattice,
                                  types=types,
                                  possible_types=['A','B','empty'])

        # Retrieve the types information from the configuration backend.
        # FXME: NEEDS IMPLEMENTATION
        print config.types()
コード例 #2
0
    def notestTypesBucketFormat(self):
        """ Test that the configuration accepts the bucket input format. """
        # Define the unit cell.
        unit_cell = KMCUnitCell(cell_vectors=numpy.array([[2.1, 0.0, 0.0],
                                                          [0.0, 1.0, 0.0],
                                                          [0.0, 0.0, 1.0]]),
                                basis_points=[[0.0, 0.0, 0.0]])

        # And a lattice.
        lattice = KMCLattice(unit_cell=unit_cell,
                             repetitions=(10, 1, 1),
                             periodic=(True, False, False))

        # Populate the lattice with types.
        types = [(2, "A"), "B", ["B", "B", "A"], ["B", (2, "A")], "B", "empty",
                 [(3, "A")], [(1, "B"), "A"], [(2, "A")], "empty"]

        # Setup the configuration.
        config = KMCConfiguration(lattice=lattice,
                                  types=types,
                                  possible_types=['A', 'B', 'empty'])

        # Retrieve the types information from the configuration backend.
        # FXME: NEEDS IMPLEMENTATION
        print config.types()
コード例 #3
0
    def testConstructionLongFormat(self):
        """ Test that the KMCConfiguration class can be constructed with the long types format. """

        # Setup a valid KMCUnitCell.
        unit_cell = KMCUnitCell(cell_vectors=numpy.array([[2.8, 0.0, 0.0],
                                                          [0.0, 3.2, 0.0],
                                                          [0.0, 0.5, 3.0]]),
                                basis_points=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5],
                                              [0.25, 0.25, 0.75]])

        # Setup the lattice.
        lattice = KMCLattice(unit_cell=unit_cell,
                             repetitions=(4, 3, 2),
                             periodic=(True, True, False))

        types = [(0, 0, 0, 0, 'g'), (3, 2, 1, 2, 'h')]
        default_type = 'a'

        # Setup the configuration.
        config = KMCConfiguration(lattice=lattice,
                                  types=types,
                                  default_type=default_type)

        # Get the types information out.
        ret_types = config.types()

        ref_types = [
            'g', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
            'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
            'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
            'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
            'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
            'a', 'a', 'a', 'a', 'a', 'a', 'h'
        ]

        # Check that they are what we inserted.
        self.assertEqual(ref_types, ret_types)

        # Check that the possible types are what we expect.
        self.assertEqual(set(['a', 'g', 'h', '*']),
                         set(config._KMCConfiguration__possible_types))

        # Check that the number of lattice sites corresponds
        # to the lattice.
        self.assertEqual(config._KMCConfiguration__n_lattice_sites,
                         len(lattice.sites()))

        # Construct again, now with a list of possible types.
        config = KMCConfiguration(lattice=lattice,
                                  types=types,
                                  default_type=default_type,
                                  possible_types=['aa', 'a', 'h', 'g'])

        # Check that the possible types are what we expect.
        self.assertEqual(set(['aa', 'a', 'g', 'h', '*']),
                         set(config._KMCConfiguration__possible_types))
コード例 #4
0
ファイル: KMCConfigurationTest.py プロジェクト: PytLab/KMCLib
    def testConstructionLongFormat(self):
        """ Test that the KMCConfiguration class can be constructed with the long types format. """

        # Setup a valid KMCUnitCell.
        unit_cell = KMCUnitCell(cell_vectors=numpy.array([[2.8,0.0,0.0],
                                                          [0.0,3.2,0.0],
                                                          [0.0,0.5,3.0]]),
                                basis_points=[[0.0,0.0,0.0],
                                              [0.5,0.5,0.5],
                                              [0.25,0.25,0.75]])

        # Setup the lattice.
        lattice = KMCLattice(unit_cell=unit_cell,
                             repetitions=(4,3,2),
                             periodic=(True,True,False))

        types = [(0,0,0,0,'g'),(3,2,1,2,'h')]
        default_type = 'a'

        # Setup the configuration.
        config = KMCConfiguration(lattice=lattice,
                                  types=types,
                                  default_type=default_type)

        # Get the types information out.
        ret_types = config.types()

        ref_types = ['g', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
                     'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
                     'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
                     'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
                     'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
                     'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
                     'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
                     'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a',
                     'a', 'a', 'a', 'a', 'a', 'a', 'a', 'h']

        # Check that they are what we inserted.
        self.assertEqual(ref_types, ret_types)

        # Check that the possible types are what we expect.
        self.assertEqual(set(['a','g','h','*']), set(config._KMCConfiguration__possible_types))

        # Check that the number of lattice sites corresponds
        # to the lattice.
        self.assertEqual(config._KMCConfiguration__n_lattice_sites, len(lattice.sites()))

        # Construct again, now with a list of possible types.
        config = KMCConfiguration(lattice=lattice,
                                  types=types,
                                  default_type=default_type,
                                  possible_types=['aa','a','h','g'])

        # Check that the possible types are what we expect.
        self.assertEqual(set(['aa','a','g','h','*']), set(config._KMCConfiguration__possible_types))
コード例 #5
0
    def testConstructionShortFormat(self):
        """ Test that the KMCConfiguration class can be constructed. """

        # Setup a valid KMCUnitCell.
        unit_cell = KMCUnitCell(cell_vectors=numpy.array([[2.8, 0.0, 0.0],
                                                          [0.0, 3.2, 0.0],
                                                          [0.0, 0.5, 3.0]]),
                                basis_points=[[0.0, 0.0, 0.0], [0.5, 0.5, 0.5],
                                              [0.25, 0.25, 0.75]])

        # Setup the lattice.
        lattice = KMCLattice(unit_cell=unit_cell,
                             repetitions=(4, 4, 1),
                             periodic=(True, True, False))

        types = [
            'a', 'a', 'a', 'a', 'b', 'b', 'a', 'a', 'a', 'b', 'b', 'b', 'b',
            'b', 'a', 'a', 'b', 'a', 'b', 'b', 'b', 'a', 'b', 'a', 'b', 'a',
            'a', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a', 'a', 'a',
            'a', 'b', 'b', 'b', 'b', 'a', 'b', 'b', 'a'
        ]

        # Setup the configuration.
        config = KMCConfiguration(lattice=lattice,
                                  types=types,
                                  possible_types=['a', 'c', 'b'])

        # Get the types information out.
        ret_types = config.types()

        # Check that they are what we inserted.
        self.assertEqual(types, ret_types)

        # Check that the possible types are what we expect.
        self.assertEqual(set(['a', 'c', 'b', '*']),
                         set(config._KMCConfiguration__possible_types.keys()))

        # Check that the number of lattice sites corresponds to the lattice.
        self.assertEqual(config._KMCConfiguration__n_lattice_sites,
                         len(lattice.sites()))

        # Check that the lattice site can be returned from the configuration.
        self.assertAlmostEqual(
            numpy.linalg.norm(
                numpy.array(config.sites()) - numpy.array(lattice.sites())),
            0.0, 10)

        # Construct without possible types and check that the list is set correctly
        # from the given types.
        config = KMCConfiguration(lattice=lattice, types=types)
        self.assertEqual(set(['a', 'b', '*']),
                         set(config._KMCConfiguration__possible_types.keys()))
コード例 #6
0
ファイル: KMCConfigurationTest.py プロジェクト: PytLab/KMCLib
    def testConstructionShortFormat(self):
        """ Test that the KMCConfiguration class can be constructed. """

        # Setup a valid KMCUnitCell.
        unit_cell = KMCUnitCell(cell_vectors=numpy.array([[2.8,0.0,0.0],
                                                          [0.0,3.2,0.0],
                                                          [0.0,0.5,3.0]]),
                                basis_points=[[0.0,0.0,0.0],
                                              [0.5,0.5,0.5],
                                              [0.25,0.25,0.75]])

        # Setup the lattice.
        lattice = KMCLattice(unit_cell=unit_cell,
                             repetitions=(4,4,1),
                             periodic=(True,True,False))

        types = ['a','a','a','a','b','b',
                 'a','a','a','b','b','b',
                 'b','b','a','a','b','a',
                 'b','b','b','a','b','a',
                 'b','a','a','a','b','b',
                 'b','b','b','b','b','b',
                 'a','a','a','a','b','b',
                 'b','b','a','b','b','a']

        # Setup the configuration.
        config = KMCConfiguration(lattice=lattice,
                                  types=types,
                                  possible_types=['a','c','b'])

        # Get the types information out.
        ret_types = config.types()

        # Check that they are what we inserted.
        self.assertEqual(types, ret_types)

        # Check that the possible types are what we expect.
        self.assertEqual(set(['a','c','b','*']), set(config._KMCConfiguration__possible_types.keys()))

        # Check that the number of lattice sites corresponds to the lattice.
        self.assertEqual(config._KMCConfiguration__n_lattice_sites, len(lattice.sites()))

        # Check that the lattice site can be returned from the configuration.
        self.assertAlmostEqual( numpy.linalg.norm(numpy.array(config.sites()) - numpy.array(lattice.sites())), 0.0, 10 )

        # Construct without possible types and check that the list is set correctly
        # from the given types.
        config = KMCConfiguration(lattice=lattice,
                                  types=types)
        self.assertEqual(set(['a','b','*']), set(config._KMCConfiguration__possible_types.keys()))