1# Hamiltonian Systems Interactive Tutorial
3The landing page simply says "Introduction to Hamiltonian Systems" with an invitation to click to get started.
5Notes:
6- The url contains the current page, so reloading the page doesn't bring us back to the beginning
7- Have navigation buttons (next/prev) always at the top of each page, and let the arrow keys (left/right) nad home/end also control this. This is an interactive slide presentation.
8- The app is meant to be viewed on a desktop but should also be compatible with mobile devices. On desktop 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.
9- The title of each slide should be at the top and the panels should be independently scrollable.
10- The next and prev buttons should have a single word hint of the content.
11- Start/stop buttons sit in the top-right corner of their diagram, next to a reset button.
12- 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.
14## Page 1: Mass on a spring with no friction
16When 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.
18This 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.
20q - the position of the block measured from rest
21m - the mass of the block
22k - the stiffness of the spring
23p = m * dq/dt - the momentum
25Hooke's law:
26F = -k * q - the force imparted by the spring
28Newton's second law:
29dp/dt = F = -k * q
31The rate of change in momentum is proportional to the position (opposite direction).
33So we have the system relating position and momentum:
35dq/dt = p/m
36dp/dt = -k q
38And the various quantities should appear on the diagram.
40Use two columns for the equations section so that it can fit better, stacking to one on a narrower screen.
42## Page 2: Conserved Energy
44Title: Total energy is conserved
46In 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.
48The details are.
50kinetic: p^2/2m and
51potential: 1/2 k * q^2
53They sum up to a constant, the total energy.
55Depict that in the diagram and show the equations below.
57The Hamiltonian is the total energy
58H = p^2/2m + 1/2 k q^2
60Exercise: Prove H is constant by differentiating with respect to it. The user clicks to reveal the solution.
63## Page 3: Hamilton's Equations
65We write
67H = p^2/2m + 1/2 k q^2
69And in general, Hamilton's equations are:
71dq/dt = \partial H/\partial p
72dp/dt = -partial H/\partial q
74which in this case yields our equations of motion
76dq/dt = \partial H/\partial p = p/m
77dp/dt = -\partial H/\partial q = -kq
79## Page 4: Phase space trajectories
81On 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.
83Then 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.
85Keep the axes fixed. Leave a trail and draw the level curve. The starting position should be a slider that lines up with the q.
87## Page 5: Pendulum with no friction
89Similarly, 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.
91In this case
93L - rod length
94m - mass of bob
95g - gravitational acceleration
97q = \theta - angular position
98p = m L^2 d\theta/dt - angular momentum
100The Hamiltonian in this case is
102H = p^2/(2 m L^2) - m g L cos \theta (kinetic plus gravitational potential)
104The Hamiltonian system is then:
106d\theta/dt = p/(mL^2)
107dp/dt = -m g L sin \theta
109Exercise: Apply Hamilton's equations to H to derive this system
111## Page 6: Pendulum phase space
113Again, 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 page 4.
115- small swings
116- large swings
117- almost to the top
118- rotation
119- balanced at the top
120- at rest
122## Page 7: Liouville's Theorem - Spring
124Go 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.
126## Page 8: Liouville's Theorem - Pendulum
128Similar, for the pendulum.