diff options
Diffstat (limited to 'hw8/RadialBoundStates.jl')
-rw-r--r-- | hw8/RadialBoundStates.jl | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/hw8/RadialBoundStates.jl b/hw8/RadialBoundStates.jl new file mode 100644 index 0000000..ed7bcc9 --- /dev/null +++ b/hw8/RadialBoundStates.jl @@ -0,0 +1,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]) |