Skip to content

Commit 61281ae

Browse files
committed
use prop.g to return the anisotropy computed from Mie
1 parent 979f691 commit 61281ae

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

src/mcx_core.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ __device__ inline void rotsphi(Stokes *s, float phi, Stokes *s2){
285285
* @param[in] prop: pointer to the current optical properties
286286
*/
287287

288-
__device__ inline void updatestokes(Stokes *s, float theta, float phi, float3 *u, float3 *u2, Medium prop, float4 *gsmatrix){
288+
__device__ inline void updatestokes(Stokes *s, float theta, float phi, float3 *u, float3 *u2, uint *mediaid, float4 *gsmatrix){
289289
float costheta = cosf(theta);
290290
Stokes s2;
291291
rotsphi(s,phi,&s2);
292292

293-
uint imedia=NANGLES*(uint)prop.g;
293+
uint imedia=NANGLES*((*mediaid & MED_MASK)-1);
294294
uint ithedeg=floorf(theta*NANGLES*R_PI);
295295

296296
s->i= gsmatrix[imedia+ithedeg].x*s2.i+gsmatrix[imedia+ithedeg].y*s2.q;
@@ -1607,7 +1607,7 @@ kernel void mcx_main_loop(uint media[],OutputType field[],float genergy[],uint n
16071607
float cphi=1.f,sphi=0.f,theta,stheta,ctheta;
16081608
float tmp0=0.f;
16091609
if(gcfg->maxpolmedia && !gcfg->is2d){
1610-
uint i=(uint)NANGLES*(uint)prop.g;
1610+
uint i=(uint)NANGLES*((mediaid & MED_MASK)-1);
16111611

16121612
/** Rejection method to choose azimuthal angle phi and deflection angle theta */
16131613
float I0,I,sin2phi,cos2phi;
@@ -1696,7 +1696,7 @@ kernel void mcx_main_loop(uint media[],OutputType field[],float genergy[],uint n
16961696
v.nscat++;
16971697

16981698
/** Update stokes parameters */
1699-
if(gcfg->maxpolmedia) updatestokes(&s, theta, tmp0, (float3*)&rv, (float3*)&v, prop, gsmatrix);
1699+
if(gcfg->maxpolmedia) updatestokes(&s, theta, tmp0, (float3*)&rv, (float3*)&v, &mediaid, gsmatrix);
17001700

17011701
/** Only compute the reciprocal vector when v is changed, this saves division calculations, which are very expensive on the GPU */
17021702
rv=float3(__fdividef(1.f,v.x),__fdividef(1.f,v.y),__fdividef(1.f,v.z));

src/mcx_utils.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,11 +1397,8 @@ void mcx_prep_polarized(Config *cfg){
13971397
/* compute scattering coefficient (in mm^-1) */
13981398
prop[i+1].mus=qsca*A*polprop[i].rho*1e3;
13991399

1400-
/* g will store the index that points to the corresponding smatrix */
1401-
prop[i+1].g=(float)i;
1402-
1403-
/* store g in polprop, which will be output to detphoton later for post-processing */
1404-
polprop[i].mua=g;
1400+
/* store anisotropy g (not used in polarized MCX simulation) */
1401+
prop[i+1].g=g;
14051402
}
14061403
free(mu);
14071404
}

src/mcxlab.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,11 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
389389

390390
/** return the final optical properties for polarized MCX simulation */
391391
if(cfg.polprop){
392-
for(int i=0;i<cfg.polmedianum;i++){
393-
// remember that g was replaced by the index of Mueller matrix, now restore it
394-
cfg.prop[i+1].g=cfg.polprop[i].mua;
395-
}
396-
392+
for(int i=0;i<cfg.polmedianum;i++){
393+
// restore mua and mus values
394+
cfg.prop[i+1].mua/=cfg.unitinmm;
395+
cfg.prop[i+1].mus/=cfg.unitinmm;
396+
}
397397
dimtype propdim[2]={4,cfg.medianum};
398398
mxSetFieldByNumber(plhs[0],jstruct,3, mxCreateNumericArray(2,propdim,mxSINGLE_CLASS,mxREAL));
399399
memcpy((float*)mxGetPr(mxGetFieldByNumber(plhs[0],jstruct,3)),cfg.prop,cfg.medianum*4*sizeof(float));

0 commit comments

Comments
 (0)