OpenMC’s gamma transport with WW just slow or am I doing something wrong?

Short story: OpenMC is 0.8 the speed of MCNP for analog gamma only transport and only 0.17 - 0.55 with WW. Varied a bunch of parameters without much success of improving the FOM. Is OpenMC just slow or am I missing something?

Long story: I’ve been benchmarking OpenMC against MCNP and experimental data for well logging applications. Results will be published in a peer review paper hopefully soon.

Generally speaking, in my experience, when comparing especially the performance of OpenMC for neutron and coupled neutron-gamma problems, OpenMC is on par or faster than MCNP. That includes cases where the convergence is accelerated by weight windows. Both global (dose fields) and localized (detectors) examples.

Things change when I’m dealing with gamma only cases. In our case, the source is usually Cs-137 with a single energy gamma at 661.657 keV. Analog cases run a bit slower than MCNP (comparing FOM on the same machine). In the simple example I’ve attached, about 0.8 of MCNP (6.3.0). That is both with 0.15.3 and the latest dev version (0.16.1-dev8). This, for our applications isn’t ideal, but would be acceptable.

However, the problem is larger when applying weight windows. Throughout this benchmarking effort I’ve been using ADVANTG generated weight windows and translating them to the OpenMC format with openmc.WeightWindowsList.from_wwinp() (just to have consistent WW for the two codes, and I have experience with optimizing ADVANTG WWs for MCNP). The “translation” to OpenMC, with the wnorm normalization factor from the MCNP wwp card, works great out of the box with default settings for, as mentioned, neutron only and coupled neutron-gamma transport.

When I do the same for this gamma only case, the results are unexpectedly slow. For the simple example I’ve attached, I’ve seen the performance with 0.15.3 (0.4 – 0.17) and with 0.16.1-dev8 (0.55 – 0.17). The FOM is also higher than MCNP closer to the source but really drops off in the air regions surrounding the source container (lead and tungsten) – contrary to how global FW-CADIS WW should perform. In this simple case there’s also a strange anisotropy that is seen in the relative error. I’ve attached a couple of plots to showcase the problem.

Thinking there’s a problem with the population control of the particles splitting vs rouletting, I’ve warried the following parameters in OpenMC trying to improve the convergence rate: ww max split; no. of particles per batch and no of batches; survival ratio; max lower bound; different random seed; different nuclear data; survival biasing; max particle events; max history splits; max secondaries; shifted the source boundary; different ww normalization.

All variations resulted in minor differences in the performance, but I could never get close to the performance in MCNP. Any and all suggestions on what to test or how to approach the problem would be greatly appreciated.

And just to confirm, the mean values, both analog and WW, of the dose integrated over parts of the mesh or within the cells, are within the uncertainty for both codes - no bias introduced.

Description of the simple test case attached to the post (all files have xml extension so I could upload them): Cs-137 source (1 cm) in a tungsten (5 cm) and lead (13 cm) cask surrounded by air (51 cm; all cubes; side of cube given in brackets). We are interested in the dose field (H*10) in and around the cask (51 cm, 50 bins in all directions).

Relative error distribution of OpenMC (left) and MCNP (right) analog - OpenMC is a bit slower but looks OK (1e9 NPS):

Relative error distribution of OpenMC 0.15.3 (left) 0.16.1-dev8 (middle) and MCNP (right) with WW (1e7 NPS). Strange anisotropy and worse performance:

gamma_shield-MCNP-analog.i.xml (2.1 KB)

wwinp.xml (7.2 MB)

gamma_shield-OpenMC-analog.xml (5.3 KB)

gamma_shield-MCNP-ww.i.xml (2.2 KB)

gamma_shield-OpenMC-ww.zip.xml (2.4 MB)

Hi Bor,

this was a nice challenge.

Resolution A

turn OFF surface weight_window_checkpoints
this removes the Rel.Error asymmetries

Resolution B

shift all your geometry off of the wwinp grid
(leaving ON surface weight_window_checkpoints)
this also removes the Rel.Error asymmetries

    <surface id="11" type="x-plane" coeffs="-2.501"/>
    <surface id="12" type="x-plane" coeffs=" 2.501"/>
    <surface id="13" type="y-plane" coeffs="-2.501"/>
