I have code that attempts to implement a solution to the Schrödinger equation where there is a central potential (more or less im thinking of hydrogen), in 1-D using the numerov method to construct the wave function. It does not take care of the states (N=1,..) as my goal is to understand the link between the theory and the software. Here are some results for some energies, whether or not they are eigenvalues, im not sure:
[6.054999999999915, 6.214999999999912, 6.534999999999905]
and a graph
.
The algorithm im trying to implement is noted here in section 6
PDF, but my potential is different. My problem is, the central potential has a 1/r at the origin,
how would I deal with that? (I did a sidestep in the code by adding an arbitrary 0.00001 to eliminate 0).
There is a more general code in another question seen here, but I do not follow the shift from equation to 3d matrix.
Here is my code:
import numpy as np
import scipy
import matplotlib.pyplot as plt
h=np.float64(1)
m=60
c=m/2
estep = 1.0/(100)
delta = 0.0002
x=np.linspace(-1000,1000,num=m)
x=(x - x[m/2]+0.00001 )
v = 1.0/(x**2)
sig=None
E = []
def get_left(wf,k):
for i in range(2,int(c)):
wf[i] = 2*(( 1- 1/12* h**2* k[i-2]**2)*wf[i-2] - (1 + 1/12 *h**2* k[i-1]**2)*wf[i-1])/(1 + 1/12* h**2* k[i]**2)
wf[0:c] = wf[0:c]/(np.sqrt(np.sum(wf[0:c]**2)))
return wf
def get_right(wf,k):
mi = m-1
for i in range(2,int(c)):
wf[mi-i] = 2*(( 1- 1/12* h**2* k[mi-i+2]**2)*wf[mi-i+2] - (1 + 1/12 *h**2* k[mi-i+1]**2)*wf[mi-i+1])/(1 + 1/12* h**2*k[mi-i]**2)
wf[c:mi] = wf[c:mi]/(np.sqrt(np.sum(wf[c:mi]**2)))
return wf
def root_search(epsilonu, epsilonl):
en = None
it =0
while it < 10000:
phil = np.zeros(m)
phir = np.zeros(m)
phil[0] =0
phil[1] = 0.001
phir[m-1]=0
phir[m-2]=0.001
k = (-v + (epsilonu+epsilonl)/2)
phil = get_left(phil,k)
phir = get_right(phir,k)
diffl = np.diff(phil)
diffr = np.diff(phir)
erri = diffl[m/2]- diffr[m/2]
if erri < delta:
plt.plot(x, (phil+phir)**2 )
plt.savefig( str('sho'+'.png' ))
return (epsilonu+epsilonl)/2
if erri < 0 :
epsilonl = (epsilonu+epsilonl)/2
if erri > 0:
epsilonu =epsilonl
epsilonl = (epsilonu+epsilonl)/2
it+=1
return None
def start():
epsilonl=0.01
eps = epsilonl
epsilonu=None
iteration=0
sig = None
while iteration < 100000:
phil = np.zeros(m)
phir = np.zeros(m)
phil[0] =0
phil[1] = 0.001
phir[m-1]=0
phir[m-2]=0.001
k = (-v + eps)
phil = get_left(phil,k)
phir = get_right(phir,k)
diffl = np.diff(phil)
diffr = np.diff(phir)
err = diffl[m/2]- diffr[m/2]
ssig = 1 if err>0 else -1
if sig:
if sig != ssig:
epsilonu= eps
E.append(root_search(epsilonu, epsilonl))
print(E)
sig = ssig
epsilonl = eps
eps = eps+estep
iteration+=1
if __name__ == "__main__":
start()
The theory: Im attempting to solve the 1-D Schroedinger equation, $$ \left( -\frac{h^2}{2m}\frac{d^2}{dx^2} + V\left(x\right)\right) \phi\left(x\right) = \epsilon \phi\left( x\right) $$ with V as a central potential (coulombic force, inverse square relation), the final equation looks like (with proper choice of units to give q^2=1, h-1..., energy in hartree) $$ \frac{d^2}{dx^2}\phi\left(x\right) + 2 \left(\epsilon -\frac{1}{x^2} \right) \phi\left(x\right) =0 $$

