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 613 : BetaEffective::validParams() 29 : { 30 613 : auto params = GeneralPostprocessor::validParams(); 31 613 : params += OpenMCBase::validParams(); 32 613 : params.addClassDescription( 33 : "A post-processor which computes and returns the kinetics parameter $\\beta_{eff}$."); 34 1226 : params.addParam<MooseEnum>( 35 : "beta_type", 36 1226 : getBetaGroupEnum(), 37 : "The delayed group to calculate $\\beta_{eff}$ for. Options are groups 1-6 " 38 : "(from the ENDF delayed neutron groups) or the sum over all groups. Defaults " 39 : "to 'sum'."); 40 1226 : params.addParam<MooseEnum>( 41 : "output", 42 1226 : getStatsOutputEnum(), 43 : "The value to output. Options are $\\beta_{eff}$ (mean), the standard deviation " 44 : "of $\\beta_{eff}$ (std_dev), or the relative error of $\\beta_{eff}$ (rel_err)."); 45 : 46 613 : return params; 47 0 : } 48 : 49 197 : BetaEffective::BetaEffective(const InputParameters & parameters) 50 : : GeneralPostprocessor(parameters), 51 : OpenMCBase(this, parameters), 52 197 : _output(getParam<MooseEnum>("output").getEnum<statistics::OutputEnum>()), 53 591 : _beta_type(getParam<MooseEnum>("beta_type").getEnum<BetaTypeEnum>()) 54 : { 55 197 : if (!_openmc_problem->computeKineticsParams()) 56 2 : mooseError( 57 : "BetaEffective can only be used if the OpenMC problem is computing kinetics parameters!"); 58 195 : } 59 : 60 : Real 61 198 : BetaEffective::getValue() const 62 : { 63 198 : const auto & common_tally = _openmc_problem->getCommonKineticsTally(); 64 198 : const auto & mg_beta = _openmc_problem->getMGBetaTally(); 65 : 66 : unsigned int n_num = 0; 67 198 : Real num_sum = 0.0; 68 198 : Real num_ss = 0.0; 69 198 : switch (_beta_type) 70 : { 71 54 : case BetaTypeEnum::Sum: 72 54 : n_num = common_tally.n_realizations_; 73 54 : num_sum = common_tally.results_.slice( 74 : openmc::tensor::all, 2, static_cast<int>(openmc::TallyResult::SUM))[0]; 75 54 : num_ss = common_tally.results_.slice( 76 : openmc::tensor::all, 2, static_cast<int>(openmc::TallyResult::SUM_SQ))[0]; 77 54 : break; 78 144 : case BetaTypeEnum::D_1: 79 : case BetaTypeEnum::D_2: 80 : case BetaTypeEnum::D_3: 81 : case BetaTypeEnum::D_4: 82 : case BetaTypeEnum::D_5: 83 : case BetaTypeEnum::D_6: 84 144 : n_num = mg_beta.n_realizations_; 85 144 : num_sum = mg_beta.results_.slice( 86 : openmc::tensor::all, 87 : 0, 88 144 : static_cast<int>(openmc::TallyResult::SUM))[static_cast<unsigned int>(_beta_type) - 1]; 89 144 : num_ss = mg_beta.results_.slice( 90 : openmc::tensor::all, 91 : 0, 92 144 : static_cast<int>(openmc::TallyResult::SUM_SQ))[static_cast<unsigned int>(_beta_type) - 1]; 93 144 : break; 94 0 : default: 95 0 : mooseError("Internal error: Unknown BetaTypeEnum."); 96 : break; 97 : } 98 : 99 198 : const auto n_den = common_tally.n_realizations_; 100 198 : const auto den_sum = common_tally.results_.slice( 101 198 : openmc::tensor::all, 1, static_cast<int>(openmc::TallyResult::SUM))[0]; 102 198 : const auto den_ss = common_tally.results_.slice( 103 198 : openmc::tensor::all, 1, static_cast<int>(openmc::TallyResult::SUM_SQ))[0]; 104 : 105 198 : const Real beta_eff = (num_sum / n_num) / (den_sum / n_den); 106 : 107 198 : const Real num_rel = _openmc_problem->relativeError(num_sum, num_ss, n_num); 108 198 : const Real den_rel = _openmc_problem->relativeError(den_sum, den_ss, n_den); 109 198 : const Real beta_eff_rel = std::sqrt(num_rel * num_rel + den_rel * den_rel); 110 : 111 198 : switch (_output) 112 : { 113 : case statistics::OutputEnum::Mean: 114 : return beta_eff; 115 : 116 66 : case statistics::OutputEnum::StDev: 117 66 : return beta_eff * beta_eff_rel; 118 : 119 66 : case statistics::OutputEnum::RelError: 120 66 : return beta_eff_rel; 121 : 122 0 : default: 123 0 : mooseError("Internal error: Unhandled statistics::OutputEnum enum in BetaEffective."); 124 : break; 125 : } 126 : 127 : return beta_eff; 128 : } 129 : 130 : #endif