hi Giovanna,
what operating system do you use? also on what MATLAB version?
although on my Linux machine running xubuntu 22.04 and MATLAB
R2023R, I was able to produce the mesh, and launch mmclab, but it
hangs at 99% - usually this suggests mesh defects or degenerated
elements.
overall, I see at least two issues with this example code:
1. our mesh retessellation code was only tested on benchmarks where the wide-field source and wide-field detectors are part of the convex hull of the combined mesh. that means, they are both located on the exterior surface of the retessellated mesh. unfortunately in your use case, where the detector is on the same side as the source, and it encloses the retessellated source mesh into the interior of the convex hull (in other words, the detector is on the convex hull, but the source domain is interior). meshing such domain is tricky, because the source tetrahedron uniquely labeled (with label -1) after the mmcaddsrc() call may be further refined and split into multiple elements - which is the case in your mesh, therefore, the launch of photons may fail because the initial element no longer covers the full source aperture
2. your square-shaped pattern source aperture's circumscribing triangle has an edge that is exactly parallel to the block-shaped domain edge. this can cause problems for matlab to tessellate such domain, as a result, matlab produces nearly degenerated tetrahedra (with elem volume nearly 0)
in the below plot, you can identify such degenerated elements using
evol=elemvolume(cfg.node, cfg.elem(:,1:4));
hold on
plotmesh(cfg.node, cfg.elem(find(evol< 1e-10), :), 'facecolor','r');
I plot these problematic elements in red in the below plot
overlaying on top of the final mesh after src/detector
retesellations
although theses elements may be valid when processed using double-precision, in MMC, we use single-precision data to handle mesh shapes, and these degenerated elements will make ray-tracing fail (therefore, hanging mmc)
problem 2 can be potentially address by using an option 'rotate'
in mmcsrcdomain
(), for example
[cfg.node,cfg.elem] = mmcaddsrc(cfg.node,cfg.elem,...
mmcsrcdomain(srcdef,[min(cfg.node);max(cfg.node)], 'rotate', pi/7));
this could avoid the parallel edges as well as degenerated
elements, with the output mesh shown as below - the minimum
element volume is now 4e-8.
although the above mentioned issue#2 can be mitigated using the rotation flag, both the source element (tetrahedra where photons are launched, must be labeled as -1) and detector elements (elements where escaping photons are captures. must be labeled as -2) are incorrectly labeled due to the overlapping nature of the src/det.
I think perhaps manual labeling of src and detector elements could potentially make mmclab to run, but I've never tested this. mmc does support multiple source elements (with -1 label) and dynamically compute the initial element at photon launch
https://github.com/fangq/mmc/blob/v2024.2/src/mmc_core.cl#L1305-L1342
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 on the web visit https://groups.google.com/d/msgid/mcx-users/2af54f05-962e-461c-a22e-40c5467c60fcn%40googlegroups.com.