[FLASH-USERS] Indexing Bug in Multipole_experimental

James Guillochon jfg at ucolick.org
Tue Sep 20 13:28:39 EDT 2011


Hi Norbert, just to clarify, rscaled is not zero in this case, it's just a
small number. The issue is that the ceiling function only applies to the
first product in the expression rscaled*inner_zone_grid_inv, and then the
int() rounds the second product to the nearest whole number.

On Tue, Sep 20, 2011 at 10:09 AM, Norbert Flocke
<flocke at flash.uchicago.edu>wrote:

> Dear James Guillochon,
>
> You are right. This is a computer representability issue for very small
> numbers. In case r falls below the smallest representable number, then
> rscaled is zero and the ceiling functions returns 0 as well. Thank you
> very much for reporting this issue. It will be fixed right away.
>
> Regards,
> Norbert Flocke
>
>
>
> On Tue, 20 Sep 2011, James Guillochon wrote:
>
>  Hi, I've discovered a small bug in Multipole_experimental. In a couple
>> places in gr_mpolePot* and gr_mpoleMom* there is the following set of
>> lines:
>>
>> rscaled = r * dr_inner_zone_inv
>>
>>> dr_unit = int (ceiling (rscaled * inner_zone_grid_inv) * inner_zone_grid)
>>> Q_lower = inner_zone_Qlower (dr_unit)
>>>
>>>
>> Occasionally, if r is small enough, dr_unit will be 0, which causes an out
>> of bounds error when referencing inner_zone_Qlower. The fix is to replace
>> the dr_unit assignments with the following:
>>
>> dr_unit = max(int (ceiling (rscaled * inner_zone_grid_inv) *
>>
>>> inner_zone_grid), 1)
>>>
>>>
>> Cheers,
>> - James
>>
>> --
>> James Guillochon
>> Department of Astronomy & Astrophysics
>> University of California, Santa Cruz
>> jfg at ucolick.org
>>
>>


-- 
James Guillochon
Department of Astronomy & Astrophysics
University of California, Santa Cruz
jfg at ucolick.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://flash.rochester.edu/pipermail/flash-users/attachments/20110920/5a8e08e2/attachment-0001.htm>


More information about the flash-users mailing list