get_passive_grid_indices Subroutine

public subroutine get_passive_grid_indices(pos, ind, input_coords)

Find closest pass_grid indices ind to position pos

Arguments

TypeIntentOptionalAttributesName
real(kind=Float64), intent(in), dimension(3):: pos

Position [cm]

integer(kind=Int32), intent(out), dimension(3):: ind

Closest indices to position

integer, intent(in), optional :: input_coords

Indicates coordinate system of pos. Beam grid (0), machine (1) and cylindrical (2)


Calls

proc~~get_passive_grid_indices~~CallsGraph proc~get_passive_grid_indices get_passive_grid_indices proc~xyz_to_cyl xyz_to_cyl proc~get_passive_grid_indices->proc~xyz_to_cyl proc~xyz_to_uvw xyz_to_uvw proc~xyz_to_cyl->proc~xyz_to_uvw proc~uvw_to_cyl uvw_to_cyl proc~xyz_to_cyl->proc~uvw_to_cyl

Called by

proc~~get_passive_grid_indices~~CalledByGraph proc~get_passive_grid_indices get_passive_grid_indices proc~track_cylindrical track_cylindrical proc~track_cylindrical->proc~get_passive_grid_indices proc~store_photons store_photons proc~store_photons->proc~get_passive_grid_indices proc~store_photon_birth store_photon_birth proc~store_photon_birth->proc~get_passive_grid_indices proc~dcx_spec dcx_spec proc~dcx_spec->proc~store_photons proc~store_fida_photons store_fida_photons proc~store_fida_photons->proc~store_photons proc~store_nbi_photons store_nbi_photons proc~store_nbi_photons->proc~store_photons proc~dcx dcx proc~dcx->proc~store_photons proc~dcx->proc~store_photon_birth proc~fida_f fida_f proc~fida_f->proc~store_photon_birth proc~fida_f->proc~store_fida_photons proc~fida_mc fida_mc proc~fida_mc->proc~store_photon_birth proc~fida_mc->proc~store_fida_photons proc~pfida_f pfida_f proc~pfida_f->proc~track_cylindrical proc~pfida_f->proc~store_photon_birth proc~pfida_f->proc~store_fida_photons proc~pfida_mc pfida_mc proc~pfida_mc->proc~track_cylindrical proc~pfida_mc->proc~store_photon_birth proc~pfida_mc->proc~store_fida_photons proc~halo halo proc~halo->proc~store_photons proc~halo->proc~store_photon_birth proc~nbi_spec nbi_spec proc~nbi_spec->proc~store_photons proc~halo_spec halo_spec proc~halo_spec->proc~store_photons proc~cold_spec cold_spec proc~cold_spec->proc~store_photons proc~make_diagnostic_grids make_diagnostic_grids proc~make_diagnostic_grids->proc~track_cylindrical program~fidasim fidasim program~fidasim->proc~dcx_spec program~fidasim->proc~dcx program~fidasim->proc~fida_f program~fidasim->proc~fida_mc program~fidasim->proc~pfida_f program~fidasim->proc~pfida_mc program~fidasim->proc~halo program~fidasim->proc~nbi_spec program~fidasim->proc~halo_spec program~fidasim->proc~cold_spec program~fidasim->proc~make_diagnostic_grids proc~ndmc ndmc program~fidasim->proc~ndmc proc~ndmc->proc~store_nbi_photons

Contents


Source Code

subroutine get_passive_grid_indices(pos, ind, input_coords)
    !+ Find closest [[libfida:pass_grid]] indices `ind` to position `pos`
    real(Float64),  dimension(3), intent(in)  :: pos
        !+ Position [cm]
    integer(Int32), dimension(3), intent(out) :: ind
        !+ Closest indices to position
    integer, intent(in), optional             :: input_coords
        !+ Indicates coordinate system of `pos`. Beam grid (0), machine (1) and cylindrical (2)

    real(Float64),  dimension(3) :: mini, differentials, loc
    integer(Int32), dimension(3) :: maxind
    integer :: i, ics

    if(present(input_coords)) then
        ics = input_coords
    else
        ics = 2
    endif

    if(ics.eq.0) then
        call xyz_to_cyl(pos, loc)
    endif

    if(ics.eq.1) then
        loc(1) = sqrt(pos(1)*pos(1) + pos(2)*pos(2))
        loc(2) = pos(3)
        loc(3) = atan2(pos(2),pos(1))
    endif

    if(ics.eq.2) then
        loc(1) = pos(1)
        loc(2) = pos(2)
        loc(3) = pos(3)
    endif

    maxind(1) = pass_grid%nr
    maxind(2) = pass_grid%nz
    maxind(3) = pass_grid%nphi

    mini(1) = minval(pass_grid%r)
    mini(2) = minval(pass_grid%z)
    mini(3) = minval(pass_grid%phi)

    differentials(1) = pass_grid%dr
    differentials(2) = pass_grid%dz
    differentials(3) = pass_grid%dphi

    do i=1,3
        ind(i) = floor((loc(i)-mini(i))/differentials(i)) + 1
        if (ind(i).gt.maxind(i)) ind(i)=maxind(i)
        if (ind(i).lt.1) ind(i)=1
    enddo

end subroutine get_passive_grid_indices