init_sites_chain Subroutine

private subroutine init_sites_chain(this)

Type Bound

chain

Arguments

Type IntentOptional Attributes Name
class(chain) :: this

Contents

Source Code


Source Code

    subroutine init_sites_chain(this)
        class(chain) :: this

        integer :: i, vec(3), j, n
        ! ok what exactly do i do here??
        ! and i think i want to write a constructor for the sites.. to do
        ! nice initialization for AIM sites etc.

        ! do i insist that other stuff is already set in the lattice type?
        ! or do i take it as input here?
        ! i think i inisist that it is set already!
        ! and i have to deal with the edge case of a one-sited lattice

        ! but how to i deal with the geometry here..
        ! i know it is a chain and i know how many sites and i know if it
        ! is periodic or not..
        ! so just create the "lattice"
        ! 1 - 2 - 3 - 4 - 5 - ...
        ! maybe us an associate structure here to not always type so much.

        ! deal with the first and last sites specifically!
        ! this initializes the site class with the index dummy variable:
        ! ok.. fortran does not really like arrays of pointers..
        ! i could make a workaround with yet another type or do i more
        ! explicit here ..

        if (this%t_bipartite_order) then
            if (t_input_order) then
                n = this%get_nsites()
                if (this%is_periodic()) then
                    vec = [-(this%length + 1) / 2 + orbital_order(1), 0, 0]
                    this%sites(orbital_order(1)) = site(orbital_order(1), 2, &
                        [orbital_order(n), orbital_order(2)], vec, vec)

                    vec = [this%length / 2, 0, 0]
                    this%sites(orbital_order(n)) = site(orbital_order(n), 2, &
                        [orbital_order(n-1), orbital_order(1)], vec, vec)


                else
                    vec = [-(this%length + 1) / 2 + orbital_order(1), 0, 0]
                    this%sites(orbital_order(1)) = site(orbital_order(1), 1, &
                        [orbital_order(2)], vec, vec)

                    vec = [this%length / 2, 0, 0]
                    this%sites(orbital_order(n)) = site(orbital_order(n), 1, &
                        [orbital_order(n-1)], vec, vec)

                end if

                ! and do the rest inbetween which is always the same
                do i = 2, this%get_nsites() - 1

                    vec = [-(this%length + 1) / 2 + orbital_order(i), 0, 0]
                    ! if periodic and first or last: already dealt with above
                    this%sites(orbital_order(i)) = site(orbital_order(i), &
                        N_CONNECT_MAX_CHAIN, [orbital_order(i-1),orbital_order(i + 1)], vec, vec)

                end do


            else
                if (this%is_periodic()) then

                    ! use more concise site contructors!
                    ! also encode k- and real-space vectors.. i have to get this right!
                    vec = [-(this%length + 1) / 2 + 1, 0, 0]

                    this%sites(1) = site(1, 2, &
                        [this%get_nsites(), this%get_nsites()/2 + 1], vec, vec)

                    vec = [this%length / 2, 0, 0]
                    this%sites(this%get_nsites()) = site(this%get_nsites(), 2, &
                                             [this%get_nsites()/2, 1], vec, vec)

                else
                    ! open boundary conditions:
                    ! first site:
                    this%sites(1) = site(1, 1, [this%get_nsites()/2 + 1], &
                                         [-(this%length + 1) / 2 + 1, 0, 0])

                    ! last site:
                    this%sites(this%get_nsites()) = site(this%get_nsites(), 1, &
                                         [this%get_nsites()/2], [this%length / 2, 0, 0])

                end if

                ! and do the rest inbetween which is always the same
                do i = 2, this%get_nsites()/2

                    vec = [-(this%length + 1) / 2 + 2 * i - 1, 0, 0]
                    ! if periodic and first or last: already dealt with above
                    this%sites(i) = site(i, N_CONNECT_MAX_CHAIN, &
                        [this%get_nsites()/2 + i - 1, this%get_nsites()/2 + i], vec, vec)

                end do

                j = 1
                do i = this%get_nsites()/2 + 1, this%get_nsites() - 1
                    vec = [-(this%length + 1) / 2 + 2*j , 0, 0]
                    ! if periodic and first or last: already dealt with above
                    this%sites(i) = site(i, N_CONNECT_MAX_CHAIN, &
                        [j, j + 1], vec, vec)

                    j = j + 1
                end do
            end if
        else
            if (this%get_nsites() == 1) then
                this%sites(1) = site(ind=1, n_neighbors=0, neighbors=[integer ::], &
                                     k_vec=[0, 0, 0], r_vec=[0, 0, 0])
                return
            end if

            if (this%is_periodic()) then
                ! use more concise site contructors!
                ! also encode k- and real-space vectors.. i have to get this right!
                vec = [-(this%length + 1) / 2 + 1, 0, 0]

                this%sites(1) = site(1, 2, [this%get_nsites(), 2], vec, vec)

                vec = [this%length / 2, 0, 0]
                this%sites(this%get_nsites()) = site(this%get_nsites(), 2, &
                                         [this%get_nsites() - 1, 1], vec, vec)

            else
                ! open boundary conditions:
                ! first site:
                this%sites(1) = site(1, 1, [2], &
                                     [-(this%length + 1) / 2 + 1, 0, 0])

                ! last site:
                this%sites(this%get_nsites()) = site(this%get_nsites(), 1, &
                             [this%get_nsites() - 1], [this%length / 2, 0, 0])

            end if

            ! and do the rest inbetween which is always the same
            do i = 2, this%get_nsites() - 1

                vec = [-(this%length + 1) / 2 + i, 0, 0]
                ! if periodic and first or last: already dealt with above
                this%sites(i) = site(i, N_CONNECT_MAX_CHAIN, [i - 1, i + 1], vec, vec)

            end do
        end if

    end subroutine init_sites_chain