{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Jupiter! and the KAM theorem\n",
"\n",
"(Sethna, \"Entropy, Order Parameters, and Complexity\", ex. 4.4)\n",
"\n",
"© 2016, James Sethna, all rights reserved."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This exercise mostly uses classical mechanics to illustrate the KAM theorem. As such, we won't do much programming -- we'll implement Netwton's law of gravitation, set up the planets, and work out the details of the Poincaré section for you. It's your job to understand and explain the implications for statistical mechanics."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The foundation of statistical mechanics is the *ergodic hypothesis*:\n",
"any large system will explore the entire energy surface. We focus on\n",
"large systems because it is well known that many systems with a few\n",
"interacting particles are definitely not ergodic.\n",
"\n",
"The classic example of a non-ergodic system is the Solar System. Jupiter\n",
"has plenty of energy to send the other planets out of the Solar\n",
"System. Most of the phase-space volume of the energy surface has eight planets\n",
"evaporated and Jupiter orbiting the Sun alone; the ergodic hypothesis would\n",
"doom us to one long harsh winter. So, the big question is:\n",
"why has the Earth not been kicked out into interstellar space?\n",
"\n",
"Mathematical physicists have studied this problem for hundreds of years.\n",
"For simplicity, they focused on the *three-body problem*: for example,\n",
"the Sun, Jupiter, and the Earth.\n",
"The early (failed) attempts tried to do perturbation theory in the strength of\n",
"the interaction between planets. Jupiter's gravitational force on the\n",
"Earth is not tiny, though; if it acted as a constant brake or accelerator,\n",
"our orbit would be seriously perturbed in a few thousand years. Jupiter's\n",
"effects must cancel out over time rather perfectly ...\n",
"\n",
"This exercise is mostly discussion and exploration."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Import packages. \n",
"\n",
"(Note: no %pylab inline, for compatibility with our mouse-click launcher later. Plots will appear in separate windows.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%pylab\n",
"from scipy import *\n",
"from scipy.integrate import odeint"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Set constants. \n",
"\n",
"Masses in earth masses; radii in AU; time in years\n",
"\n",
"G = 4 * Pi^2 / SunMass\n",
"\n",
"Jovian year frequency = omega = sqrt(G*(JupiterMass+SunMass) / RJ^3) \n",
"\n",
"Jupiter and the Sun go around in circular orbits about their center of mass, with radii RJcm and RScm. The other constants are just to simplify the typing."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"EarthMass = 1.;\n",
"TrueJupiterMass = 317.83;\n",
"SunMass = 332830.\n",
"RJ = 5.20316\n",
"G = 4*pi**2 / SunMass"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We'll vary Jupiter's mass several times, so we write a routine to reset the frequency of its orbit (omega), and to reset other useful constants. That way we can just pass its mass Mj to the various routines."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def SetOmega(JupiterMass):\n",
" \"\"\"\n",
" As Jupiter's mass is varied, its orbital angular frequency changes\n",
" \"\"\"\n",
" return sqrt(G*(JupiterMass+SunMass) / RJ**3)\n",
"\n",
"def SetJupiterMass(JupiterMass):\n",
" \"\"\"\n",
" Usage: \n",
" JupiterMass, omega, RJcm, RScm, GMeMj, GMeMs = SetJupiterMass(newJupiterMass)\n",
" \n",
" omega is Jupiter's orbital frequency (which in the original app wasn't changed with the mass)\n",
" RJcm is the circular orbit radius Jupiter makes about the center of mass\n",
" RScm is the same for the Sun\n",
" GMeMj and GMeMs are just convenient for Newton's laws\n",
" \"\"\"\n",
" omega = SetOmega(JupiterMass)\n",
" RJcm = RJ * (SunMass/(JupiterMass+SunMass))\n",
" RScm = RJ * (JupiterMass/(JupiterMass+SunMass))\n",
" GMeMj = G*EarthMass*JupiterMass\n",
" GMeMs = G*EarthMass*SunMass\n",
" return JupiterMass, omega, RJcm, RScm, GMeMj, GMeMs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Standard initial conditions: start Earth along x, with velocity along y. (Jupiter starts along x as well.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"RxEarth0 = 1.\n",
"RyEarth0 = 0.\n",
"VxEarth0 = 0.\n",
"VyEarth0 = 2*pi\n",
"t0 = 0."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Planetary Motion ('dydt' or 'func' giving time evolution)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def Newton(RV,t,Mj):\n",
" \"\"\"\n",
" Given time and RV = (Rx, Ry, Vx, Vy) for Earth, returns derivatives of RV wrt time\n",
" \"\"\"\n",
" JupiterMass, omega, RJcm, RScm, GMeMj, GMeMs = SetJupiterMass(Mj)\n",
" Rx, Ry, Vx, Vy = RV\n",
" # Solar and Jovian positions at time t\n",
" RxJupiter = RJcm * cos(omega * t);\n",
" RyJupiter = RJcm * sin(omega * t);\n",
" RxSun = - RScm * cos(omega * t);\n",
" RySun = - RScm * sin(omega * t);\n",
" # vx, vy derivatives are F/M\n",
" REJ = sqrt( (RxJupiter-Rx)**2 + (RyJupiter-Ry)**2 );\n",
" RSJ = sqrt( (RxSun-Rx)**2 + (RySun-Ry)**2 );\n",
" Fx = GMeMj*(RxJupiter-Rx) / REJ**3 + GMeMs*(RxSun-Rx)/RSJ**3;\n",
" Fy = GMeMj*(RyJupiter-Ry)/REJ**3 + GMeMs*(RySun-Ry)/RSJ**3;\n",
" return array([Vx, Vy, Fx/EarthMass, Fy/EarthMass])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Function that plots the Earth's trajectory for a given mass, up to a given time."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def PlotTrajectory(Mj,tMax,dt=0.01):\n",
" figure()\n",
" times = arange(0.,tMax,dt)\n",
" Rx, Ry, Vx, Vy = odeint(Newton, [RxEarth0, RyEarth0, VxEarth0, VyEarth0],\\\n",
" times, args=(Mj,)).transpose()\n",
" plot(Rx,Ry); axes().set_aspect('equal')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Run for 100 years. Does it look like Jupiter is kicking Earth out of the solar system? Be sure to zoom in (say, to the top arc in the orbit). Estimate the fraction that the Earth's radius from the Sun changes due to Jupiter's varying gravitational pull."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"PlotTrajectory(TrueJupiterMass,tMax=12.)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Maybe Jupiter just pulls the earth out and back depending on which side of the Sun it lies? We can check this by looking at Earth's orbit in a rotating reference frame. (If $\\hat v = [\\cos(\\omega t), \\sin(\\omega t)]$ is a unit vector pointing from the center of mass to Jupiter, and $\\bf{R}$ is Earth's position, we're looking at $\\hat{\\bf{v}} \\cdot \\bf{R}$ on the x-axis and $\\hat{\\bf{v}} \\times \\bf{R}$ on the y-axis.) Now Jupiter is fixed at $y=0$, $x\\sim 5$ Earth orbit radii. Zoom in on the part of the orbit where Earth is closest to Jupiter, and the segment at the top. Is the orbit now a simple closed curve, or is it still tubular in the rotating frame?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def PlotRotatingFrame(Mj,tMax,dt=0.01):\n",
" omega = SetOmega(Mj)\n",
" figure()\n",
" times = arange(0.,tMax,dt)\n",
" Rx, Ry, Vx, Vy = odeint(Newton, [RxEarth0, RyEarth0, VxEarth0, VyEarth0], \\\n",
" times, args=(Mj,)).transpose()\n",
" plot(Rx*cos(omega*times)+Ry*sin(omega*times), Ry*cos(omega*times)-Rx*sin(omega*times)); axes().set_aspect('equal')\n",
"\n",
"PlotRotatingFrame(TrueJupiterMass,100.)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The n$^{th}$ time Jupiter passes by, the Earth is shifted no further than the first time. Jupiter thus warps Earth's orbit into a kind of spiral around a tube. This orbit in physical three-dimensional space is a projection of the tube in dimensional phase space. Jupiter thus warps Earth's orbit into a kind of spiral around a tube. This orbit in physical three-dimensional space is a projection of the tube in 6N-dimensional phase space."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now try increasing Jupiter's mass to 31000 Earth masses. (The book says 35000, but it's a little less fun.) What happens? What are the tiny loops? If you increase the time, does the Earth leave the Solar System?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"PlotTrajectory(Mj=...,tMax=100.)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The tube in phase space already exists for massless planets...\n",
"\n",
"Let us start in the non-interacting planet approximation (where Earth and\n",
"Jupiter are assumed to have zero mass). Both Earth's orbit and Jupiter's orbit\n",
"then become circles, or more generally ellipses. The field of topology\n",
"does not distinguish an ellipse from a circle; any stretched, 'wiggled' rubber\n",
"band is a circle so long as it forms a curve that closes into a loop.\n",
"Similarly, a torus (the surface of a doughnut) is topologically equivalent\n",
"to any closed surface with one hole in it (like the surface of a coffee cup,\n",
"with the handle as the hole). Convince yourself in this non-interacting\n",
"approximation that Earth's orbit remains topologically a circle in its\n",
"six-dimensional phase space.\n",
"\n",
"In the non-interacting planet approximation, what topological surface is it that contains the trajectory of the Earth, Jupiter, and the Sun? Choose between (i) sphere, (ii) torus, (iii) Klein bottle, (iv) two-hole torus, or (v) complex projective plane. About how many times does the Earth wind around this surface during each Jovian year?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The mathematical understanding of the three-body problem was only solved in the\n",
"past hundred years or so, by Kolmogorov, Arnol'd, and Moser. Their proof\n",
"focuses on the topological integrity of this tube in phase space (called\n",
"now the KAM torus). The KAM theorem tells us that the motion stays on a surface with the same topology even when Jupiter's mass becomes non-zero -- but only if Jupiter's year is a 'sufficiently irrational' number of Earth years. This protects the Earth from flying out of the solar system.\n",
"\n",
"More specifically, they could prove in this case that for\n",
"sufficiently small planetary masses there is a distorted torus in\n",
"phase space, near the unperturbed one, around which the planets\n",
"spiral around with the same winding number. About how large can you make Jupiter's mass before Earth's orbit stops looking like a torus? Admire the surface formed at large masses before the surface changes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"PlotTrajectory(Mj=...,tMax=1000.)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"(You may find that there are regions of unstable motion followed by regions of stable tori, and the behavior depends on the initial condition; there is no single correct answer for the largest mass before the torus disappears. Also, if you look in the rotating frame, interesting things happen before the Earth departs the Solar System.)\n",
"\n",
"We will explore these using a Poincaré section..."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The fact that the motion is stabilized by this invariant surface is a serious problem for statistical mechanics! The orbit does not explore the entire allowed energy surface. Our climate would be very unpleasant, on the average, if our orbit were ergodic.\n",
"\n",
"The Poincaré section shown in Fig. 4.8 in the text is a planar\n",
"cross-section\n",
"in a three-dimensional phase space. Can we reduce our problem to an\n",
"interesting problem with three phase-space coordinates?\n",
"The original problem has an eighteen-dimensional phase space.\n",
"In the center of mass frame it has twelve interesting dimensions. If we\n",
"restrict the motion to a plane, it reduces to eight dimensions. If we\n",
"assume that the mass of the Earth is zero (the *restricted* planar\n",
"three-body problem)\n",
"we have five relevant coordinates (Earth $xy$ positions and velocities,\n",
"and the location of Jupiter along its orbit).\n",
"If we remove one more variable by going to a rotating coordinate system that\n",
"rotates with Jupiter, the current state of our model can be described with four\n",
"numbers: two positions and two momenta for the Earth. We can remove another\n",
"variable by confining ourselves to a fixed 'energy'. The true energy of the\n",
"Earth is not conserved (because Earth feels a periodic potential), but there\n",
"is a conserved quantity which is like the energy in the rotating frame. \n",
"This leaves us with a trajectory\n",
"in three dimensions (so, for small Jovian masses, we have a torus\n",
"embedded in a three-dimensional space). Finally, we take a Poincaré\n",
"cross-section; we plot a point of the trajectory every time Earth passes\n",
"directly between Jupiter and the Sun. We plot the distance to Jupiter\n",
"along the horizontal axis, and the velocity component towards Jupiter\n",
"along the vertical axis; the perpendicular component of the velocity\n",
"is not shown (and is determined by the 'energy').\n",
"\n",
"Let us use a Poincaré section to explore these tori and the chaotic regions between them. We want to take a snapshot of the position of the Earth each time it passes Jupiter. We need to interpolate between our trajectory points (using a spline), and find out where the snapshot times should be, and then report the corresponding positions. Rather than returning all four positions, we can go into the rotating frame and report the 'radial' position and velocity along the direction pointing to Jupiter. (The angular position is zero by the rules of the snapshot. The angular velocity is set by the total energy.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from scipy.interpolate import InterpolatedUnivariateSpline\n",
"\n",
"def PoincareIntersections(Rx,Ry,Vx,Vy,times,Mj):\n",
" \"\"\"\n",
" Returns coordinates where Earth passes through Jupiter's line through the origin, \n",
" with positive y velocity in rotating frame\n",
" \"\"\"\n",
" omega = SetOmega(Mj)\n",
" SJ = sin(omega*times) # Note these operations work on the whole array of times at once\n",
" CJ = cos(omega*times)\n",
" check = Rx*SJ - Ry*CJ # Zero if Earth and Jupiter are in same line with the origin (and hence with the Sun)\n",
" checkI = InterpolatedUnivariateSpline(times, check)\n",
" tZeroBothDirections = checkI.roots() # Finds interpolated times where they cross\n",
" # direction = True for those where Earth passes with positive velocity\n",
" direction = (checkI.derivative()(tZeroBothDirections) < 0.) \n",
" tZero = array([tZ for tZ, d in zip(tZeroBothDirections, direction) if d])\n",
" # Interpolate four coordinates. (Could interpolate r_radial and v_radial instead.)\n",
" RxI = InterpolatedUnivariateSpline(times, Rx)\n",
" RyI = InterpolatedUnivariateSpline(times, Ry)\n",
" VxI = InterpolatedUnivariateSpline(times, Vx)\n",
" VyI = InterpolatedUnivariateSpline(times, Vy)\n",
" r_radial = RxI(tZero)*cos(omega*tZero) + RyI(tZero)*sin(omega*tZero)\n",
" v_radial = VxI(tZero)*cos(omega*tZero) + VyI(tZero)*sin(omega*tZero)\n",
" \n",
" return r_radial, v_radial"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Try a Poincaré plot for Jupiter's true mass."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def PoincarePlot(Mj,tMax,dt=0.01):\n",
" figure()\n",
" times = arange(0.,tMax,dt)\n",
" Rx, Ry, Vx, Vy = odeint(Newton, [RxEarth0, RyEarth0, VxEarth0, VyEarth0], \\\n",
" times, args=(Mj,)).transpose()\n",
" r, v = PoincareIntersections(Rx, Ry, Vx, Vy, times, Mj)\n",
" plot(r,v,'r.');"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"PoincarePlot(TrueJupiterMass,tMax=500.)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Notice that the trajectory forms a closed curve. This curve is the intersection of a KAM torus with the Poincaré cross section. Does the range of r coordinates roughly correspond to the range of maximum x-coordinates you saw in the rotating reference frame for the true Jupiter mass above?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Try a Poincaré plot for a mass of 22000."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"PoincarePlot(Mj=22000.,tMax=500.)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This time we have something that looks like three closed curves, but is noticeably irregular. Something is very roughly repeating every third time Earth crosses Jupiter's angle. It represents the Earth in 'resonance' with Jupiter -- every third time it crosses Jupiter's angle, it returns roughly to the same point. (Resonances are often associated with 'mode locking', where the Earth's year becomes an integer multiple of Jupiter's year.) The irregularity, we shall see, is a sign of chaotic motion -- something that happens near resonances. \n",
"\n",
"The trajectory in the rotating reference frame also looks funky. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"PlotRotatingFrame(Mj=22000.,tMax=500.)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Would other initial conditions, with this same mass, look maybe more like the original KAM torus? (After all, you found trajectories for larger Jupiter masses that looked like tori earlier: 22000 is a weird interlude with mode locking.) To test this, we want to launch many trajectories at the same 'energy' (the conserved integral of motion in the rotating reference frame)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def RotatingFrameEnergy(RV, t, Mj):\n",
" \"\"\"\n",
" Given time and RV = (Rx, Ry, Vx, Vy) for Earth, returns the conserved 'rotating reference frame' energy\n",
" \"\"\"\n",
" JupiterMass, omega, RJcm, RScm, GMeMj, GMeMs = SetJupiterMass(Mj)\n",
" Rx, Ry, Vx, Vy = RV\n",
" # Kinetic Energy in rotating frame\n",
" KineticEnergy = 0.5 * EarthMass * (Vx**2+Vy**2) + EarthMass*omega*(Vx*Ry-Vy*Rx)\n",
" # Solar and Jovian positions at time t\n",
" RxJupiter = RJcm * cos(omega * t);\n",
" RyJupiter = RJcm * sin(omega * t);\n",
" RxSun = - RScm * cos(omega * t);\n",
" RySun = - RScm * sin(omega * t);\n",
" REJ = sqrt( (RxJupiter-Rx)**2 + (RyJupiter-Ry)**2 );\n",
" RES = sqrt( (RxSun-Rx)**2 + (RySun-Ry)**2 );\n",
" PotentialEnergy = -GMeMj/REJ - GMeMs/RES\n",
" return PotentialEnergy+KineticEnergy\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Just to check, for the default initial conditions and true Jupiter mass, the rotating frame energy is around -22.88..."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(RotatingFrameEnergy([RxEarth0, RyEarth0, VxEarth0, VyEarth0],t0,TrueJupiterMass));"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We define a function that, given the two coordinates r_radial and v_radial we plot on the Poincaré section, gives initial conditions that launch the Earth with the current energy in the right direction."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def EnergySurfaceInitial(r_radial, v_radial, Current_Energy, Mj):\n",
" \"\"\"\n",
" Given Jupiter, Earth, and Sun are in a line with the Earth between Jupiter and the Sun, find initial conditions\n",
" that will give a trajectory at a given rotating reference frame energy.\n",
" \n",
" Assumes new trajectory is launched with the three bodies along the x-axis, so solves for Vy given Rx, Vx.\n",
" \n",
" Doesn't do anything if v_radial too large for solution (too much radial kinetic and potential energy already)\n",
" prints 'verboten' if so.\n",
" \"\"\"\n",
" JupiterMass, omega, RJcm, RScm, GMeMj, GMeMs = SetJupiterMass(Mj)\n",
" Rx = r_radial\n",
" Vx = v_radial\n",
" Ry = 0.\n",
" RxJupiter = RJcm\n",
" RxSun = -RScm\n",
" Potential_Energy = -GMeMj/abs(RxJupiter-Rx) -GMeMs/abs(RxSun-Rx)\n",
" C = -Current_Energy + Potential_Energy + 0.5 * EarthMass*Vx**2\n",
" discriminant = omega**2 * Rx**2 - 2*C/EarthMass\n",
" if discriminant > 0:\n",
" Vy = omega * Rx + sqrt(discriminant)\n",
" return array([Rx, Ry, Vx, Vy])\n",
" else:\n",
" print('verboten')\n",
" return NULL"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test it by seeing if it gives the right initial y-velocity for the default initial conditions and true Jupiter mass. Do they look familiar?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"CurrentEnergy=RotatingFrameEnergy([RxEarth0,RyEarth0,VxEarth0,VyEarth0],t0,TrueJupiterMass)\n",
"EnergySurfaceInitial(RxEarth0,VxEarth0,CurrentEnergy,TrueJupiterMass)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We now define a function that takes a mouse click event on the plot (event.xdata giving the radial Earth position and event.ydata giving its radial velocity), launches a trajectory with that initial condition on the energy surface, and returns the Poincaré intersections for that trajectory."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"class PoincareLauncher:\n",
" def __init__(self, Mj, tMax=50.):\n",
" self.Mj = Mj\n",
" self.tMax = tMax\n",
" omega = SetOmega(Mj)\n",
" self.omega = omega\n",
" self.Current_Energy = RotatingFrameEnergy([RxEarth0,RyEarth0,VxEarth0,VyEarth0],\\\n",
" t0,Mj)\n",
" self.times = arange(t0,tMax,0.02)\n",
" Rx, Ry, Vx, Vy = odeint(Newton,[RxEarth0, RyEarth0, VxEarth0, VyEarth0],\\\n",
" self.times,args=(self.Mj,)).transpose()\n",
" figure(\"Rotating Reference Frame, Mj=%s\"%self.Mj)\n",
" r_parallel = Rx * cos(self.omega*self.times) + Ry * sin(self.omega*self.times)\n",
" r_perp = Ry * cos(self.omega*self.times) - Rx*sin(self.omega*self.times)\n",
" plot(r_parallel, r_perp); axes().set_aspect('equal')\n",
" r, v = PoincareIntersections(Rx,Ry,Vx,Vy,self.times,self.Mj)\n",
" fig = figure(\"Poincaré Section, Mj=%s\"%self.Mj)\n",
" plot(r,v,'.')\n",
" show()\n",
" self.cid = fig.canvas.mpl_connect('button_press_event', self)\n",
"\n",
" def __call__(self, event):\n",
" Rx = event.xdata\n",
" Vx = event.ydata\n",
" initial = EnergySurfaceInitial(Rx, Vx, self.Current_Energy, self.Mj)\n",
" Rx,Ry,Vx,Vy = odeint(Newton,initial,self.times,args=(self.Mj,)).transpose()\n",
" figure(\"Rotating Reference Frame, Mj=%s\"%self.Mj)\n",
" clf()\n",
" r_parallel = Rx * cos(self.omega*self.times) + Ry * sin(self.omega*self.times)\n",
" r_perp = Ry * cos(self.omega*self.times) - Rx*sin(self.omega*self.times)\n",
" plot(r_parallel, r_perp); axes().set_aspect('equal')\n",
" draw()\n",
" r, v = PoincareIntersections(Rx,Ry,Vx,Vy, self.times, self.Mj)\n",
" figure(\"Poincaré Section, Mj=%s\"%self.Mj)\n",
" plot(r,v,'.')\n",
" draw()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can now use PoincareLauncher to form an interactive window that allows us to explore the dynamics as a function of the initial condition. Click on the plot and see new orbits launched! Compare the Poincaré intersection rings with the corresponding full orbits."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"launcher = PoincareLauncher(Mj=22000.,tMax=1000.)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"Notice that the Rotating Reference Frame figure may be hidden behind the Poincaré section figure. \n",
"\n",
"Click on points in the plot to launch new trajectories. Can you find an orbit that is periodic (returns to the same point after three crossings)? What do the orbits look like in the rotating reference frame? The orbits near this periodic orbit, forming a torus which winds in a four-fold pattern in the rotating reference frame, are called *mode locked*. \n",
"\n",
"Can you find initial conditions that give KAM tori that are more like those for small Jupiter masses (that is, that intersect the Poincaré surface only once)? Do the orbits in the rotating reference frame look like deformed tori? (Notice that the KAM tori are squashed and twisted: they are topologically still tori.) \n",
"\n",
"Can you find regions that look chaotic? Can you find a five-fold pattern in the rotating reference frame? Nine-fold?\n",
"\n",
"Notice that the chaotic orbit does not throw the Earth\n",
" out of the Solar System. The chaotic regions near infinity and near\n",
" our initial condition are not connected. This may be an artifact of\n",
" our low-dimensional model; in other larger systems it is believed that\n",
" all chaotic regions (on a connected energy surface) are joined through\n",
" *Arnol'd diffusion*."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It turns out that proving that Jupiter's effects cancel out depends\n",
"on Earth's smoothly averaging over the surface of the torus. If Jupiter's\n",
"year is a rational multiple of Earth's year, the orbit closes after a few years\n",
"and you do not average over the whole torus; only a closed spiral. Rational\n",
"winding numbers, we now know, lead to chaos when the interactions are\n",
"turned on; the large chaotic region you found above is associated with\n",
"an unperturbed orbit with a winding ratio of 3:1 (hence the three\n",
"circles). Disturbingly,\n",
"the rational numbers are dense; between any two KAM tori there\n",
"are chaotic regions, just because between any two irrational numbers there\n",
"are rational ones. It is even worse; it turns out that numbers\n",
"which are extremely close to rational (Liouville numbers like\n",
"$1+1/10 + 1/10^{10} + 1/10^{10^{10}} + \\dots$) may also lead to chaos. It was\n",
"amazingly tricky to prove that lots of tori survive nonetheless. You can\n",
"imagine why this took hundreds of years to understand (especially without\n",
"computers to illustrate the tori and chaos graphically).\n",
"\n",
"Try other masses."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"launcher = PoincareLauncher(Mj=20000.,tMax=1000.)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}