diff options
Diffstat (limited to 'hw8/10-3.jl')
-rw-r--r-- | hw8/10-3.jl | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/hw8/10-3.jl b/hw8/10-3.jl index 8616a69..2f4a690 100644 --- a/hw8/10-3.jl +++ b/hw8/10-3.jl @@ -60,16 +60,43 @@ function map_n_to_energies(n) return e end -n_max = 18 -n_to_e = [map_n_to_energies(n) for n in 1:n_max] +n_s = collect(0:1:18) +n_to_e = [map_n_to_energies(n) for n in n_s] # plot e[0] for all N -eList = zeros(0) -for i in 1:n_max - push!(eList, n_to_e[i][1]) +ground_state = [] +excited_1 = [] +excited_2 = [] +excited_3 = [] +for i in 1:length(n_to_e) + push!(ground_state, n_to_e[i][1]) + push!(excited_1, n_to_e[i][2]) + push!(excited_2, n_to_e[i][3]) + push!(excited_3, n_to_e[i][4]) end -plot(eList) +plot(ground_state, label = "groud state energy for n", xlabel = "n (level)", ylabel = "energy", title = "excited energy levels for V(n) = abs(x)^n", marker = :circle) +plot!(excited_1, label = "1st excited state", marker = :circle) +plot!(excited_2, label = "2nd excited state", marker = :circle) +plot!(excited_3, label = "3rd excited state", marker = :circle) + +# plot the energies for an inifinite square well as a horizontial line +# function excited_state_to_energy_inf_square_well(n) +# return n^2 * pi^2 / 2 +# end + +# ground_state_inf_square_well = [excited_state_to_energy_inf_square_well(1) for i in 1:length(n_s)] +# excited_1_inf_square_well = [excited_state_to_energy_inf_square_well(2) for i in 1:length(n_s)] +# excited_2_inf_square_well = [excited_state_to_energy_inf_square_well(3) for i in 1:length(n_s)] +# excited_3_inf_square_well = [excited_state_to_energy_inf_square_well(4) for i in 1:length(n_s)] + +# plot!(ground_state_inf_square_well, label = "ground state energy for infinite square well") +# plot!(excited_1_inf_square_well, label = "1st excited state for infinite square well") +# plot!(excited_2_inf_square_well, label = "2nd excited state for infinite square well") +# plot!(excited_3_inf_square_well, label = "3rd excited state for infinite square well") + + +savefig("hw8/10-3.png") # gs(x) = exp(-0.5 * x^2) # Gaussian that is exact ground state of SHO |