Boundary effects for cyclic boundary conditions

20 views
Skip to first unread message

Tamara Tromp

unread,
Oct 14, 2025, 10:16:31 AMOct 14
to mcx-users

---Sorry, the images were not visible in my previous message so let me try this again.---

Dear dr. Fang,

Recently I was trying out some different resolutions when I noticed something remarkable, namely that there can be boundary effects even when using cyclic boundary conditions (cc_cc_).

For  example, running a simulation with a test slab with LengthUnit 0.002 mm yields the following CCD image, where no boundary effects are visible:

CCD_image_002mm.png

The corresponding mcfg is:

{'dim': [425, 200, 384],

 'prop': array([[  0.  ,   0.  ,   1.  ,   1.35],

        [  0.5 , 150.  ,   0.9 ,   1.35]]),

 'issrcfrom0': 0,

 'unitinmm': 0.002,

 'tstart': 0,

 'tend': 5e-09,

 'tstep': 5e-09,

 'srctype': 'planar',

 'srcpos': [0, 0, 0],

 'srcdir': [0, 0, 1, 0],

 'srcparam1': [425, 0, 0, 0],

 'srcparam2': [0, 200, 0, 0],

 'nphoton': 100000000.0,

 'respin': 1,

 'isreflect': 1,

 'bc': 'cc_cc_001000',

 'isnormalize': 1,

 'maxdetphoton': 100000000.0,

 'autopilot': 1,

 'outputtype': 'flux',

 'savedetflag': 'pxv',

 'debuglevel': 'P',

 'issavedet': 1,

 'issaveseed': 1,

 'verb': 8} 

However, when running the same simulation but with LengthUnit 0.008 mm, I obtain the following CCD image, which displays a clear intensity dropoff at the boundaries:

CCD_image_008mm.png

The corresponding mcfg is:

{'dim': [106, 50, 96],

 'prop': array([[  0.  ,   0.  ,   1.  ,   1.35],

        [  0.5 , 150.  ,   0.9 ,   1.35]]),

 'issrcfrom0': 0,

 'unitinmm': 0.008,

 'tstart': 0,

 'tend': 5e-09,

 'tstep': 5e-09,

 'srctype': 'planar',

 'srcpos': [0, 0, 0],

 'srcdir': [0, 0, 1, 0],

 'srcparam1': [106, 0, 0, 0],

 'srcparam2': [0, 50, 0, 0],

 'nphoton': 100000000.0,

 'respin': 1,

 'isreflect': 1,

 'bc': 'cc_cc_001000',

 'isnormalize': 1,

 'maxdetphoton': 100000000.0,

 'autopilot': 1,

 'outputtype': 'flux',

 'savedetflag': 'pxv',

 'debuglevel': 'P',

 'issavedet': 1,

 'issaveseed': 1,

 'verb': 8}

I did some small test simulations to investigate this issue (all with a single slab) and the boundary effects seem to be more pronounced for a coarser resolution (larger LengthUnit), for a smaller g, for a larger mu_s and for a smaller mu_a, as you can see in the figure below. In that figure, I used [mean(I_middle) - mean(I_edge)]/[max(I_middle) - min(I_middle)] as a boundary effect metric, where I is the array with CCD image intensity values, the middle of the CCD image is taken from 0.25* the height and width to 0.75 * the height and width, and the edge is taken as all the outer pixels. (For comparison, the boundary effect metric of the 0.002 mm image above is 0.02, while the metric of the 0.008 mm image is 0.30.)

 BoundaryEffects_sweeps.png

One possible explanation I could think of is the source (planar in this case) being non-cyclic. Therefore, in the x and y direction there might occur a similar effect as Li 2015 (doi: 10.1117/1.JBO.20.9.095014., section 2.1.2) describes for the w-direction. However, I am not sure whether this makes sense.

I was wondering whether you have encountered this before and if you maybe know what is happening and why. Any help is greatly appreciated!

 

Kind regards,

Tamara Tromp 

Qianqian Fang

unread,
Oct 14, 2025, 12:25:54 PMOct 14
to mcx-...@googlegroups.com, Tamara Tromp

hi Tamara,

you should set cfg.issrcfrom0 to 1 instead of 0.

when you set it to 0, the domain origin is actually located at [1,1,1] instead of [0,0,0]. because of this, your source and the domain are not aligned.

see this line in the cyclic boundary demo script, this line is critical

https://github.com/fangq/mcx/blob/v2025.10/mcxlab/examples/demo_infinite_slab_cyclic_bc.m#L13

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/555fab7b-7ad5-4f9d-8f75-fb36630a02b9n%40googlegroups.com.

Qianqian Fang

unread,
Oct 14, 2025, 12:52:58 PMOct 14
to mcx-...@googlegroups.com, Tamara Tromp

just to explain what happened  -

every user's first post will be moderated, which means I have to manually approve your first post before your post can appear. This way we can prevent spams.

As a matter of fact, I approved your post about 1 hour before you repost, likely you did not refresh and saw the approved post.


For future users, please wait with patience, it may take up to a day or two for me to see the notification and approve your post, but I will handle it eventually, no need to repost (unless you want to add/correct something)


On 10/14/25 10:16, Tamara Tromp wrote:
--

Tamara Tromp

unread,
Oct 15, 2025, 5:09:23 AMOct 15
to mcx-users
Dear dr. Fang,

Thanks a lot, this solves the issue indeed!

Kind regards, Tamara 
Reply all
Reply to author
Forward
0 new messages