Sample uniformally in passive grid cell
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in), | dimension(3) | :: | ind | Cell index |
|
real(kind=Float64), | intent(out), | dimension(3) | :: | ri | Position in cell |
subroutine mc_passive_grid(ind, ri)
!+ Sample uniformally in passive grid cell
integer, dimension(3), intent(in) :: ind
!+ Cell index
real(Float64), dimension(3), intent(out) :: ri
!+ Position in cell
real(Float64) :: rmin, rmax, zmin, phimin
real(Float64), dimension(3) :: randomu3, ri_cyl
call randu(randomu3)
rmin = pass_grid%r(ind(1))
rmax = rmin + pass_grid%dr
zmin = pass_grid%z(ind(2))
phimin = pass_grid%phi(ind(3))
! Sample uniformally in annulus
ri_cyl(1) = sqrt(randomu3(1)*(rmax**2 - rmin**2) + rmin**2)
ri_cyl(2) = zmin + randomu3(2)*pass_grid%dz
ri_cyl(3) = phimin + randomu3(3)*pass_grid%dphi
call cyl_to_uvw(ri_cyl, ri)
end subroutine mc_passive_grid