setup_spin_free_exchange Subroutine

private subroutine setup_spin_free_exchange(in_lat)

Arguments

Type IntentOptional Attributes Name
class(lattice), intent(in), pointer :: in_lat

Contents


Source Code

    subroutine setup_spin_free_exchange(in_lat)
        ! spin-free version of the exchange matrix
        class(lattice), intent(in), pointer :: in_lat
        character(*), parameter :: this_routine = "setup_spin_free_exchange"

        integer :: i, ind, iunit

        ASSERT(associated(in_lat))

        if (allocated(spin_free_exchange)) deallocate(spin_free_exchange)
        allocate(spin_free_exchange(nBasis / 2, nBasis / 2), source=0.0_dp)

        ASSERT(in_lat%get_nsites() == nBasis / 2)

        iunit = get_free_unit()
        open(iunit, file = 'spatial-exchange', status = 'replace')

        do i = 1, in_lat%get_nsites()
            ind = in_lat%get_site_index(i)

            ASSERT(ind > 0)
            ASSERT(ind <= nBasis / 2)

            associate(next => in_lat%get_neighbors(ind))
                ASSERT(all(next > 0))
                ASSERT(all(next <= nBasis / 2))

                ! in the spin-free form I have to divide by one 1/2 more!
                spin_free_exchange(ind, next) = -exchange_j / 2.0_dp
                write(iunit, *) ind, next, -exchange_j / 2.0_dp

            end associate

        end do

        close(iunit)

    end subroutine setup_spin_free_exchange