Python |
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 |
Fortran |
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 |