NaN values in photon position and direction from detp file

52 views
Skip to first unread message

G Buist

unread,
Oct 3, 2022, 8:50:20 AM10/3/22
to mcx-users

Dear Dr. Fang,

 

After running an MCX simulation with a homogeneous medium some of the exit position and exit direction (‘p’, ‘v’) of the saved photons have NaN values on their x and y position (z-position does contain actual values).  Could you tell me what can cause this behaviour?

Other photon information in the detp file (nscat, detid and ppath) are fine and do not contain NaN values. The NaN values in ‘p’ and ‘v’ are at the same photon indices. As detector condition I used --bc ______001000.

Files relevant to the simulation https://surfdrive.surf.nl/files/index.php/s/TQQbWe3UxA4eu5q . I used jdata to load the detp data in Python.

Best Regards,

Gijs

Qianqian Fang

unread,
Oct 5, 2022, 1:51:35 PM10/5/22
to mcx-...@googlegroups.com
hi Gijs,

I was able to reproduce the issue. after debugging, I traced it back to this line of the code that you contributed last year


when rand_uniform01(t) returns 0, it produces inf and subsequently made p/v nans.

I replaced it by rand_next_scatlen(t), which is essentially -logf(rand_uniform01(t) + EPS). the added EPS prevented taking log from 0. after this patch, the results are free of nans.


Qianqian
--
You received this message because you are subscribed to the Google Groups "mcx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mcx-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mcx-users/d0e84e58-0538-4661-a9f9-b3edfa1d4ab1n%40googlegroups.com.


Reply all
Reply to author
Forward
0 new messages