Fit Function: HLOSS2

Fit Function \[\sigma (pe) = 10^{-14} \cdot \text{pcf}(1) \left[1.0 - \exp\left(-\text{pcf}(2) \cdot \frac{\log\left(\exp(1.0) + \text{pcf}(3) \cdot 10^{-3} \cdot pe \right)}{10^{-3} \cdot pe}\right)\right]\]
Comments Python code requires NumPy imported as `np` and `warnings`.

Fortran

Arguments
namedescriptionunitstype(s)
pe requested energy eV u-1 real, dimension(:)
pcf coefficient data array real, dimension(9)
kncf number of coefficients in the data array integer
pxs cross section cm2 real, dimension(:)
kermsg error message character
Return values
namedescriptionunitstype(s)
pxs cross section cm2 real, dimension(:)
Code
c
c###################################################################
c
      subroutine hloss2(pe, pcf, kncf, pxs, kermsg)
c
c     this is a subroutine to calculate cross sections (cm[2])
c     versus energy (eV) for electron removal.
c
c     pe = collision energy in eV/amu
c
c     pcf(1-3) = A1 - A3
c
c    - warning- .
c
c     the coefficient array pcf is updated by this routine to
c     include energy independent constants. these coefficients can be
c     used in subsequent calls for the same entry.
c
c     kermsg = blank if no errors
c
c     pxs = cross section in cm[2]
c
c------------------------------------------------------------------------
c
      double precision e, pe, pcf, pxs
      double precision xs1
      double precision a1, a2, a3
c
      dimension pcf(3)
      character*(*) kermsg
c
      if(pe .ge. 0.0) then
        kermsg = ' '
      else
        pxs = 0.0
        return
      endif
c
c generate the energy in keV
c
      e = pe*1.0e-03
c
c     determine the value of the cross section  pxs
c
      if(kncf .eq. 3) then
        a1 = pcf(1)
        a2 = pcf(2)
        a3 = pcf(3)
        xs1 = a1 * (1.d0 - dexp(-a2*dlog(dexp(1.d0) + a3*e)/e))
        pxs = 1.0e-14 * xs1 
      else
          kermsg = ' incorrect number of coefficients passed to hloss2'
          return
      endif
c
      return
      end

Python

Arguments
namedescriptionunitstype(s)
pe requested energy eV u-1 float, np.ndarray
pcf coefficient data array float, np.ndarray
kncf number of coefficients in the data array integer
Return values
namedescriptionunitstype(s)
pxs cross section cm2 float, np.ndarray
Code
def hloss2(pe, pcf, kncf):
    """
    This function calculates the cross-section (cm2) for electron removal.

    pe: collision energy in eV/amu
    pcf: parameter data array
        pcf[0:3]: parameters for fit to the cross section
    """    
    if pe < 0.0:
        pxs = 0.0
        warnings.warn('Collision energy (pe) must be greater than or equal to zero.')
        return pxs

   #change the energy in keV
    e = pe * 1.0e-03   
    # Determine the value of the cross section pxs
    if kncf == 3:
        xs1 = pcf[0] * (1.0 - np.exp(-pcf[1] * np.log(np.exp(1.0) + pcf[2] * e) / e))
        pxs = 1.0e-14 * xs1
    else:
        raise ValueError('Incorrect number of coefficients passed to hloss2')
    
    return pxs