Figure 2.19:

Periodic (left) and quasiperiodic (right) orbits on the surface of a torus. The orbit on the right eventually passes through every point in the domain.

Code for Figure 2.19

Text of the GNU GPL.

main.py


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import numpy as np
import matplotlib.pyplot as plt

pq = np.sqrt(2)
phi0 = 0
theta0 = 0

phi = np.linspace(theta0, 50 * np.pi, 5001)

theta = pq * (phi - phi0) + theta0
thetamod = np.mod(theta, 2 * np.pi) / np.pi
phimod = np.mod(phi, 2 * np.pi) / np.pi

plt.plot(phimod, thetamod, '.')
plt.show(block=False)

data = np.column_stack((phimod, thetamod))

with open("tori_irrat.dat", "w") as f:
    np.savetxt(f, data, fmt='%f')