Store neutrals in reservoir
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(NeutralParticleReservoir), | intent(inout) | :: | res | beam_grid indices |
||
real(kind=Float64), | intent(in), | dimension(3) | :: | vn | Neutral particle velocity [cm/s] |
|
real(kind=Float64), | intent(in) | :: | wght | Neutral weight |
subroutine update_reservoir(res, vn, wght)
!+ Store neutrals in reservoir
type(NeutralParticleReservoir), intent(inout) :: res
!+ [[libfida:beam_grid]] indices
real(Float64), dimension(3), intent(in) :: vn
!+ Neutral particle velocity [cm/s]
real(Float64), intent(in) :: wght
!+ Neutral weight
integer, dimension(1) :: randomi
real(Float64), dimension(2) :: randomu
!print*, res%n, res%k, res%i
!$OMP CRITICAL(update_reservoir_1)
if (res%n.le.res%k) then
if (res%n.le.0) then
call init_reservoir(res)
endif
res%R(res%n)%w = wght
res%R(res%n)%v = vn
elseif (res%n.eq.res%i) then
call randind(res%k, randomi)
res%R(randomi(1)) = NeutralParticle(wght, vn)
call randu(randomu)
res%W = res%W*exp(log(randomu(1))/res%k)
res%i = res%i + floor(log(randomu(2))/log(1.0-res%W)) + 1
endif
res%n = res%n + 1
!$OMP END CRITICAL(update_reservoir_1)
end subroutine update_reservoir