Exemplo n.º 1
0
    h = 1e-2
    return (func(x + h * v) + func(x - h * v) - 2 * func(x)) / h / h


# Callback function used to monitor the geodesic after each step, integrate
# until norm of parameter velocity has grown by factor of 25
def callback(geo):
    # Integrate until the norm of the velocity has grown by a factor of 10
    # and print out some diagnotistic along the way
    print("Iteration: %i, tau: %f, |v| = %f" %
          (len(geo.vs), geo.ts[-1], np.linalg.norm(geo.vs[-1])))
    return np.linalg.norm(geo.vs[-1]) < 25.0 * np.linalg.norm(geo.vs[0])


# Calculate initial velocity
v = InitialVelocity(x, jacobian, Avv)

# Calculate geodesic
geo = geodesic(func,
               jacobian,
               Avv,
               M,
               N,
               x,
               v,
               atol=1e-2,
               rtol=1e-2,
               callback=callback)
geo.integrate(5.0)

print('Got to t={0}'.format(geo.ts[-1]))
Exemplo n.º 2
0
import numpy as np
from MMR import r, j, Avv
from geodesic import geodesic, InitialVelocity


# Choose starting parameters
x = np.log([1.0, 1.0])
v = InitialVelocity(x, j, Avv)

# Callback function used to monitor the geodesic after each step
def callback(geo):
    # Integrate until the norm of the velocity has grown by a factor of 10
    # and print out some diagnotistic along the way
    print("Iteration: %i, tau: %f, |v| = %f" %(len(geo.vs), geo.ts[-1], np.linalg.norm(geo.vs[-1])))
    return np.linalg.norm(geo.vs[-1]) < 100.0

# Construct the geodesic
# It is usually not necessary to be very accurate here, so we set small tolerances
geo_forward = geodesic(r, j, Avv, 2, 2, x, v, atol = 1e-2, rtol = 1e-2, callback = callback)  

# Integrate
geo_forward.integrate(25.0)
import pylab
# plot the geodesic path to find the limit
# This should show the singularity at the "fold line" x[0] = x[1]
pylab.figure()
pylab.plot(geo_forward.ts, geo_forward.xs)
pylab.xlabel("tau")
pylab.ylabel("Parameter Values")
pylab.show()