hannorein / rebound

💫 An open-source multi-purpose N-body code.
https://rebound.readthedocs.io/
GNU General Public License v3.0
820 stars 217 forks source link

TES unit tests #675

Closed hannorein closed 1 year ago

hannorein commented 1 year ago

@PeterBartram: One TES unit test fails on my computer:

FAIL: test_integration_output_particles (rebound.tests.test_tes.TestIntegratorTES)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rein/git/rebound/rebound/tests/test_tes.py", line 89, in test_integration_output_particles
    self.assertLess(de, 1e-15)
AssertionError: 1.039239216630799e-15 not less than 1e-15

However, it passes on the CI. That is a bit worrying because they results of the test should be the same, regardless where they are run. I don't think this is related, but FWIW, I just fixed a bug in the rebound_integrator_tes ctypes structure definition (what is actually a double was listed as a pointer to a double).

PeterBartram commented 1 year ago

Ah, that's not good, it sounds like undefined behaviour somewhere. I'll see if I can track down the problem. What OS are you seeing the failing test on?

hannorein commented 1 year ago

That's on MacOS.

PeterBartram commented 1 year ago

I got to the bottom of this one, I'd left a call to pow() in the code for the step size update. I have replaced it with ias15 version of x^1/7. I have tested for bitwise energy violation matching for the longterm integration test is the unit test file (1e6 orbits for inner solar system) using a ubuntu desktop and an M1 macbook.

I have opened a pull request for the fix but wasn't sure if I was meant to link it to this issue somehow.

hannorein commented 1 year ago

Closed in #685