init_var_space Subroutine

private subroutine init_var_space(rep)

Arguments

Type IntentOptional Attributes Name
type(core_space_t), intent(in) :: rep

Contents

Source Code


Source Code

    subroutine init_var_space(rep)

        ! Initialize data needed for the determ-proj-approx-hamil option.
        ! This basically does a deterministic version of the simple-init
        ! option, i.e. it uses the full Hamiltonian in the main 'variational'
        ! space, and just the rectangular block of the Hamiltonian connecting
        ! the vartiational space to the connected space.

        ! To be able to set up this Hamiltonian, we need a way of checking
        ! whether a given state in the full deterministic space is also within
        ! the smaller variational space. To do this, we need a hash table to
        ! the variational space. The following sets that up.

        ! After this has table (var_ht) is created, then generate the
        ! approximate Hamiltonian.

        type(core_space_t), intent(in) :: rep
        integer :: i, ierr
        integer(MPIArg) :: mpi_temp

        allocate(var_sizes(0:nProcessors - 1))
        allocate(var_displs(0:nProcessors - 1))
        var_sizes = 0_MPIArg

        mpi_temp = var_size_this_proc
        call MPIAllGather(mpi_temp, var_sizes, ierr)

        var_space_size = sum(var_sizes)
        var_space_size_int = int(var_space_size)

        var_displs(0) = 0
        do i = 1, nProcessors - 1
            var_displs(i) = var_displs(i - 1) + var_sizes(i - 1)
        end do

        ! var_space is the variational space from all processes stuck together.
        allocate(var_space(0:NIfTot, var_space_size), stat=ierr)
        call MPIAllGatherV(temp_var_space(0:NIfTot, 1:var_sizes(iProcIndex)), &
                           var_space, var_sizes, var_displs)

        call initialise_shared_rht(var_space, var_space_size_int, var_ht)

        write(stdout, '("Generating the approximate Hamiltonian...")'); call neci_flush(stdout)
        if (tHPHF) then
            call calc_approx_hamil_sparse_hphf(rep)
        else
            call stop_all("init_var_space", "Not implemented yet.")
        end if

    end subroutine init_var_space