adjust_nRefs Subroutine

public subroutine adjust_nRefs()

Arguments

None

Contents

Source Code


Source Code

    subroutine adjust_nRefs()
        ! update the number of SIs used
        use adi_data, only: targetRefPopTol, tSingleSteps
        use FciMCData, only: AllNoatHF
        implicit none
        real(dp) :: cAllNoatHF
        integer :: nRefsOld

        if (tVariableNRef) then

            nRefsOld = nRefs
            ! average reference population
            cAllNoatHF = sum(AllNoatHF) / inum_runs
            ! check if we reached the destination
            if (abs(targetRefPop - cAllNoatHF) < targetRefPopTol) return

            if (tSingleSteps) then
                if (cAllNoatHF < targetRefPop) then
                    ! we cannot go below 0 SIs, if we hit 0, disable the adi option
                    if (nRefs > 1) then
                        nRefs = nRefs - 1
                    else
                        ! might change the behaviour here, to whatever makes sense
                        tAdiActive = .false.
                    end if
                end if
                if (cAllNoatHF > targetRefPop) nRefs = nRefs + 1
                tSingleSteps = .false.
            else
                ! do the extrapolationx
                nRefs = guess_target_nref()
            end if

            ! store the current values for the next step
            lastAllNoatHF = cAllNoatHF
            lastNRefs = nRefsOld

            write(stdout, *) "Now at ", nRefs, " superinitiators"

        end if
    end subroutine adjust_nRefs