!23456789a123456789b123456789c123456789d123456789e123456789f123456789g12
! D.J. Jeffery, 2020jan06
! An analytic solution for the Saha electron density equation exists
!   for hydrogen (without H-).
!   Here we subprograms for that equation and solution 
!   reduced electron density and reduced ion density.
!   Reduced means divided by 1/phi-tilde-function (Mihalas-1978-113).
!   which means temperature eliminated. 
!      include 'xne_h_analytic.f' ! The analytic H subprograms.
!                                ! H- is not included in this analytic solution.
!
!23456789a123456789b123456789c123456789d123456789e123456789f123456789g12
      function func_xne_h_analytic_equation(x,xx)    ! The Saha electron density equation for H.
      use precision_set
      use contants
      include 'module_implicit.f'
      include 'function_type_declaration.f'
      real (kind=np), intent(in) :: x  ! Input reduced electron density.
      real (kind=np), intent(in) :: xx ! Reduced ion density.
!
      func_xne_h_analytic_equation=xx/(1.0_np+x)
      end function func_xne_h_analytic_equation 
!23456789a123456789b123456789c123456789d123456789e123456789f123456789g12
      function func_xne_h_analytic_exact(xx)   ! The Saha electron density exact solution for H.
      use precision_set
      use contants
      include 'module_implicit.f'
      include 'function_type_declaration.f'
      real (kind=np), intent(in) :: xx ! Reduced ion density.
!
      func_xne_h_analytic_exact=2.0_np*xx                                  &
     &         /(1.0_np+sqrt(1.0_np+4.0_np*xx))                         ! Exact result.
!        xx=2, gives x=1.  xx=1, gives x=(sqrt(5)-1)/2=(golden ratio)-1=0.6180...
!        https://en.wikipedia.org/wiki/Golden_ratio
      end function func_xne_h_analytic_exact 
!23456789a123456789b123456789c123456789d123456789e123456789f123456789g12
      function func_xne_h_analytic_exact2(xx)   ! The Saha electron density exact solution for H.
      use precision_set
      use contants
      include 'module_implicit.f'
      include 'function_type_declaration.f'
      real (kind=np), intent(in) :: xx ! Reduced ion density.
!
      func_xne_h_analytic_exact2=0.5_np*(sqrt(1.0_np+4.0_np*xx)-1.0_np) ! Exact result.
!        xx=2, gives x=1.  xx=1, gives x=(sqrt(5)-1)/2=(golden ratio)-1=0.6180...
!        https://en.wikipedia.org/wiki/Golden_ratio
      end function func_xne_h_analytic_exact2
!23456789a123456789b123456789c123456789d123456789e123456789f123456789g12
      function func_xne_h_analytic_series_small(xx)    ! The Saha electron density series solution for H.
      use precision_set
      use contants
      include 'module_implicit.f'
      include 'function_type_declaration.f'
      real (kind=np), intent(in) :: xx ! Reduced ion density.
!
      func_xne_h_analytic_series_small=                                    &
     & xx*(1.0_np+xx*(-1.0_np+2.0_np*xx))  
!        ! Series result to 3rd order
!        !   for an alternating series, where the error is less than
!        !   last term neglected (Arf-294).
      end function func_xne_h_analytic_series_small
!23456789a123456789b123456789c123456789d123456789e123456789f123456789g12
      function func_xne_h_analytic_series_large(xx)    ! The Saha electron density series solution for H.
      use precision_set
      use contants
      include 'module_implicit.f'
      include 'function_type_declaration.f'
      real (kind=np), intent(in) :: xx ! Reduced ion density.
!
      func_xne_h_analytic_series_large=-0.5_np+sqrt(xx)                      &
     & *(1.0_np+(f_1_8/xx)*(1.0_np-(f_1_16/xx)*(1.0_np-(f_1_32/xx) )))
!        ! Series result to 3rd order
!        !   for an alternating series, where the error is less than
!        !   last term neglected (Arf-294).
      end function func_xne_h_analytic_series_large
!23456789a123456789b123456789c123456789d123456789e123456789f123456789g12
