init_sites_ole Subroutine

private subroutine init_sites_ole(this)

Type Bound

ole

Arguments

Type IntentOptional Attributes Name
class(ole) :: this

Contents

Source Code


Source Code

    subroutine init_sites_ole(this)
        class(ole) :: this

        ! i think i can index an array in fortran in reversed order
        integer :: ind_array(-this%length(1):(this%length(1) + 1), &
                             -this%length(2):this%length(1))

        integer :: i, j, k, mat_ind(this%n_sites, 2), up, down, left, right, &
                   k_vec(3), A(2), B(2), C(2), D(2), k_vec_prep(24, 3)
        integer, allocatable :: neigh(:)

        ! how do i set up Ole cluster..
        ! in real and k-space.. this will be a pain i guess..

        ! i could make the same neighboring matrices as for the tilted
        k = 1
        ind_array = 0
        ! define the vertices of the parallelogram
        A = [-this%length(2), 0]
        B = [0, -this%length(1)]
        C = [this%length(1), 0]
        D = [this%length(1) - this%length(2), this%length(1)]

        ! i do not need to loop over the edge values, which belong to a
        ! different unit cell!
        do j = -this%length(2) + 1, this%length(1) - 1
            do i = this%length(1) - 1, -(this%length(1) + 1), -1

                ! i have to take 2 special points into account ! which are
                ! by definition on the edge of the (3,3) boundary
                if (inside_bz_2d(j, i, A, B, C, D) .and. .not. on_line_2d([j, i], A, D) &
                    .and. .not. on_line_2d([j, i], C, D)) then

                    ind_array(-i, j) = k
                    mat_ind(k, :) = [-i, j]

                    k = k + 1

                end if
            end do
        end do

        k_vec_prep(1, :) = [1, -3, 0]
        k_vec_prep(2, :) = [-2, 1, 0]
        k_vec_prep(3, :) = [-2, 0, 0]

        k_vec_prep(4, :) = [-1, 2, 0]
        k_vec_prep(5, :) = [-1, 1, 0]
        k_vec_prep(6, :) = [-1, 0, 0]
        k_vec_prep(7, :) = [-1, -1, 0]
        k_vec_prep(8, :) = [-1, -2, 0]

        k_vec_prep(9, :) = [0, 3, 0]
        k_vec_prep(10, :) = [0, 2, 0]
        k_vec_prep(11, :) = [0, 1, 0]
        k_vec_prep(12, :) = [0, 0, 0]
        k_vec_prep(13, :) = [0, -1, 0]
        k_vec_prep(14, :) = [0, -2, 0]
        k_vec_prep(15, :) = [0, -3, 0]

        k_vec_prep(16, :) = [1, 2, 0]
        k_vec_prep(17, :) = [1, 1, 0]
        k_vec_prep(18, :) = [1, 0, 0]
        k_vec_prep(19, :) = [1, -1, 0]
        k_vec_prep(20, :) = [1, -2, 0]

        k_vec_prep(21, :) = [2, 0, 0]
        k_vec_prep(22, :) = [2, -1, 0]
        k_vec_prep(23, :) = [2, -2, 0]

        k_vec_prep(24, :) = [3, -1, 0]

        ! now i want to get the neigbhors
        do i = 1, this%get_nsites()
            ! how to efficiently do this, and in a general way?
            ! better than in the other cases
            ! i am not going over the boundaries, due to the way i set up
            ! the matrix above.. hopefully
            up = ind_array(mat_ind(i, 1) - 1, mat_ind(i, 2))
            if (up == 0) then
                up = this%find_periodic_neighbors([mat_ind(i, 1) - 1, mat_ind(i, 2)], &
                                                  ind_array)
            end if

            down = ind_array(mat_ind(i, 1) + 1, mat_ind(i, 2))
            if (down == 0) then
                down = this%find_periodic_neighbors([mat_ind(i, 1) + 1, mat_ind(i, 2)], &
                                                    ind_array)
            end if

            left = ind_array(mat_ind(i, 1), mat_ind(i, 2) - 1)
            if (left == 0) then
                left = this%find_periodic_neighbors([mat_ind(i, 1), mat_ind(i, 2) - 1], &
                                                    ind_array)
            end if

            right = ind_array(mat_ind(i, 1), mat_ind(i, 2) + 1)
            if (right == 0) then
                right = this%find_periodic_neighbors([mat_ind(i, 1), mat_ind(i, 2) + 1], &
                                                     ind_array)
            end if

            neigh = sort_unique([up, down, left, right])

            ! i have to get the matrix indiced again, with the correct
            ! sign..
            if (this%get_nsites() == 24) then
                k_vec = k_vec_prep(i, :)
            else
                k_vec = [mat_ind(i, 2), -mat_ind(i, 1), 0]
            end if

            this%sites(i) = site(i, size(neigh), neigh, k_vec)

        end do

    end subroutine init_sites_ole