trajectory on mcxlab

123 views
Skip to first unread message

Mor Wainberg

unread,
Apr 22, 2022, 4:46:53 AM4/22/22
to mcx-users
Dear Qianqian,
I want to work with trajectory output to know the trajectory of the photon.
I use the following format:
[flux,det,vol,seed,traj]=mcxlab(cfg);
The number of photons I set in the simulation is: 1e8 (cfg.nphoton=1e8;)
I additionally set cfg.maxjumpdebug to be 1e8 (any value greater than this gives me an error), can you please explain to me why?
In addition at the end of the run, the following note appears in the command window:

retrieving fields ...     WARNING: the saved trajectory positions (2006453278) are more than what your have specified (100000000), please use the --maxjumpdebug option to specify a greater number
detected 126842 photons, total: 126842    transfer complete:    52350 ms


I would appreciate your help
Thank you
Mor Wainberg



Qianqian Fang

unread,
Apr 22, 2022, 9:16:08 PM4/22/22
to mcx-...@googlegroups.com, Mor Wainberg
On 4/22/22 04:46, Mor Wainberg wrote:
Dear Qianqian,
I want to work with trajectory output to know the trajectory of the photon.
I use the following format:
[flux,det,vol,seed,traj]=mcxlab(cfg);
The number of photons I set in the simulation is: 1e8 (cfg.nphoton=1e8;)
I additionally set cfg.maxjumpdebug to be 1e8 (any value greater than this gives me an error), can you please explain to me why?


hi Mor,

ou misunderstood the meaning of "cfg.maxjumpdebug". This number sets the maximum number of "jump positions", i.e. scattering sites of all photons (plus launch position and exit position - these define the key-points of the trajectory). It is not the number of photons.

For example, if a photon on average takes ~100 scattering events before exiting, the maxjumpdebug needs to be ~100xcfg.nphoton in order to save all trajectories. This usually leads prohibitive memory allocation and is not realistic (for example, if you run 1e8 photons, this takes 1e10^6^4 bytes = 223GB memory )


In addition at the end of the run, the following note appears in the command window:

retrieving fields ...     WARNING: the saved trajectory positions (2006453278) are more than what your have specified (100000000), please use the --maxjumpdebug option to specify a greater number


this message tells you exactly what I mentioned above - it appears that in your setting, each photon on average takes 20 scattering events before exit, therefore you will need to set maxjumdebug to ~2006453278, however, mcx won't even run because you don't have that amount of memory in your GPU.


Qianqian


detected 126842 photons, total: 126842    transfer complete:    52350 ms


I would appreciate your help
Thank you
Mor Wainberg



--
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/1446a74d-acc1-4a82-907e-47495cde0af1n%40googlegroups.com.

Mor Wainberg

unread,
Apr 23, 2022, 3:00:13 AM4/23/22
to mcx-users
Dear  Qianqian, 
Thank you for your detailed answer.
If I understood correctly, in the situation where I simulate 1e8 photons it is not possible to save the photon trajectories.
If I still need it, is there a way to know what the photons trajectories and what the scattering sites of each trajectory are?
In addition, is there a connection between nscat and the scattering events that occur during the trajectory? And how can they be linked?

Thank you very much,
Mor Wainberg


ב-יום שבת, 23 באפריל 2022 בשעה 04:16:08 UTC+3, q.fang כתב/ה:

G Buist

unread,
Apr 29, 2022, 5:39:09 AM4/29/22
to mcx-users
Hello Mor,

You can save the trajectories of many photons by repeating the same simulations with different seeds and a lower amount of photons such that you will not run out of memory due to the amount of trajectory data. For example say you have enough memory for trajectory data of 1e2 photons in your simulation, you then just need to run 4 of such simulations with different seeds.
It is also good to take a look at the  'trajectory data photon id bug'  thread since this could also influence the number of photon trajectories you can save.

In addition, is there a connection between nscat and the scattering events that occur during the trajectory? And how can they be linked?

nscat gives the number of scattering events per media for each photon. The events in trajectory are the start position, scatter positions and final position of each photon. Therefore the sum over all media types of nscat for a photon should be equal to the total number of events - 2 of the trajectory data of that same photon.

Best,
Gijs Buist
Op zaterdag 23 april 2022 om 09:00:13 UTC+2 schreef Mor Wainberg:

Mor Wainberg

unread,
May 1, 2022, 6:57:44 AM5/1/22
to mcx-users
Hi Gijs,
First of all thanks a lot for the answer.
I would appreciate it if you could please explain how to configure the seed so that the simulation will run as you described above.

Best Regards, 
Mor Wainberg
ב-יום שישי, 29 באפריל 2022 בשעה 12:39:09 UTC+3, G Buist כתב/ה:

G Buist

unread,
May 2, 2022, 11:40:48 AM5/2/22
to mcx-users
Hi Mor,

The RNG seed can be changed  in mcxlab via  cfg.seed or in the JSON input file format via  "Session":  "RNGSeed": number.

Best,
Gijs


Op zondag 1 mei 2022 om 12:57:44 UTC+2 schreef Mor Wainberg:
Reply all
Reply to author
Forward
0 new messages