Hi Owen,
I've been working on this for a while this week and am stumped. I found another reference of Bargo's: IEEE Journal of Selected topics in Quantum Electronics 9(2) 2003 and tried a few cases from that manuscript. My code appears to be determining a value for eta_c that is twice what it should be. I have reviewed the code, stepped through examples and still no luck determining where the problem is. I think I would like to share with you the code that checks for if the photon is exiting within NA or not:
/// <summary>
/// method to determine whether photon direction is within NA of detector
/// </summary>
/// <param name="dp">photon data point</param>
/// <param name="detectorNA">numerical aperture of detector</param>
/// <param name="n">refractive index of region where the detector resides</param>
/// <returns>boolean</returns>
public static bool IsWithinNA(this PhotonDataPoint dp, double detectorNA, Direction detectorNormal, double n)
{
var photonDirection = dp.Direction;
// determine if sin(theta)<=NA/n where theta is angle between photon direction and detector normal
var cosTheta = Direction.GetDotProduct(photonDirection, detectorNormal);
var sinTheta = Math.Sqrt(1 - cosTheta * cosTheta);
return sinTheta <= (detectorNA/n);
//return (detectorNA/n) >= Math.Sqrt(1 - cosTheta * cosTheta);
}
I commented out the last line and added intermediate variables so I could view them when I'm debugging. In the test cases we are running detectorNormal is always (0,0,-1) (positive z is into tissue). So Direction.GetDotProduct is just picking off the Uz of photonDirection (it will have a negative Uz since escaping tissue). I checked Scott Prahl's website because he is good about sharing code, however, the code they used for their papers is not included in his website. As a last resort, I might contact Bargo or Scott. I thought I'd share the code with you first to see if anything pops out at you that is wrong. I tried several NA cases and here are the results using N=1e5 and tissue n=1.33, mus'=1/mm, mua=0.5/mm, s-d separation 2.5mm, detector width 0.6mm.
NA Infinity 1.33 1.0 0.39 0.22
MC eta_c 1 1 1 0.1538 0.0476
theory (NA/n)^2 1 1 0.56 0.086 0.0274
Aside from setting NA=Infinity and 1.33, the MC eta_c values are almost twice theory.
So I think I need to enlist your help. If nothing seems wrong with my code, I'll contact Bargo or Scott.
Thanks for any feedback you might offer.
Carole