Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
lectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Matthias Flór
lectures
Commits
4f403ded
Commit
4f403ded
authored
6 years ago
by
Sathish Kumar RK
Browse files
Options
Downloads
Patches
Plain Diff
harmonic_oscillator_plot.md
parent
8bdc6408
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/1_einstein_model.md
+96
-0
96 additions, 0 deletions
src/1_einstein_model.md
with
96 additions
and
0 deletions
src/1_einstein_model.md
+
96
−
0
View file @
4f403ded
...
...
@@ -65,6 +65,102 @@ This can be explained by considering a _quantum_ harmonic oscillator:

```
python
import
math
from
numpy.polynomial.hermite
import
Hermite
def
ho_evec
(
x
,
n
,
no_states
):
"""
Calculate the wavefunction of states confined in the harmonic oscillator
Input:
------
x: numpy array of x coordinates (in units of hbar.omega)
n: n^th bound state in the oscillator
no_states: no of states confined
Returns:
--------
Wavefunctions
"""
# calculate hermite polynomial
vec
=
[
0
]
*
no_states
vec
[
n
]
=
1
/
2
Hn
=
Hermite
(
vec
)
return
((
1
/
np
.
sqrt
(
math
.
factorial
(
n
)
*
2
**
n
))
*
pow
(
np
.
pi
,
-
1
/
4
)
*
np
.
exp
(
-
pow
(
x
,
2
)
/
2
)
*
Hn
(
x
))
def
h0_ener
(
n
):
"""
Calculate the energy of nth bound state
"""
return
(
n
+
1
/
2
)
x
=
np
.
linspace
(
-
4
,
4
,
100
)
#units of hbar.omega
no_states
=
7
#no of bound states confined in the quantum well
omega
=
1.0
#frequency of harmonic oscillator
V
=
0.5
*
(
omega
**
2
)
*
(
x
**
2
)
fig
,
ax
=
pyplot
.
subplots
(
figsize
=
(
10
,
7
))
ax
.
plot
(
x
,
V
)
#plot harmonic potential
for
i
in
range
(
no_states
):
ax
.
hlines
(
h0_ener
(
i
),
x
[
0
],
x
[
len
(
x
)
-
1
],
linestyles
=
'
dotted
'
,
colors
=
'
k
'
)
ax
.
plot
(
x
,
ho_evec
(
x
,
i
,
no_states
)
+
h0_ener
(
i
))
#plot wavefunctions
# annotate plot
ax
.
text
(
x
[
len
(
x
)
-
1
],
h0_ener
(
i
)
+
1
/
4
,
'
$\Psi_%2i (x)$
'
%
(
i
),
horizontalalignment
=
'
center
'
,
fontsize
=
14
)
ax
.
text
(
1
/
4
,
h0_ener
(
i
)
+
1
/
4
,
'
$E_%2i$
'
%
(
i
),
horizontalalignment
=
'
center
'
,
fontsize
=
14
)
if
i
==
0
:
ax
.
text
(
x
[
0
]
+
1
/
4
,
h0_ener
(
i
)
/
4
,
r
'
$\frac{\hbar\omega}{2}$
'
,
horizontalalignment
=
'
center
'
,
fontsize
=
14
)
ax
.
annotate
(
""
,
xy
=
(
x
[
0
]
+
1
/
2
,
h0_ener
(
i
)
-
1
/
2
),
xytext
=
(
x
[
0
]
+
1
/
2
,
h0_ener
(
i
)),
arrowprops
=
dict
(
arrowstyle
=
"
<->
"
))
elif
i
==
1
:
ax
.
text
(
x
[
0
]
+
1
/
4
,
h0_ener
(
i
-
1
)
+
1
/
3
,
'
$\hbar\omega$
'
,
horizontalalignment
=
'
center
'
,
fontsize
=
14
)
ax
.
annotate
(
""
,
xy
=
(
x
[
0
]
+
1
/
2
,
h0_ener
(
i
)),
xytext
=
(
x
[
0
]
+
1
/
2
,
h0_ener
(
i
-
1
)),
arrowprops
=
dict
(
arrowstyle
=
"
<->
"
))
ax
.
fill_between
(
x
,
h0_ener
(
i
),
ho_evec
(
x
,
i
,
no_states
)
+
h0_ener
(
i
))
# Move left y-axis and bottim x-axis to centre, passing through (0,0)
ax
.
spines
[
'
left
'
].
set_position
(
'
center
'
)
ax
.
spines
[
'
bottom
'
].
set_position
((
'
data
'
,
0.0
))
# Eliminate upper and right axes
ax
.
spines
[
'
right
'
].
set_color
(
'
none
'
)
ax
.
spines
[
'
top
'
].
set_color
(
'
none
'
)
# Eliminate x and y axes labels
ax
.
set_yticklabels
([])
ax
.
set_xticklabels
([])
# Set x and y labels
ax
.
set_xlabel
(
'
X
'
+
'
($\sqrt{\hbar/m\omega}$)
'
,
fontsize
=
12
)
ax
.
set_ylabel
(
'
E
'
+
'
($\hbar\omega$)
'
,
fontsize
=
12
)
ax
.
yaxis
.
set_label_coords
(
0.5
,
1
)
```
$$
\v
arepsilon_n=
\l
eft(n+
\f
rac{1}{2}
\r
ight)
\h
bar
\o
mega$$
Phonons are bosons $
\R
ightarrow$ they follow Bose-Einstein statistics.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment