From 37b49149aef64e59e2e89eb8f84d1834361ce086 Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Fri, 4 Sep 2020 18:19:48 -0400 Subject: [PATCH] add demo script for mirror bc --- mcxlab/examples/demo_focus_mirror_bc.m | 33 ++++++++++++++++++++++++++ src/mcx_core.cu | 6 ++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 mcxlab/examples/demo_focus_mirror_bc.m diff --git a/mcxlab/examples/demo_focus_mirror_bc.m b/mcxlab/examples/demo_focus_mirror_bc.m new file mode 100644 index 00000000..cb4b2ab3 --- /dev/null +++ b/mcxlab/examples/demo_focus_mirror_bc.m @@ -0,0 +1,33 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% MCXLAB - Monte Carlo eXtreme for MATLAB/Octave by Qianqina Fang +% +% In this demo script, we verify the following two bugs are fixed +% +% https://github.com/fangq/mcx/issues/103 (to handle focal point) +% https://github.com/fangq/mcx/issues/104 (to handle mirror bc) +% +% This file is part of Monte Carlo eXtreme (MCX) URL:http://mcx.sf.net +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +clear cfg +cfg.nphoton=1e7; +cfg.vol=uint8(ones(60,60,60)); +cfg.srctype='pattern'; +cfg.srcpos=[-40,-40, 0]; +cfg.srcparam1=[80 0 0 100]; +cfg.srcparam2=[0 80 0 100]; +cfg.srcdir=[0 0 1 30]; +cfg.issrcfrom0=1; +cfg.srcpattern=zeros(100,100); +cfg.srcpattern(51:end,51:end)=1; +cfg.gpuid=1; +cfg.autopilot=1; +cfg.prop=[0 0 1 1;0.005 0.1 0 1]; +cfg.tstart=0; +cfg.tend=5e-9; +cfg.tstep=5e-09; +cfg.bc='mm____'; + +flux=mcxlab(cfg); + +mcxplotvol(log10(double(flux.data))) diff --git a/src/mcx_core.cu b/src/mcx_core.cu index 209d75eb..16a0a365 100644 --- a/src/mcx_core.cu +++ b/src/mcx_core.cu @@ -991,6 +991,10 @@ __device__ inline int launchnewphoton(MCXpos *p,MCXdir *v,MCXtime *f,float3* rv, break; } } + + if(p->w<=gcfg->minenergy) + continue; + /** * If beam focus is set, determine the incident angle */ @@ -1470,7 +1474,7 @@ kernel void mcx_main_loop(uint media[],OutputType field[],float genergy[],uint n if(isreflect){ if(gcfg->mediaformat<100) updateproperty(&prop,mediaid,t); ///< optical property across the interface - if(((isreflect && (isdet & 0xF)==0) || ((isdet & 0xF) & 0x1)) && ((isdet & 0xF)==bcMirror || n1!=((gcfg->mediaformat<100)? (prop.n):(gproperty[(mediaid>0 && gcfg->mediaformat>=100)?1:mediaid].w)))){ + if(((isreflect && (isdet & 0xF)==0) || (isdet & 0x1)) && ((isdet & 0xF)==bcMirror || n1!=((gcfg->mediaformat<100)? (prop.n):(gproperty[(mediaid>0 && gcfg->mediaformat>=100)?1:mediaid].w)))){ float Rtotal=1.f; float cphi,sphi,stheta,ctheta,tmp0,tmp1;