Hamiltonian Systems Interactive Tutorial#
The landing page simply says "Introduction to Hamiltonian Systems" with an invitation to click to get started.
Notes:
- Each slide should be 1920 × 1080 pixels with a rectangle border
- The url contains the current page, so reloading the page doesn't bring us back to the beginning
- Have navigation buttons (next/prev) always at the bottom of each page, and let the arrow keys (left/right) and home/end also control this. This is an interactive slide presentation.
- There should be two panels. On the left is the text, equations, etc. On the right is the interactive content, diagrams and controls. But some pages start with centered content, and only expand to two panels when the user clicks something.
- The title of each slide should be at the top and the panels should be independently scrollable.
- The next and prev buttons should have a single word hint of the content.
- Start/stop buttons sit in the top-right corner of their diagram, next to a reset button.
- On the main page, we should have a crafted by human link that takes us to the https://magland.github.io/arewehuman/ app with the appropriate data embedded in the url for the crafting of the recipe.md.
Mass on a spring with no friction#
When user clicks, we go to the first (non title page). It shows a mass on a spring with no friction with the text Example 1: Mass on a spring with no friction. We see a representation of a mass on a spring held at a particular position. The user clicks to "start" and we see the motion start. The user can click to stop it as well.
This is centered at first with no labels and no equations. Users click a button "show details" reveal the two panels with the equations on left and the labeled diagram on the right.
q - the position of the block measured from rest m - the mass of the block k - the stiffness of the spring p = m * dq/dt - the momentum
Hooke's law: F = -k * q - the force imparted by the spring
Newton's second law: dp/dt = F = -k * q
The rate of change in momentum is proportional to the position (opposite direction).
So we have the system relating position and momentum:
dq/dt = p/m dp/dt = -k q
And the various quantities should appear on the diagram.
Use two columns for the equations section so that it can fit better, stacking to one on a narrower screen.
Conserved Energy#
Title: Total energy is conserved
In this page, we show the same spring diagram with a start/stop button, and we depict the kinetic/potential/total energy with bars. But we don't want people to feel dizzy. Again, we just show the unlabeled diagram at the center with the kinetic/potential/total bars with a start/stop button and a details button.
The details are.
kinetic: p^2/2m and potential: 1/2 k * q^2
They sum up to a constant, the total energy.
Depict that in the diagram and show the equations below.
The Hamiltonian is the total energy H = p^2/2m + 1/2 k q^2
Exercise: Prove H is constant by differentiating with respect to it. The user clicks to reveal the solution.
Hamilton's Equations#
We write
H = p^2/2m + 1/2 k q^2
And in general, Hamilton's equations are:
dq/dt = \partial H/\partial p dp/dt = -partial H/\partial q
which in this case yields our equations of motion
dq/dt = \partial H/\partial p = p/m dp/dt = -\partial H/\partial q = -kq
Spring - phase space trajectories#
On this page, we will show the trajectory through phase space. We will have the diagram again at the top, but this time with only p and q and k labeled, together with initial position q_0. Then below that we will have an axes with q horizontal and p vertical and the q should line up.
Then user can adjust the initial position, k, and m. These controls go in the left panel, with the diagram and axes in the right panel.
Keep the axes fixed. Leave a trail and draw the level curve. The starting position should be a slider that lines up with the q.
Pendulum with no friction#
Similarly, we will have a diagram at the top with a swinging pendulum. The bob will be on a massless rod at an initial position and again a "Let Go" button. And then a button to reveal the equations of motion and labels on the diagram.
In this case
L - rod length m - mass of bob g - gravitational acceleration
q = \theta - angular position p = m L^2 d\theta/dt - angular momentum
The Hamiltonian in this case is
H = p^2/(2 m L^2) - m g L cos \theta (kinetic plus gravitational potential)
The Hamiltonian system is then:
d\theta/dt = p/(mL^2) dp/dt = -m g L sin \theta
Exercise: Apply Hamilton's equations to H to derive this system
Pendulum phase space#
Again, the pendulum diagram is at the top. Below that we have an axes for q and p. And the user can control the parameters in the same way. But we should also have an initial momentum. And there should be a dropdown that has presets to show the different types of phenomena. The controls go in the left panel, as on "phase space trajectories" page.
- small swings
- large swings
- almost to the top
- rotation
- balanced at the top
- at rest
Liouville's Theorem - Spring#
Go back to the block on a spring example in phase space and show a disk of starting points. On play, let them evolve, and compute and display the area somewhere. The idea is to show that the area is preserved. We should also show the spring diagram (no labels), with a bunch of blocks represented as points. The spring itself follows the single simulation started from the center of the disk, not the average of the points (on all three Liouville slides).
Liouville's Theorem - Pendulum#
Similar, for the pendulum.
Spring with damping#
Same as the "Spring - phase space trajectories" page except we have another parameter, b, a damping coefficient.
Then we should write out the system (no longer Hamilton)
dq/dt = p / m dp/dt = -kq-(b/m)p
where we have an additional force
F = -b dq/dt = -(b/m)p, proportional to the velocity.
Keep the initial energy's level curve as reference.
Example 3: Double pendulum, no friction#
Same as the "Pendulum with no friction" except with a double pendulum with two bobs.
When user clicks to show details we give
Left panel:
definitions for L_1, L_2, m_1, m_2, g, theta_1, theta_2, p_1, p_2.
p_1 = (m_1 + m_2) L_1^2 d\theta_1/dt + m_2 L_1 L_2 cos(\theta_1 - \theta_2) d\theta_2/dt p_2 = m_2 L_2^2 d\theta_2/dt + m_2 L_1 L_2 cos(\theta_1 - \theta_2) d\theta_1/dt
And we write down the Hamiltonian and then derive Hamilton's equations for this example.
With \Delta = \theta_1 - \theta_2 and D = m_1 + m_2 sin^2 \Delta:
H = T + V T = (m_2 L_2^2 p_1^2 + (m_1 + m_2) L_1^2 p_2^2 - 2 m_2 L_1 L_2 p_1 p_2 cos \Delta) / (2 m_2 L_1^2 L_2^2 D) (kinetic) V = -(m_1 + m_2) g L_1 cos \theta_1 - m_2 g L_2 cos \theta_2 (gravitational potential)
Hamilton's equations:
d\theta_1/dt = \partial H/\partial p_1 = (L_2 p_1 - L_1 p_2 cos \Delta) / (L_1^2 L_2 D) d\theta_2/dt = \partial H/\partial p_2 = ((m_1 + m_2) L_1 p_2 - m_2 L_2 p_1 cos \Delta) / (m_2 L_1 L_2^2 D) dp_1/dt = -\partial H/\partial \theta_1 = -(m_1 + m_2) g L_1 sin \theta_1 - \partial T/\partial \Delta dp_2/dt = -\partial H/\partial \theta_2 = -m_2 g L_2 sin \theta_2 + \partial T/\partial \Delta
where, since T depends on \theta_1 and \theta_2 only through \Delta,
\partial T/\partial \Delta = (p_1 p_2 sin \Delta / (L_1 L_2) - m_2 T sin 2\Delta) / D
Try to keep the layout neat
Right panel:
The double pendulum with things labeled
Double pendulum phase space#
Similar to "Pendulum phase space" slide
Left panel:
All the parameter controls, neatly organized
Right panel
Top: the double pendulum animation
Bottom: The phase space projected onto the (theta_1, p_1) and (theta_2, p_2) planes side by side, with the same axes as the double pendulum Liouville slide. Leave a trail in each plane. Below the planes, note that each plane is a projection of the 4D phase space, so the trails can cross even though trajectories in phase space never do.
(note that with fixed energy level, phase space is 3d)
Liouville's theorem: double pendulum#
Similar to the other Liouville slides, except with a dropdown to select the various parameter sets (same choices as previous slide).
Don't compute the area. Instead, start with a small 4D ball of points around the preset's initial state and show how they disperse, projected onto the (theta_1, p_1) and (theta_2, p_2) planes side by side. Show the double pendulum diagram (no labels) above, with the bobs represented as points.