コード例 #1
0
ファイル: KMCLatticeTest.py プロジェクト: zqhuang2014/KMCLib
    def testLatticeMap(self):
        """ Check that we can get a valid lattice map out. """
        cell_vectors = [[2.3, 0.0, 0.0], [2.4, 3.0, 0.0], [0.0, 0.0, 11.8]]

        basis_points = [[0.0, 0.0, 0.0], [0.5, 0.5, 0.0]]

        unit_cell = KMCUnitCell(cell_vectors=cell_vectors,
                                basis_points=basis_points)

        # Setup the repetitions.
        nI = 2
        nJ = 12
        nK = 3
        nB = 2
        repetitions = (nI, nJ, nK)
        periodic = (True, True, False)

        # Construct the KMCLattice object.
        lattice = KMCLattice(unit_cell=unit_cell,
                             repetitions=repetitions,
                             periodic=periodic)

        # Get the lattice map.
        cpp_lattice_map = lattice._map()

        # Check the type.
        self.assertTrue(isinstance(cpp_lattice_map, Backend.LatticeMap))

        # Get it again and check that we get the same instance.
        cpp_lattice_map2 = lattice._map()

        # Check the instance.
        self.assertTrue(cpp_lattice_map == cpp_lattice_map2)
コード例 #2
0
    def testLatticeMap(self):
        """ Make sure the lattice map we get correspond to the lattice we give. """
        # 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 lattice map.
        cpp_lattice_map = config._latticeMap()

        # Get the map from the lattice.
        cpp_lattice_map_ref = lattice._map()

        # Check that these two are references to the same underlying object.
        self.assertTrue(cpp_lattice_map == cpp_lattice_map_ref)
コード例 #3
0
ファイル: KMCLatticeTest.py プロジェクト: PytLab/KMCLib
    def testLatticeMap(self):
        """ Check that we can get a valid lattice map out. """
        cell_vectors = [[2.3, 0.0, 0.0],
                        [2.4, 3.0, 0.0],
                        [0.0, 0.0, 11.8]]

        basis_points = [[0.0, 0.0, 0.0],
                        [0.5, 0.5, 0.0]]

        unit_cell = KMCUnitCell(cell_vectors=cell_vectors,
                                basis_points=basis_points)

        # Setup the repetitions.
        nI = 2
        nJ = 12
        nK = 3
        nB = 2
        repetitions = (nI,nJ,nK)
        periodic = (True,True,False)

        # Construct the KMCLattice object.
        lattice = KMCLattice(unit_cell=unit_cell,
                             repetitions=repetitions,
                             periodic=periodic)

        # Get the lattice map.
        cpp_lattice_map = lattice._map()

        # Check the type.
        self.assertTrue(isinstance(cpp_lattice_map, Backend.LatticeMap))

        # Get it again and check that we get the same instance.
        cpp_lattice_map2 = lattice._map()

        # Check the instance.
        self.assertTrue(cpp_lattice_map == cpp_lattice_map2)
コード例 #4
0
ファイル: KMCConfigurationTest.py プロジェクト: PytLab/KMCLib
    def testLatticeMap(self):
        """ Make sure the lattice map we get correspond to the lattice we give. """
        # 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 lattice map.
        cpp_lattice_map = config._latticeMap()

        # Get the map from the lattice.
        cpp_lattice_map_ref = lattice._map()

        # Check that these two are references to the same underlying object.
        self.assertTrue(cpp_lattice_map == cpp_lattice_map_ref)