Skip to content

Commit

Permalink
add sanity check for incident Stokes vector
Browse files Browse the repository at this point in the history
  • Loading branch information
ShijieYan committed Dec 15, 2021
1 parent f1537bd commit 99293dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mcxlab/mcxlab.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@
% source, see cfg.srctype='pattern' for details
% Example <demo_photon_sharing.m>
% cfg.omega: source modulation frequency (rad/s) for RF replay, 2*pi*f
% cfg.srciquv: 1x4 vector [I,Q,U,V], Stokes vector of the incident light
% I: total light intensity (I >= 0)
% Q: balance between horizontal and vertical linearly
% polaized light (-1 <= Q <= 1)
% U: balance between +45° and -45° linearly polaized
% light (-1 <= Q <= 1)
% V: balance between right and left circularly polaized
% light (-1 <= Q <= 1)
% cfg.lambda: source light wavelength (nm) for polarized MC
% cfg.issrcfrom0: 1-first voxel is [0 0 0], [0]- first voxel is [1 1 1]
% cfg.replaydet: only works when cfg.outputtype is 'jacobian', 'wl', 'nscat', or 'wp' and cfg.seed is an array
Expand Down Expand Up @@ -361,7 +369,7 @@

if(isstruct(varargin{1}))
for i=1:length(varargin{1})
castlist={'srcpattern','srcpos','detpos','prop','workload','srcdir'};
castlist={'srcpattern','srcpos','detpos','prop','workload','srcdir','srciquv'};
for j=1:length(castlist)
if(isfield(varargin{1}(i),castlist{j}))
varargin{1}(i).(castlist{j})=double(varargin{1}(i).(castlist{j}));
Expand Down
3 changes: 3 additions & 0 deletions src/mcx_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,9 @@ void mcx_preprocess(Config *cfg){
MCX_ERROR(-6,"number of particle types does not match number of media");
if(cfg->lambda==0.f)
MCX_ERROR(-1,"you must specify light wavelength lambda to run polarized photon simulation");
if(cfg->srciquv.x<0.f) MCX_ERROR(-4,"initial total light intensity must not be negative");
if(cfg->srciquv.y<-1.f || cfg->srciquv.y>1.f || cfg->srciquv.z<-1.f || cfg->srciquv.z>1.f || cfg->srciquv.w<-1.f || cfg->srciquv.w>1.f)
MCX_ERROR(-4,"initial Q, U and V must be floating-point numbers between -1 and 1");
mcx_prep_polarized(cfg); // cfg->medianum will be updated
}

Expand Down

0 comments on commit 99293dd

Please sign in to comment.