-
Notifications
You must be signed in to change notification settings - Fork 3
/
InfinitePotentialWell.jl
60 lines (48 loc) · 1.17 KB
/
InfinitePotentialWell.jl
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
60
export InfinitePotentialWell, V, E, ψ
@kwdef struct InfinitePotentialWell
L = 1.0
m = 1.0
ℏ = 1.0
end
function V(model::InfinitePotentialWell, x)
L = model.L
return 0<x<L ? 0 : Inf
end
function E(model::InfinitePotentialWell; n=1)
L = model.L
m = model.m
ℏ = model.ℏ
return (ℏ^2*n^2*π^2) / (2*m*L^2)
end
function ψ(model::InfinitePotentialWell, x; n=1)
L = model.L
return 0<x<L ? sqrt(2/L) * sin(n*π*x/L) : 0
end
@doc raw"""
`InfinitePotentialWell(L=1.0, m=1.0, ℏ=1.0)`
``L`` is the length of the box, ``m`` is the mass of particle and ``\hbar`` is the reduced Planck constant (Dirac's constant).
""" InfinitePotentialWell
@doc raw"""
`V(model::InfinitePotentialWell; x)`
```math
V(x) =
\left\{
\begin{array}{ll}
\infty & x \lt 0, L \lt x \\
0 & 0 \leq x \leq L
\end{array}
\right.
```
""" V(model::InfinitePotentialWell, x)
@doc raw"""
`E(model::InfinitePotentialWell; n=1)`
```math
E_n = \frac{\hbar^2 n^2 \pi^2}{2 m L^2}
```
""" E(model::InfinitePotentialWell; n=1)
@doc raw"""
`ψ(model::InfinitePotentialWell, x; n=1)`
```math
\psi_n(x) = \sqrt{\frac{2}{L}} \sin \frac{n\pi x}{L}
```
""" ψ(model::InfinitePotentialWell, x; n=1)