hi Haohui,
your code does not run.
can you clarify what you are trying to compute?
if your goal is to get specular reflection, you should not use flux.dref, which is diffuse reflectance - which is different from specular reflection.
Qianqian
--
You received this message because you are subscribed to the Google Groups "mcx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mcx-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mcx-users/1fa8d080-bea2-441d-90d2-f28dce2ce5cdn%40googlegroups.com.
Sorry for the inconvenience.
In the code below, I obtain a final value of 0.0768 in the last row, which represents the percentage of light that is specularly reflected on the surface. This matches the theoretical result for a Lambertian source using the Fresnel equation.
However, when I modify the prop parameter to:
I expect the final result to be 0.5290, which corresponds to the theoretical specular reflectance. Despite this change, the result remains 0.0768.
Could you please advise if I am missing something in the setup or if there's another parameter I should adjust?
Thank you for your help.
hi Haohui,
if your goal is to validate the Fresnel's law at the tissue surface, try the below code instead
you don't need a large domain and large number of photos to verify this - my cfg.vol below contains 3 layers, layer 1 is label 0 (background), used to store reflectance; layer 2 is material 1, layer 3 is material 2.
I use cfg.bc='aaaaaa' to disable reflection from all bounding box
surfaces, but allows mcx to reflect for mismatches within the
medium.
you can verify using the trajectory plot I used at the bottom of my script - with a screen capture shown on the right panel of the attached figure.
if you comment out the cfg.bc line, you can see multiple
reflections.
I verified both directions for an incident angle of pi/4, it
matches the Fresnel's equation.
air_to_tissue=1;
if(air_to_tissue)
prop = [0,0,1,1;0,0,1,1;1e6,0,1,1.4]; % All unit is 1/mm
else
prop = [0,0,1,1.4;0,0,1,1.4;1e6,0,1,1]; % All unit is 1/mm
end
% Bulid the shape
Vfinal = zeros(10,10,3);
Vfinal(:,:,2) = 1;
Vfinal(:,:,3) = 2;
%% prepare cfg for MCX simulation
clear cfg
cfg.nphoton=1e6;
cfg.outputtype='energy';
% tissue labels:0-ambient air,1-tissue
cfg.vol=Vfinal;
cfg.prop = prop;
% light source
cfg.srctype = 'pencil';
cfg.srcpos=[4.9,4.9,1];
theta=pi/4;
cfg.srcdir=[0,sin(theta),cos(theta)];
cfg.issrcfrom0=1;
% time windows
cfg.tend=1e-8;
cfg.tstep=cfg.tend;
cfg.bc='aaaaaa';
% other simulation parameters
cfg.isspecular=0;
cfg.issaveref=1; % save diffuse reflectance
cfg.unitinmm = 0.2;
tic
%% run MCX simulation
[flux, detp, vol, seeds, traj]=mcxlab(cfg);
toc
%% post-simulation data processing and visualization
% convert time-resolved fluence to CW fluence
disp(struct('reflection', sum(flux.dref(:,:,1), 'all')))
mcxplotphotons(traj);
Qianqian
To view this discussion visit https://groups.google.com/d/msgid/mcx-users/7f085623-42a5-4375-9569-e208eccabe9cn%40googlegroups.com.
did you try adapting from my code instead?
I changed cfg.srctype to 'disk', and cfg.srcdir to [0,sin(theta),cos(theta), -inf] to use a Lambertian source, I see my code returned different reflection energy when air_to_tissue is set to 1 and to 0.
To view this discussion visit https://groups.google.com/d/msgid/mcx-users/f9d1f2f2-ef40-47c7-a6ba-9906dfd58c2an%40googlegroups.com.
Your method definitely yields the correct result. I will adopt your method.
Best wishes
Haohui