bem_surface_closure_contract.f90 Source File


This file depends on

sourcefile~~bem_surface_closure_contract.f90~~EfferentGraph sourcefile~bem_surface_closure_contract.f90 bem_surface_closure_contract.f90 sourcefile~bem_kinds.f90 bem_kinds.f90 sourcefile~bem_surface_closure_contract.f90->sourcefile~bem_kinds.f90 sourcefile~bem_runtime_modes.f90 bem_runtime_modes.f90 sourcefile~bem_surface_closure_contract.f90->sourcefile~bem_runtime_modes.f90 sourcefile~bem_runtime_modes.f90->sourcefile~bem_kinds.f90 sourcefile~bem_string_utils.f90 bem_string_utils.f90 sourcefile~bem_runtime_modes.f90->sourcefile~bem_string_utils.f90

Files dependent on this one

sourcefile~~bem_surface_closure_contract.f90~~AfferentGraph sourcefile~bem_surface_closure_contract.f90 bem_surface_closure_contract.f90 sourcefile~bem_simulator.f90 bem_simulator.f90 sourcefile~bem_simulator.f90->sourcefile~bem_surface_closure_contract.f90 sourcefile~bem_surface_current_model.f90 bem_surface_current_model.f90 sourcefile~bem_simulator.f90->sourcefile~bem_surface_current_model.f90 sourcefile~bem_output_writer.f90 bem_output_writer.f90 sourcefile~bem_simulator.f90->sourcefile~bem_output_writer.f90 sourcefile~bem_run_outputs.f90 bem_run_outputs.f90 sourcefile~bem_simulator.f90->sourcefile~bem_run_outputs.f90 sourcefile~bem_simulator_charge.f90 bem_simulator_charge.f90 sourcefile~bem_simulator_charge.f90->sourcefile~bem_surface_closure_contract.f90 sourcefile~bem_simulator_charge.f90->sourcefile~bem_simulator.f90 sourcefile~bem_surface_current_model.f90->sourcefile~bem_surface_closure_contract.f90 sourcefile~bem_zhao_outflow_refresh.f90 bem_zhao_outflow_refresh.f90 sourcefile~bem_zhao_outflow_refresh.f90->sourcefile~bem_surface_closure_contract.f90 sourcefile~bem_zhao_outflow_refresh.f90->sourcefile~bem_surface_current_model.f90 sourcefile~bem_output_writer.f90->sourcefile~bem_surface_current_model.f90 sourcefile~bem_output_writer_summary.f90 bem_output_writer_summary.f90 sourcefile~bem_output_writer_summary.f90->sourcefile~bem_surface_current_model.f90 sourcefile~bem_output_writer_summary.f90->sourcefile~bem_output_writer.f90 sourcefile~bem_simulator_io.f90 bem_simulator_io.f90 sourcefile~bem_simulator_io.f90->sourcefile~bem_simulator.f90 sourcefile~bem_simulator_io.f90->sourcefile~bem_output_writer.f90 sourcefile~bem_simulator_loop.f90 bem_simulator_loop.f90 sourcefile~bem_simulator_loop.f90->sourcefile~bem_simulator.f90 sourcefile~bem_simulator_loop.f90->sourcefile~bem_zhao_outflow_refresh.f90 sourcefile~bem_simulator_loop.f90->sourcefile~bem_output_writer.f90 sourcefile~bem_periodic_checkpoint.f90 bem_periodic_checkpoint.f90 sourcefile~bem_simulator_loop.f90->sourcefile~bem_periodic_checkpoint.f90 sourcefile~bem_simulator_loop.f90->sourcefile~bem_run_outputs.f90 sourcefile~bem_simulator_particles.f90 bem_simulator_particles.f90 sourcefile~bem_simulator_particles.f90->sourcefile~bem_simulator.f90 sourcefile~bem_simulator_stats.f90 bem_simulator_stats.f90 sourcefile~bem_simulator_stats.f90->sourcefile~bem_simulator.f90 sourcefile~main.f90 main.f90 sourcefile~main.f90->sourcefile~bem_simulator.f90 sourcefile~main.f90->sourcefile~bem_output_writer.f90 sourcefile~main.f90->sourcefile~bem_periodic_checkpoint.f90 sourcefile~main.f90->sourcefile~bem_run_outputs.f90 sourcefile~bem_output_writer_files.f90 bem_output_writer_files.f90 sourcefile~bem_output_writer_files.f90->sourcefile~bem_output_writer.f90 sourcefile~bem_output_writer_history.f90 bem_output_writer_history.f90 sourcefile~bem_output_writer_history.f90->sourcefile~bem_output_writer.f90 sourcefile~bem_periodic_checkpoint.f90->sourcefile~bem_output_writer.f90 sourcefile~bem_run_outputs.f90->sourcefile~bem_output_writer.f90 sourcefile~bem_run_outputs.f90->sourcefile~bem_periodic_checkpoint.f90

