Changes

Jump to: navigation, search

Lightning Adventures

2,250 bytes added, 18:19, 5 October 2012
Assignment 1
==Assignment 1==
 
=== <u>Fluorescent Monte Carlo - Simulation of fluoresence in scattering medium</u> ===
Attempted by: Stanley Tsang
 
Uses the Monte Carlo subroutine mcsub.c to simulate
the penetration and escape of excitation light from a semi-infinite medium,
the distribution and escape of fluorescence from a uniform fluorophore in the medium, and
the distribution and escape of fluorescence from a localized heterogeneity in the medium.
Monte Carlo process-based simulations generally respond very well to parallelization as the random input process consists of entirely independent iterations and thus can be run in parallel (in theory).
 
The project can be found here: http://omlc.ogi.edu/software/mc/mcfluor/index.html
 
My goal for this project will be to parallelize the mcsub() function in mcsubLIB.c. The target function is quite long so I present a truncated version of the hotspot below: Note that Nphotons is extremely large, at least 1e6.
 
<big><pre>
 
for (iphoton=1; iphoton<=Nphotons; iphoton++) {
 
/* Print out progress for user if mcflag < 3 */
temp = (double)iphoton;
if ((PRINTOUT == 1) & (mcflag < 3) & (temp >= 100)) {
if (temp<1000) {
if (fmod(temp,100)==0) printf("%1.0f photons\n",temp);
}
if (temp<10000) {
if (fmod(temp,1000)==0) printf("%1.0f photons\n",temp);
}
else if (temp<100000) {
if (fmod(temp,10000)==0) printf("%1.0f photons\n",temp);
}
else if (temp<1000000) {
if (fmod(temp,100000)==0) printf("%1.0f photons\n",temp);
}
else if (temp<10000000) {
if (fmod(temp,1000000)==0) printf("%1.0f photons\n",temp);
}
else if (temp<100000000) {
if (fmod(temp,10000000)==0) printf("%1.0f photons\n",temp);
}
}
.
.
.
.
.
for (ir=1; ir<=NR; ir++) {
r = (ir - 0.5)*dr;
temp += J[ir]; /* accumulate total escaped photon weight */
J[ir] /= 2.0*PI*r*dr*Nphotons; /* flux density */
for (iz=1; iz<=NZ; iz++)
F[iz][ir] /= 2.0*PI*r*dr*dz*Nphotons*mua; /* fluence rate */
}
 
*Sptr = S = Rsptot/Nphotons;
*Aptr = A = Atot/Nphotons;
*Eptr = E = temp/Nphotons;
 
}
</pre></big>
1
edit

Navigation menu