1 This is symplectic_ode.info, produced by makeinfo version 6.1 from
5 File: symplectic_ode.info, Node: Top, Next: Introduction to symplectic_ode, Prev: (dir), Up: (dir)
12 * Introduction to symplectic_ode::
13 * Definitions for symplectic_ode::
14 * Function and variable index::
20 File: symplectic_ode.info, Node: Introduction to symplectic_ode, Next: Definitions for symplectic_ode, Prev: Top, Up: Top
22 1.1 Introduction to symplectic_ode
23 ==================================
25 For a hamiltonian of the form F(p) + G(q), the function 'symplectic_ode'
26 numerically solves Hamilton's equations of motion p' = -dH/dq, q' =
27 dH/dp, where H is the hamiltonian. The method preserves the Poisson
28 bracket of p and q. One time step is accomplished with the loop
31 q <- q + c(k)*diff(H,p)*dt ;update momentum p
32 p <- p - d(k)*diff(H,q)*dt ;use updated position q
35 where c1, c2, ..., cn and d1, d2, ..., dn are constants and H is the
38 This code has built-in methods for the symplectic Euler, the Verlet
39 method, and third and fourth order methods that are due to Ronald Ruth.
40 For a complete description of these methods, see
41 <https://en.wikipedia.org/wiki/Symplectic_integrator>. Additionally,
42 there is a fifth order method that is due to Kostas Tselios and T. E.
45 The function 'symplectic_ode' creates and compiles functions for
46 updating <p> & <q>. The arguments to these functions are modedeclared
47 to have type given by an optional argument (defaults to float). Of
48 course, hand coding of these functions could increase speed or accuracy,
49 but the automatically generated functions are convenient.
51 Unlike adaptive methods such as RK45, 'symplectic_ode' uses a fixed
52 step size. Generally symplectic methods that use an adaptive step size
53 lose their advantages over non-symplectic methods.
56 File: symplectic_ode.info, Node: Definitions for symplectic_ode, Next: Function and variable index, Prev: Introduction to symplectic_ode, Up: Top
58 1.2 Definitions for symplectic_ode
59 ==================================
61 -- Function: poisson_bracket poisson_bracket(<f>, <g>, <p>, <q>)
62 poisson_bracket(<f>, <g>, [<p1>,..., <pn>], [<q1>,..., <qn>])
64 Compute the Poisson bracket of the expressions <f> and <g> with
65 respect to the canonical coordinates <p> and <q> (or <p1>,
66 <p2>,..., <pn> and <p1>, <p2>,..., <pn>).
69 (%i1) load("symplectic_ode")$
70 (%i2) poisson_bracket(p,p^2/2+q^4,p,q);
73 (%i3) poisson_bracket(q,p^2/2+q^4,p,q);
76 (%i4) poisson_bracket(q1,p1^2/2+p2^2/2+q1^4+q2^4,[p1,p2],[q1,q2]);
79 (%i5) poisson_bracket(p1,p1^2/2+p2^2/2+q1^4+q2^4,[p1,p2],[q1,q2]);
83 -- Function: symplectic_ode symplectic_ode(ham,p,q,po,qo,dt,N)
84 symplectic_ode(ham,p,q,po,qo,dt,N,method)
85 symplectic_ode(ham,p,q,po,qo,dt,N,method,type)
87 Numerically solve Hamilton's equations of motion using a symplectic
90 * The hamiltonian is the Maxima expression <ham> that depends on
91 the canonical coordinates <p> and <q>. The hamiltonian must
92 be time independent. The method is symplectic when the
93 hamiltonian is separable; that is when it has the form 'f(p) +
96 * The canonical coordinates are <p> and <q>. The arguments <p>
97 and <q> should be mapatoms or equal length lists of mapatoms.
99 * The arguments <po> and <q0> are the initial values of <p> and
100 <q>, respectively. These should be mapatoms or equal length
103 * <dt> is the fixed time step.
105 * <N> is the number of time steps.
107 * The optional argument <method> determines the integration
108 method. It must be either symplectic_euler (default), verlet,
109 symplectic_third_order, symplectic_fourth_order, or
110 symplectic_fifth_order. For an explanation of these methods,
111 see https://en.wikipedia.org/wiki/Symplectic_integrator.
113 * The optional argument <type> determines the value for
114 mode_declare for various automatically generated functions.
115 The value <type> must be one of float (default), rational, or
116 any (no type). Since <float> is a Maxima option variable, the
117 <type> variable should be quoted, especially for type <float>.
121 For both the scalar case (both <p> and <q> are mapatoms) and the
122 nonscalar case (both <p> and <q> are lists of mapatoms),
123 'symplectic_ode' returns a list of two lists. For the scalar case,
124 the first list is a list of the values of <p> at the times '0, dt,
125 2*dt,..., N*dt' and similarly for the second list. For a nonscalar
126 case, the first list is a list of the form [p1, p2,..., pn] at the
127 times '0, dt, 2*dt,..., N*dt'.
131 (%i2) load("symplectic_ode")$
132 (%i3) symplectic_ode(p^2/2 + q^4/4,p,q,1,0,1/10,2);
133 (%o3) [[1.0,1.0,0.9999],[0.0,0.1,0.19999]]
135 (%i4) symplectic_ode(p^2/2 + q^4/4,[p],[q],[1],[0],1/10,2);
136 (%o4) [[[1.0],[1.0],[0.9999]],[[0.0],[0.1],[0.19999]]]
138 (%i5) symplectic_ode(p^2/2 + q^4/4,p,q,1,0,1/10,2,verlet);
139 (%o5) [[1.0,0.9999875,0.9996500084374297],[0.0,0.099999375,0.1999812504218715]]
141 (%i6) symplectic_ode(p^2/2 + q^4/4,p,q,1.0b0,0.0b0, 0.1b0,2,verlet,'any);
142 (%o6) [[1.0b0,9.999875b-1,9.996500084374297b-1],[0.0b0,9.9999375b-2,1.999812504218715b-1]]
146 File: symplectic_ode.info, Node: Function and variable index, Prev: Definitions for symplectic_ode, Up: Top
148 Appendix A Function and variable index
149 **************************************
154 * poisson_bracket: Definitions for symplectic_ode.
156 * symplectic_ode: Definitions for symplectic_ode.
163 Node: Introduction to symplectic_ode
\x7f373
164 Node: Definitions for symplectic_ode
\x7f1932
165 Node: Function and variable index
\x7f5650