Ejemplo n.º 1
0
    def test_lattice_get_unique_sites_squaregeom(self):
        """
        Test ed_geometry.Lattice.get_unique_sites for a square lattice
        :return:
        """
        latt_vect1 = np.array([1, 0])
        latt_vect2 = np.array([0, 1])
        periodicity_vect1 = np.array([3, 0])
        periodicity_vect2 = np.array([0, 3])
        basis_vects = [np.array([[0.], [0.]])]
        phase1 = 0
        phase2 = 0
        latt = ed_geometry.Lattice(latt_vect1, latt_vect2, basis_vects,
                                   periodicity_vect1, periodicity_vect2,
                                   phase1, phase2)

        nsites, xlocs, ylocs = latt.get_unique_sites()

        nsites_expected = 9
        xlocs_expected = np.array([0., 0., 0., 1., 1., 1., 2., 2., 2.])
        ylocs_expected = np.array([0., 1., 2., 0., 1., 2., 0., 1., 2.])
        correct_sites = nsites == nsites_expected and \
                        np.array_equal(xlocs, xlocs_expected) and \
                        np.array_equal(ylocs, ylocs_expected)
        self.assertTrue(correct_sites)
Ejemplo n.º 2
0
    def test_lattice_reduce_to_unit_cell(self):
        """
        Test ed_geometry.Lattice.reduce_to_unit_cell
        :return:
        """
        latt_vect1 = np.array([1, 0])
        latt_vect2 = np.array([0, 1])
        basis_vects = [np.array([[0.], [0.]])]
        periodicity_vect1 = np.array([3, 1])
        periodicity_vect2 = np.array([-1, 3])
        phase1 = 0
        phase2 = 0
        latt = ed_geometry.Lattice(latt_vect1, latt_vect2, basis_vects,
                                   periodicity_vect1, periodicity_vect2,
                                   phase1, phase2)

        xlocs_test = [0., 1., 2., 3., 4., 5., 6., 7., 8.]
        ylocs_test = [0., 0., 0., 0., 0., 0., 0., 0., 0.]
        xs_reduced, ys_reduced, n1s, n2s = latt.reduce_to_unit_cell(
            xlocs_test, ylocs_test, mode='positive')

        xs_reduced_expected = np.array([0., 0., 1., 2., 0., 1., 2., 0., 1.])
        ys_reduced_expected = np.array([0., 3., 3., 3., 2., 2., 2., 1., 1.])
        n1s_expected = np.array([[0., 0., 0, 0., 1., 1., 1., 2., 2.]])
        n2s_expected = np.array([[0., -1., -1., -1., -1., -1., -1., -1., -1.]])

        self.assertTrue(
            np.array_equal(xs_reduced, xs_reduced_expected)
            and np.array_equal(ys_reduced, ys_reduced_expected)
            and np.array_equal(n1s, n1s_expected)
            and np.array_equal(n2s, n2s_expected))
Ejemplo n.º 3
0
    def test_lattice_get_reduced_distance(self):
        """
        Test ed_geometry.Lattice.get_reduced_distances for a 1D chain
        :return:
        """
        num_sites = 7

        latt_vect1 = np.array([1, 0])
        latt_vect2 = np.array([0, 1])
        basis_vects = [np.array([[0.], [0.]])]
        periodicity_vect1 = np.array([num_sites, 0])
        periodicity_vect2 = np.array([0, 0])
        phase1 = 0.333
        phase2 = 0.
        bc1_open = False
        bc2_open = True
        latt = ed_geometry.Lattice(latt_vect1, latt_vect2, basis_vects,
                                   periodicity_vect1, periodicity_vect2,
                                   phase1, phase2)

        nsites, xlocs, ylocs = latt.get_unique_sites()
        # xdist_min_mat, ydist_min_mat, dist_reduced_multiplicity = \
        #     latt.get_reduced_distance(xlocs, ylocs)
        xdist_min_mat, ydist_min_mat, _, _ = latt.get_reduced_distance(
            xlocs, ylocs)

        xi, xj = np.meshgrid(np.arange(0, num_sites), np.arange(0, num_sites))
        xdist_exp = xj - xi
        xdist_exp[xdist_exp < -num_sites /
                  2.] = xdist_exp[xdist_exp < -num_sites / 2.] + num_sites
        xdist_exp[xdist_exp > num_sites /
                  2.] = xdist_exp[xdist_exp > num_sites / 2.] - num_sites

        self.assertTrue(np.array_equal(xdist_min_mat, xdist_exp))
