Skip to content

Conversation

@SteSeg
Copy link
Collaborator

@SteSeg SteSeg commented Sep 2, 2025

Workflow for implementing uncertainty quantification via total Monte Carlo in the repository.

  • specifications.yaml and benchmark_schema.yaml have a new uncertainty_quantification section that specifies what to perturb (currently working only for nuclear data).
  • New dependencies: sandy and njoy
  • In functions that convert openmc.Statepoint results to xarray.DataArray objects and save them in netcdf binary files have been separated from the OpenmcBenchmark object and put in a utils.py file as they are useful also for the TMC engine and might be useful also for other future workflow
  • The _openmc_to_ofb() function converts pandas.DataFrames from Openmc.Statepoint to xarray.DataArrays, in the process it adds one dimension to the array called realization that is the dimension that gets populated as the TMC is triggered
  • The _save_result() function save such DataArrays into a h5 file with one caveat: if the result and file already exist, it populates the realization dimension of the result with the new result
  • A _uncertainty_quantification() function has been added to the OpenmcBenchmark class. It deploys the TMC engine and it gets triggered if the uq flag in Benchmark.run() is specified
  • A uq\ folder has been added in src/openmc_fusion_benchmarks/ with the TMC engine
  • in uq\uq_utils.py there are some function that deploy sandy for nuclear data perturbation and adaptation to openmc required formats
  • In tmc_engine.py there's the actual TMC engine

Usage:

import openmc_fusion_benchmarks as ofb
import xarray as xr

# Instantiate benchmark
ok = ofb.OpenmcBenchmark(name='oktavian_al')
# Run TMC-UQ
ok.run(uq=True)

# Results extraction is temporary!
result = xr.load_dataarray("benchmark_results.h5", group="photon_leakage")

Some observations:

  • Currently the TMC engine handles only nuclear data perturbation while specifications and schema cand handle more. In the future we can generalize the TMC engine to handle any type of input data perturbation
  • The _openmc_to_ofb() currently handles 2d results (from DataFrames) adding a 3rd dimension for the realizations of the TMC, might need to become more elastic dimension-wise in the future
  • The engine works only for the openmc code
  • Currently the engine removes at each iteration the statepoint.100.h5 file of the previous iteration and overwrites the cross_sections.xml. The perturbed cross sections are preserved instead in a different folder in the same path. In the future the capability of storing the statepoint and corresponding cross_section in separate folders will be added
  • An easy way of retrieving results (both of standalone simulations and TMC runs) from benchmark_results.h5 files will be implemented in future PRs
  • Some result analysis (distribution analysis, statistical checks etc.) for the TMC results will be implemented in future PRs

@coveralls
Copy link

Pull Request Test Coverage Report for Build 18326211042

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+3.5%) to 38.186%

Totals Coverage Status
Change from base Build 16295961673: 3.5%
Covered Lines: 181
Relevant Lines: 474

💛 - Coveralls

@SteSeg SteSeg merged commit 50e1a99 into eepeterson:develop Nov 19, 2025
2 checks passed
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