LCOV - code coverage report
Current view: top level - src/postprocessors - BetaEffective.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: be601f Lines: 28 31 90.3 %
Date: 2025-07-15 20:50:38 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /********************************************************************/
       2             : /*                  SOFTWARE COPYRIGHT NOTIFICATION                 */
       3             : /*                             Cardinal                             */
       4             : /*                                                                  */
       5             : /*                  (c) 2021 UChicago Argonne, LLC                  */
       6             : /*                        ALL RIGHTS RESERVED                       */
       7             : /*                                                                  */
       8             : /*                 Prepared by UChicago Argonne, LLC                */
       9             : /*               Under Contract No. DE-AC02-06CH11357               */
      10             : /*                With the U. S. Department of Energy               */
      11             : /*                                                                  */
      12             : /*             Prepared by Battelle Energy Alliance, LLC            */
      13             : /*               Under Contract No. DE-AC07-05ID14517               */
      14             : /*                With the U. S. Department of Energy               */
      15             : /*                                                                  */
      16             : /*                 See LICENSE for full restrictions                */
      17             : /********************************************************************/
      18             : 
      19             : #ifdef ENABLE_OPENMC_COUPLING
      20             : 
      21             : #include "BetaEffective.h"
      22             : 
      23             : #include "OpenMCProblemBase.h"
      24             : 
      25             : registerMooseObject("CardinalApp", BetaEffective);
      26             : 
      27             : InputParameters
      28         100 : BetaEffective::validParams()
      29             : {
      30         100 :   auto params = GeneralPostprocessor::validParams();
      31         100 :   params += OpenMCBase::validParams();
      32         100 :   params.addClassDescription(
      33             :       "A post-processor which computes and returns the kinetics parameter $\\beta_{eff}$.");
      34         200 :   params.addParam<MooseEnum>(
      35             :       "output",
      36         200 :       getStatsOutputEnum(),
      37             :       "The value to output. Options are $\\beta_{eff}$ (mean), the standard deviation "
      38             :       "of $\\beta_{eff}$ (std_dev), or the relative error of $\\beta_{eff}$ (rel_err).");
      39             : 
      40         100 :   return params;
      41           0 : }
      42             : 
      43          26 : BetaEffective::BetaEffective(const InputParameters & parameters)
      44             :   : GeneralPostprocessor(parameters),
      45             :     OpenMCBase(this, parameters),
      46          52 :     _output(getParam<MooseEnum>("output").getEnum<statistics::OutputEnum>())
      47             : {
      48          26 :   if (!_openmc_problem->computeKineticsParams())
      49           2 :     mooseError(
      50             :         "BetaEffective can only be used if the OpenMC problem is computing kinetics parameters!");
      51          24 : }
      52             : 
      53             : Real
      54          24 : BetaEffective::getValue() const
      55             : {
      56          24 :   const auto & ifp_tally = _openmc_problem->getKineticsParamTally();
      57          24 :   const auto n = ifp_tally.n_realizations_;
      58             : 
      59             :   const auto num_sum =
      60          24 :       xt::view(ifp_tally.results_, xt::all(), 1, static_cast<int>(openmc::TallyResult::SUM));
      61             :   const auto den_sum =
      62          24 :       xt::view(ifp_tally.results_, xt::all(), 2, static_cast<int>(openmc::TallyResult::SUM));
      63             : 
      64             :   const auto num_ss =
      65          24 :       xt::view(ifp_tally.results_, xt::all(), 1, static_cast<int>(openmc::TallyResult::SUM_SQ));
      66             :   const auto den_ss =
      67          24 :       xt::view(ifp_tally.results_, xt::all(), 2, static_cast<int>(openmc::TallyResult::SUM_SQ));
      68             : 
      69          24 :   const Real beta_eff = (num_sum[0] / n) / (den_sum[0] / n);
      70             : 
      71          24 :   const Real num_rel = _openmc_problem->relativeError(num_sum, num_ss, n)[0];
      72          24 :   const Real den_rel = _openmc_problem->relativeError(den_sum, den_ss, n)[0];
      73          24 :   const Real beta_eff_rel = std::sqrt(num_rel * num_rel + den_rel * den_rel);
      74             : 
      75          24 :   switch (_output)
      76             :   {
      77             :     case statistics::OutputEnum::Mean:
      78             :       return beta_eff;
      79             : 
      80           8 :     case statistics::OutputEnum::StDev:
      81           8 :       return beta_eff * beta_eff_rel;
      82             : 
      83           8 :     case statistics::OutputEnum::RelError:
      84           8 :       return beta_eff_rel;
      85             : 
      86           0 :     default:
      87           0 :       mooseError("Internal error: Unhandled statistics::OutputEnum enum in BetaEffective.");
      88             :       break;
      89             :   }
      90             : 
      91             :   return beta_eff;
      92             : }
      93             : 
      94             : #endif

Generated by: LCOV version 1.14