def main(): outpath = "/vega/astro/users/amp2217/projects/morphology/output/pal5" x0 = np.array([8.312877511, 0.242593717, 16.811943627]) v0 = ([-52.429087, -96.697363, -8.156130] * u.km / u.s).to(u.kpc / u.Myr).value w0 = np.append(x0, v0) potential = gp.LM10Potential() dt, nsteps = estimate_dt_nsteps(potential, w0, nperiods=10000, nsteps_per_period=1024) print("estimated dt, nsteps: {0:2f}, {1:d}".format(dt, nsteps)) le, t, w = gd.fast_lyapunov_max(w0, potential, dt, nsteps) print("saving stuff to: {0}".format(outpath)) np.save(os.path.join(outpath, "le.npy"), le) np.save(os.path.join(outpath, "t.npy"), t) np.save(os.path.join(outpath, "w.npy"), w) plt.figure(figsize=(10, 8)) plt.loglog(t[1:-10:10], le, marker=None) plt.savefig(os.path.join(outpath, "le.pdf")) plt.figure(figsize=(8, 6)) E = potential.total_energy(w[:, 0, :3], w[:, 0, 3:]) plt.loglog(np.abs((E[1:] - E[0]) / E[0]), marker=None, drawstyle="steps") plt.savefig(os.path.join(outpath, "energy.pdf"))
def test_mle(): potential = gp.LogarithmicPotential(v_c=1., r_h=0.1, q1=1., q2=1., q3=0.8, units=galactic) w0 = np.array([1., 0., 1., 0., 0.75, 0.]) l,t,w = gd.fast_lyapunov_max(w0, potential, dt=0.1, nsteps=100000) l2,t2,w2 = mle(w[0].copy(), potential, dt=0.1, nsteps=100000) print(l[-2] - l2) print(t[-2] - t2) print(w[-2] - w2.reshape(3,6))