Make multipole variable names more consistent

This commit is contained in:
Sterling Harper 2016-12-02 14:25:20 -05:00
parent 9649d112ea
commit 7035192625
2 changed files with 21 additions and 21 deletions

View file

@ -71,15 +71,15 @@ def _faddeeva(z):
return -np.conj(wofz(z))
def _broaden_wmp_polynomials(En, dopp, n):
def _broaden_wmp_polynomials(E, dopp, n):
"""Evaluate Doppler-broadened windowed multipole curvefit.
The curvefit is a polynomial of the form
a/En + b/sqrt(En) + c + d sqrt(En) ...
a/E + b/sqrt(E) + c + d sqrt(E) ...
Parameters
----------
En : Real
E : Real
Energy to evaluate at.
dopp : Real
sqrt(atomic weight ratio / kT) in units of eV.
@ -92,7 +92,7 @@ def _broaden_wmp_polynomials(En, dopp, n):
The value of each Doppler-broadened curvefit polynomial term.
"""
sqrtE = np.sqrt(En)
sqrtE = np.sqrt(E)
beta = sqrtE * dopp
half_inv_dopp2 = 0.5 / dopp**2
quarter_inv_dopp4 = half_inv_dopp2**2
@ -100,10 +100,10 @@ def _broaden_wmp_polynomials(En, dopp, n):
if beta > 6.0:
# Save time, ERF(6) is 1 to machine precision.
# beta/sqrtpi*exp(-beta**2) is also approximately 1 machine epsilon.
erfBeta = 1.0
erf_beta = 1.0
exp_m_beta2 = 0.0
else:
erfBeta = np.erf(beta)
erf_beta = np.erf(beta)
exp_m_beta2 = np.exp(-beta**2)
# Assume that, for sure, we'll use a second order (1/E, 1/V, const)
@ -111,9 +111,9 @@ def _broaden_wmp_polynomials(En, dopp, n):
factors = np.zeros(n)
factors[0] = erfBeta / En
factors[0] = erf_beta / E
factors[1] = 1.0 / sqrtE
factors[2] = (factors[0] * (half_inv_dopp2 + En)
factors[2] = (factors[0] * (half_inv_dopp2 + E)
+ exp_m_beta2 / (beta * np.sqrt(np.pi)))
# Perform recursive broadening of high order components. range(1, n-4)
@ -122,11 +122,11 @@ def _broaden_wmp_polynomials(En, dopp, n):
for i in range(1, n-4):
if i != 1:
factors[i+2] = (-factors[i-2] * (i - 1.0) * i * quarter_inv_dopp4
+ factors[i] * (En + (1.0 + 2.0 * i) * half_inv_dopp2))
+ factors[i] * (E + (1.0 + 2.0 * i) * half_inv_dopp2))
else:
# Although it's mathematically identical, factors[0] will contain
# nothing, and we don't want to have to worry about memory.
factors[i+2] = factors[i]*(En + (1.0 + 2.0 * i) * half_inv_dopp2)
factors[i+2] = factors[i]*(E + (1.0 + 2.0 * i) * half_inv_dopp2)
return factors

View file

@ -772,11 +772,11 @@ contains
!===============================================================================
! BROADEN_WMP_POLYNOMIALS Doppler broadens the windowed multipole curvefit. The
! curvefit is a polynomial of the form
! a/En + b/sqrt(En) + c + d sqrt(En) ...
! a/E + b/sqrt(E) + c + d sqrt(E) ...
!===============================================================================
subroutine broaden_wmp_polynomials(En, dopp, n, factors)
real(8), intent(in) :: En ! Energy to evaluate at
subroutine broaden_wmp_polynomials(E, dopp, n, factors)
real(8), intent(in) :: E ! Energy to evaluate at
real(8), intent(in) :: dopp ! sqrt(atomic weight ratio / kT),
! kT given in eV.
integer, intent(in) :: n ! number of components to polynomial
@ -788,10 +788,10 @@ contains
real(8) :: beta ! sqrt(atomic weight ratio * E / kT)
real(8) :: half_inv_dopp2 ! 0.5 / dopp**2
real(8) :: quarter_inv_dopp4 ! 0.25 / dopp**4
real(8) :: erfbeta ! error function of beta
real(8) :: erf_beta ! error function of beta
real(8) :: exp_m_beta2 ! exp(-beta**2)
sqrtE = sqrt(En)
sqrtE = sqrt(E)
beta = sqrtE * dopp
half_inv_dopp2 = HALF / dopp**2
quarter_inv_dopp4 = half_inv_dopp2**2
@ -799,30 +799,30 @@ contains
if (beta > 6.0_8) then
! Save time, ERF(6) is 1 to machine precision.
! beta/sqrtpi*exp(-beta**2) is also approximately 1 machine epsilon.
erfBeta = ONE
erf_beta = ONE
exp_m_beta2 = ZERO
else
erfBeta = erf(beta)
erf_beta = erf(beta)
exp_m_beta2 = exp(-beta**2)
end if
! Assume that, for sure, we'll use a second order (1/E, 1/V, const)
! fit, and no less.
factors(1) = erfbeta / En
factors(1) = erf_beta / E
factors(2) = ONE / sqrtE
factors(3) = factors(1) * (half_inv_dopp2 + En) &
factors(3) = factors(1) * (half_inv_dopp2 + E) &
+ exp_m_beta2 / (beta * SQRT_PI)
! Perform recursive broadening of high order components
do i = 1, n-3
if (i /= 1) then
factors(i+3) = -factors(i-1) * (i - ONE) * i * quarter_inv_dopp4 &
+ factors(i+1) * (En + (ONE + TWO * i) * half_inv_dopp2)
+ factors(i+1) * (E + (ONE + TWO * i) * half_inv_dopp2)
else
! Although it's mathematically identical, factors(0) will contain
! nothing, and we don't want to have to worry about memory.
factors(i+3) = factors(i+1)*(En + (ONE + TWO * i) * half_inv_dopp2)
factors(i+3) = factors(i+1)*(E + (ONE + TWO * i) * half_inv_dopp2)
end if
end do
end subroutine broaden_wmp_polynomials