sample_shifted_maxwell_velocities Subroutine

public subroutine sample_shifted_maxwell_velocities(drift_velocity, m_particle, v, temperature_k, thermal_speed, sigma_cutoff)

ドリフト速度付きMaxwell分布(温度または熱速度指定)から粒子速度を生成する。

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: drift_velocity(3)
real(kind=dp), intent(in) :: m_particle

粒子1個あたりの質量 [kg](temperature_k 指定時に使用)。

real(kind=dp), intent(out) :: v(:,:)
real(kind=dp), intent(in), optional :: temperature_k

熱運動の温度 [K](thermal_speed 未指定時に使用)。

real(kind=dp), intent(in), optional :: thermal_speed

熱速度の標準偏差 sigma [m/s](指定時は温度より優先)。

real(kind=dp), intent(in), optional :: sigma_cutoff

標準正規変量を [-sigma_cutoff, sigma_cutoff] に切る上限(省略時 6)。


Calls

proc~~sample_shifted_maxwell_velocities~~CallsGraph proc~sample_shifted_maxwell_velocities sample_shifted_maxwell_velocities proc~sample_standard_normal sample_standard_normal proc~sample_shifted_maxwell_velocities->proc~sample_standard_normal

Called by

proc~~sample_shifted_maxwell_velocities~~CalledByGraph proc~sample_shifted_maxwell_velocities sample_shifted_maxwell_velocities proc~init_random_beam_particles init_random_beam_particles proc~init_random_beam_particles->proc~sample_shifted_maxwell_velocities proc~sample_reservoir_face_particles sample_reservoir_face_particles proc~sample_reservoir_face_particles->proc~sample_shifted_maxwell_velocities

Source Code

  subroutine sample_shifted_maxwell_velocities(drift_velocity, m_particle, v, temperature_k, thermal_speed, sigma_cutoff)
    real(dp), intent(in) :: drift_velocity(3)
    real(dp), intent(in) :: m_particle
    real(dp), intent(out) :: v(:, :)
    real(dp), intent(in), optional :: temperature_k
    real(dp), intent(in), optional :: thermal_speed
    real(dp), intent(in), optional :: sigma_cutoff
    integer :: i
    real(dp) :: sigma, cutoff

    if (size(v, 1) /= 3) error stop "v first dimension must be 3"
    if (m_particle <= 0.0_dp) error stop "m_particle must be > 0"

    if (.not. present(temperature_k) .and. .not. present(thermal_speed)) then
      error stop "either temperature_k or thermal_speed must be provided"
    end if

    if (present(thermal_speed)) then
      if (thermal_speed < 0.0_dp) error stop "thermal_speed must be >= 0"
      sigma = thermal_speed
    else
      if (temperature_k < 0.0_dp) error stop "temperature_k must be >= 0"
      sigma = sqrt(k_boltzmann*temperature_k/m_particle)
    end if
    cutoff = default_velocity_sigma_cutoff
    if (present(sigma_cutoff)) cutoff = sigma_cutoff

    ! Zero temperature still consumes the same draws for restart and trial replay.
    call sample_standard_normal(v, sigma_cutoff=cutoff)
    do i = 1, size(v, 2)
      v(:, i) = sigma*v(:, i) + drift_velocity
    end do
  end subroutine sample_shifted_maxwell_velocities