defining light source and measuring reflected photon's angle

534 views
Skip to first unread message

Kris Peterson

unread,
Jun 30, 2014, 3:20:47 AM6/30/14
to mcx-...@googlegroups.com
Hi,

Recently I found our MCX software. It looks like a very good software for 3D Monte Carlo simulations. Right now we have a project and we have simulated the light source using ZMax, and I have all the incident light angles and intensity distribution from ZMax. I have two questions about using MCX. 

1) Can I custom define all the incident angles, locations, and intensities of the input light source? That is, instead of a Gaussian or point light source, can I define a arbitrary light source with a set of input points with different input angles, locations and intensities and use this in the MCX simulation?  

2) If I understand correctly, I noticed that the output from MCX is the fluence and also the photon path length information. I'm just wondering, how can I get all the reflected photons' angle information. Can you give me some suggestions on what I should change in the code to record this information?

Thank you,

Best regards,
Kris

Qianqian Fang

unread,
Sep 12, 2014, 4:43:58 PM9/12/14
to mcx-...@googlegroups.com
On 06/30/2014 03:20 AM, Kris Peterson wrote:
Hi,

Recently I found our MCX software. It looks like a very good software for 3D Monte Carlo simulations. Right now we have a project and we have simulated the light source using ZMax, and I have all the incident light angles and intensity distribution from ZMax. I have two questions about using MCX.

hi Kris

sorry for taking so long. I hope you have already found your
answers. here are some of my suggestions


1) Can I custom define all the incident angles, locations, and intensities of the input light source? That is, instead of a Gaussian or point light source, can I define a arbitrary light source with a set of input points with different input angles, locations and intensities and use this in the MCX simulation? 

the fluence output has a linear relationship to the source. in other
words, you can run separate MCX simulates, each with a different
source definition (locations, angles, types), and then add the MCX
fluence/flux output (weighted by their intensities), this will give you
the combined source fluence/flux. Comparing to implementing a
"lumped" complex source in MCX, the above approach does not
add significant overhead in the computation.

the only thing you need to pay attention is the source intensity.
To match the fluence's noise characteristics in your final addition step,
you should set the total simulated photon number for each sub-source
proportional to it's intensity.

If your complex source has many many components, you may
consider using a pattern to represent your source in MCX. You will have
to change the code if you want to use different incidence angles at
different locations.



2) If I understand correctly, I noticed that the output from MCX is the fluence and also the photon path length information. I'm just wondering, how can I get all the reflected photons' angle information. Can you give me some suggestions on what I should change in the code to record this information?

I am not sure how easy this can be done. Be aware that when there
is refractive index mismatch, a photon can be reflected multiple times
before exiting the media (or exceeding the time window). Do you want
to get the angular info at the first reflection? all reflection instances?

In my mesh-based MC code (MMC), I have implemented a flag,
'--saveexit', to store the propagation vector of an exiting photon
in the file along side with the partial paths. However, this flag has
not been implemented in MCX, also, it is the angle before the final
transmission, not reflection. Storing the reflection events
of a photon is harder to program in a GPU given the memory
limitations.

If you are interested, the photon reflection codes in MMC can
be found here:

https://sourceforge.net/p/mcx/git/ci/master/tree/mmc/trunk/src/tettracing.c#l875

uncomment some of the debug lines will allow to print out the angular
info when a reflection event is detected.

Qianqian


Thank you,

Best regards,
Kris
--
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 post to this group, send email to mcx-...@googlegroups.com.
Visit this group at http://groups.google.com/group/mcx-users.
For more options, visit https://groups.google.com/d/optout.

The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

Clément Dupont

unread,
Jun 16, 2015, 12:04:07 PM6/16/15
to mcx-...@googlegroups.com
Hello,

I am sorry to restart this topic but I have the same problem as Kris. I want to define several ponctual light sources into the matrix. I thought to use GPU computing to parallelize computation of these sources.
One year after your post, is it possible to implement several sources into the same simulation? Run separate MCX simulates could be unfortunate (because the addition of all the MCX results would take long time to compute, I am wrong?)

thank you for your help.

Best regards,

Clément Dupont.

Qianqian Fang

unread,
Jun 16, 2015, 12:21:18 PM6/16/15
to mcx-...@googlegroups.com
On 06/16/2015 11:32 AM, Clément Dupont wrote:
Hello,

I am sorry to restart this topic but I have the same problem as Kris. I want to define several ponctual light sources into the matrix. I thought to use GPU computing to parallelize computation of these sources.
One year after your post, is it possible to implement several sources into the same simulation? Run separate MCX simulates could be unfortunate (because the addition of all the MCX results would take long time to compute, I am wrong?)

hi Clément

running multiple simulations and merging the results are not
necessarily inefficient. In fact, MCX adds very little overhead
to each simulation. If you run sufficient number of photons,
the overhead is only a tiny fraction of the total run-time.

Using the example/quicktest/run_qtest.sh as an example,
in this simulation, the overhead is only around 100ms,
compared to the 25300ms GPU run-time for 10^8 photons.
This is <0.4% of the total run-time. If you run 10 of these
simulations, the total overhead is only 1 second out of
4.2 minute total run-time, which is negligible.

The addition of the MCX results are quite easy, if you run
each source with equal amount of photons, simply load
the data with loadmc2, and take a mean. If each source
has it's own total photon count, you need to do a weighted
average. but this takes only a fraction of a second in matlab.

If you don't like managing many data files from multiple simulations,
consider MCXLAB, everything is done in memory, and no file IO
involved. In that case, the overhead is even smaller.

