init_particles Subroutine

public subroutine init_particles(pcls, x, v, q, m, w)

位置・速度・電荷・質量(と任意重み)配列から particles_soa を検証付きで構築する。

Arguments

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

検証済み配列を内部に保持した particles_soa 構造体。

real(kind=dp), intent(in) :: x(:,:)
real(kind=dp), intent(in) :: v(:,:)
real(kind=dp), intent(in) :: q(:)
real(kind=dp), intent(in) :: m(:)
real(kind=dp), intent(in), optional :: w(:)

Called by

proc~~init_particles~~CalledByGraph proc~init_particles init_particles proc~init_particle_batch_from_config init_particle_batch_from_config proc~init_particle_batch_from_config->proc~init_particles proc~init_particles_from_config init_particles_from_config proc~init_particles_from_config->proc~init_particles proc~init_random_beam_particles init_random_beam_particles proc~init_random_beam_particles->proc~init_particles

Source Code

  subroutine init_particles(pcls, x, v, q, m, w)
    type(particles_soa), intent(out) :: pcls
    real(dp), intent(in) :: x(:, :), v(:, :), q(:), m(:)
    real(dp), intent(in), optional :: w(:)
    integer(i32) :: n

    n = size(q)
    if (size(x, 1) /= 3 .or. size(v, 1) /= 3) then
      error stop "particle input first dimension must be 3"
    end if
    if (size(x, 2) /= n .or. size(v, 2) /= n .or. size(m) /= n) then
      error stop "particle input size mismatch"
    end if

    pcls%n = n
    allocate (pcls%x(3, n), pcls%v(3, n), pcls%q(n), pcls%m(n), pcls%w(n), pcls%alive(n))
    pcls%x = x
    pcls%v = v
    pcls%q = q
    pcls%m = m
    if (present(w)) then
      if (size(w) /= n) error stop "w size mismatch"
      pcls%w = w
    else
      pcls%w = 1.0d0
    end if
    pcls%alive = .true.
  end subroutine init_particles