aboutsummaryrefslogtreecommitdiff
path: root/hw8/RadialBoundStates.jl
blob: ed7bcc98ccd252d329df291fee5cf7e75aaf26c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env julia

"""Find eigenstates and eigenenergies of central potential problems"""

using LinearAlgebra
using Plots

N = 5000  # number of lattice points
L = 20.0 # r runs from 0 to L
dr = L / N

D = zeros(N, N) # discrete radial 2nd derivative operator
V = zeros(N, N) # potential

for i in 1:N
	D[i, i] = -2.0
end

for i in 1:N-1
	D[i, i+1] = 1.0
	D[i+1, i] = 1.0
end

#println("\nLattice Laplacian operator")
#println(D)

function potential(r,  = 0)
	""" The potential energy"""
	#return 0.5 * ell * (ℓ+1.0) * pow(r, -2.0) # V=0: Free particle in spherical coordinates	

	return -1.0 / r + 0.5 *  * ( + 1.0) * r^(-2.0) # Hydrogen atom

	#return -r^(-1.1) + 0.5 * ℓ * (ℓ+1.0) * r^(-2.0) # modified Coulomb potential
end

for i in 1:N
	r = (i + 0.5) * dr # radial coordinates of lattice points
	V[i, i] = potential(r, 0)
end

H = -0.5 * dr^(-2.0) * D + V # Hamiltonian.  Here m = hbar = 1

#println("\nMatrix elements of Hamiltonian = ")
#println(H)

e, v = eigen(H) # diagonalize Hamiltonian

println("\nGround state energy = ", e[1])
println("\n1st excited state energy = ", e[2])
println("\n2nd excited state energy = ", e[3])
println("\n3rd excited state energy = ", e[4])
println("\n4th excited state energy = ", e[5])


plot(potential)


plot(v[:, 1])
#plot(v[:,2])