Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: IEEE invalid operation when checking for central body collision #18

Closed
wants to merge 2 commits into from

Conversation

tobiscode
Copy link

Hi all,

I sometimes stumble across the following warning message when running Mercury:

Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG

With not much more to go on, I added the gfortran compiler flag -ffpe-trap=invalid to find the problem: calling acos() for a value less than -1, for which acos is not defined. Here is the part (line 963 in mercury6_2.for):

u0 = sign (acos((1.d0 - r0/a )/e), rv0)

I assumed that it was a rounding issue, since the values I got when checking were -1.0000000000288831 and -1.0000000002232341 (all at high e), but I don't understand all of the variabls exactly so I can't be 100% sure. I therefore added a check for the value before passing it on to acos, and setting the boundary values when a value is outside the (-1, 1) range. I also added the compiler flags to the Makefile to make sure people will catch more of these bugs when/if they occur.

Hope that helps someone!
Cheers

@texadactyl
Copy link
Contributor

texadactyl commented Feb 6, 2020

@tobiscode Suggest you create an issue for tracking. Explain precisely how you ran Mercury (E.g. parameter values).

Since you were debug printing, what were the values of r0, a, e, and rv0 when this occurred?

What environment ('nix, Windows, Mac, ...) do you use and how did you compile the project?

@texadactyl
Copy link
Contributor

texadactyl commented Feb 7, 2020

@tobiscode

"Avoid invalid acos calls when checking for central body collision"

Given certain input parameter values, what if that calculation uncovered an inherent issue never before seen? Your code would cover it up.

A value of -1.0000000000288831 can be excused with an appropriate error tolerance. But, a value of -42 should not be excused - throw an exception and provide as much empirical evidence as possible (E.g. values for r0, a, e, ev0).

You need to distinguish between "close enough" and "this is not correct at all".

Again, before the project owners (4xxi) take any action, they will probably need to see an issue recorded with DETAILED directions from you for reproducing your findings. Your report must be reproducible by a second party.

Using the sample parameters, I cannot reproduce your findings.

@tobiscode
Copy link
Author

I totally agree @texadactyl, it should not mask a different error - Sorry for the delayed response (busy week). I've created an issue #20 with initial conditions that reproduce the error, and with more debugging info.

@texadactyl
Copy link
Contributor

@tobiscode I suggest that you withdraw/cancel this pull request as @idovgalyov-4xxi has said that he will address issue #20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants