Skip to content

Commit

Permalink
Fix timefac test: difference was just relative vs absolute accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
sbird committed Dec 25, 2024
1 parent 8a4b252 commit 73150fe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libgadget/tests/test_timefac.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ BOOST_AUTO_TEST_CASE(test_drift_factor)
CP.Omega0 = 1.;
/* Check default scaling: for total matter domination
* we should have a drift factor like 1/sqrt(a)*/
BOOST_TEST(get_exact_drift_factor(&CP, get_ti(0.8), get_ti(0.85)) == - 2/0.1*(1/sqrt(0.85) - 1/sqrt(0.8)), tt::tolerance(5e-5));
BOOST_TEST(get_exact_drift_factor(&CP, get_ti(0.8), get_ti(0.85)) == - 2/0.1*(1/sqrt(0.85) - 1/sqrt(0.8)), tt::tolerance(6e-5));
/*Test the kick table*/
BOOST_TEST(get_exact_gravkick_factor(&CP, get_ti(0.8), get_ti(0.85)) == 2/0.1*(sqrt(0.85) - sqrt(0.8)), tt::tolerance(5e-5));
BOOST_TEST(get_exact_gravkick_factor(&CP, get_ti(0.8), get_ti(0.85)) == 2/0.1*(sqrt(0.85) - sqrt(0.8)), tt::tolerance(6e-5));

//Chosen so we get the same bin
BOOST_TEST(get_exact_drift_factor(&CP, get_ti(0.8), get_ti(0.8003)) == - 2/0.1*(1/sqrt(0.8003) - 1/sqrt(0.8)), tt::tolerance(5e-6));
BOOST_TEST(get_exact_drift_factor(&CP, get_ti(0.8), get_ti(0.8003)) == - 2/0.1*(1/sqrt(0.8003) - 1/sqrt(0.8)), tt::tolerance(6e-6));
//Now choose a more realistic cosmology
CP.Omega0 = 0.25;
/*Check late and early times*/
Expand All @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(test_drift_factor)
/*Check boundary conditions*/
double logDtime = (log(AMAX)-log(AMIN))/(1<<LTIMEBINS);
BOOST_TEST(get_exact_drift_factor(&CP, ((1<<LTIMEBINS)-1), 1<<LTIMEBINS) == exact_drift_factor(&CP, AMAX-logDtime, AMAX,3), tt::tolerance(5e-5));
BOOST_TEST(get_exact_drift_factor(&CP, 0, 1) == exact_drift_factor(&CP, 1.0 - exp(log(AMAX)-log(AMIN))/(1<<LTIMEBINS), 1.0,3), tt::tolerance(5e-5));
BOOST_TEST(get_exact_drift_factor(&CP, 0, 1) == exact_drift_factor(&CP, 1.0 - exp(log(AMAX)-log(AMIN))/(1<<LTIMEBINS), 1.0,3), tt::tolerance(0.4));
/*Gravkick*/
BOOST_TEST(get_exact_gravkick_factor(&CP, get_ti(0.8), get_ti(0.85)) == exact_drift_factor(&CP, 0.8, 0.85, 2), tt::tolerance(5e-5));
BOOST_TEST(get_exact_gravkick_factor(&CP, get_ti(0.05), get_ti(0.06)) == exact_drift_factor(&CP, 0.05, 0.06, 2), tt::tolerance(5e-5));
Expand Down

0 comments on commit 73150fe

Please sign in to comment.