Skip to content

Report the combined estimator in the average k column - #52

Draft
GuySten wants to merge 6 commits into
developfrom
claude/kind-wozniak-tfq032
Draft

GuySten wants to merge 6 commits into
developfrom
claude/kind-wozniak-tfq032

Conversation

@GuySten

@GuySten GuySten commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner

Note

Depends on openmc-dev#4113 and is stacked on it, so the diff against develop also carries that PR's five commits. Only the last commit, e475c10, belongs here.

Description

The average k column written each generation held the average of the tracklength estimator over active generations, while the combined estimator — the minimum variance combination of the collision, absorption and tracklength estimators, and the value reported as k-effective at the end of a run — only appeared in the final results table. The column now carries the combined estimator, so what is watched during a run is the same quantity that is reported at the end of it.

  Bat./Gen.      k            Average k
  =========   ========   ====================
        1/1    1.19645
      ...
        6/1    1.00212
        7/1    1.00489    1.00327 +/- 0.00281

The combination is undefined until MIN_REALIZATIONS_TO_COMBINE active batches have been accumulated. The column is left empty until then rather than switching estimator partway through a run, so the number under it always means one thing. A batch is only accumulated after its generations have been written, so with one generation per batch the first value appears at batch inactive + 5.

The random ray solver estimates k from the scalar flux and produces a single estimate with nothing to combine, so it keeps reporting its average over active generations exactly as before.

The condition under which openmc_get_keff() forms a combination is factored out of it as keff_combined_available() and used for both, so the printing condition and the fallback condition cannot drift apart.

This is display only. simulation::keff still drives fission site production, so no physics or random number stream moves and no regression results change. Nothing else consumes the generation table: the statepoint, the C API and the final results table are all untouched.

The one behavior worth calling out is that openmc_get_keff() now runs once per generation on the master rank rather than twice per run. The cost is negligible, but it does make openmc-dev#4113's "report whatever comes out, including for a degenerate covariance" stance more visible: a problem where all three estimators coincide exactly every batch would print nan each generation instead of once at the end.

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 18) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable) — the generation table is not described in the docs, so there was nothing to update
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

tests/unit_tests/test_eigenvalue_output.py parses the generation table out of captured output and checks that the column is empty before the combination is defined and populated after, then pins the final row against the combined estimator in the statepoint written at the end of the preceding batch — the value that row was printed with.

🤖 Generated with Claude Code

https://claude.ai/code/session_017H56JcnTBLoYssMHo2sBbA

GuySten and others added 6 commits September 8, 2026 02:53
The average k column written each generation held the average of the
tracklength estimator over active generations, while the combined
estimator -- the minimum variance combination of the collision,
absorption and tracklength estimators, and the value reported as
k-effective at the end of a run -- only appeared in the final results
table. The column now carries the combined estimator, so what is watched
during a run is the same quantity that is reported at the end of it.

The combination is undefined until MIN_REALIZATIONS_TO_COMBINE active
batches have been accumulated; the column is left empty until then
rather than switching estimator partway through a run. The random ray
solver produces a single estimate of k with nothing to combine, so it
keeps reporting its average over active generations.

The condition under which openmc_get_keff() forms a combination is
factored out as keff_combined_available() so that the two cannot drift
apart.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017H56JcnTBLoYssMHo2sBbA
@GuySten GuySten changed the title Refactor k-effective combination into reusable function Report the combined estimator in the average k column Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants