### Fit Function: FNAGEX

 Fit Function \begin{align*} \end{align*} Comments

#### Fortran

Arguments
namedescriptionunitstype(s)
pt electron temperature eV real, dimension(:)
pcf coefficient data array real, dimension(9)
kncf number of coefficients in the data array integer
pfit rate coefficient cm3 s-1 real, dimension(:)
kermsg error message character
Return values
namedescriptionunitstype(s)
pfit rate coefficient cm3 s-1 real, dimension(:)
Code
c
c##############################################################################
c
c
c###################################################################
c
subroutine fnagex(pt, pcf, kncf, pfit, kermsg)
c
c     this is an iaea subroutine to calculate the electron impact
c     excitation rate coefficients as a function of the electron
c     temperature.
c
c     pt = electron temperature in ev
c
c     pcf is the coefficient data array, where
c
c     pcf(1)  = itype, index for type of fit, either 1 or 2
c
c     pcf(2)  = excitation energy , v (also referred to as delta e)
c
c     pcf(3)  = lower limit of fitting of reduced energy x
c
c     pcf(4)  = upper limit of fitting of reduced energy x
c
c     pcf(5)  = statistical weight of initial state (2s+1)*(2l+1)
c
c     pcf(6)  = parameter a
c
c     pcf(7)  = parameter b
c
c     pcf(8)  = parameter c
c
c     pcf(9)  = parameter d
c
c     pcf(10)  = parameter e
c
c if ftype = 1 this can be followed by three more parameters for
c the region which contains resonances represented by a linear term
c
c     pcf(11)  = parameter p
c
c     pcf(12)  = parameter q
c
c     pcf(13)  = parameter x1, the upper limit of the range over which
c                the collision strength is represented by a linear
c                approximation.
c
c if ftype = 2, the pcf array element 10 can be followed by
c
c     pcf(11)  = parameter f
c
c and possibly three more parameters follow for the region which
c contains resonances represented by a linear term
c
c     pcf(12)  = parameter p
c
c     pcf(13)  = parameter q
c
c     pcf(14)  = parameter x1, the upper limit of the range over which
c                the collision strength is represented by a linear
c                approximation.
c
c     kermsg = blank if no errors
c
c     pfit = rate coefficient in cm/s
c
c     written by j. j. smith , iaea atomic and molecular data unit
c     (taken from report ippj-am-27, y. itikawa et al, nagoya,
c      institute of plasma physics, nsgoya univ., (1983))
c
c------------------------------------------------------------------------
c
double precision pt, pcf, pfit
dimension pcf(14)
character*(*) kermsg
data s/0.5/
c
c	DH, Dec, 16, 2003 ---- kermsg = ' ' to avoid loop on error message ----
kermsg = ' '
itype = pcf(1)
const = 8.010e-8 / (dsqrt(pt)*pcf(5))
y = pcf(2) / pt
c
if (kncf .lt. 12) then
c
c---    rate coefficient without resonances
c
if (itype .eq. 1) then
c
c---    rate coefficient represented by power-log type of fit
c
ra = pcf(6)/y + pcf(8) + s * pcf(9) * (1.0 - y)
rb = pcf(7) - pcf(8)*y + s * pcf(9) * y * y + pcf(10)/y
rnor = const * exp(-y) * y *  (ra + eiexp(y) * rb)
rres = 0.0
c
else if (itype .eq. 2) then
c
c---    rate coefficient represented by exponential type of fit
c
ra = pcf(6) * (1.0 - eiexp(y)*y)
f = pcf(11)
rb = pcf(7) * exp(-f) / (f+y)
1         + pcf(8) * exp (-2.*f) / (2.*f+y)
2         + pcf(9) * exp (-3.*f) / (3.*f+y)
3         + pcf(10) * exp (-4.*f) / (4.*f+y)
rnor = const * exp(-y) * y *  (ra + rb)
rres = 0.0
c
else
kermsg =
1       ' invalid integer for fit type in fnagex - must be 1 or 2'
return
endif
c
else
c
c---    rate coefficient with resonances
c
if (itype .eq. 1) then
c
c---    rate coefficient represented by power-log type of fit
c
x1 = pcf(13)
y1 = y * x1
ra = pcf(6)/y + pcf(8)/x1
1         + s * pcf(9) * (1./(x1 * x1)  - y/x1)
2         + pcf(10) * log(x1) / y
rb = pcf(7) - pcf(8)*y + s * pcf(9) * y * y + pcf(10)/y
rnor = const * y * exp(-y1) * (ra + eiexp(y1) * rb)
rres = const * exp (-y) * (pcf(11) * (1. + 1./y)
1         * (1. - exp ((1. - x1) * y) * (x1 + 1./y)
2         / (1. + 1./y))  + pcf(12) * (1. - exp ((1. - x1) * y )))
c
else if (itype .eq. 2) then
c
c---    rate coefficient represented by exponential type of fit
c
x1 = pcf(14)
y1 = y * x1
ra = pcf(6) * (1. / x1 - eiexp(y1) * y)
f = pcf(11)
rb = pcf(7) * exp(-f*x1) / (f+y)
1        + pcf(8) * exp (-2.*f*x1) / (2.*f+y)
2        + pcf(9) * exp (-3.*f*x1) / (3.*f+y)
3        + pcf(10) * exp (-4.*f*x1) / (4.*f+y)
rnor = const * y * exp(-y1) * (ra + rb)
rres = const * exp (-y) * (pcf(12) * (1. + 1./y)
1         * (1. - exp ((1. - x1) * y) * (x1 + 1./y)
2         / (1. + 1./y))  + pcf(13) * (1. - exp ((1. - x1) * y )))
else
kermsg =
1       ' invalid integer for fit type in fnagex - must be 1 or 2'
return
endif
c
endif
c
pfit = rnor + rres
c
if (pfit .le. 0.0d0) then
kermsg =
1  ' error reaction rate is negative check data and temp. range '
return
endif
c
end

#### Python

Arguments
namedescriptionunitstype(s)
pt electron temperature eV float, np.ndarray
pcf coefficient data array float, np.ndarray
kncf number of coefficients in the data array int
pfit rate coefficient cm3 s-1 float, np.ndarray
kermsg error message str
Return values
namedescriptionunitstype(s)
pfit rate coefficient cm3 s-1 float, np.ndarray
Code