ovidiopr/scattnlay

Error in the radiative pressure efficiency factor

Closed this issue · 4 comments

Hello everybody,

I have seen something seeming like an error, in scattnlay v1.0.0. It has stayed in the newest codes.
The radiative pressure efficiency factor Qpr is finally calculated using the Eq. 29 of the Pena & Pal paper. At a point in the formula appears the ratio n*(n+2)/(n+1) .
In the code this is written with ... (n*(n + 2)/(n + 1)) ... , where n is an integer variable. The C/C++ compiler places here integer operations, including an integer division.
Such an operation discards the fractional part, and reading the publication it does not seem to be the wanted behaviour (since it is not mentioned in the paper formula, I suppose the division is an ordinary one). It would not be a problem if n*(n+2)/(n+1) had a null fractional part, but as n is a strictly positive integer this fractional part is never zero.
I tested that point a little bit, experiencing a difference of a few percents in Qpr when enforcing or not a floating point division.

Best regards,

Nice point, thank you! I hope that @ovidiopr will find some time to review this part of the code, as soon as the repair should be trivial (if needed) like (n+2.0)/(n+1.0)

Thank you for reporting the bug. I am quite busy right now but I will check it and fix it ASAP (in a week or so).

I have fixed the problem but don't have any example at hand to check it. Could you please confirm if this is working OK?

Best regards.

No response, closing.