fangq / mcx

Monte Carlo eXtreme (MCX) - GPU-accelerated photon transport simulator

Home Page:http://mcx.space

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[CRITICAL] double-multiplication of initial weight in single-pattern-source fluence output

fangq opened this issue · comments

@ShijieYan helped debugging the issue reported by Haohui Zhang in this mailing list thread

https://groups.google.com/g/mcx-users/c/KEH754XnJdY

he noticed that our single-pattern simulations have been generating incorrect outputs at least since 4 years ago (v2020 and onward, may be even earlier).

in 2020, a similar bug was fixed for diffuse transmittance c04bff5, but somehow we did not apply this fix to the volumetric fluence output.

if you use photon-sharing (multiple patterns) or if you just compute diffuse transmittance, your results were not impacted by this bug.

But if you are using the fluence output from a single pattern or pattern3d source, unfortunately mcx was giving you wrong results.

This is a critical bug.

detailed information on this bug was described in the below mailing list announcement:
https://groups.google.com/g/mcx-users/c/l-glzQk1UgU

quoted below

What version was affected

we found that this bug appeared in MCX and MCXCL v2020, could be even earlier (although Shijie believes it was not there when we completed photon-sharing between 2019-2020)

What type of simulations were affected

all single-pattern simulations using 'pattern' or 'pattern3d' source type (excluding multi-pattern simulations using photon-sharing) with non-binary sources have been giving incorrect volumetric outputs (fluence/flux/energy)

photon-sharing based simulations, surface diffuse-reflectance outputs and detected photon outputs were not affected. other source types (fourier etc) were not affected.

simulations using binary (0-1) single pattern/pattern3d were not affected

What happened

our code mistakenly multiplied the photons launch weight twice when saving fluence/energy deposition. This effectively make the simulated pattern squared. In other words, if you simulate a pattern [0.1,0.2;0.5,1], mcx/mcxcl effectively simulated [0.01,0.04;0.25,1].

we discovered the same issue in Aug 2020, but was only fixed it in diffuse reflectance outputs (c04bff5); but somehow we missed the fluence output.

How to fix

If you happen to use non-binary single-pattern simulation in your work, please immediately update your mcx/mcxlab/mcxcl/mcxlabcl to the Github version at

https://mcx.space/nightly/github/
We sincerely apologize for the inaccurate results mcx/mcxcl produced. Please rerun your simulations and verify if your results were affected.

If you use pmcx, I have already updated pmcx to v0.2.12 after fixing this bug. Please upgrade your pmcx from pypi (https://pypi.org/project/pmcx/).

Hello Fang! Does this bug affect mmc simulations?

@Giovannatc, no, it does not.