Fit Function: JAN1

Fit Function \[\text{pfit} = \exp \left( \sum_{i=3}^{11} \text{pcf}(i) \cdot \log(pet) \cdot \left(\log(pet)\right)^{i-3}\right)\]
Comments Python code requires NumPy imported as `np`.

Fortran

Arguments
namedescriptionunitstype(s)
pet energy/electron temperature eV real, dimension(:)
pcf coefficient data array real, dimension(9)
kncf number of coefficients in the data array integer
pfit cross section cm2 real, dimension(:)
kermsg error message character
Return values
namedescriptionunitstype(s)
pfit cross section cm2 real, dimension(:)
Code
c
c###################################################################
c
      subroutine aljan1(pet, pcf, kncf, pfit, kermsg)
c
c     this is a subroutine to calculate cross sections (cm[2])
c     versus energy (ev) or electron impact reaction rate
c     coefficient (cm[3]/s) versus electron tempreature (ev).
c     using the log natural polynomial fit of janev et al.
c
c     these fits are valid only between the limits emin and emax,
c     which are parameters pcf(1) and pcf(2) in the entry data field
c     the parameters pcf(3-11) are the coeficients for the fiiting
c     formula.
c
c     pet = collision energy in ev
c
c     kermsg = blank if no errors
c
c     pfit = cross section in cm[2]
c
c     written by j. j. smith , iaea atomic and molecular data unit
c
c------------------------------------------------------------------------
c
      double precision pet, pcf, pfit
      double precision emin, emax, aloge1, aloge, xjan, xcon
      dimension pcf(11)
      character*(*) kermsg

      emin=pcf(1)
      emax = pcf(2)
      if(pet .ge. emin .and. pet .le. emax) then
        kermsg = ' '
      else
        kermsg = 'outside range of fit in aljanxs'
        return
      endif
c
c     calculate natutral log polynomial
c
      aloge1 = dlog(pet)
      aloge = aloge1
      xjan = pcf(3)
      do 10 i=4,11
      xcon = pcf(i)*aloge
      xjan = xjan + xcon
   10 aloge=aloge * aloge1
      pfit = dexp(xjan)
  100 return
c
      end

Python

Arguments
namedescriptionunitstype(s)
pet energy/electron temperature eV float, np.ndarray
pcf coefficient data array float, np.ndarray
Return values
namedescriptionunitstype(s)
pfit cross section cm2 float, np.ndarray
Code
def jan1(pet, pcf):
    """
    This is a subroutine to calculate cross sections (cm^2) versus energy (eV) or rate 
    coefficient (cm^3/s) versus electron temperature (eV), using the log 
     natural polynomial fit.

    pet = collision energy in eV
    pcf: parameter data array
        pcf[0]: emin
        pcf[1]: emax; the fits are valid only between the limits emin and emax, 
        pcf[2:10]: parameters for analytic function
    """

    emin = pcf[0]
    emax = pcf[1]

    if not emin <= pet <= emax:
        raise ValueError('Collision energy is outside the range of fit in aljanxs')

    aloge1 = np.log(pet)
    aloge = aloge1
    xjan = pcf[2]

    for i in range(3, 11):
        xcon = pcf[i] * aloge
        xjan += xcon
        aloge *= aloge1

    pfit = np.exp(xjan)
    return pfit