Source Code

!> シミュレータが外部の表面電流モデルから受け取るモデル非依存の境界契約。
module bem_surface_closure_contract
  use bem_kinds, only: dp, i32
  use bem_runtime_modes, only: closure_mode_none, closure_mode_target, closure_mode_escape_partner, &
                               closure_mode_tracked_source
  implicit none
  private

  public :: species_closure_mode

  type, public :: surface_closure_contract_type
    logical :: active = .false.
    logical, allocatable :: has_absorbed_target(:)
    logical, allocatable :: has_emission_target(:)
    logical, allocatable :: has_escape_target(:)
    logical, allocatable :: has_inflow_kinetic_map(:)
    logical, allocatable :: has_outflow_kinetic_barrier(:)
    logical, allocatable :: has_inflow_number_flux(:)
    real(dp), allocatable :: absorbed_current_a(:)
    real(dp), allocatable :: emission_current_a(:)
    real(dp), allocatable :: escaped_particle_current_a(:)
    real(dp), allocatable :: inflow_reservoir_potential_v(:)
    real(dp), allocatable :: inflow_access_potential_v(:)
    !> 流入写像の0 V貯留部にあるMaxwellianの密度。0以下ならspecies設定の密度を使う。
    real(dp), allocatable :: inflow_reservoir_density_m3(:)
    integer(i32), allocatable :: inflow_kinetic_face(:)
    real(dp), allocatable :: outflow_barrier_potential_v(:)
    integer(i32), allocatable :: outflow_barrier_face(:)
    real(dp), allocatable :: inflow_number_flux_m2_s(:)
    !> この species の脱出・帰還目標から、そのバッチで追跡した脱出電荷を差し引く species(0 なら無し)。
    !! 外部根の脱出束が複数の放出電子種の合算なら、追跡した側に充てた残りをこの species の目標にする。
    integer(i32), allocatable :: escape_partner_species(:)
    !> 放出目標が、根が予測した放出ではなく、根に与えた外側源(追跡した放出の窓平均)である種(PE なしの SEE)。
    !! raw channel が空のバッチでも止まらず、帰還目標は放出へ畳み、放出がなければ根の脱出分を未閉として記録する。
    logical, allocatable :: emission_target_from_tracked_source(:)
    !> この species の脱出・帰還・放出目標から差し引く、セル内で反射して H を抜けた上流電子の species(0 なら無し)。
    !! 外部根の源に反射電子を含めると根の脱出・帰還は放出電子と反射電子の合算なので、追跡で決まる反射分を先に充て、
    !! 残りをこの species に固定する。
    integer(i32), allocatable :: reflected_electron_species(:)
    !> 吸収目標に、この species 自身が外部障壁を越えて脱出した追跡電荷を足し戻す(反射して出た上流電子は壁に届かない)。
    logical, allocatable :: absorbed_target_credits_tracked_escape(:)
    !> 照射セル契約の壁面の平均電位を外部シース解の壁電位へ固定する場合だけ有効。
    logical :: has_plane_gauge = .false.
    real(dp) :: plane_gauge_potential_v = 0.0_dp
    real(dp) :: top_field_v_m = 0.0_dp
    !> 外部障壁で戻る粒子を周期セル内の一様な位置へ戻す。
    logical :: outer_return_cell_uniform = .false.
  end type surface_closure_contract_type

contains

  !> 種 species_idx の固定電流 closure 方式(bem_runtime_modes の closure_mode_*)。
  !! 設定が fixed_current でも外部根の目標もなければ none。方式は contract のフラグから導くので、
  !! 方式とフラグが食い違うことはない。
  pure integer(i32) function species_closure_mode(contract, species_idx, configured_fixed_current) result(mode)
    class(surface_closure_contract_type), intent(in) :: contract
    integer(i32), intent(in) :: species_idx
    logical, intent(in) :: configured_fixed_current

    mode = closure_mode_none
    if (.not. (configured_fixed_current .or. contract%has_absorbed_target(species_idx) .or. &
               contract%has_emission_target(species_idx) .or. contract%has_escape_target(species_idx))) return
    mode = closure_mode_target
    if (allocated(contract%emission_target_from_tracked_source)) then
      if (contract%emission_target_from_tracked_source(species_idx)) then
        mode = closure_mode_tracked_source
        return
      end if
    end if
    if (allocated(contract%escape_partner_species)) then
      if (contract%escape_partner_species(species_idx) > 0_i32) mode = closure_mode_escape_partner
    end if
    if (allocated(contract%reflected_electron_species)) then
      if (contract%reflected_electron_species(species_idx) > 0_i32) mode = closure_mode_escape_partner
    end if
  end function species_closure_mode

end module bem_surface_closure_contract