Beispiel #1
0
def test_cputimeout():
  '''Make sure that the integration halts after exceeding the maximum CPU
  integration time.'''
  large_time = 1e9
  tv = TripleVectorial()
  tv.cputstop = .1
  tv.evolve(large_time)
  assert tv.t < large_time
Beispiel #2
0
def test_repr():
  '''Make sure that the triple can print its state.'''
  t = TripleVectorial(inc=80, m1=1e-3)
  t.octupole = False
  j = t.__repr__()
  state = json.loads(j)
  assert_allclose(state['m1'], 1e-3)
  assert_allclose(state['inc'], 80)
  assert state['octupole'] == False
Beispiel #3
0
def test_numerical_kl_period_vectorial():
  '''See if the numerical calculation of the KL period by explicitly
  integrating the equations of motion works.'''

  # Triple_vector test
  tv = TripleVectorial(a1=1, a2=20, e1=.1, e2=.3, m1=1, m3=1, g1=0,
    Omega=180)
  tv.octupole = False
  assert_allclose(numeric_kl_period(tv, nperiods=3), 4201.6634127,
    rtol=1e-3, atol=1e-3)
Beispiel #4
0
def test_reset():
  '''Try to reset the triple.'''
  tv = TripleVectorial()
  tstop = 1e3
  burn = tv.evolve(tstop)
  tv.reset()
  ev1 = tv.evolve(tstop)
  tv.reset()
  ev2 = tv.evolve(tstop)
  assert_allclose(ev1[-1], ev2[-1], rtol=1e-2, atol=1e-2)
Beispiel #5
0
def test_numerical_kl_period_vectorial():
    '''See if the numerical calculation of the KL period by explicitly
  integrating the equations of motion works.'''

    # Triple_vector test
    tv = TripleVectorial(a1=1,
                         a2=20,
                         e1=.1,
                         e2=.3,
                         m1=1,
                         m3=1,
                         g1=0,
                         Omega=180)
    tv.octupole = False
    assert_allclose(numeric_kl_period(tv, nperiods=3),
                    4201.6634127,
                    rtol=1e-3,
                    atol=1e-3)
Beispiel #6
0
def test_kl_period_vectorial():
    '''Test the KL period semi-analytic calculation.'''
    tv = TripleVectorial(a1=1,
                         a2=20,
                         e1=.1,
                         e2=.3,
                         m1=1,
                         m3=1,
                         g1=0,
                         Omega=np.pi)
    assert_allclose(kl_period(tv), 4195.8240184679735, atol=1e-5, rtol=1e-5)
Beispiel #7
0
def test_save_as_initial():
  '''Try to set a parameter after creating the object and saving it as an
  initial condition.'''
  t = TripleVectorial()
  t.m1 = 1e-3
  t.save_as_initial()
  j = t.__repr__()
  state = json.loads(j)
  assert_allclose(state['m1'], 1e-3)
Beispiel #8
0
def test_Phi0():
  '''Test calculation of Phi0.  The calculation is done in units of Solar
  masses, years, and AU.'''
  tv = TripleVectorial(a1=1, a2=20, e1=.1, e2=.3, m1=1, m3=3)
  assert_allclose(tv.Phi0, 383313.6993558)
Beispiel #9
0
def test_tsec():
  '''Make sure the calculation of the secular timescale is correct.'''
  tv = TripleVectorial(a1=1, a2=20, e1=.1, e2=.3, m1=1, m3=3)
  assert_allclose(tv.tsec, 11625553844.775972)
Beispiel #10
0
def test_Th():
  '''Test the calculation of Kozai's integral.'''
  tv = TripleVectorial(e1=.05, inc=70)
  assert_allclose(tv.Th, .11668533399441)
Beispiel #11
0
def test_epsoct():
  '''Test the epsoct calculation.'''
  tv = TripleVectorial(a1=1, a2=20, e2=.3)
  assert_allclose(tv.epsoct, .01648351648)
Beispiel #12
0
def test_klperiod_oom():
    '''Test the OOM period of KL oscillations.'''
    tv = TripleVectorial(a1=1, a2=20, m1=1, m3=1, e2=.3)
    assert_allclose(kl_period_oom(tv), 1178.965050)
Beispiel #13
0
def test_inc70():
  '''Make a triple with inclination of 70 degrees.'''
  tv = TripleVectorial(e1=.05, inc=70)
Beispiel #14
0
def test_integrate():
  '''See that we can integrate the triple.'''
  tv = TripleVectorial()
  ev = tv.evolve(1e3)
  assert len(ev) > 0
Beispiel #15
0
def test_islibrating():
    '''Test the islibrating calculation.'''
    tv = TripleVectorial(e1=.1, inc=80, g1=45)
    assert is_librating(tv) == True
    tv = TripleVectorial(e1=.1, inc=80, g1=0)
    assert is_librating(tv) == False
Beispiel #16
0
def test_CKL():
  '''Test the CKL calculation.'''
  tv = TripleVectorial(e1=.1, inc=80, g1=45)
  assert_allclose(tv.CKL, -.00212307888)
Beispiel #17
0
def test_make_Triple_vector():
  '''Try to create a Triple_vector class.'''
  tv = TripleVectorial()
Beispiel #18
0
def test_P_out():
    '''Test the P_out calculation.'''
    tv = TripleVectorial(a2=20, m1=1, m3=1)
    assert_allclose(P_out(tv), 63.2455532)
Beispiel #19
0
def test_Hhatquad():
  tv = TripleVectorial(e1=.1, inc=80, g1=45)
  assert_allclose(tv.Hhatquad, 1.846364030293)
Beispiel #20
0
def test_flip_period():
  '''Test the flip_period method.'''
  tv = TripleVectorial(inc=80, e1=.1, m1=1)
  p = tv.flip_period(nflips=3)
  assert_allclose(p, 98589.004419462)
Beispiel #21
0
def test_set_options():
  '''Create a Triple_vector class with a few options.'''
  tv = TripleVectorial(a1=1, a2=20, e1=.1, e2=.3, m1=1, m3=3)
Beispiel #22
0
def test_set_octupole():
  tv = TripleVectorial()
  tv.octupole = False
Beispiel #23
0
def test_ecc_extrema():
  '''See that we can use the eccmaxima function.'''
  tv = TripleVectorial()
  ex = tv.extrema(1e4)
  assert len(ex) > 0
Beispiel #24
0
def test_P_in():
    '''Test the P_in calculation.'''
    tv = TripleVectorial(a1=1, m1=1)
    assert_allclose(P_in(tv), 1)