EMsoft-org / EMsoft

Public EMsoft repository
Other
61 stars 94 forks source link

Missing energy computation in MCfoil and MCxyz kernels ? #138

Open clementlfnd opened 3 years ago

clementlfnd commented 3 years ago

Hi Marc,

New energy is not computed before while loop in MCfoil and MCxyz kernels compared to MC kernel. Is there any reason or is it a missing computation ?

Clément

elena-pascal commented 3 years ago

I found that bit confusing as well. I think in one version of the code it is doing a scattering step before the scattering loop. I think it would make more sense to not do a scattering step before the scattering loop, ie start scattering loop with incident energy and start computing energies in scattering loop (the while loop). But that's just me

clementlfnd commented 3 years ago

Hi Elena,

I agree with you, maybe it is possible to make smalls kernels with the common portion of code of the differents Monte-Carlo facilities to unify the computations steps and avoid differences... I am not a specialist of OpenCL but I can try.

elena-pascal commented 3 years ago

The MC code could definitely use some structure. You could try to make it a common kernel and expose the exit conditions. What I mean is that the difference, as far as I can tell, between MCfoil and MC is the end condition for the while loop; for MC is z<0 (or whatever the scatter out from the top of the sample is) and for MCfoil is z>t (or scatter from the bottom of the foil). I can't remember how MCxyz was different, but I bet is something with the coordinate system. So then if you have a way to switch inside the kernel this exit condition and have it as a parameter, the rest of the code should be virtually identical.