-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Photon sharing and dual grid give inconsistent output when used with more than one pattern (demo_photon_sharing.m) #97
Comments
thanks @andreafarina for reporting this - can you provide a reproducer code to show the problem? |
For sure! It is a slight variation of the example demo_photon_sharing.m adapted to grid instead of elem. cfg.nphoton=3e6;
[cfg.node face cfg.elem]=meshabox([0 0 0],[60 60 20],2, 2);
cfg.elemprop=ones(size(cfg.elem,1),1);
cfg.srcpos=[10 10 -2];
cfg.srcdir=[0 0 1];
cfg.srctype='pattern';
cfg.srcparam1=[40.0 0.0 0.0 40];
cfg.srcparam2=[0.0 40.0 0.0 40];
cfg.prop=[0 0 1 1;0.01 10 0.9 1.37];
cfg.tstart=0;
cfg.tend=5e-9;
cfg.tstep=1e-10;
cfg.gpuid=-1;
cfg.method='grid';
cfg.debuglevel='TP';
%% 5 patterns represented by a 3D matrix
pat=zeros(40,40,5);
pat(:,:,1) = ones(40); % full field illumination pattern
pat(1:20,:,2) = 1; % pattern with left half bright
pat(:,1:20,3) = 1; % pattern with top half bright
pat(11:30,11:30,4) = 1; % pattern with bright square in the middle
pat(16:25,:,5) = 1;
pat(:,16:25,5) = 1; % pattern with a bright cross
cfg.srcpattern = pat;
%% run the simulation
flux=mmclab(cfg);
data = flux.data;
disp(['size(flux.data) = ',num2str(size(flux.data))]);
% 5D array: [Npatt,Nx,Ny,Nz,Ntime]
cwdata = squeeze(sum(data,5)); %sum over time
%% look z = 3
z = 3;
for i = 1:size(cwdata,1) % changed cw to cwdata to avoid an error
figure(1),
subplot(2,3,i),
imagesc(squeeze(cwdata(i,:,:,z))),
title(['pattern ',num2str(i)]),
axis image
end |
@andreafarina, I was able to reproduce the issue and fixed it with the following commit the screenshot of the output is attached below. the photon-sharing feature is now supported with DMMC on the CPU - still need to work on GPU port of photon-sharing (#86). please test and let me know if you see any additional problem. |
Thanks a lot!! It works now!! |
@andreafarina, FYI, the photon-sharing feature is now working on the GPU (for both OpenCL and CUDA). see #86 and #99 - please note that the srcpattern array now uses the 1st dimension (left-most) as the pattern dimension, instead of the right-most dimension. This way, it is consistent with the photon-sharing in mcx. |
@fangq thank you very much! It works great! And I can run also using CUDA with the Andrea |
Dear Qinqian,
I've tried to change the cfg.method from 'elem' to 'grid' to test the dual grid in demo_photon_sharing.m. As expected the flux.data output is a 5D array having the following dimensions: [Num_pattern, Nx, Ny, Nz, NTime]. After summing up the last (time) I tried to plot the fluence in the z dimension for each pattern. I obtain inconsistent results, which does not happen if only one pattern is simulated in the source. Probably there is some bug in reshaping the output data.
Thanks a lot!
Andrea
The text was updated successfully, but these errors were encountered: