Repository navigation
New Random Ray VTK Plot Testing Strategy - #4204
Merged
Merged
Conversation
Add VTKTestHarness, a TolerantPyAPITestHarness that keeps one voxel plot and appends the flux and source arrays of the VTK files it writes to the results, and a random_ray_vtk regression test that uses it for eigenvalue and fixed source problems with flat and linear sources. This replaces test_random_ray_vtk_normalization from openmc-dev#4192, which compared the mean of 8 voxels to a source region tally within 15%. Its voxels sit at the centers of the source regions, where the linear term is close to zero, so it still passes with that term removed, and it always runs serially, so it never covers the domain decomposed writer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The linear source keeps its gradients at zero for the first ten batches, so with the examples' 5 inactive + 5 active batches the linear cases compared the moments of a flat source solve. Run 10 inactive + 5 active batches instead, so that every active batch uses the gradients, and regenerate the reference results. Also say why the other VTK arrays are not compared, and list the harness in AGENTS.md. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
paulromano
approved these changes
Oct 26, 2026
paulromano
left a comment
Contributor
There was a problem hiding this comment.
Thanks for improving the robustness of these tests!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
#4192 fixed the double normalization of the random ray VTK flux, with a unit test that checks the mean of 8 voxels against a source region tally to within 15%. That test has several gaps:
To remedy the above issues, this PR replaces the existing unit test with a more traditional "expected results" reference file regression test along with a new harness that facilitates reading/testing of the VTK files. This PR adds:
VTKTestHarness(tests/testing_harness.py) extendsTolerantPyAPITestHarness. It keeps the voxel plot it is given (the base class removes all plots), appends the flux and source arrays of each VTK file to the results (adjoint runs also write a.forward.vtk), and deletes the VTK files on cleanup. The other arrays are not compared:FSRsandrank_subdomainsare random colors,measured_loadis timing dependent, andMaterialsandweight_window_lowerare not the quantities under test. The harness is listed with the others inAGENTS.md.tests/regression_tests/random_ray_vtk/uses it for eigenvalue (random_ray_lattice) and fixed source (random_ray_three_region_cube) problems with flat and linear sources, with voxel centers away from region boundaries. The runs are 10 inactive + 5 active batches, so that every active batch lies past the ten batches in which the linear source keeps its gradients at zero. The four cases take about a second on 2 threads.Adding more VTK tests in the future should be easy to do with the new harness. Also note that because the new test compares against stored reference results, it lives in
tests/regression_tests/rather than the unit suite, and the unit test is removed.Follow-up to #4192.
AI Assistance
Checklist
Summary by CodeRabbit
Tests
Documentation