3

Firstly, I have seen Symplectic integration for non-separable hamiltonian, and I do not believe it answers my question.

I have been attempting to modify a symplectic integrator that I wrote a while ago. It works very well for "separable" hamiltonians, but I want to use it to simulate a double pendulum.

I am using the Hamiltonian from (13) in this source.

I am using the Stormer-Verlet equation (3) from this source. From the article "Even order 2 follows from its symmetry."

In the case of a separable hamiltonian, ∇q is a function only of q, and similarly for p, so that the equations form a symmetrical sequence of three function calls.

For a non-separable hamiltonian, this is no longer true, and it is necessary to use the full equations, but these are no longer symmetrical (the first two are implicit whilst the last is explicit). In other words, the first and third (q update) equations are not the same.

Anyhow, I have implemented the full non symmetrical equations, and while they are "symplectic" in the sense that there is no systematic "energy creep" in the output, they are only first order WRT step size, and my attempts to increase the order via composition are ineffective (the composition is still first order).

So, my question is this: is it possible to compose these implicit equations, or does their asymmetry prevent this? In other words, have I just made an error somewhere in my implementation?

Lutz Lehmann
  • 131,652
m4r35n357
  • 151
  • 7
  • I am currenty looking at https://arxiv.org/abs/1609.02212, which seems to offer a generic and possible very simple solution to non-separable systems (double pendulum, black hole metrics). – m4r35n357 Jan 28 '23 at 13:40
  • @ViktorStein I am afraid it was "above my pay-grade", at the time (I am an amateur at this!). I will have another look at it and see if anything has changed ;) – m4r35n357 Mar 08 '25 at 09:33
  • @ViktorStein on re-reading I remember I did actually try to implement it, but was not sure if I did it properly (as I couldn't get it to produce anything useful). I think the notation in equation (1) defeated me - I couldn't make the $I$ "fit" the other equations, if you see what I mean. – m4r35n357 Mar 08 '25 at 13:46
  • What is the $I$ you mention? Is the first integral of the ODE to be solved? And is equation (13) from the blog post you mention still the correct reference? – ViktorStein Mar 08 '25 at 21:44
  • @ViktorStein as I understand it, the $I$s are 2x2 identity matrices. That is how I interpreted them, but it didn't seem to work. I am still not quite in up to speed with this after a few years gap so pardon my vagueness. – m4r35n357 Mar 09 '25 at 09:31
  • @ViktorStein it looks like the equations might have been renumbered, 14 is the one I meant! – m4r35n357 Mar 09 '25 at 09:48

1 Answers1

0

As a first step and in response to OP's comments, in this post I aim to explain equation (1) in the arXiv version of Tao's paper and the resulting iterative scheme

To kind of circumvent the non-separability of a Hamiltonian H, Tao defines the still non-separable augmented Hamiltonian \begin{equation*} \tilde{H} := H_A + H_B + \omega H_C, \end{equation*} for some coupling constant $\omega \ge 0$, where \begin{equation*} H_A(q, p, x, y) := H(q, y), \quad H_B(q, p, x, y) := H(x, p), \quad H_C(q, p, x, y) := \frac{1}{2} \| q - x \|_2^2 + \frac{1}{2} \| p - y \|_2^2. \end{equation*}

The key idea is now to approximate the flow of $\tilde{H}$ (which is essentially the flow of $H$) by composing the flows of $H_A$, $H_B$ and $H_C$.

With respect to the new variables $\tilde{q} := (q, x)$ and $\tilde{p} := (p, y)$, the Hamiltonian flow of $H_A$ is \begin{equation*} \begin{cases} \dot{q} = \partial_p H(q, p, x, y) = 0, \\ \dot{p} = - \partial_q H(q, p, x, y) = - \partial_q H(q, y), \\ \dot{x} = \partial_y H(q, p, x, y) = \partial_y H(q, y), \\ \dot{y} = - \partial_x H(q, p, x, y) = 0, \end{cases} \end{equation*} Note that this system is easily solvable in closed form:

1. Since $\dot{q} = \dot{y} = 0$, the variables $q$ and $y$ are constant in time, so $q(t) = q(0)$ and $y(t) = y(0)$.

2. For the other ODEs, the right hand side does not depend on the argument of the left hand side, they are essentially of the for $f'(t) = x$, so integrating yields $f(t) = t x + \text{const}$.

For some $\delta > 0$, the time $\delta$ flow map associated to $H_A$, i.e. the symplectomorphism with $\phi_{H_A}^{\delta}( q(0), p(0), x(0), y(0)) = (q(\delta), p(\delta), x(\delta), y(\delta))$, where $(( q(t), p(t), x(t), y(t)))_{t \ge 0}$ is the Hamiltonian flow of $H_A$ is thus given by \begin{equation*} \phi_{H_A}^{\delta}(q, p, x, y) = \big(q, p - \delta \partial_q H(q, y), x + \delta \partial_y H(q, y), y\big). \end{equation*}

By the same argument, the Hamiltonian flow of $H_B$ is \begin{equation*} \begin{cases} \dot{q} = \nabla_p H_B = \nabla_p H(x, p), \\ \dot{p} = \nabla_y H_B = 0, \\ \dot{p} = - \nabla_q H_B = 0, \\ \dot{y} = - \nabla_x H_B = - \nabla_x H(x, p) \end{cases} \end{equation*} and thus the flow map is \begin{equation*} \phi_{H_B}^{\delta}(q, p, x, y) = \big(q + \delta \nabla_p H(x, p), p, x, y - \delta \nabla_x H(x, p)\big). \end{equation*} The Hamiltonian flow of $\omega H_C$ is $$ \begin{cases} \dot{q} = \omega (p - y), \\ \dot{x} = \omega (y - p), \\ \dot{p}= \omega (x - q), \\ \dot{y}= \omega (q - x) \end{cases} $$ This is a coupled system of linear first order ODEs of the form $\dot{w} = A w$, which has the solution $w(t) = \exp(t A) w_0$, where $w = (q, x, p, y)$. Calculating the matrix exponential gives $$ \exp(t A) = \frac{1}{2}\begin{pmatrix} \cos(2 t) + 1 & \sin(2 t) & 1 - \cos(2 t) & -\sin(2 t) \\ -\sin(2 t) & \cos(2 t) + 1 & \sin(2 t) & 1 - \cos(2 t) \\ 1 - \cos(2 t) & -\sin(2 t) & \cos(2 t) + 1 & \sin(2 t) \\ \sin(2 t) &1 - \cos(2 t) & -\sin(2 t) & \cos(2 t) + 1 \\ \end{pmatrix} $$ and in this way you can derive \begin{equation*} \phi_{\omega H_C}^{\delta}(q, p, x, y) = \frac{1}{2} \left(\begin{pmatrix} q + x \\ p + y \end{pmatrix} + R(\delta) \begin{pmatrix} q - x \\ p - y \end{pmatrix}, \begin{pmatrix} q + x \\ p + y \end{pmatrix} - R(\delta) \begin{pmatrix} q - x \\ p - y \end{pmatrix}\right), \end{equation*} where \begin{equation*} R(\delta) := \begin{pmatrix} \cos(2 \omega \delta) I & \sin(2 \omega \delta) I \\ - \sin(2 \omega \delta) I & \cos(2 \omega \delta) I \end{pmatrix} \end{equation*} is a rotation matrix.

One way to compose the flows of $H_A$, $H_B$ and $H_C$ is given by Strang splitting $$\phi^{\delta} := \phi_{H_A}^{\frac{\delta}{2}} \circ \phi_{H_B}^{\frac{\delta}{2}} \circ \phi_{\omega H_C}^{\delta} \circ \phi_{H_B}^{\frac{\delta}{2}} \circ \phi_{H_A}^{\frac{\delta}{2}}.$$ This means that our approximation of $q$ and $p$ at time $N \delta$ is given by iteratively applying $\phi^{\delta}$ to the initial conditions, that is, by (the first two components of) $$(\phi^{\delta})^N(q(0), p(0), x(0), y(0)).$$

One update step is hence of the form $$ (q_{k + 1}, p_{k + 1}, x_{k + 1}, y_{k + 1}) = \phi^{\tau}(q_k, p_k, x_k, y_k), $$ where $k$ are the discrete time steps and $\tau > 0$ is the step size.

Composing all the maps and writing these steps out, one could summarize this as follows: \begin{align*} \text{(First } H_A\text{ and } H_B \text{ steps) } & \begin{cases} p_{k + \frac{1}{3}} \gets p_k - \frac{\tau}{2} \delta_1 H(q_k, y_k), \\ x_{k + \frac{1}{3}} \gets x_k + \frac{\tau}{2} \delta_2 H(q_k, y_k), \\ q_{k + \frac{1}{3}} \gets q_k + \frac{\tau}{2} \delta_2 H(x_{k + \frac{1}{2}}, p_{k + \frac{1}{2}}), \\ y_{k + \frac{1}{3}} \gets y_k - \frac{\tau}{2} \delta_2 H(x_{k + \frac{1}{2}}, p_{k + \frac{1}{2}}), \\ \end{cases} \\ \text{(} H_C \text{ step) } & \begin{cases} q_{k + \frac{2}{3}} \gets \frac{1}{2} \left( q_{k + \frac{1}{3}} + x_{k + \frac{1}{3}} + \cos(2 \tau \omega) \left(q_{k + \frac{1}{3}} - x_{k + \frac{1}{3}} \right) + \sin(2 t) \left(y_{k + \frac{1}{3}} - p_{k + \frac{1}{3}}\right) \right) , \\ p_{k + \frac{2}{3}} \gets \frac{1}{2} \left( p_{k + \frac{1}{3}} + y_{k + \frac{1}{3}} + \cos(2 \tau \omega) (p_{k + \frac{1}{3}} - y_{k + \frac{1}{3}}) - \sin(2 t) (q_{k + \frac{1}{3}} - x_{k + \frac{1}{3}}) \right), \\ x_{k + \frac{2}{3}} \gets \frac{1}{2} \left( q_{k + \frac{1}{3}} + x_{k + \frac{1}{3}} - \cos(2 \tau \omega) \left(q_{k + \frac{1}{3}} - x_{k + \frac{1}{3}} \right) - \sin(2 t) \left(y_{k + \frac{1}{3}} - p_{k + \frac{1}{3}}\right) \right), \\ y_{k + \frac{2}{3}} \gets \frac{1}{2} \left( p_{k + \frac{1}{3}} + y_{k + \frac{1}{3}} - \cos(2 \tau \omega) (p_{k + \frac{1}{3}} + y_{k + \frac{1}{3}}) - \sin(2 t) (q_{k + \frac{1}{3}} - x_{k + \frac{1}{3}}) \right), \\ \end{cases} \\ \text{(Second } H_A\text{ and } H_B \text{ steps) } & \begin{cases} q_{k + 1} \gets q_{k + \frac{2}{3}} + \frac{\tau}{2} \delta_2 H(x_{k + \frac{2}{3}}, p_{k + \frac{2}{3}}), \\ y_{k + 1} \gets y_{k + \frac{2}{3}} - \frac{\tau}{2} \delta_1 H(x_{k + \frac{2}{3}}, p_{k + \frac{2}{3}}), \\ p_{k + 1} \gets p_{k + \frac{2}{3}} - \frac{\tau}{2} \delta_1 H(q_{k + 1}, y_{k + 1}), \\ x_{k + 1} \gets x_{k + \frac{2}{3}} + \frac{\tau}{2} \delta_2 H(q_{k + 1}, y_{k + 1}). \end{cases} \end{align*} But I think one could also replace the $H_C$ step by implicit steps, which are still available in closed-form.

ViktorStein
  • 5,024
  • Thanks for the extra info! I am still confused about the $I$s though. They cannot be 2x2 matrices as I previously thought, so what are they? They are not explicitly defined in the paper at all, that is why I "guessed" about the 2x2 matrix thing . . . but that makes $R(\delta)$ a 4x4 matrix, which clearly is not right as it is multiplied by a 2-vector in (1). – m4r35n357 Mar 09 '25 at 09:36
  • @m4r35n357 The variables $p,q,x$ and $y$ are from $\mathbb R^d$ and and $I$ is the $d \times d$ identity matrix, so $R(\delta) \in \mathbb R^{ 2 d \times 2 d}$. – ViktorStein Mar 10 '25 at 14:51
  • You seem to be agreeing (without saying so explicitly) with me that it is 4x4. That being the case, I am unable to perform the multiplication of a 4x4 matrix with a 2x1 matrix. That is where I came in, and I cannot proceed further until I know how to do that calculation! – m4r35n357 Mar 10 '25 at 15:15
  • @m4r35n357 It's not a $2 \times 1$ matrix, since $q, x \in \mathbb R^{d = 2}$, so $\begin{pmatrix} q - x \ p - y \end{pmatrix} \in \mathbb R^{2 d = 4}$, so the matrix-vector product ends up in $\mathbb R^{2 d = 4}$. – ViktorStein Mar 11 '25 at 16:11
  • 1
    OK thanks for your persistence I get it now, so it is 4x4 multiplied by 4x1 (in my "notation"), I haven't looked at this for several years, and it was a long shot even trying it at the time. I might see if I can dig out the code, it is entirely possible I actually did the right thing back then, then forgot it ;) – m4r35n357 Mar 12 '25 at 09:33