zhao_residuals_type_b Subroutine

public subroutine zhao_residuals_type_b(p, x, f)

Arguments

Type IntentOptional Attributes Name
type(zhao_params_type), intent(in) :: p
real(kind=dp), intent(in) :: x(:)
real(kind=dp), intent(out) :: f(:)

Calls

proc~~zhao_residuals_type_b~~CallsGraph proc~zhao_residuals_type_b zhao_residuals_type_b proc~swe_free_current_term swe_free_current_term proc~zhao_residuals_type_b->proc~swe_free_current_term

Called by

proc~~zhao_residuals_type_b~~CalledByGraph proc~zhao_residuals_type_b zhao_residuals_type_b proc~evaluate_monotonic_stationary_phi evaluate_monotonic_stationary_phi proc~evaluate_monotonic_stationary_phi->proc~zhao_residuals_type_b proc~try_solve_zhao_monotonic_scalar try_solve_zhao_monotonic_scalar proc~try_solve_zhao_monotonic_scalar->proc~zhao_residuals_type_b proc~try_solve_zhao_monotonic_scalar->proc~evaluate_monotonic_stationary_phi proc~try_solve_zhao_branch_b try_solve_zhao_branch_b proc~try_solve_zhao_branch_b->proc~try_solve_zhao_monotonic_scalar proc~try_solve_zhao_branch_c try_solve_zhao_branch_c proc~try_solve_zhao_branch_c->proc~try_solve_zhao_monotonic_scalar proc~solve_zhao_branch_b solve_zhao_branch_b proc~solve_zhao_branch_b->proc~try_solve_zhao_branch_b proc~solve_zhao_branch_c solve_zhao_branch_c proc~solve_zhao_branch_c->proc~try_solve_zhao_branch_c proc~try_solve_zhao_unknowns try_solve_zhao_unknowns proc~try_solve_zhao_unknowns->proc~try_solve_zhao_branch_b proc~try_solve_zhao_unknowns->proc~try_solve_zhao_branch_c proc~evaluate_surface_current_model evaluate_surface_current_model proc~evaluate_surface_current_model->proc~try_solve_zhao_unknowns proc~solve_zhao_unknowns solve_zhao_unknowns proc~solve_zhao_unknowns->proc~try_solve_zhao_unknowns proc~evaluate_surface_closure evaluate_surface_closure proc~evaluate_surface_closure->proc~evaluate_surface_current_model

Source Code

  subroutine zhao_residuals_type_b(p, x, f)
    type(zhao_params_type), intent(in) :: p
    real(dp), intent(in) :: x(:)
    real(dp), intent(out) :: f(:)

    real(dp) :: phi0_v, n_swe_inf_m3, ion_term

    phi0_v = x(1)
    n_swe_inf_m3 = x(2)
    if (phi0_v <= 0.0d0 .or. n_swe_inf_m3 <= 0.0d0) then
      f = 1.0d6
      return
    end if

    ion_term = p%n_swi_inf_m3*sqrt(2.0d0*pi*p%t_swe_ev/p%t_phe_ev*p%m_e_kg/p%m_i_kg)*p%mach
    f(1) = 0.5d0*n_swe_inf_m3*(1.0d0 + erf(p%u)) + &
           0.5d0*p%photoelectron_population_fraction*p%n_phe0_m3*exp(-phi0_v/p%t_phe_ev) - p%n_swi_inf_m3
    f(2) = p%n_phe0_m3*exp(-phi0_v/p%t_phe_ev) - swe_free_current_term(p, n_swe_inf_m3, -p%u) + ion_term
  end subroutine zhao_residuals_type_b