🤖 AI Summary
Integrating machine learning models—particularly deep and Bayesian neural networks (DNNs/BNNs)—into legacy Fortran-based nuclear engineering simulation codes remains challenging due to language interoperability barriers and reliance on external runtimes (e.g., Python, TensorFlow C API, or ONNX).
Method: This work introduces the first fully native Fortran 2008 implementation of a DNN/BNN inference framework. It eschews external dependencies by employing modular design, hand-coded backpropagation, controlled pseudo-random sampling, and a lightweight tensor arithmetic library, enabling seamless coupling with iterative solvers and uncertainty quantification (UQ).
Contribution/Results: On a noisy sine benchmark, the framework achieves 19.6× and 8.0× inference speedups for DNNs and BNNs, respectively, with negligible prediction error. For critical heat flux (CHF) prediction, accuracy matches state-of-the-art tools while significantly improving computational efficiency. The framework has been successfully embedded into the CTF thermal-hydraulics code, overcoming long-standing cross-language deployment bottlenecks in nuclear simulation.
📝 Abstract
Over the past decade, the investigation of machine learning (ML) within the field of nuclear engineering has grown significantly. With many approaches reaching maturity, the next phase of investigation will determine the feasibility and usefulness of ML model implementation in a production setting. Several of the codes used for reactor design and assessment are primarily written in the Fortran language, which is not immediately compatible with TensorFlow-trained ML models. This study presents a framework for implementing deep neural networks (DNNs) and Bayesian neural networks (BNNs) in Fortran, allowing for native execution without TensorFlow's C API, Python runtime, or ONNX conversion. Designed for ease of use and computational efficiency, the framework can be implemented in any Fortran code, supporting iterative solvers and UQ via ensembles or BNNs. Verification was performed using a two-input, one-output test case composed of a noisy sinusoid to compare Fortran-based predictions to those from TensorFlow. The DNN predictions showed negligible differences and achieved a 19.6x speedup, whereas the BNN predictions exhibited minor disagreement, plausibly due to differences in random number generation. An 8.0x speedup was noted for BNN inference. The approach was then further verified on a nuclear-relevant problem predicting critical heat flux (CHF), which demonstrated similar behavior along with significant computational gains. Discussion regarding the framework's successful integration into the CTF thermal-hydraulics code is also included, outlining its practical usefulness. Overall, this framework was shown to be effective at implementing both DNN and BNN model inference within Fortran, allowing for the continued study of ML-based methods in real-world nuclear applications.