Closed devhello145 closed 1 year ago
mmc treats the space outside of the mesh (i.e. the entire space outside of your mesh) as medium 0 (background) and use cfg.prop(1,:)=[0,0,1,1] for such medium.
when you calculate your reflection ratio, did you consider the secondary reflection between your layer1 and the background medium?
As I understand, there are only one reflection layer1 -> layer2. I took care for reflection of "layer2-> outside". It is impossible due to high mu_a and low mu_s of layer2. So all photons will die in layer2.
Is it possible that photons reflects from layer2, go to layer 1 and then reflects from outside?
when you calculate your reflection ratio, did you consider the secondary reflection between your layer1 and the background medium?
But I also experimented without secondary reflection by setting
n1=1.3;
prop = [0, 0, 1, n1; 0, 0, 1, n1; 1e+4, 1e-6, 1, n2];
gpuid = 1;
and detected nothing (0 photons on PD). Therefore the issue is still exist.
again, sorry for the long delay in getting back to you.
I ran your simulation and plotted a trajectory of a photon, see below
you can see that the photon is bounced at nearly all interfaces due to total internal reflection - with the exception that the y/z plane interface of medium type 1 (layer 1).
you can set your detpos
to have a large radius (such as detpos = [2 * tand(alpha) * h, 0, 0, 50];
) to capture all photons and plot the exiting position using
mcxpreview(cfg);
hold on
plotmesh(detp.p, 'bo')
you can see that all photons exit from the two strips along y=-20 and y=20.
from your domain setting, I believe mmc traces the photon properly and there should be no photon exiting from the z=0 plane.
I am closing this ticket. if you see any issue, feel free to reopen.
When Fresnel coefficient is small (< 0.02), photons are not reflected, even with large number nphoton (1e+7). Maybe the problem is in random number generator.
In this example of code, I create a 2layer mesh (1 - layer is transparent with n1 refractive index, 2-layer is absorb everything with n2 refractive index). The source is pencil, place on the botton of layer1 and incident angle (alpha) is const. So we know position of incident on boundary of layer 1 and layer 2.
The detector is placed in the position of reflected photons (in bottom of layer 1).
Also I add Fresnel calculation coefficient (r) for MMC (take from source code and slightly modify for octave) and MCML (see link), but they are almost same.
So we expect to detect (r * nphoton), when nphoton is enough large. But It does not (detect 0 photons)!!!WHY???.
See MAIN PARAMS section for setup:
Output for n1=1.3:
Cpu (gpuid=-1)//Nothing detects!!!:
```txt generating tetrahedral mesh from closed surfaces ... creating volumetric mesh from a surface mesh ... volume mesh generation is complete Launching MMCLAB - Mesh-based Monte Carlo for MATLAB & GNU Octave ... Running simulations for configuration #1 ... mmc.seed=1; mmc.srctype='pencil'; mmc.srcpos=[0 0 0]; mmc.srcdir=[0.819152 0 0.573576 0]; mmc.tstart=0; mmc.tend=1e-06; mmc.tstep=1e-06; mmc.isreflect=1; mmc.issaveexit=1; mmc.issaveseed=1; mmc.outputtype='fluence'; mmc.unitinmm=1; mmc.minenergy=1e-09; mmc.maxdetphoton=1e+07; mmc.method='elem'; mmc.gpuid=-1; mmc.debuglevel='TP'; mmc.prop=2; mmc.detnum=1; mmc.nn=7062; mmc.elem=[36761,4]; mmc.ne=36761; mmc.nphoton=1e+07; mmc.facenb=[36761,4]; mmc.evol=36761; mmc.e0=1874; done 3 simulating ... ############################################################################### # Mesh-based Monte Carlo (MMC) - OpenCL # # Copyright (c) 2010-2020 Qianqian FangGPU (gpuid=1)//nothing detects!!!
```txt generating tetrahedral mesh from closed surfaces ... creating volumetric mesh from a surface mesh ... volume mesh generation is complete Launching MMCLAB - Mesh-based Monte Carlo for MATLAB & GNU Octave ... Running simulations for configuration #1 ... mmc.seed=1; mmc.srctype='pencil'; mmc.srcpos=[0 0 0]; mmc.srcdir=[0.819152 0 0.573576 0]; mmc.tstart=0; mmc.tend=1e-06; mmc.tstep=1e-06; mmc.isreflect=1; mmc.issaveexit=1; mmc.issaveseed=1; mmc.outputtype='fluence'; mmc.unitinmm=1; mmc.minenergy=1e-09; mmc.maxdetphoton=1e+07; mmc.method='elem'; mmc.gpuid=1; mmc.debuglevel='TP'; mmc.prop=2; mmc.detnum=1; mmc.nn=7062; mmc.elem=[36761,4]; mmc.ne=36761; mmc.nphoton=1e+07; mmc.facenb=[36761,4]; mmc.evol=36761; mmc.e0=1874; done 4 simulating ... ############################################################################### # Mesh-based Monte Carlo (MMC) - OpenCL # # Copyright (c) 2010-2020 Qianqian FangOutput for n1=1.2: (please modify code example: set n1)
GPU (gpuid=1) // Detects smaller and not all good photons (but it's maybe another bag)
```txt generating tetrahedral mesh from closed surfaces ... creating volumetric mesh from a surface mesh ... volume mesh generation is complete Launching MMCLAB - Mesh-based Monte Carlo for MATLAB & GNU Octave ... Running simulations for configuration #1 ... mmc.seed=1; mmc.srctype='pencil'; mmc.srcpos=[0 0 0]; mmc.srcdir=[0.819152 0 0.573576 0]; mmc.tstart=0; mmc.tend=1e-06; mmc.tstep=1e-06; mmc.isreflect=1; mmc.issaveexit=1; mmc.issaveseed=1; mmc.outputtype='fluence'; mmc.unitinmm=1; mmc.minenergy=1e-09; mmc.maxdetphoton=1e+07; mmc.method='elem'; mmc.gpuid=1; mmc.debuglevel='TP'; mmc.prop=2; mmc.detnum=1; mmc.nn=7062; mmc.elem=[36761,4]; mmc.ne=36761; mmc.nphoton=1e+07; mmc.facenb=[36761,4]; mmc.evol=36761; mmc.e0=1874; done 3 simulating ... ############################################################################### # Mesh-based Monte Carlo (MMC) - OpenCL # # Copyright (c) 2010-2020 Qianqian Fang