http://mcx.sourceforge.net/cgi-bin/index.cgi?Doc/MCXLAB

Qianqian


thank you for your help.

Best regards,

Clément Dupont.

On Monday, June 30, 2014 at 9:20:47 AM UTC+2, Kris Peterson wrote:
Hi,

Recently I found our MCX software. It looks like a very good software for 3D Monte Carlo simulations. Right now we have a project and we have simulated the light source using ZMax, and I have all the incident light angles and intensity distribution from ZMax. I have two questions about using MCX. 

1) Can I custom define all the incident angles, locations, and intensities of the input light source? That is, instead of a Gaussian or point light source, can I define a arbitrary light source with a set of input points with different input angles, locations and intensities and use this in the MCX simulation?  

2) If I understand correctly, I noticed that the output from MCX is the fluence and also the photon path length information. I'm just wondering, how can I get all the reflected photons' angle information. Can you give me some suggestions on what I should change in the code to record this information?

Thank you,

Best regards,
Kris
--
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 post to this group, send email to mcx-...@googlegroups.com.
Visit this group at http://groups.google.com/group/mcx-users.
For more options, visit https://groups.google.com/d/optout.

Qianqian Fang

unread,
Jun 16, 2015, 12:25:31 PM6/16/15
to mcx-...@googlegroups.com
On 06/16/2015 12:18 PM, Qianqian Fang wrote:
On 06/16/2015 11:32 AM, Clément Dupont wrote:
Hello,

I am sorry to restart this topic but I have the same problem as Kris. I want to define several ponctual light sources into the matrix. I thought to use GPU computing to parallelize computation of these sources.
One year after your post, is it possible to implement several sources into the same simulation? Run separate MCX simulates could be unfortunate (because the addition of all the MCX results would take long time to compute, I am wrong?)

if you are looking for an example of running multiple simulations
and merge the results, checkout this script:

http://mcx.sourceforge.net/cgi-bin/index.cgi?Doc/AnimationCode

it is the script for generating the animation on the mcx's website:

http://mcx.sf.net/upload/mcx_dice.gif

simulating multiple pencil beam source is much easier compared
to this example (where we use complex patterns). All you need to
do is to redefine cfg.srcpos and cfg.srcdir for each source.

Qianqian

Clément Dupont

unread,
Jun 17, 2015, 8:18:52 AM6/17/15
to mcx-...@googlegroups.com
Hello,

thank you for your reply, I did not see the example made for the "MCX" animation.
Is their any possibility to obtain the fluence rate value in a steady-state illumination with MCXYZ?

best regards,

Clément.

Qianqian Fang

unread,
Jun 17, 2015, 1:25:40 PM6/17/15
to mcx-...@googlegroups.com
On 06/17/2015 08:18 AM, Clément Dupont wrote:
Hello,

thank you for your reply, I did not see the example made for the "MCX" animation.

the animation script is part of the demo_mcxlab_srctype.m script
under mcxlab/examples, see

https://github.com/fangq/mcx/blob/master/mcxlab/examples/demo_mcxlab_srctype.m#L116-L257


Is their any possibility to obtain the fluence rate value in a steady-state illumination with MCXYZ?

did you mean MCX or MCXYZ?

Qianqian

Clément Dupont

unread,
Jun 18, 2015, 3:29:31 AM6/18/15
to mcx-...@googlegroups.com
Oh I am sorry, this is a mistake! I am trying several Monte-carlo codes with almost the same name, beginning with "MC...".
 
So, not MCXYZ, but the MCX. Is it possible to obtain fluence rate values in a steady-state illumination with MCX?

However, I obtained great results with "MCxyz" but it does not exist GPU version. But if I want to have the same results, I have to translate the MCxyz code into CUDA language.

Best regards,

Clément.

Qianqian Fang

unread,
Jun 18, 2015, 6:31:14 PM6/18/15
to mcx-...@googlegroups.com
On 06/18/2015 03:29 AM, Clément Dupont wrote:
Oh I am sorry, this is a mistake! I am trying several Monte-carlo codes with almost the same name, beginning with "MC...".
 
So, not MCXYZ, but the MCX. Is it possible to obtain fluence rate values in a steady-state illumination with MCX?

the steady-state solution, what we often called the continuous wave (CW)
solution, can be obtained by integrating all time points (assuming your simulation
time window is long enough). This can be done conveniently by a sum() call in matlab,
see

https://github.com/fangq/mcx/blob/master/mcxlab/examples/demo_validation_homogeneous.m#L104-L105


However, I obtained great results with "MCxyz" but it does not exist GPU version. But if I want to have the same results, I have to translate the MCxyz code into CUDA language.

Did you compare the results from the two simulators?

MCX handles the same voxelated domain as MCxyz, so, it is supposed to
produce the same solution. If you see difference in the outcome, first make
sure your simulations were done with the same settings (specular reflection,
source settings, boundary reflection settings, etc). If you are sure they have
the same settings, but the results are different, please send your inputs to me
so I can debug.

Qianqian

Clément Dupont

unread,
Jun 19, 2015, 4:51:04 AM6/19/15
to mcx-...@googlegroups.com
Hello,

thank you for your help. I am not comparing those two simulators. I did some simulations with MCxyz in order to validate numerical approaches (partial differential equation). Now, I am looking for a GPU Monte-Carlo program able to deliver steady state solution.

Best regards,

Clément
Reply all
Reply to author
Forward
0 new messages