Consider the anisotropic harmonic potential in two dimensions $(q_1,q_2)$ given by
$$ V(q_1,q_2) = \frac{m}{2} \, q_1^2 + \frac{k}{2} \, q_2^2, $$
or V = m/2 q1^2 + k/2 q2^2;
in Mathematica.
The Newtonian e.o.m.s of a particle moving through this potential are
$$ \ddot{q}_1 = -q_1, \qquad \ddot{q}_2 = -\omega^2 \, q_2, $$
where $\omega = \sqrt{k/m}$ is the angular frequency of oscillations in the $q_2$-direction. Given the initial conditions $q_i(0) = q_{i,0}$ and $p_i(0) = p_{i,0}$, the e.o.m.s are solved by
$$ \begin{aligned} q_1(t) &= q_{1,i} \cos(t) + \frac{p_{1,i}}{m} \, \sin(t),\\ q_2(t) &= q_{2,i} \cos(\omega t) + \frac{p_{2,i}}{m \omega} \, \sin(\omega t), \end{aligned} \qquad \text{with $p_i = m \dot{q}_i$.} $$
In Mathematica:
DSolve[{q1''[t] == -q1[t], q2''[t] == -ω^2 q2[t], q1[0] == q10,
q1'[0] == p10/m, q2[0] == q20, q2'[0] == p20/m}, {q1[t], q2[t]}, t]
//FullSimplify
{{q1[t] -> q10 Cos[t] + (p10 Sin[t])/m, q2[t] -> q20 Cos[t ω] + (p20 Sin[t ω])/(m ω)}}
A 3d plot of the potential looks like this.
Plot3D[V /. {m -> 1, k -> 3}, {q1, -5, 5}, {q2, -5, 5},RegionFunction -> Function[{q1, q2}, m/2 q1^2 + k/2 q2^2 <= 12 /. {m -> 1, k -> 3}]]
What I would like to do now is draw the particle as a ball moving through this potential with a fixed energy. Any help would be much appreciated.
Some remarks about the physics behind this simulation: The particle always reaches a certain height both in $q_1$- and $q_2$-direction before rolling back down again and up the other side. This is because the Hamiltonian $H = \frac{p_1^2}{2 m} + \frac{p_2^2}{2 m} + V(q_1,q_2)$ does not couple the degrees of freedom in $q_1$- and $q_2$-direction. Therefore, the total energies $E_1$ and $E_2$ available in dimensions $q_1$ and $q_2$ are conserved separately.
For long times $t \to \infty$ and irrational angular frequency $\omega \notin \mathbb{Q}$ (which ensures that the trajectory never closes, thus making the system ergodic), the particle's trajectory should therefore trace out a rectangle $R$ whose length and width are determined by $E_1$ and $E_2$.
Update: With anderstood's and BlacKow's help, I was able to piece together this solution that does exactly what I want.
V = m/2 q1^2 + k/2 q2^2; \[Omega] = Sqrt[k/m];
sol = {q1[t], q2[t], m/2 q1[t]^2 + k/2 q2[t]^2} /.
DSolve[{q1''[t] == -q1[t], q2''[t] == -\[Omega]^2 q2[t],
q1[0] == q10, q1'[0] == p10/m, q2[0] == q20,
q2'[0] == p20/m}, {q1[t], q2[t]}, t] // FullSimplify
Manipulate[Block[{m = 1, k = 5, q10 = 5, p10 = 1, q20 = 2, p20 = 1},
surf = Plot3D[V, {q1, -7, 7}, {q2, -5, 5},
RegionFunction -> Function[{q1, q2}, m/2 q1^2 + k/2 q2^2 <= 25], PlotStyle -> Opacity[0.5]];
Show[surf, Graphics3D@{Blue, Ball[sol /. {t -> tf}, 0.4]},
ParametricPlot3D[sol, {t, 0, tf}]]], {tf, 0.1, 100}]
Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.
Looking on Meta, it appears this issue has come up before. $\endgroup${}
button. $\endgroup$