Repository navigation
Add stat:sum field to MCPL files for proper weight normalization - #3522
Conversation
…nmc-dev#3514) - Implements stat:sum field (key: "openmc_np1") in MCPL file headers - Initially sets to -1 for crash safety, updates with particle count before closing - Compatible with MCPL >= 2.1.0, gracefully degrades for older versions - Enables proper file merging and McStas/McXtrace integration - Adds C++ and Python unit tests
|
Thanks a lot for picking up this work @bpolania, it is truly appreciated! :-) It looks good to me in general, but I have a few comments and questions. Some I will leave in-line as a review, but two things I would like to mention in particular here (also, @ebknudsen might have some comments):
|
- Remove unused mcpl_hdr_add_data_fpt declaration and related code - Fix empty bank_index case to return -1 instead of 0 (statistics unavailable) - Update Python test to use hasattr(f,'stat_sum') convenience property - Clarify that mcpl_hdr_add_data was available from MCPL beginning, not 2.1.0
Adjust line break in function pointer declaration to match clang-format v15 style used by CI
|
Thank you @tkittel for the review! I've addressed all your feedback in commits 787ba30 and 58b1c92: Changes made:
|
|
Thanks @bpolania ! So from my POV, all that is missing is feedback (and perhaps a general review) from the core devs about the items I raised in my previous comment :-) |
- Use openmc.examples.pwr_pin_cell() which includes cross sections - Run full eigenvalue simulation to generate MCPL files - Handle cases where MCPL interface or files are not available - Test uses proper sourcepoint setting and batch configuration
Per issue openmc-dev#3514 requirements, stat:sum should contain the original number of source particles in the simulation, not the number written to the file. Changed implementation to calculate: (n_batches - n_inactive) * n_particles instead of using bank_index.back() This ensures proper weight normalization when merging MCPL files.
Well, still failing some tests. I just pushed again and see if they are fixed. |
|
I like:
or
|
…nmc-dev#3522) Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
Description
This PR implements the
stat:sumfield in MCPL file headers to enable proper weight normalization when merging MCPL files, as requested in #3514.Changes
stat:sumfield (key:"openmc_np1") to MCPL file headers for files written with MCPL >= 2.1.0Implementation Details
The implementation follows the specification from @tkittel:
mcpl_hdr_add_stat_sum()function from MCPL >= 2.1.0"openmc_np1"Testing
tests/cpp_unit_tests/test_mcpl_stat_sum.cpp)tests/unit_tests/test_mcpl_stat_sum.py)Fixes
Fixes #3514
Checklist