subroutine add_permutations_to_pgen(pgen, pgen_pick, pool_sizes, ms, tgt, cc_unocc)
real(dp), intent(inout) :: pgen
real(dp), intent(inout) :: pgen_pick
integer, intent(in) :: pool_sizes(3), ms, tgt(3), cc_unocc(ScratchSize)
integer :: swap_pool_size, spin_ind, cc_ind, i
integer :: irreps(3)
do i = 1, 3
irreps(i) = int(G1(tgt(i))%Sym%S)
end do
! adjust the probability by taking permutations into account
! these depend on the spin
if (abs(ms) == 1) then
! We can only swap the first two electrons => factor of two
pgen_pick = pgen_pick * 2
else
! The first two could have been picked in any order
pgen_pick = pgen_pick * 2
! get the spin index. Convention: 1 == alpha, 2 == beta
if (ms > 0) then
spin_ind = 1
else
spin_ind = 2
end if
! Either the first or the second might have been chosen last as well
do i = 1, 2
! The first might have been the last orb
cc_ind = ClassCountInd(spin_ind, irreps(i), 0)
swap_pool_size = cc_unocc(cc_ind)
! Check if the first irrep appears multiple times (shrinks pool)
if (irreps(i) == irreps(mod(i, 3) + 1)) swap_pool_size = swap_pool_size - 1
if (irreps(i) == irreps(mod(i + 1, 3) + 1)) swap_pool_size = swap_pool_size - 1
! The first two could have been picked in any order (same pool_size as above)
pgen_pick = pgen_pick + 2.0_dp * pgen / (pool_sizes(1)) * 1.0_dp / (pool_sizes(2)) &
* 1.0_dp / (swap_pool_size)
end do
end if
pgen = pgen_pick
end subroutine add_permutations_to_pgen