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 "LambdaEffective.h" 22 : 23 : #include "OpenMCProblemBase.h" 24 : 25 : #include "openmc/eigenvalue.h" 26 : 27 : registerMooseObject("CardinalApp", LambdaEffective); 28 : 29 : InputParameters 30 105 : LambdaEffective::validParams() 31 : { 32 105 : auto params = KEigenvalue::validParams(); 33 105 : params.addClassDescription( 34 : "A post-processor which computes and returns the kinetics parameter $\\Lambda_{eff}$."); 35 210 : params.addParam<MooseEnum>( 36 : "output", 37 210 : getStatsOutputEnum(), 38 : "The value to output. Options are $\\Lambda_{eff}$ (mean), the standard deviation " 39 : "of $\\Lambda_{eff}$ (std_dev), or the relative error of $\\Lambda_{eff}$ (rel_err)."); 40 : 41 105 : return params; 42 0 : } 43 : 44 29 : LambdaEffective::LambdaEffective(const InputParameters & parameters) : KEigenvalue(parameters) 45 : { 46 29 : if (!_openmc_problem->computeKineticsParams()) 47 2 : mooseError( 48 : "LambdaEffective can only be used if the OpenMC problem is computing kinetics parameters!"); 49 27 : } 50 : 51 : Real 52 30 : LambdaEffective::getValue() const 53 : { 54 30 : const auto & ifp_tally = _openmc_problem->getCommonKineticsTally(); 55 30 : const auto n = ifp_tally.n_realizations_; 56 : 57 30 : const auto num_sum = ifp_tally.results_.slice( 58 30 : openmc::tensor::all, 0, static_cast<int>(openmc::TallyResult::SUM))[0]; 59 30 : const auto den_sum = ifp_tally.results_.slice( 60 30 : openmc::tensor::all, 1, static_cast<int>(openmc::TallyResult::SUM))[0]; 61 : 62 30 : const auto num_ss = ifp_tally.results_.slice( 63 30 : openmc::tensor::all, 0, static_cast<int>(openmc::TallyResult::SUM_SQ))[0]; 64 30 : const auto den_ss = ifp_tally.results_.slice( 65 30 : openmc::tensor::all, 1, static_cast<int>(openmc::TallyResult::SUM_SQ))[0]; 66 : 67 30 : const auto mean_k = kMean(_type); 68 30 : const auto k_rel = kRelativeError(); 69 : 70 30 : const Real lambda_eff = (num_sum / n) / (den_sum / n) / mean_k; 71 : 72 30 : const Real num_rel = _openmc_problem->relativeError(num_sum, num_ss, n); 73 30 : const Real den_rel = _openmc_problem->relativeError(den_sum, den_ss, n); 74 30 : const Real lambda_rel = std::sqrt(num_rel * num_rel + den_rel * den_rel + k_rel * k_rel); 75 : 76 30 : switch (_output) 77 : { 78 : case statistics::OutputEnum::Mean: 79 : return lambda_eff; 80 : 81 10 : case statistics::OutputEnum::StDev: 82 10 : return lambda_eff * lambda_rel; 83 : 84 10 : case statistics::OutputEnum::RelError: 85 10 : return lambda_rel; 86 : 87 0 : default: 88 0 : mooseError("Internal error: Unhandled statistics::OutputEnum enum in LambdaEffective."); 89 : break; 90 : } 91 : 92 : return lambda_eff; 93 : } 94 : 95 : #endif