particles_per_batch_from_config Function

public function particles_per_batch_from_config(cfg) result(batch_n)

有効な粒子種の npcls_per_step を合計し、1バッチあたりの粒子数を返す。 1つ以上の粒子種が有効で、かつ合計が正でない場合は停止する。

Arguments

Type IntentOptional Attributes Name
type(app_config), intent(in) :: cfg

粒子種設定を含むアプリ設定。

Return Value integer(kind=i32)


Calls

proc~~particles_per_batch_from_config~~CallsGraph proc~particles_per_batch_from_config particles_per_batch_from_config proc~species_config_path species_config_path proc~particles_per_batch_from_config->proc~species_config_path

Source Code

  integer(i32) function particles_per_batch_from_config(cfg) result(batch_n)
    type(app_config), intent(in) :: cfg
    integer(i32) :: s
    logical :: has_dynamic_source

    if (cfg%n_particle_species <= 0) then
      error stop 'At least one [[particles.species]] entry is required.'
    end if

    batch_n = 0_i32
    has_dynamic_source = .false.
    do s = 1, cfg%n_particle_species
      if (.not. cfg%particle_species(s)%enabled) cycle
      select case (trim(cfg%particle_species(s)%source_mode))
      case ('volume_seed')
        if (cfg%particle_species(s)%npcls_per_step < 0_i32) then
          error stop species_config_path(int(s))//'.sampling.volume_macro_particles_per_batch must be >= 0.'
        end if
        if (cfg%particle_species(s)%npcls_per_step > huge(batch_n) - batch_n) then
          error stop 'Total volume particles per batch exceed the supported 32-bit integer range.'
        end if
        batch_n = batch_n + cfg%particle_species(s)%npcls_per_step
      case ('photo_raycast')
        has_dynamic_source = .true.
      case ('secondary_emission')
        cycle
      case default
        error stop 'Unknown '//species_config_path(int(s))//'.source.mode.'
      end select
      has_dynamic_source = has_dynamic_source .or. &
                           any(cfg%particle_species(s)%boundary_inflow_low == particle_inflow_reservoir) .or. &
                           any(cfg%particle_species(s)%boundary_inflow_high == particle_inflow_reservoir)
    end do

    if (batch_n <= 0_i32 .and. .not. has_dynamic_source) then
      error stop 'At least one enabled [[particles.species]] entry must have sampling.volume_macro_particles_per_batch > 0.'
    end if
  end function particles_per_batch_from_config