def Analatic_sol(R, n=0, De=10, a=1, Re=1): e = exp(1) X = R * a Xe = Re * a lam = ((2 * m * De)**.5) / (a * h) eps = -(lam - n - .5)**2 alp = (2 * lam - 2 * n - 1) #alpha En = (eps * (a * h)**2 / (2 * m)) + 10 Z = 2 * lam * e**(-(X - Xe)) Nn = (fac(n) * (alp) / (gm(2 * lam - n)))**.5 L = lag(n, alp, Z) #lagragian Psi = Nn * Z**(alp / 2) * e**(-.5 * Z) * L Psi_N, A = Normalize(R, Psi) if n % 2 == 1: Psi_N = -Psi_N return Psi_N, En
from scipy.special import gamma as gm import numpy as np from math import exp from math import factorial as fac import matplotlib.pyplot as plt De = 10 a = .8 Re = 1 e = exp(1) R = np.linspace(-1, 5, 100) X = R * a Xe = Re * a m, h = 1, 1 lam = ((2 * m * De)**.5) / (a * h) n = 5 #n<=[lamda-1/2] eps = -(lam - n - .5)**2 alp = (2 * lam - 2 * n - 1) #alpha En = eps * (a * h)**2 / (2 * m) + 10 Z = 2 * lam * e**(-(X - Xe)) Nn = (fac(n) * (alp) / (gm(2 * lam - n)))**.5 L = lag(n, alp, Z) #lagragian Psi = Nn * Z**(alp / 2) * e**(-.5 * Z) * L plt.plot(X, Psi) plt.show()
def beta_function(a, b, u): # function to calculate beta distribution value for given a, b, and u beta = (gm(a + b) / (gm(a) * gm(b))) * (u**(a - 1)) * ((1 - u)**(b - 1)) return beta
def Deuteron(B, minimized=False): #Constants #--------------------------------------- hbarC = 197.327054 #MeV fm m1 = 938.28 #Proton Mass m2 = 939.57 #Neutron Mass mu = m1 * m2 / (m1 + m2) R = 20 #fm dx = 1 / 128 xi = 2 * mu / hbarC**2 gamma = np.sqrt(xi * B) #--------------------------------------- #Long Range Solutions VNN = 0 # s-wave l=0 #--------------------------------------- f_s = np.exp(-gamma * R) f_s_prime = -gamma * f_s #--------------------------------------- # d-wave l=2 #--------------------------------------- f_d = (1 + 3 / (gamma * R) + 3 / (gamma**2 * R**2)) * f_s f_d_prime = -f_s * (gamma + 3 / R + 6 / (gamma * R**2) + 6 / (gamma**2 * R**3)) #--------------------------------------- #Starting Value of Independent Solutions ~0 #--------------------------------------- c = 10**-6 U_zero = np.array([c, 0]) U_two = np.array([0, c]) # Run Numerov #-------------------------------------- r, u0, w0 = Numerov(U_zero, B, xi, dx, R) r, u2, w2 = Numerov(U_two, B, xi, dx, R) #--------------------------------------- #Compute Derivatives -- Central Difference #--------------------------------------- phi = [u0[-2],\ w0[-2],\ (u0[-1] - u0[-3])/(2*dx),\ ((w0[-1] - w0[-3]))/(2*dx)] psi = [u2[-2],\ w2[-2],\ (u2[-1] - u2[-3])/(2*dx),\ ((w2[-1] - w2[-3]))/(2*dx)] #--------------------------------------- #Generate Matrix (4x4) #--------------------------------------- FS = np.array([-f_s, 0, -f_s_prime, 0]) FD = np.array([0, -f_d, 0, -f_d_prime]) M = np.array([phi, psi, FS, FD]) #--------------------------------------- #Compute Determanint -- Should be zero #--------------------------------------- det = abs(np.linalg.det(M)) #--------------------------------------- ######################################## # Deuteron Properties # ######################################## if minimized == True: print("Binding Energy: " + str(-B)) phi_c, phi_t, phi_c_prime, phi_t_prime = phi psi_c, psi_t, psi_c_prime, psi_t_prime = psi # a = (f_s*psi_c_prime-f_s_prime*psi_c)/(phi_c*psi_c_prime-phi_c_prime*psi_c) # b = (f_s*phi_c_prime-f_s_prime*phi_c)/(psi_c*phi_c_prime-psi_c_prime*phi_c) b = (f_s * phi_c_prime - f_s_prime * phi_c) / (psi_c * phi_c_prime - psi_c_prime * phi_c) a = b * (f_d * psi_t_prime - psi_t * f_d_prime) / (phi_t * f_d_prime - phi_t_prime * f_d) u = a * u0 + b * u2 #s-wave Solution w = a * w0 + b * w2 #d-wave Solution #Proportion of Deuteron in d-wave eta = (a * phi_t + b * psi_t) / f_d print("Eta: " + str(eta)) #--------------------------------------- Iu = simps(u**2, r) Iw = simps(w**2, r) fs_I = (np.exp(-2 * gamma * R)) / (2 * gamma) fd_I = fs_I * (1 + 6 / (gamma * R) + 12 / (gamma * R)**2 + 6 / (gamma * R)**3) inf = fs_I + eta**2 * fd_I As = Iu + Iw + inf As2 = 1 / (As) print("As: " + str(np.sqrt(As2))) #--------------------------------------- #Useful Calculation -- Total Probabilty of d-wave Pd = Iw + eta**2 * fd_I Pd *= As2 print("Pd: " + str(Pd)) #--------------------------------------- muP = 2.793 #Magnetic Moment of Proton (Exp) muN = -1.913 #Magnetic Moment of Neutron (Exp) #Deuteron Magnetic Moment muD = (muN + muP) * (1 - 1.5 * Pd) + .75 * Pd print("Magnetic Moment: " + str(muD)) #--------------------------------------- #Useful Constants -- infinite integration of fs -- fd -- *r^2 # integrand = exp(-2*gamma*R)*r^(2)/(gamma*r)^(pow) #factored out exp(-2*gamma*R)/(4*gamma**3) I0 = 2 * gamma * R * (gamma * R + 1) + 1 #pow = 0 I1 = 2 * gamma * R + 1 #pow = 1 I2 = 2 #pow = 2 #---- #Incomplete Gamma Function -- Scipy Uses Regularized -- Fixed a = 10**(-8) ginc = gm(a) * gammaincc(a, 2 * R * gamma) / np.exp(-2 * gamma * R) #---- I3 = 4 * ginc I4 = 4 / (gamma * R) - 8 * ginc #--------------------------------------- #Deteron Radius: integrand = (r**2) * (u**2 + w**2) rd_inf = I0 + eta**2 * (I0 + 6 * I1 + 15 * I2 + 18 * I3 + 9 * I4) rd_inf *= np.exp(-2 * gamma * R) / (4 * gamma**3) rd = simps(integrand, r) + rd_inf rd = np.sqrt(As2 * rd / 4) print("Deteron Radius: " + str(rd)) #--------------------------------------- #Quadrapole Moment: integrand = (u * w * np.sqrt(8) - w**2) * r**2 Qd_inf = eta * np.sqrt(8) * (I0 + 3 * I1 + 3 * I2) - eta**2 * ( I0 + 6 * I1 + 15 * I2 + 18 * I3 + 9 * I4) Qd_inf *= np.exp(-2 * gamma * R) / (4 * gamma**3) Qd = simps(integrand, r) + Qd_inf Qd *= As2 / 20 print("Quadrapole Moment: " + str(Qd)) #--------------------------------------- ######################################## else: print("Evaluated at B = " + str(B)) return det