sample_uniform_positions Subroutine

public subroutine sample_uniform_positions(low, high, x)

直方体領域 [low, high] 内で一様分布の初期位置をサンプリングする。

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: low(3)
real(kind=dp), intent(in) :: high(3)
real(kind=dp), intent(out) :: x(:,:)

Called by

proc~~sample_uniform_positions~~CalledByGraph proc~sample_uniform_positions sample_uniform_positions proc~init_random_beam_particles init_random_beam_particles proc~init_random_beam_particles->proc~sample_uniform_positions

Source Code

  subroutine sample_uniform_positions(low, high, x)
    real(dp), intent(in) :: low(3), high(3)
    real(dp), intent(out) :: x(:, :)
    real(dp) :: span(3)
    integer :: i

    if (size(x, 1) /= 3) error stop "x first dimension must be 3"
    if (any(high < low)) error stop "high must be >= low for all axes"

    span = high - low
    call random_number(x)
    do i = 1, size(x, 2)
      x(:, i) = low + span*x(:, i)
    end do
  end subroutine sample_uniform_positions