CurrentModule = Antique
The infinite potential well (particle in a box) is the simplest model for quantum mechanical system.
This model is described with the time-independent Schrödinger equation
and the Hamiltonian
Parameters are specified with the following struct.
Antique.InfinitePotentialWell
Antique.V(::InfinitePotentialWell, ::Any)
Antique.E(::InfinitePotentialWell)
Antique.ψ(::InfinitePotentialWell, ::Any)
[Install Antique.jl](@ref Install) for the first use and run using Antique
before each use. The energy E()
, wavefunction ψ()
and potential V()
will be exported. In this system, the model is generated by InfinitePotentialWell
and several parameters L
, m
and ℏ
are set as optional arguments.
using Antique
IPW = InfinitePotentialWell(L=1.0, m=1.0, ℏ=1.0)
; #hide
Parameters:
IPW.L
IPW.m
IPW.ℏ
Eigenvalues:
E(IPW, n=1)
E(IPW, n=2)
Wave functions:
using CairoMakie
# settings
f = Figure()
ax = Axis(f[1,1], xlabel=L"$x$", ylabel=L"$\psi(x)$")
# plot
w1 = lines!(ax, 0..1, x -> ψ(IPW, x, n=1))
w2 = lines!(ax, 0..1, x -> ψ(IPW, x, n=2))
w3 = lines!(ax, 0..1, x -> ψ(IPW, x, n=3))
w4 = lines!(ax, 0..1, x -> ψ(IPW, x, n=4))
w5 = lines!(ax, 0..1, x -> ψ(IPW, x, n=5))
# legend
axislegend(ax, [w1, w2, w3, w4, w5], [L"n=1", L"n=2", L"n=3", L"n=4", L"n=5"], position=:lb)
f
Potential energy curve, Energy levels, Wave functions:
using CairoMakie
# settings
f = Figure()
ax = Axis(f[1,1], xlabel=L"$x$", ylabel=L"$V(x),~E_n,~\psi_n(x) \times 5 + E_n$", aspect=1, limits=(-0.5,1.5,0,140))
# hidespines!(ax)
# hidedecorations!(ax)
# plot
for n in 1:5
# energy
lines!(ax, [0,IPW.L], fill(E(IPW,n=n),2), color=:black, linewidth=2)
# wave function
lines!(ax, 0..IPW.L, x -> E(IPW,n=n) + 5*ψ(IPW,x,n=n), linewidth=2)
end
#potential
lines!(ax, [0,0,IPW.L,IPW.L], [140,0,0,140], color=:black, linewidth=2)
f
save("assets/fig/InfinitePotentialWell.png", f) # hide
; # hide
Unit testing and Integration testing were done using numerical integration (QuadGK.jl). The test script is here.
using Markdown
using Antique
Markdown.parse(Antique.load("../../test/result/InfinitePotentialWell.log"))