compute_macro_particles_from_flux Subroutine

public subroutine compute_macro_particles_from_flux(particle_flux_m2_s, inject_face, pos_low, pos_high, batch_duration, w_particle, residual, n_macro)

指定済み粒子 flux・重み・残差から今バッチのマクロ粒子数を決める。

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: particle_flux_m2_s

粒子数 flux [1/m^2/s]。

character(len=*), intent(in) :: inject_face

注入面識別子。

real(kind=dp), intent(in) :: pos_low(3)
real(kind=dp), intent(in) :: pos_high(3)
real(kind=dp), intent(in) :: batch_duration

1バッチの物理時間長 [s]。

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

1バッチの物理時間長 [s]。 マクロ粒子重み。

real(kind=dp), intent(inout) :: residual

前バッチから繰り越すマクロ粒子端数。

integer(kind=i32), intent(out) :: n_macro

今バッチで生成するマクロ粒子数。


Calls

proc~~compute_macro_particles_from_flux~~CallsGraph proc~compute_macro_particles_from_flux compute_macro_particles_from_flux proc~compute_face_area_from_bounds compute_face_area_from_bounds proc~compute_macro_particles_from_flux->proc~compute_face_area_from_bounds

Called by

proc~~compute_macro_particles_from_flux~~CalledByGraph proc~compute_macro_particles_from_flux compute_macro_particles_from_flux proc~compute_macro_particles_for_species compute_macro_particles_for_species proc~compute_macro_particles_for_species->proc~compute_macro_particles_from_flux proc~init_particle_batch_from_config init_particle_batch_from_config proc~init_particle_batch_from_config->proc~compute_macro_particles_for_species

Source Code

  subroutine compute_macro_particles_from_flux( &
    particle_flux_m2_s, inject_face, pos_low, pos_high, batch_duration, w_particle, residual, n_macro &
    )
    real(dp), intent(in) :: particle_flux_m2_s
    character(len=*), intent(in) :: inject_face
    real(dp), intent(in) :: pos_low(3), pos_high(3)
    real(dp), intent(in) :: batch_duration, w_particle
    real(dp), intent(inout) :: residual
    integer(i32), intent(out) :: n_macro

    real(dp) :: area, n_phys_batch, n_macro_expected, macro_budget

    if (.not. ieee_is_finite(particle_flux_m2_s) .or. particle_flux_m2_s < 0.0_dp) then
      error stop "particle_flux_m2_s must be finite and >= 0"
    end if
    if (w_particle <= 0.0_dp) error stop "w_particle must be > 0"
    if (batch_duration < 0.0_dp) error stop "batch_duration must be >= 0"

    area = compute_face_area_from_bounds(inject_face, pos_low, pos_high)
    n_phys_batch = particle_flux_m2_s*area*batch_duration
    n_macro_expected = n_phys_batch/w_particle
    macro_budget = residual + n_macro_expected
    if (macro_budget < 0.0_dp) macro_budget = 0.0_dp
    if (macro_budget > real(huge(0_i32), dp)) error stop "macro particle count exceeds integer range"
    n_macro = int(floor(macro_budget), i32)
    residual = macro_budget - real(n_macro, dp)
  end subroutine compute_macro_particles_from_flux