Thursday, March 24, 2016

Shooting Method on Potential Well

It's the base code I wrote using Python, still need improvement to get energy level or even what energy allowed in the system.

from pylab import *

n   = 19
psi0= zeros(n)
psi = psi0
x   = linspace(0,1,n)

psi0[0]  = 1.

plot(x,psi)

t   = 0
dx  = 1./8.
E   = .1
V   = 0.
while t< 27:
    t   += 1
    E   += .2
    k   = 2*dx*dx*(E-V)
    for i in range (1,n-1):
        psi[i+1]  = 2*psi0[i]-psi0[i-1]-k*psi0[i]
    
    psi0    = psi

    plot(x,psi)


xlabel('x')
ylabel('psi')
title(':)')
grid(True)
savefig("els.png")
show()


.