Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Introduction to particle and continuum mechanics
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
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open textbooks
Introduction to particle and continuum mechanics
Commits
705e8066
Commit
705e8066
authored
7 months ago
by
Timon Idema
Browse files
Options
Downloads
Patches
Plain Diff
Fixed typo in Maxwell dist plot legend.
parent
5efd0bd1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
content/thermodynamicsbasics.md
+1
-1
1 addition, 1 deletion
content/thermodynamicsbasics.md
notebooks/Maxwelldistribution.ipynb
+1
-1
1 addition, 1 deletion
notebooks/Maxwelldistribution.ipynb
with
2 additions
and
2 deletions
content/thermodynamicsbasics.md
+
1
−
1
View file @
705e8066
...
...
@@ -414,7 +414,7 @@ v = np.linspace(0, 6, 600)
# Actual plots.
line1 = ax.plot(v, f(v, 1), label='low $T$')
line2 = ax.plot(v, f(v, 3), label='high
t
$T$')
line2 = ax.plot(v, f(v, 3), label='high $T$')
# Lines to plot from v-axis.
ax.plot([v0(1), v0(1)], [0, f(v0(1), 1)], color='C0', linestyle = '--')
...
...
This diff is collapsed.
Click to expand it.
notebooks/Maxwelldistribution.ipynb
+
1
−
1
View file @
705e8066
...
...
@@ -90,7 +90,7 @@
"v = np.linspace(0, 6, 600)\n",
"\n",
"line1 = ax.plot(v, f(v, 1), label='low $T$')\n",
"line2 = ax.plot(v, f(v, 3), label='high
t
$T$')\n",
"line2 = ax.plot(v, f(v, 3), label='high $T$')\n",
"\n",
"# Lines to plot from v-axis.\n",
"ax.plot([v0(1), v0(1)], [0, f(v0(1), 1)], color='C0', linestyle = '--')\n",
...
...
%% Cell type:markdown id: tags:
# Plot of the Maxwell distribution
For section 13.5.3
%% Cell type:markdown id: tags:
Maxwell distribution:
$$
f_
\m
athrm{Maxwell}(v) =
\l
eft(
\f
rac{m}{2
\p
i k_
\m
athrm{B} T}
\r
ight)^{3/2} 4
\p
i v^2
\e
xp
\l
eft(-
\f
rac{m v^2}{2 k_
\m
athrm{B} T}
\r
ight)
$$
Average 'thermal speed' of each molecule
$$
v_
\m
athrm{th} =
\s
qrt{
\f
rac{3 k_
\m
athrm{B} T}{m}}.
$$ (thermalspeed)
%% Cell type:code id: tags:
```
python
# Python libraries.
%
matplotlib
inline
import
numpy
as
np
import
matplotlib.pyplot
as
plt
```
%% Cell type:code id: tags:
```
python
def
f
(
v
,
T
):
# Returns f(v), in units where kB = 1 and m = 1.
return
np
.
power
(
1
/
(
2
*
np
.
pi
*
T
),
1.5
)
*
4
*
np
.
pi
*
v
*
v
*
np
.
exp
(
-
0.5
*
v
*
v
/
T
)
def
v0
(
T
):
# Returns v0(T), the maximum of the Maxwell distribution, in units where kB = 1 and m = 1.
return
np
.
sqrt
(
2
*
T
)
def
vth
(
T
):
# Returns v_{th}T, in units where kB = 1 and m = 1.
return
np
.
sqrt
(
3
*
T
)
```
%% Cell type:code id: tags:
```
python
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
6
,
4
))
v
=
np
.
linspace
(
0
,
6
,
600
)
line1
=
ax
.
plot
(
v
,
f
(
v
,
1
),
label
=
'
low $T$
'
)
line2
=
ax
.
plot
(
v
,
f
(
v
,
3
),
label
=
'
high
t
$T$
'
)
line2
=
ax
.
plot
(
v
,
f
(
v
,
3
),
label
=
'
high $T$
'
)
# Lines to plot from v-axis.
ax
.
plot
([
v0
(
1
),
v0
(
1
)],
[
0
,
f
(
v0
(
1
),
1
)],
color
=
'
C0
'
,
linestyle
=
'
--
'
)
ax
.
plot
([
vth
(
1
),
vth
(
1
)],
[
0
,
f
(
vth
(
1
),
1
)],
color
=
'
C0
'
,
linestyle
=
'
:
'
)
ax
.
plot
([
v0
(
3
),
v0
(
3
)],
[
0
,
f
(
v0
(
3
),
3
)],
color
=
'
C1
'
,
linestyle
=
'
--
'
)
ax
.
plot
([
vth
(
3
),
vth
(
3
)],
[
0
,
f
(
vth
(
3
),
3
)],
color
=
'
C1
'
,
linestyle
=
'
:
'
)
# Below doesn't work as matplotlib interprets fractional values of ymax as fraction of total height.
#ax.axvline(x=v0(1), ymax=f(v0(1),1), color = 'k', linestyle = ':')
#ax.axvline(x=vth(1), ymax=f(vth(1), 1), color = 'k', linestyle = '--')
#ax.axvline(x=v0(3), ymax=f(v0(3), 3), color = 'k', linestyle = ':')
#ax.axvline(x=vth(3), ymax=f(vth(3), 3), color = 'k', linestyle = '--')
ax
.
set_xlim
(
0
,
6
)
#ax.set_xticks([0, np.pi, 2*np.pi, 3*np.pi, 4*np.pi], labels=['$0$', '$\\pi$', '$2\\pi$', '$3\\pi$', '$4\\pi$'])
#ax.set_yticks([-1, -0.5, 0, 0.5, 1], labels=['$-1$', '$-\\frac{1}{2}$', '$0$', '$\\frac{1}{2}$', '$1$'])
ax
.
set_ylim
(
0
,
0.6
)
ax
.
set_xlabel
(
'
$v$
'
)
ax
.
set_ylabel
(
'
$f(v)$
'
)
ax
.
text
(
v0
(
1
),
-
0.01
,
r
'
$v_0$
'
,
color
=
'
C0
'
,
horizontalalignment
=
'
center
'
,
verticalalignment
=
'
top
'
)
ax
.
text
(
vth
(
1
),
-
0.01
,
r
'
$v_\mathrm{th}$
'
,
color
=
'
C0
'
,
horizontalalignment
=
'
center
'
,
verticalalignment
=
'
top
'
)
ax
.
text
(
v0
(
3
),
-
0.01
,
r
'
$v_0$
'
,
color
=
'
C1
'
,
horizontalalignment
=
'
center
'
,
verticalalignment
=
'
top
'
)
ax
.
text
(
vth
(
3
)
+
.
18
,
-
0.01
,
r
'
$v_\mathrm{th}$
'
,
color
=
'
C1
'
,
horizontalalignment
=
'
center
'
,
verticalalignment
=
'
top
'
)
ax
.
legend
()
#plt.savefig("dampedoscillations.pdf", format="pdf", bbox_inches="tight")
#plt.savefig("dampedoscillations.svg", format="svg", bbox_inches="tight")
```
%% Output
<matplotlib.legend.Legend at 0x12f52b680>
%% Cell type:code id: tags:
```
python
```
...
...
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