Repository navigation
Conversation
|
hi @jolkkonen, mcx already supports Lambertian launch over most area sources by setting cfg.srcdir(4) to does your patch aims to the same source profile? |
|
Dear Dr. Fang/@fangq, Yes, my modification is specifically for the The intended source profile is the 2D analogue of the existing 3D cosine-weighted (Lambertian) profile. My understanding is that the issue is specifically with the current implementation in 2D: the Lambertian branch uses the same 3D sampling procedure even when The patch adds this separate 2D sampling case under the Lambertian branch, while leaving the existing 3D Lambertian sampling unchanged. Best regards, |
Summary
This change extends the existing
disksource and Lambertian direction sampling to support 2D simulations, while preserving the existing 3D behaviour.srctype = diskcontinues to sample initial photon positions uniformly over a disc.srctype = disknow samples initial photon positions uniformly along a line segment centred atsrcpos, with total length 2 ×srcparam1.x.srcdir.w = -Infcontinues to use cosine-weighted (Lambertian) sampling over a hemisphere.srcdir.w = -Infnow uses the corresponding cosine-weighted angular sampling over a semicircle.Thus, the existing 3D source models are extended to their natural 2D counterparts: a disc becomes a line segment, and a hemisphere becomes a semicircle of possible unit propagation directions. No new source type is introduced.
This provides a way to model unit-strength diffuse boundary sources in 2D MCX simulations and facilitates comparisons with 2D diffusion-approximation (DA) simulations.
Validation
I compared the implementation against an independent 2D frequency-domain DA finite-element code. The boundary source in the DA model was represented by an indicator function over a boundary line segment, normalised by the segment length so that the total input flux was unity. The resulting complex photon fluence showed close agreement between MCX and the DA model in both amplitude and phase.
The modified MCX code was also successfully compiled with CUDA and tested through both the
mcxexecutable and thepmcxPython interface.A regression test was also added to
test/testmcx.shcovering a 2Ddisksource with Lambertian direction sampling. The new test passes.The full
test/testmcx.shsuite was run. All tests passed except the existingcolin27volume-data JSON export check (--bench colin27 --dumpjson), which fails independently of this change.Check List
Before you submit your pull-request, please verify and check all below items
make pretty(requiresastylein the command line) under thesrc/folder and formatted your C/C++/CUDA source codes before every commit; similarly, you should runpython3 -m black *.py(pip install blackfirst) to reformat all modified Python codes, or runmh_style --fix .(pip install miss-hitfirst) at the top-folder to format all MATLAB scripts.doxygenC formatIf your commits included in this PR contain changes that did not follow the above guidelines, you are strongly recommended to create a clean patch using
git rebaseandgit cherry-pickto prevent in-compliant history from appearing in the upstream code.Moreover, you are highly recommended to
mcx/test/testmcx.shscript, following existing examples, to test the newly added feature; or add a MATLAB script undermcxlab/examplesto gives examples of the desired outputsPlease copy/paste the corresponding Issue's URL after the below dash