InverseLight / ValoMC

Monte Carlo software for simulating light propagation
https://inverselight.github.io/ValoMC/
Other
43 stars 14 forks source link

non-scattering medium to scattering medium transition #5

Open akipulkkinen opened 4 years ago

akipulkkinen commented 4 years ago

MC2D.hpp & MC3D.hpp: The bug only affects situations where there are non-scattering and scattering medium.

Transmission test from non-scattering medium to scattering medium (if statement following comment "Test transmission from vacuum -> scattering media") should most likely be shifted down after comment "Upgrade remaining photon propagation lenght in case it is transmitted to different mus domain".

Otherwise the first test will draw a finite value for 'prop' and the latter test will change it to zero. In the next loop over 'while(1){}' variable 'ds' will end being zero and photon position will not get updated. 'WhichFace' will have changed values of photon structure under assumption that the photon will actually propagate. This will end up screwing up tracking of the photon and will end up in tears.

tlunttil commented 4 years ago

Similarly, there doesn't seem to be any checks to prevent divisions by zero when calculating the propagation length in case there's a mus=0 medium somewhere.