Ejemplo n.º 4
0
    def test_lattice_get_unique_sites_triangle_geom(self):
        """
        Test ed_geometry.Lattice.get_unique_sites for a triangular lattice
        :return:
        """
        latt_vect1 = np.array([1, 0])
        latt_vect2 = np.array([0.5, np.sqrt(3) / 2])
        basis_vects = [np.array([[0.], [0.]])]
        periodicity_vect1 = 3 * latt_vect1
        periodicity_vect2 = 3 * latt_vect2
        phase1 = 0
        phase2 = 0
        latt = ed_geometry.Lattice(latt_vect1, latt_vect2, basis_vects,
                                   periodicity_vect1, periodicity_vect2,
                                   phase1, phase2)

        nsites, xlocs, ylocs = latt.get_unique_sites()

        nsites_expected = 9
        xlocs_expected = np.array([0., 0.5, 1., 1., 1.5, 2., 2., 2.5, 3.])
        ylocs_expected = np.array([
            0.,
            np.sqrt(3) / 2, 0.,
            np.sqrt(3),
            np.sqrt(3) / 2, 0.,
            np.sqrt(3),
            np.sqrt(3) / 2,
            np.sqrt(3)
        ])

        self.assertTrue(
            nsites == nsites_expected
            and np.round(np.abs(xlocs - xlocs_expected).max(), 12) == 0
            and np.round(np.abs(ylocs - ylocs_expected).max(), 12) == 0)
Ejemplo n.º 5
0
    def test_lattice_get_unique_sites_tiltedgeom(self):
        """
        Test ed_geometry.Lattice.get_unique_sites for a square lattice with periodicity vectors that are not colinear
        with the lattice vectors.
        :return:
        """
        latt_vect1 = np.array([1, 0])
        latt_vect2 = np.array([0, 1])
        basis_vects = [np.array([[0.], [0.]])]
        periodicity_vect1 = np.array([3, 1])
        periodicity_vect2 = np.array([-1, 3])
        phase1 = 0
        phase2 = 0
        latt = ed_geometry.Lattice(latt_vect1, latt_vect2, basis_vects,
                                   periodicity_vect1, periodicity_vect2,
                                   phase1, phase2)

        nsites, xlocs, ylocs = latt.get_unique_sites()

        nsites_expected = 10
        xlocs_expected = np.array([0., 0., 0., 0., 1., 1., 1., 2., 2., 2.])
        ylocs_expected = np.array([0., 1., 2., 3., 1., 2., 3., 1., 2., 3.])
        correct_sites = nsites == nsites_expected and \
                        np.array_equal(xlocs, xlocs_expected) and \
                        np.array_equal(ylocs, ylocs_expected)
        self.assertTrue(correct_sites)
Ejemplo n.º 6
0
    def test_lattice_get_phase_mat(self):
        latt_vect1 = np.array([1, 0])
        latt_vect2 = np.array([0, 0])
        basis_vects = [np.array([[0.], [0.]])]
        periodicity_vect1 = np.array([6, 0])
        periodicity_vect2 = np.array([0, 0])
        phase1 = 0.333
        phase2 = 0.
        bc1_open = False
        bc2_open = True
        latt = ed_geometry.Lattice(latt_vect1, latt_vect2, basis_vects,
                                   periodicity_vect1, periodicity_vect2,
                                   phase1, phase2)

        nsites, xlocs, ylocs = latt.get_unique_sites()
        xdist_min_mat, ydist_min_mat, _, _ = \
            latt.get_reduced_distance(xlocs, ylocs)

        phase_mat = latt.get_phase_mat(xdist_min_mat, ydist_min_mat)

        phase_mat_expected = 0
        #phase_mat_expected = np.exp(1j * phase1 * )

        self.assertTrue(np.array_equal(phase_mat, phase_mat_expected))