computes minimum distance between two sets of particles
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(particle_type), | intent(in), | dimension(:) | :: | particles_one | ||
class(particle_type), | intent(in), | dimension(:) | :: | particles_two |
pure function compute_minimum_distance(particles_one, particles_two) result(minimum_distance)
class(particle_type), dimension(:), intent(in) :: particles_one
class(particle_type), dimension(:), intent(in) :: particles_two
integer :: i, j
real(dp) :: current_distance
real(dp) :: minimum_distance
real(dp), dimension(3) :: coordinate_one
real(dp), dimension(3) :: coordinate_two
minimum_distance = huge(dp)
do i = 1, size(particles_one)
coordinate_one = particles_one(i)%coordinate
do j = 1, size(particles_two)
coordinate_two = particles_two(j)%coordinate
current_distance = norm2(coordinate_two - coordinate_one)
if (current_distance < minimum_distance) then
minimum_distance = current_distance
end if
end do
end do
end function compute_minimum_distance