I am looking for the ground state energy of the wavefcn that can fit in a given potential:
import numpy as np
import matplotlib.pyplot as plt
import math
ximin=-8
ximax=-ximin
Nsteps=1001
nu0=4.0
psi = np.linspace(ximin,ximax,Nsteps)
h = psi[1] - psi[0]
v = -nu0*np.exp(-psi**2) #potential
Emin = -3.5 #first two guesses
Emax = -2.0
while ((Emin- Emax)/(Emin + Emax) > 10**(-8)): #tolerance
if abs(fi[-1]) > abs(10**(-8)): #condition that the wavefcn doesnt blow up
Eo = (Emin + Emax)/2.0
if fi[-1] < -10**(-8): #blows down
Emax = Eo
if fi[-1] > 10**(-8): #blows up
Emin = Eo
else:
break
fi = np.zeros(Nsteps)
fi[0]= 1
k = (-Eo)**(0.5)
fi[1] = np.exp(k*h)
for i in range(2,len(psi)):
fi[i]=(2+h**2 * (v[i-1]-Eo))*fi[i-1]-fi[i-2] #wavefcn
plt.plot(psi, fi)
the idea is that when the energy that we plug in is wrong, the wavefcn either blows up or down. Then for example we take an energy that is in the middle between the previous two and if that one blows up, then we will look for a new value between this last one and the one that blows down and so on . I should get a good energy value but I dont. Can anyone help?