detect_sheath_species Subroutine

public subroutine detect_sheath_species(cfg, electron_idx, ion_idx, photo_idx)

Arguments

Type IntentOptional Attributes Name
type(app_config), intent(in) :: cfg
integer(kind=i32), intent(out) :: electron_idx
integer(kind=i32), intent(out) :: ion_idx
integer(kind=i32), intent(out) :: photo_idx

Calls

proc~~detect_sheath_species~~CallsGraph proc~detect_sheath_species detect_sheath_species proc~lower_ascii lower_ascii proc~detect_sheath_species->proc~lower_ascii

Called by

proc~~detect_sheath_species~~CalledByGraph proc~detect_sheath_species detect_sheath_species proc~resolve_sheath_injection_context resolve_sheath_injection_context proc~resolve_sheath_injection_context->proc~detect_sheath_species proc~init_particle_batch_from_config init_particle_batch_from_config proc~init_particle_batch_from_config->proc~resolve_sheath_injection_context

Source Code

  subroutine detect_sheath_species(cfg, electron_idx, ion_idx, photo_idx)
    type(app_config), intent(in) :: cfg
    integer(i32), intent(out) :: electron_idx, ion_idx, photo_idx

    integer(i32) :: s
    character(len=16) :: mode

    electron_idx = 0_i32
    ion_idx = 0_i32
    photo_idx = 0_i32
    do s = 1_i32, cfg%n_particle_species
      if (.not. cfg%particle_species(s)%enabled) cycle
      mode = trim(lower_ascii(cfg%particle_species(s)%source_mode))
      select case (mode)
      case ('reservoir_face')
        if (cfg%particle_species(s)%q_particle < 0.0d0) then
          if (electron_idx == 0_i32) electron_idx = s
        else if (cfg%particle_species(s)%q_particle > 0.0d0) then
          if (ion_idx == 0_i32) ion_idx = s
        end if
      case ('photo_raycast')
        if (cfg%particle_species(s)%q_particle < 0.0d0 .and. photo_idx == 0_i32) photo_idx = s
      end select
    end do

    if (electron_idx <= 0_i32) error stop 'sheath injection requires one enabled negative-q reservoir_face species.'
    if (ion_idx <= 0_i32) error stop 'sheath injection requires one enabled positive-q reservoir_face species.'
    if (trim(lower_ascii(cfg%particle_species(electron_idx)%inject_face)) &
        /= trim(lower_ascii(cfg%particle_species(ion_idx)%inject_face))) then
      error stop 'sheath electron/ion reservoir species must share the same inject_face.'
    end if
  end subroutine detect_sheath_species