init_random_beam_particles Subroutine

public subroutine init_random_beam_particles(pcls, n, q_particle, m_particle, w_particle, pos_low, pos_high, drift_velocity, temperature_k, thermal_speed)

指定粒子数ぶんの位置/速度/電荷/質量/重みを生成し particles_soa を初期化する。

Arguments

Type IntentOptional Attributes Name
type(particles_soa), intent(out) :: pcls

生成した粒子群を保持する particles_soa

integer(kind=i32), intent(in) :: n

生成するマクロ粒子数。

real(kind=dp), intent(in) :: q_particle

粒子1個あたりの電荷 [C]。

real(kind=dp), intent(in) :: m_particle

粒子1個あたりの電荷 [C]。 粒子1個あたりの質量 [kg]。

real(kind=dp), intent(in) :: w_particle

粒子1個あたりの電荷 [C]。 粒子1個あたりの質量 [kg]。 粒子1個あたりのマクロ粒子重み。

real(kind=dp), intent(in) :: pos_low(3)
real(kind=dp), intent(in) :: pos_high(3)
real(kind=dp), intent(in) :: drift_velocity(3)
real(kind=dp), intent(in), optional :: temperature_k

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

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

熱運動の温度 [K](thermal_speed 未指定時に使用)。 熱速度の標準偏差 sigma [m/s](指定時は温度より優先)。


Calls

proc~~init_random_beam_particles~~CallsGraph proc~init_random_beam_particles init_random_beam_particles proc~init_particles init_particles proc~init_random_beam_particles->proc~init_particles proc~sample_shifted_maxwell_velocities sample_shifted_maxwell_velocities proc~init_random_beam_particles->proc~sample_shifted_maxwell_velocities proc~sample_uniform_positions sample_uniform_positions proc~init_random_beam_particles->proc~sample_uniform_positions

Source Code

  subroutine init_random_beam_particles(pcls, n, q_particle, m_particle, w_particle, pos_low, pos_high, drift_velocity, &
                                        temperature_k, thermal_speed)
    type(particles_soa), intent(out) :: pcls
    integer(i32), intent(in) :: n
    real(dp), intent(in) :: q_particle, m_particle, w_particle
    real(dp), intent(in) :: pos_low(3), pos_high(3), drift_velocity(3)
    real(dp), intent(in), optional :: temperature_k, thermal_speed

    real(dp), allocatable :: x(:, :), v(:, :), q(:), m(:), w(:)

    if (n < 0) error stop "n must be non-negative"

    allocate (x(3, n), v(3, n), q(n), m(n), w(n))
    call sample_uniform_positions(pos_low, pos_high, x)
    call sample_shifted_maxwell_velocities(drift_velocity, m_particle, v, temperature_k, thermal_speed)
    q = q_particle
    m = m_particle
    w = w_particle

    call init_particles(pcls, x, v, q, m, w)
  end subroutine init_random_beam_particles