SUBROUTINE CreateDoubExcitBiased(nI, nJ, iLut, ExcitMat, tParity, nParts, WSign, Tau, iCreate)
INTEGER :: nI(NEl), nJ(NEl), ExcitMat(2, maxExcit), iCreate, iSpn, OrbA, OrbB, SymProduct
INTEGER(KIND=n_int) :: iLut(0:NIfTot)
INTEGER :: Elec1Ind, Elec2Ind, nParts, SumMl
REAL(dp) :: WSign
HElement_t(dp) :: rh
LOGICAL :: tParity
real(dp) :: Tau
!First, we need to pick an unbiased distinct electron pair.
!These have symmetry product SymProduct, and spin pair iSpn = 1=beta/beta; 2=alpha/beta; 3=alpha/alpha
!The probability for doing this is 1/ElecPairs.
CALL PickElecPair(nI, Elec1Ind, Elec2Ind, SymProduct, iSpn, SumMl, -1)
!This routine runs through all distinct ab pairs for the chosen ij and stochastically chooses how many particles to create.
!If spawning wants to occur, then it runs through the list again and chooses a pair, which it returns.
CALL CalcAllab(nI, iLut, Elec1Ind, Elec2Ind, SymProduct, iSpn, OrbA, OrbB, nParts, iCreate, Tau)
if (tGUGA) then
call stop_all("CreateDoubExcitBiased", &
"modify get_helement for GUGA")
end if
!We now know that we want to create iCreate particles, from orbitals nI(Elec1/2Ind) -> OrbA + OrbB.
IF (iCreate > 0) THEN
call make_double(nI, nJ, elec1ind, elec2ind, orbA, orbB, &
ExcitMat, tParity)
!Once we have the definitive determinant, we also want to find out what sign the particles we want to create are.
!iCreate is initially positive, so its sign can change depending on the sign of the connection and of the parent particle(s)
rh = get_helement(nI, nJ, 2, ExcitMat, tParity)
IF (WSign > 0) THEN
!Parent particle is positive
IF (real(rh, dp) > 0.0_dp) THEN
iCreate = -iCreate !-ve walker created
end if
ELSE
IF (real(rh, dp) < 0.0_dp) THEN
iCreate = -iCreate !-ve walkers created
end if
end if
end if
END SUBROUTINE CreateDoubExcitBiased