element_potential_without_self Function

public function element_potential_without_self(mesh, elem_idx, softening) result(phi)

要素自身の点電荷寄与を除いた要素中心電位 [V] を返す。

Arguments

Type IntentOptional Attributes Name
type(mesh_type), intent(in) :: mesh
integer(kind=i32), intent(in) :: elem_idx
real(kind=dp), intent(in) :: softening

Return Value real(kind=dp)


Called by

proc~~element_potential_without_self~~CalledByGraph proc~element_potential_without_self element_potential_without_self proc~photo_escape_weight_factor photo_escape_weight_factor proc~photo_escape_weight_factor->proc~element_potential_without_self proc~init_particle_batch_from_config init_particle_batch_from_config proc~init_particle_batch_from_config->proc~photo_escape_weight_factor

Source Code

  real(dp) function element_potential_without_self(mesh, elem_idx, softening) result(phi)
    type(mesh_type), intent(in) :: mesh
    integer(i32), intent(in) :: elem_idx
    real(dp), intent(in) :: softening

    integer(i32) :: j
    real(dp) :: dx, dy, dz, r2, soft2, phi_sum

    if (elem_idx < 1_i32 .or. elem_idx > mesh%nelem) error stop 'photo_escape_model elem_idx is out of range.'

    soft2 = softening*softening
    phi_sum = 0.0d0
    do j = 1_i32, mesh%nelem
      if (j == elem_idx) cycle
      dx = mesh%center_x(elem_idx) - mesh%center_x(j)
      dy = mesh%center_y(elem_idx) - mesh%center_y(j)
      dz = mesh%center_z(elem_idx) - mesh%center_z(j)
      r2 = dx*dx + dy*dy + dz*dz + soft2
      if (r2 <= tiny(1.0d0)) cycle
      phi_sum = phi_sum + mesh%q_elem(j)/sqrt(r2)
    end do
    phi = k_coulomb*phi_sum
  end function element_potential_without_self