<commit_before>module hellmann_feynmann_sampling

! Module for performing Hellmann--Feynmann sampling in FCIQMC.

use const

use hfs_data

implicit none

contains

    subroutine init_hellmann_feynmann_sampling()

        ! Initialisation of HF sampling: setup parameters for the operators being
        ! sampled.

        use basis, only: basis_length, set_orb_mask

        integer :: ierr

        allocate(lmask(basis_length), stat=ierr)

        lmag2 = 1
        write (6,*) 'lmag2 = ', lmag2

        call set_orb_mask(lmag2, lmask)

    end subroutine init_hellmann_feynmann_sampling

    subroutine do_hfs_fciqmc(decoder, update_proj_energy, spawner, sc0)

        ! Run the FCIQMC algorithm starting from the initial walker
        ! distribution and perform Hellmann--Feynmann sampling in conjunction on
        ! the instantaneous wavefunction.

        ! This is implemented by abusing fortran's ability to pass procedures as
        ! arguments (if only function pointers (F2003) were implemented in more
        ! compilers!).  This allows us to avoid many system dependent if blocks,
        ! which are constant for a given calculation.  Avoiding such branching
        ! is worth the extra verbosity (especially if procedures are written to
        ! be sufficiently modular that implementing a new system can reuse many<commit_msg>Initialise <D_0|O|D_0>.<commit_after>module hellmann_feynmann_sampling

! Module for performing Hellmann--Feynmann sampling in FCIQMC.

use const

use hfs_data

implicit none

contains

    subroutine init_hellmann_feynmann_sampling()

        ! Initialisation of HF sampling: setup parameters for the operators being
        ! sampled.

        use basis, only: basis_length, set_orb_mask
        use fciqmc_data, only: D0_proc, f0, walker_energies, tot_walkers
        use hfs_data, only: lmask
        use operators, only: calc_orb_occ
        use parallel, only: iproc

        integer :: ierr

        allocate(lmask(basis_length), stat=ierr)

        lmag2 = 1
        write (6,*) 'lmag2 = ', lmag2

        call set_orb_mask(lmag2, lmask)

        if (iproc == D0_proc) then
            walker_energies(2,tot_walkers) = calc_orb_occ(f0, lmask)
        end if

    end subroutine init_hellmann_feynmann_sampling

    subroutine do_hfs_fciqmc(decoder, update_proj_energy, spawner, sc0)

        ! Run the FCIQMC algorithm starting from the initial walker
        ! distribution and perform Hellmann--Feynmann sampling in conjunction on
        ! the instantaneous wavefunction.

        ! This is implemented by abusing fortran's ability to pass procedures as
        ! arguments (if only function pointers (F2003) were implemented in more
        ! compilers!).  This allows us to avoid many system dependent if blocks,
        ! which are constant for a given calculation.  Avoiding such branching
        ! is worth the extra verbosity (especially if procedures are written to
        ! be sufficiently modular that implementing a new system can reuse many
{'fraction_non_alphanumeric': 0.050746268656716415, 'fraction_numerical': 0.009618573797678276, 'mean_word_length': 3.0106382978723403, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '67841', 'n_tokens_mistral': 890, 'n_tokens_neox': 827, 'n_words': 306}