etc etc

Those resolutions were sniffed out by the Wolf himself.

Codex Astra explains it this way:

When a geometry surface lines up with the weight-window grid, 
OpenMC picks the window on the same side of that boundary, 
no matter which way the particle is moving. That can lead to 
more particle splitting on one side of the model and noisier results there

- /OpenMC-dev/src/particle.cpp:380 crosses the geometry surface; the surface checkpoint follows at line 386.
- /OpenMC-dev/src/weight_windows.cpp:294 looks up a window using the particle’s position, without its direction.
- /OpenMC-dev/src/mesh.cpp:1825 maps that position to a rectilinear mesh cell.
- /OpenMC-dev/include/openmc/search.h:14 makes an exact boundary position resolve to the lower-coordinate side.

There be a bug there

@yrrepy thank you for the extensive detective work! I did some more digging by myself. Here are my conclusions.

  1. The anisotropy issue

The issue was resolved, as you suggested, both by switching off the ww surface checks and also by shifting the ww mesh grid.

  1. The slowness/performance issue

With the anisotropy issue gone I could focus on the performance issue. And the underlying cause I think, as you suggested in the bug report, is the lack of checks of the WW at a certain amount of mean free paths. I confirmed this in two ways.

First: I set the nmfp parameter of the MCNP wwp card to 1000. MCNPs performance dropped and I basically got the performance match of analog simulations (OpenMC is still only about 80 % as fast as MCNP). Interestingly with increasing nmfp MCNP also showed some anisotropy of the results so I also bumped the WW grid and the issue went away (might report this to the MCNP forum). Figure shows OpenMC (default ww settings, shifted ww mesh) relative error on the left and MCNP (nmfp 1000, shifted ww mesh) on the right.

Second: I went ahead and added additional led and air cells to the OpenMC model to force nmfp behavior with surface crossing checks in OpenMC. And I also got to the 80 % of MCNP performance - excellent result! Figure shows OpenMC (default ww settings, shifted ww mesh, additional lead (every 0.5 cm) and additional air (every 5.5 cm) cells) relative error on the left and MCNP (everything default) on the right.

Conclusion

IMO an nmfp equivalent should be implemented in OpenMC as this will highly improve the performance of calculating radiation dose fields in air filed regions. A very common application I would assume.

One question remains - why is OpenMC (only) 80% as fast as MCNP with gamma only transport problems and should we address this?

Many thanks to you both, Bor and Perry! Regarding the last question – yes, we absolutely should address that, and I see there are already a few PRs submitted that may help performance and I also have some work in progress that should improve things. @BorAtBH it would be great to incorporate your problem into our performance benchmarking suite so we can track performance on it over time. Can you let me know if there is an updated version of the model/parameters that you shared in the first post? or should I just use that one as is?

@paulromano great to hear work is being done to improve the efficiency of gamma transport overall.

I think the input, that was shared with the first post, should be used to track the performance. It will show the issue with the anisotropic behavior with the WWs and overall poor efficency. Maybe I’d bump the max_split to 100, but leave everything else as is.

I’ve also attached the tweaked input that overcomes those issues (bumped WW grid and additional surfaces both in air and lead). This is the input that was used to produce the results in the alst post. Let me know if you need anything else!

gamma_shield-OpenMC-ww-tweaked.zip.xml (2.4 MB)

One implementation route for the nmfp-style check that avoids the coincident-surface problem entirely: track the distance a particle has travelled since its last window lookup, and trigger a new lookup at the collision site (or after a set number of mean free paths) rather than only when crossing a geometry surface. The particle is then strictly inside a mesh element, so the position-only lookup can’t land on a boundary, and the check becomes resolution- and geometry-independent. The extra bookkeeping per collision is probably small compared with the splitting savings.

Olivia, thanks for the comment. I agree, ww checks at collision sites + nmfp should circumvent the issue we identifies and as far as I know OpenMC already checks weights at collision sites. It’s controlled by:

weight_window_checkpoints (dict) –

Indicates the checkpoints for weight window split/roulettes. Valid keys include “collision” and “surface”. Values must be of type bool.

Added in version 0.14.0.

So we only need an nmfp equivalent and we should be sorted.