hi Giovanna,
thanks for the report. I was able to reproduce the issue - when running on the CPU (cfg.gpuid=-1), but the detp outputs are empty. I also noticed that not just dept, seeds output were also empty if requested. both outputs were non-empty if using GPU
I created the below bug report
https://github.com/fangq/mmc/issues/87
and was also able to fix it with this one-line change (as part of
a jumble commit in which I added support for saving
photon trajectories in mmc last night)
please download the github or nightly build from this folder and test again
let me know if you see any other problem - please also be aware
that photon sharing is still not supported in the GPU.
Qianqian
Thank you for your quickly reply!
But the patter is working fine with gpuid = -1. The problem happens when I put the wide detector, because them I receive an empty output for detp after the simulation.
Is the wide detector implemented for gpu and cpu?Giovanna
--Em terça-feira, 5 de março de 2024 às 19:36:05 UTC+1, Qianqian Fang escreveu:
hi Giovanna,
unfortunately, photon-sharing -i.e. simulating multiple pattern sources simultaneously- was only implemented in the CPU version of mmc, but not the GPU/OpenCL version.
I just created a ticket to add this to the TODO list. please keep an eye on this ticket for future updates.
https://github.com/fangq/mmc/issues/86
Qianqian
On 3/5/24 12:32, Giovanna Tramontin wrote:
Hello Professor Fang,
I have a problem with mmclab. I am trying to simulate a slab with an inclusion and, apparently, the functionality of the code depends on the status of cfg.gpuid.
If -1, them mmc is used to run the code and the patterns works just fine (as you can see in the plot) but the detector does not, meaning that there is no output for detp.
If gpuid is 1, them openCL is used to run the code and the detector works just fine, but the patterns are not illuminated into the sample.
I need to use both the patterns and the detector. But, I only have this problem for cfg.srctype = 'planar' or 'pattern'. With Fourier, I can use both ate the same time with OpenCl. Can you help me?
Here is the code, you can try changing cfg.gpuid to -1 and to 1 and look at the outputs.
%
clear cfg;
clear all;
%% Geometry
[node1, face1] = meshabox([0 0 0],[65 65 15], 2, 2);
[node2, face2] = meshacylinder([20 0+1e-1 12], [20 65-1e-1 12], 2, 2, 2);
[node, face] = mergemesh(node1, face1, node2, face2);
[cfg.node, cfg.elem] = surf2mesh(node, face, [0 0 0], [65 65 15], 1, 2, [1,1,1;21,1,13], [], 0);
%% Source
cfg.srcpos = [10 30 -1];
cfg.srcdir = [0 0 1];
cfg.srctype = 'pattern';
%Generate patterns:
val(:,:,1) = [1 1; 1 1];
val(:,:,2) = [1 1; 0 0];
val(:,:,3) = [1 0; 1 0];
val(:,:,4) = [1 0; 0 1];
M=4;
cfg.srcpattern = val;
cfg.srcparam1=[20 0 0 2];
cfg.srcparam2=[0 20 0 2];
srcdef=struct('srctype',cfg.srctype,'srcpos',cfg.srcpos,'srcdir',cfg.srcdir,...
'srcparam1',cfg.srcparam1,'srcparam2',cfg.srcparam2);
[cfg.node,cfg.elem] = mmcaddsrc(cfg.node,cfg.elem,...
mmcsrcdomain(srcdef,[min(cfg.node);max(cfg.node)]));
%Detector
cfg.detpos = [10.0, 30.0, 16.0, 0.0];
cfg.detdir = [0 0 -1];
cfg.detparam1 = [20.0, 0.0, 0.0, 20];
cfg.detparam2 = [0.0, 20.0, 0.0, 20];
detpos = cfg.detpos(1:3);
detdef = struct('srctype', 'planar', 'srcpos', detpos, 'srcdir', cfg.detdir, ...
'srcparam1', cfg.detparam1, 'srcparam2', cfg.detparam2);
[cfg.node, cfg.elem] = mmcadddet(cfg.node, cfg.elem, detdef);
cfg.elemprop=cfg.elem(:,5);
cfg.elem=cfg.elem(:,1:4);
cfg.e0 = tsearchn(cfg.node,cfg.elem,cfg.srcpos);
%General config
cfg.unitinmm = 1;
cfg.nphoton = 1e6;
cfg.srcpos = [10 30 -1];
cfg.srcdir = [0 0 1];
cfg.tsart = 0;
cfg.tend = 5e-9;
cfg.tstep = 5e-10;
cfg.debuglevel = 'TP';
cfg.method='elem';
cfg.prop = [0, 0, 1, 1; 0.1, 0.001, 0.89, 1.37; 1, 0.01, 0.89, 1.37];
%If 1 use OpenCL, if -1, classical MMC - THIS CHANGES THE OUTPUT
cfg.gpuid = -1;
%% Run simulation
cfg.issaveexit = 1; %1 2 and 3 changes the output in detp. 1 and 3 are the same and 2 is different
cfg.outputtype = 'fluence';
[output, detp] = mmclab(cfg);
data = output.data;
cwdata = squeeze(sum(data,3));
%% prepare subplots
nCol = round(sqrt(M));
nRow = round(M/nCol);
figure(10),figure(11)
for i = 1:M
figure(10)
subplot(nRow,nCol,i); title(['output pattern ', num2str(i)]);
qmeshcut(cfg.elem(cfg.elemprop>0,1:4),cfg.node,(cwdata(i,:)'),'z=14','linestyle','none');
figure(11)
subplot(nRow,nCol,i); title(['input pattern ', num2str(i)]);
plotmesh([cfg.node,cwdata(i,1:length(cfg.node))'],cfg.elem(cfg.elemprop>0,1:4),'z>0','linestyle','none');
shading interp
axis on
% view([0,0,-1])
end
--
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 on the web visit https://groups.google.com/d/msgid/mcx-users/f57b0ede-50ad-423e-bc16-e93f4bd3fa2bn%40googlegroups.com.
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 on the web visit https://groups.google.com/d/msgid/mcx-users/f770efa2-4a09-44ba-a1a7-0c61907a894an%40googlegroups.com.