compute_macro_particles_for_batch Subroutine

public subroutine compute_macro_particles_for_batch(number_density_m3, temperature_k, m_particle, drift_velocity, box_min, box_max, inject_face, pos_low, pos_high, batch_duration, w_particle, residual, n_macro, vmin_normal)

物理流量・重み・残差から今バッチのマクロ粒子数を決める。

Arguments

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

粒子数密度 [1/m^3]。

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

温度 [K]。

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

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

real(kind=dp), intent(in) :: drift_velocity(3)
real(kind=dp), intent(in) :: box_min(3)
real(kind=dp), intent(in) :: box_max(3)
character(len=*), intent(in) :: inject_face

注入面識別子(x_low/x_high/y_low/y_high/z_low/z_high)。

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

マクロ粒子重み。

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

前バッチから繰り越すマクロ粒子端数(呼び出し後に更新)。

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

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

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

法線速度の下限 [m/s](省略時は 0)。


Calls

proc~~compute_macro_particles_for_batch~~CallsGraph proc~compute_macro_particles_for_batch compute_macro_particles_for_batch proc~compute_face_area_from_bounds compute_face_area_from_bounds proc~compute_macro_particles_for_batch->proc~compute_face_area_from_bounds proc~compute_inflow_flux_from_drifting_maxwellian compute_inflow_flux_from_drifting_maxwellian proc~compute_macro_particles_for_batch->proc~compute_inflow_flux_from_drifting_maxwellian

Called by

proc~~compute_macro_particles_for_batch~~CalledByGraph proc~compute_macro_particles_for_batch compute_macro_particles_for_batch proc~compute_macro_particles_for_species compute_macro_particles_for_species proc~compute_macro_particles_for_species->proc~compute_macro_particles_for_batch 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_for_batch( &
    number_density_m3, temperature_k, m_particle, drift_velocity, box_min, box_max, inject_face, pos_low, pos_high, &
    batch_duration, w_particle, residual, n_macro, vmin_normal &
    )
    real(dp), intent(in) :: number_density_m3
    real(dp), intent(in) :: temperature_k
    real(dp), intent(in) :: m_particle
    real(dp), intent(in) :: drift_velocity(3)
    real(dp), intent(in) :: box_min(3), box_max(3)
    character(len=*), intent(in) :: inject_face
    real(dp), intent(in) :: pos_low(3), pos_high(3)
    real(dp), intent(in) :: batch_duration
    real(dp), intent(in) :: w_particle
    real(dp), intent(inout) :: residual
    integer(i32), intent(out) :: n_macro
    real(dp), intent(in), optional :: vmin_normal

    real(dp) :: inward_normal(3), gamma_in, area, n_phys_batch, n_macro_expected, macro_budget

    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"

    call resolve_face_geometry(box_min, box_max, inject_face, inward_normal=inward_normal)
    gamma_in = compute_inflow_flux_from_drifting_maxwellian( &
               number_density_m3, temperature_k, m_particle, drift_velocity, inward_normal, vmin_normal=vmin_normal &
               )
    area = compute_face_area_from_bounds(inject_face, pos_low, pos_high)
    n_phys_batch = gamma_in*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_for_batch