def integrand_btz_n(u, tau, n, R, rh, l, pm1, Om, lam, sig, deltaphi=0): s_int_fnc = lambda s: lam**2 * fp.exp(-s**2/4/sig**2)\ * (fp.exp(-fp.j*Om*s) * wightman_btz_n(s,n,R,rh,l,pm1,Om,lam,sig)) if n != 0 or deltaphi != 0: pt1 = fp.mpf( mp.acosh(rh**2 / (R**2 - rh**2) * (R**2 / rh**2 * fp.cosh(rh / l * (deltaphi - 2 * fp.pi * n)) - 1))) pt2 = fp.mpf( mp.acosh(rh**2 / (R**2 - rh**2) * (R**2 / rh**2 * fp.cosh(rh / l * (deltaphi - 2 * fp.pi * n)) + 1))) uplim = 2 * tau - u if n == 0: if uplim < pt2: output = fp.quad(s_int_fnc, [0, uplim]) else: output = fp.quad(s_int_fnc, [0, pt2]) + fp.quad( s_int_fnc, [pt2, uplim]) else: if uplim < pt1: output = fp.quad(s_int_fnc, [0, uplim]) elif uplim < pt2: output = fp.quad(s_int_fnc, [0, pt1]) + fp.quad( s_int_fnc, [pt1, uplim]) else: output = fp.quad(s_int_fnc,[0,pt1]) + fp.quad(s_int_fnc,[pt1,pt2])\ + fp.quad(s_int_fnc,[pt2,uplim]) output *= fp.exp(-u**2 / 4 / sig**2) return output
def mycoulfg_mix_rescaled(angL, eta, rho, hvalue, dirvalue): f, df, g, dg = mycoulfg_mix(angL, eta, rho, hvalue, dirvalue) f = f / fp.mpf(mp.coulombc(angL, eta)) * eta**(angL + 1) df = df / fp.mpf(mp.coulombc(angL, eta)) * eta**(angL + 1) g = g * fp.mpf(mp.coulombc(angL, eta)) / eta**angL dg = dg * fp.mpf(mp.coulombc(angL, eta)) / eta**angL return f, df, g, dg
def Pdot_n(tau, n, R, rh, l, pm1, Om, lam, sig, deltaphi=0, eps=1e-6): if n == 0: if deltaphi == 0: lim2 = fp.mpf(mp.acosh(mp.mpf(rh**2/(R**2-rh**2)\ *(R**2/rh**2 * fp.cosh(rh/l * (deltaphi - 2*fp.pi*n)) + 1)))) #print(lim2) fmins = lambda s: integrand_Pdotm_n(s, tau, 0, R, rh, l, pm1, Om, lam, sig, deltaphi, eps).real fplus = lambda s: integrand_Pdotp_n(s, tau, 0, R, rh, l, pm1, Om, lam, sig, deltaphi, eps).real return fp.quad(fmins, [0, tau + 10 * sig]) + fp.quad( fplus, [0, lim2]) + fp.quad(fplus, [lim2, tau + 10 * sig]) else: lim1 = fp.mpf(mp.acosh(mp.mpf(rh**2/(R**2-rh**2)\ *(R**2/rh**2 * fp.cosh(rh/l * (deltaphi - 2*fp.pi*n)) - 1)))) lim2 = fp.mpf(mp.acosh(mp.mpf(rh**2/(R**2-rh**2)\ *(R**2/rh**2 * fp.cosh(rh/l * (deltaphi - 2*fp.pi*n)) + 1)))) fmins = lambda s: integrand_Pdotm_n(s, tau, 0, R, rh, l, pm1, Om, lam, sig, deltaphi, 0).real fplus = lambda s: integrand_Pdotp_n(s, tau, 0, R, rh, l, pm1, Om, lam, sig, deltaphi, 0).real return fp.quad(fmins,[0,lim1]) + fp.quad(fmins,[lim1,tau+10*sig])\ + fp.quad(fplus,[0,lim2]) + fp.quad(fplus,[lim2,tau+10*sig]) else: lim1 = fp.mpf(mp.acosh(mp.mpf(rh**2/(R**2-rh**2)\ *(R**2/rh**2 * fp.cosh(rh/l * (deltaphi - 2*fp.pi*n)) - 1)))) lim2 = fp.mpf(mp.acosh(mp.mpf(rh**2/(R**2-rh**2)\ *(R**2/rh**2 * fp.cosh(rh/l * (deltaphi - 2*fp.pi*n)) + 1)))) fmins = lambda s: integrand_Pdotm_n(s, tau, n, R, rh, l, pm1, Om, lam, sig, deltaphi, 0).real fplus = lambda s: integrand_Pdotp_n(s, tau, n, R, rh, l, pm1, Om, lam, sig, deltaphi, 0).real return fp.quad(fmins,[0,lim1]) + fp.quad(fmins,[lim1,tau+10*sig])\ + fp.quad(fplus,[0,lim2]) + fp.quad(fplus,[lim2,tau+10*sig])
def mycoulfg_rescaled(angL, eta, rho): f, df, g, dg, IFAIL = mycoulfg(angL, eta, rho) f = f / fp.mpf(mp.coulombc(angL, eta)) * eta**(angL + 1) df = df / fp.mpf(mp.coulombc(angL, eta)) * eta**(angL + 1) g = g * fp.mpf(mp.coulombc(angL, eta)) / eta**angL dg = dg * fp.mpf(mp.coulombc(angL, eta)) / eta**angL return f, df, g, dg, IFAIL
def P_BTZn(n,R,rh,l,pm1,Om,lam,sig): b = fp.sqrt(R**2-rh**2)/l lim = 20*sig*rh/b/l**2 print('limit: ',lim) Zm = fp.mpf(1) #rh**2/(R**2-rh**2)*(R**2/rh**2 * fp.cosh(2*fp.pi*rh/l * n) - 1) Zp = rh**2/(R**2-rh**2)*(R**2/rh**2 * fp.cosh(2*fp.pi*rh/l * n) + 1) print('Zm: ',Zm, 'Zp: ',Zp, 'acosh(Zp): ', fp.mpf(mp.acosh(Zp))) #print(Zm,fp.acosh(Zm)) # plt.figure() # xaxis = fp.linspace(0,lim/5,50) # yaxis = [f02(x,n,R,rh,l,pm1,Om,lam,sig) for x in xaxis] # plt.plot(xaxis,yaxis) # plt.show() if pm1==-1 or pm1==1 or pm1==0: if n==0: return 0\ - fp.quad(lambda x: f02(x,n,R,rh,l,pm1,Om,lam,sig),[0,fp.mpf(mp.acosh(Zp))])\ - fp.quad(lambda x: f02(x,n,R,rh,l,pm1,Om,lam,sig),[fp.mpf(mp.acosh(Zp)),lim]) #fp.quad(lambda x: f01(x,n,R,rh,l,pm1,Om,lam,sig),[-fp.inf,fp.inf]) # else: # if fp.cosh(lim) < Zm or Zm < 1: # return fp.quad(lambda x: fn1(x,n,R,rh,l,pm1,Om,lam,sig)\ # - fn2(x,n,R,rh,l,pm1,Om,lam,sig),[0,lim]) # else: # return fp.quad(lambda x: fn1(x,n,R,rh,l,pm1,Om,lam,sig)\ # - fn2(x,n,R,rh,l,pm1,Om,lam,sig),[0,fp.mpf(mp.acosh(Zm))])\ # - fp.quad(lambda x: fn1(x,n,R,rh,l,pm1,Om,lam,sig)\ # - fn2(x,n,R,rh,l,pm1,Om,lam,sig),[fp.mpf(mp.acosh(Zm)),lim]) else: print("Please enter a value of 1, -1, or 0 for pm1.")
def drho_coulombg_rescaled(angL, eta, rho, hvalue, dirvalue): return fp.mpf( mp.diff(lambda x: mp.coulombg(angL, eta, x), rho, 1, h=hvalue, direction=dirvalue)) * fp.mpf(mp.coulombc(angL, eta)) / eta**angL
def sigma_geon_n(y, n, RA, RB, rh, l, pm1, deltaphi, isP): if isP: return RA*RB/rh**2 * fp.mpf( mp.cosh(rh/l * (deltaphi-2*fp.pi*n)) ) - 1\ + fp.sqrt(RA**2-rh**2)*fp.sqrt(RB**2-rh**2)/rh**2 \ * fp.mpf(mp.cosh(rh/l/mp.sqrt(RA*RB-rh**2) * y) ) else: return RA*RB/rh**2 * fp.mpf( mp.cosh(rh/l * (deltaphi-2*fp.pi*n)) ) - 1\ + fp.sqrt(RA**2-rh**2)*fp.sqrt(RB**2-rh**2)/rh**2 \ * fp.mpf(mp.cosh(rh/l**2 * y) )
def f02(y, n, R, rh, l, pm1, Om, lam, sig): K = lam**2 * sig / 2 / fp.sqrt(2 * fp.pi) a = (R**2 - rh**2) * l**2 / 4 / sig**2 / rh**2 b = fp.sqrt(R**2 - rh**2) * Om * l / rh Zp = mp.mpf((R**2 + rh**2) / (R**2 - rh**2)) if Zp - mp.cosh(y) > 0: return fp.mpf(K * mp.exp(-a * y**2) * mp.cos(b * y) / mp.sqrt(Zp - mp.cosh(y))) elif Zp - mp.cosh(y) < 0: return fp.mpf(-K * mp.exp(-a * y**2) * mp.sin(b * y) / mp.sqrt(mp.cosh(y) - Zp)) else: return 0
def f02(y,n,R,rh,l,pm1,Om,lam,sig): K = lam**2*sig/2/fp.sqrt(2*fp.pi) a = (R**2-rh**2)*l**2/4/sig**2/rh**2 b = fp.sqrt(R**2-rh**2)*Om*l/rh Zp = mp.mpf((R**2+rh**2)/(R**2-rh**2)) if Zp == mp.cosh(y): print("RIP MOM PLSSS") #print(Zp, y, fp.cosh(y)) if Zp - mp.cosh(y) > 0: return K * fp.exp(-a*y**2) * fp.cos(b*y) / fp.mpf(mp.sqrt(Zp - mp.cosh(y))) elif Zp - mp.cosh(y) < 0: return -K * fp.exp(-a*y**2) * fp.sin(b*y) / fp.mpf(mp.sqrt(mp.cosh(y) - Zp)) else: return 0
def fn1(y, n, R, rh, l, pm1, Om, lam, sig): K = lam**2 * sig / 2 / fp.sqrt(2 * fp.pi) a = (R**2 - rh**2) * l**2 / 4 / sig**2 / rh**2 b = fp.sqrt(R**2 - rh**2) * Om * l / rh Zm = mp.mpf(rh**2 / (R**2 - rh**2) * (R**2 / rh**2 * fp.cosh(2 * fp.pi * rh / l * n) - 1)) if Zm == mp.cosh(y): return 0 elif Zm - fp.cosh(y) > 0: return fp.mpf(K * mp.exp(-a * y**2) * mp.cos(b * y) / mp.sqrt(Zm - mp.cosh(y))) else: return fp.mpf(-K * mp.exp(-a * y**2) * mp.sin(b * y) / mp.sqrt(mp.cosh(y) - Zm))
def PGEON_n(n, R, rh, l, pm1, Om, lam, sig): """ Om = energy difference lam = coupling constant """ if pm1 == -1 or pm1 == 1 or pm1 == 0: return lam**2*sig*fp.sqrt(fp.pi) * fp.mpf(mp.exp(-sig**2 * Om**2)) *\ fp.quad(lambda x: h_n(x,n,R,rh,l,pm1) * PGEON_gaussian(x,sig), [-fp.inf, fp.inf]) else: print("Please enter a value of 1, -1, or 0 for pm1.")
def P_BTZn(n, RA, RB, rh, l, pm1, Om, lam, tau0, width, deltaphi=0, eps=1e-8, isP=True): f = lambda y: integrandof_P_BTZn(y, n, RA, RB, rh, l, pm1, Om, lam, tau0, width, deltaphi, isP) if n == 0 and deltaphi == 0 and RA == RB: # P0m P0m = 2 * fp.quad( lambda x: integrandPBTZ_0m(x, RA, rh, l, pm1, Om, lam, tau0, width, eps), [0, width]) intlim = l**2/rh * mp.acosh( (RA*RB/rh**2 * fp.mpf( mp.cosh(rh/l * (deltaphi-2*fp.pi*n)) ) + 1)\ / fp.sqrt(RA**2-rh**2)/fp.sqrt(RB**2-rh**2)*rh**2) if intlim < width: return fp.quad(f, [0, intlim]) + fp.quad(f, [intlim, width]) + P0m else: return fp.quad(f, [0, width]) + P0m else: intlim1 = l**2/rh * mp.acosh( (RA*RB/rh**2 * fp.mpf( mp.cosh(rh/l * (deltaphi-2*fp.pi*n)) ) - 1)\ / fp.sqrt(RA**2-rh**2)/fp.sqrt(RB**2-rh**2)*rh**2) intlim2 = l**2/rh * mp.acosh( (RA*RB/rh**2 * fp.mpf( mp.cosh(rh/l * (deltaphi-2*fp.pi*n)) ) + 1)\ / fp.sqrt(RA**2-rh**2)/fp.sqrt(RB**2-rh**2)*rh**2) #print('%.4f, %.4f'%(intlim1,intlim2)) if intlim2 < width: return fp.quad(f, [0, intlim1]) + fp.quad( f, [intlim1, intlim2]) + fp.quad(f, [intlim2, width]) elif intlim1 < width: return fp.quad(f, [0, intlim1]) + fp.quad(f, [intlim1, width]) else: return fp.quad(f, [0, width])
def Xn_plus(n, RA, RB, rh, l, pm1, Om, lam, tau0, width, deltaphi, isP): intlim2 = l**2/rh * mp.acosh( (RA*RB/rh**2 * fp.mpf( mp.cosh(rh/l * (deltaphi-2*fp.pi*n)) ) + 1)\ / fp.sqrt(RA**2-rh**2)/fp.sqrt(RB**2-rh**2)*rh**2) #print('plus, %.4f ;'%intlim2) f = lambda y: integrandof_Xn_plus(y, n, RA, RB, rh, l, pm1, Om, lam, tau0, width, deltaphi, isP) if intlim2 < width: return fp.quad(f, [0, intlim2]) + fp.quad(f, [intlim2, width]) else: return fp.quad(f, [0, width])
def P_BTZn(n, R, rh, l, pm1, Om, lam, sig): b = fp.sqrt(R**2 - rh**2) / l lim = 20 * sig * rh / b / l**2 #Zp = mp.mpf(rh**2/(R**2-rh**2)*(R**2/rh**2 * fp.cosh(2*fp.pi*rh/l * n) + 1)) #print('Zm: ',Zm, 'Zp: ',Zp) #print(Zm,fp.acosh(Zm)) if pm1 == -1 or pm1 == 1 or pm1 == 0: if n == 0: return fp.quad(lambda x: f01(x, n, R, rh, l, pm1, Om, lam, sig), [-fp.inf, fp.inf]) else: Zm = rh**2 / (R**2 - rh**2) * ( R**2 / rh**2 * fp.cosh(2 * fp.pi * rh / l * n) - 1) if fp.cosh(lim) < Zm or Zm < 1: return fp.quad(lambda x: fn1(x,n,R,rh,l,pm1,Om,lam,sig)\ - fn2(x,n,R,rh,l,pm1,Om,lam,sig),[0,lim]) else: return fp.quad(lambda x: fn1(x,n,R,rh,l,pm1,Om,lam,sig)\ - fn2(x,n,R,rh,l,pm1,Om,lam,sig),[0,fp.mpf(mp.acosh(Zm))])\ - fp.quad(lambda x: fn1(x,n,R,rh,l,pm1,Om,lam,sig)\ - fn2(x,n,R,rh,l,pm1,Om,lam,sig),[fp.mpf(mp.acosh(Zm)),lim]) else: print("Please enter a value of 1, -1, or 0 for pm1.")
def mycoulfg_mix(angL, eta, rho, hvalue, dirvalue): if rho > (eta + np.sqrt(eta**2 + angL * (angL + 1))): f, df, g, dg, IFAIL = mycoulfg(angL, eta, rho) if (IFAIL != 0): print(IFAIL) else: f = fp.mpf(mp.coulombf(angL, eta, rho)) g = fp.mpf(mp.coulombg(angL, eta, rho)) df = fp.mpf( mp.diff(lambda x: mp.coulombf(angL, eta, x), rho, 1, h=hvalue, direction=dirvalue)) dg = fp.mpf( mp.diff(lambda x: mp.coulombg(angL, eta, x), rho, 1, h=hvalue, direction=dirvalue)) # print(f,df,g,dg) return f, df, g, dg
def T_P_int_geon(x, tau, tau0, n, R, rh, l, pm1, Om, lam, sig, deltaphi=0): K = lam**2 / (np.sqrt(2) * np.pi * l * Om) * rh / np.sqrt(R**2 - rh**2) Gm = rh**2 / (R**2 - rh**2) * (R**2 / rh**2 * fp.mpf( mp.cosh(rh / l * (deltaphi - 2 * np.pi * (n + 0.5)))) - 1) Gp = rh**2 / (R**2 - rh**2) * (R**2 / rh**2 * fp.mpf( mp.cosh(rh / l * (deltaphi - 2 * np.pi * (n + 0.5)))) + 1) if tau < tau0: return 0 elif x < (tau + tau0): return K * fp.sin(Om*(2*tau0+x))\ * (1/fp.sqrt(Gm + fp.mpf(mp.cosh(rh/l**2 * x))) - 1/fp.sqrt(Gp + fp.mpf(mp.cosh(rh/l**2 * x)))) else: return K * fp.sin(Om*(2*tau-x))\ * (1/fp.sqrt(Gm + fp.mpf(mp.cosh(rh/l**2 * x))) - 1/fp.sqrt(Gp + fp.mpf(mp.cosh(rh/l**2 * x))))
def f01(y, n, R, rh, l, pm1, Om, lam, sig): return lam**2*sig**2/2 * fp.exp(-sig**2*(y-Om)**2)\ / fp.mpf((mp.exp(y * 2*mp.pi*l*mp.sqrt(R**2-rh**2)/rh) + 1))
def coulombg_rescaled(angL, eta, rho): return fp.mpf(mp.coulombg(angL, eta, rho)) * fp.mpf(mp.coulombc( angL, eta)) / eta**angL
dR = 1 R = 1 / 2 * np.exp(-dR / l) * (rh * np.exp(2 * dR / l) + rh) lowlim, uplim = -3, 3 tau = np.linspace(lowlim, uplim, num=30) #tau = np.exp(np.linspace(np.log(lowlim),np.log(uplim),num=20)) y = 0 * tau P = P_BTZn(0, R, rh, l, pm1, Om, lam, sig) #for n in range(1,nmax+1): # P += 2*P_BTZn(n,R,rh,l,pm1,Om,lam,sig) print("i=") for i in range(len(tau)): print(i, end=', ', flush=True) for n in range(nmax + 1): y[i] += fp.mpf( P_BTZ_n_tau(tau[i], n, R, rh, l, pm1, Om, lam, sig).real) print(y[-1]) #fig = plt.figure(figsize=(9,5)) plt.plot(tau, y) plt.plot([lowlim, uplim], [P, P], linestyle=':', label=r'$P$') plt.legend() plt.xlabel(r'$\tau$') plt.ylabel(r'$P(\tau)$') #%% x = np.linspace(-5, 5, num=100) #y=[T_P_int_geon(xi,-1,0,R,rh,l,pm1,Om,lam,sig) for xi in x] y = [fp.erf(xi + fp.j).real for xi in x] plt.plot(x, y)
def coulombf_rescaled(angL, eta, rho): return fp.mpf(mp.coulombf(angL, eta, rho)) / fp.mpf(mp.coulombc( angL, eta)) * eta**(angL + 1)
def PGEON_gaussian(x, sig): return fp.mpf(mp.exp(-x**2 / 4 / sig**2))
def sigma_geon(x, n, R, rh, l): return R**2/rh**2 * fp.mpf(mp.cosh(2*mp.pi * rh/l * (n+1/2))) - 1 + (R**2-rh**2)/rh**2\ * fp.mpf(mp.cosh(rh/l**2 * x))
# use fp.mpf to change the results to float numbers. # To speed up the calculation, the Coulomb functions from a Fortran code embedded in the r-matrix code is also # included here, imported as mycoulfg . # So I have code to return mycoulfy calculations in the region the Fortran code is reliable and mpmmath calculations # outside that region. These functions are labeled by _mix # Also the rescaled Coulomb functions are also provided here, to mitigate the problem of F and G becoming too small # or too big in the near zero energy region. import numpy as np from mpmath import fp, mp from scipy import special as ss from coulomb_Barnett import mycoulfg mp.dps = 20 coulombf_ufunc = np.frompyfunc( lambda angL, eta, rho: fp.mpf(mp.coulombf(angL, eta, rho)), 3, 1) # argment: angL, eta, rho=k*r coulombg_ufunc = np.frompyfunc( lambda angL, eta, rho: fp.mpf(mp.coulombg(angL, eta, rho)), 3, 1) # argment: angL, eta, rho=k*r coulombw_ufunc = np.frompyfunc( lambda angL, eta, rho: fp.mpf(mp.whitw(eta, angL + 0.5, 2 * rho)), 3, 1) # argment: angL, eta, rho=k*r # argment: angL, eta, rho=k*r, note this order is different from whitw's argument, i #and there is a factor of 2 for the 3rd argument drho_coulombf_ufunc = np.frompyfunc( lambda angL, eta, rho, hvalue, dirvalue: fp.mpf( mp.diff(lambda x: mp.coulombf(angL, eta, x), rho, 1, h=hvalue,
def integrand2(u, a): f = lambda s: fp.exp(-s**2) * (fp.exp(fp.j*(s+u)) * fp.mpf(mp.exp(-np.abs(u)))\ + fp.exp(fp.j*u) * fp.mpf(mp.exp(-np.abs(s+u))) ) return fp.quad(f, [0, fp.inf])