Skip to content

Commit

Permalink
Second test corrected to 0.99-1.01 and 0.97-1.01, issue rpoleski#84
Browse files Browse the repository at this point in the history
  • Loading branch information
rapoliveira committed May 20, 2024
1 parent d768f97 commit a071bd0
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions source/MulensModel/tests/test_ModelParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,38 +173,45 @@ def test_q_gt_1_is_good():
planet.set_magnification_methods(list_of_methods)
planet_2.set_magnification_methods(list_of_methods)
planet_3.set_magnification_methods(list_of_methods)
t_range = [3580, 3589, 3590, 3592, 3593, 3595]
magnifications_1 = planet.get_magnification(time=t_range)
magnifications_2 = planet_2.get_magnification(time=t_range)
magnifications_3 = planet_3.get_magnification(time=t_range)
t_checks = [3580, 3589, 3590, 3592, 3593, 3595]
magnifications_1 = planet.get_magnification(time=t_checks)
magnifications_2 = planet_2.get_magnification(time=t_checks)
magnifications_3 = planet_3.get_magnification(time=t_checks)

assert max(magnifications_1 - magnifications_2) < 1e-10
assert max(magnifications_1 - magnifications_3) < 1e-10


def test_q_gt_1_is_smooth():
"""
Check that there is a smooth transition from q = 0.99 and q = 1.01.
Check that there is a smooth transition between q = 0.97, 0.99 and 1.01.
In this case, a trajectory with caustic approaching is adopted.
"""
t_0 = 3583.
u_0 = 0.3
t_E = 12.
s = 2.18
q = 0.99 # 0.999 also works fine
alpha = 339.0
q = 0.99
alpha = 310.
rho = 0.001
planet = mm.Model({'t_0': t_0, 'u_0': u_0, 't_E': t_E, 's': s, 'q': q,
'alpha': alpha, 'rho': rho})
planet_2 = mm.Model({'t_0': t_0, 'u_0': u_0, 't_E': t_E, 's': s, 'q': 1/q,
'alpha': alpha+180., 'rho': rho})

planet.set_magnification_methods([3590., 'VBBL', 3595.])
planet_2.set_magnification_methods([3590., 'VBBL', 3595.])
t_range = [3571, 3590.5, 3591, 3592, 3593.4, 3594.5]
magnifications_1 = planet.get_magnification(time=t_range)
magnifications_2 = planet_2.get_magnification(time=t_range)

assert max(magnifications_1 - magnifications_2) < 1e-10
q_min = mm.Model({'t_0': t_0, 'u_0': u_0, 't_E': t_E, 's': s, 'q': q-0.02,
'alpha': alpha, 'rho': rho})
q_max = mm.Model({'t_0': t_0, 'u_0': u_0, 't_E': t_E, 's': s, 'q': q+0.02,
'alpha': alpha, 'rho': rho})

planet.set_magnification_methods([3580., 'VBBL', 3595.])
q_min.set_magnification_methods([3580., 'VBBL', 3595.])
q_max.set_magnification_methods([3580., 'VBBL', 3595.])
t_checks = [3571, 3583, 3585.5, 3586, 3586.5, 3592.5]
magnification = planet.get_magnification(time=t_checks)
diff_min = magnification - q_min.get_magnification(time=t_checks)
diff_max = magnification - q_max.get_magnification(time=t_checks)
limits = np.array([0.01, 0.01, 0.01, 0.56, 0.01, 0.03])

assert np.all(abs(diff_min) < limits)
assert np.all(abs(diff_max) < limits)


def test_rho_t_e_t_star():
Expand Down

0 comments on commit a071bd0

Please sign in to comment.