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 "KEigenvalue.h" 22 : 23 : registerMooseObject("CardinalApp", KEigenvalue); 24 : 25 : InputParameters 26 2573 : KEigenvalue::validParams() 27 : { 28 2573 : InputParameters params = GeneralPostprocessor::validParams(); 29 2573 : params += OpenMCBase::validParams(); 30 2573 : params.addClassDescription("k eigenvalue computed by OpenMC"); 31 5146 : params.addParam<MooseEnum>("value_type", 32 5146 : getEigenvalueEnum(), 33 : "Type of eigenvalue global tally to report"); 34 5146 : params.addParam<MooseEnum>( 35 : "output", 36 5146 : getStatsOutputEnum(), 37 : "The value to output. Options are $k_{eff}$ (mean), the standard deviation " 38 : "of $k_{eff}$ (std_dev), or the relative error of $k_{eff}$ (rel_err)."); 39 2573 : return params; 40 0 : } 41 : 42 845 : KEigenvalue::KEigenvalue(const InputParameters & parameters) 43 : : GeneralPostprocessor(parameters), 44 : OpenMCBase(this, parameters), 45 845 : _type(getParam<MooseEnum>("value_type").getEnum<eigenvalue::EigenvalueEnum>()), 46 2535 : _output(getParam<MooseEnum>("output").getEnum<statistics::OutputEnum>()) 47 : { 48 845 : if (openmc::settings::run_mode != openmc::RunMode::EIGENVALUE) 49 4 : mooseError("Eigenvalues are only computed when running OpenMC in eigenvalue mode!"); 50 : 51 841 : if (_openmc_problem->runRandomRay() && _type != eigenvalue::EigenvalueEnum::tracklength) 52 2 : paramError("value_type", 53 : "'tracklength' k-eigenvalue estimators are required when running OpenMC's " 54 : "random-ray solver!"); 55 839 : } 56 : 57 : Real 58 854 : KEigenvalue::getValue() const 59 : { 60 854 : switch (_output) 61 : { 62 663 : case statistics::OutputEnum::Mean: 63 663 : return kMean(_type); 64 : 65 119 : case statistics::OutputEnum::StDev: 66 119 : return kStandardDeviation(_type); 67 : 68 72 : case statistics::OutputEnum::RelError: 69 72 : return kRelativeError(); 70 : 71 0 : default: 72 0 : mooseError("Internal error: Unhandled statistics::OutputEnum enum in KEigenvalue."); 73 : break; 74 : } 75 : } 76 : 77 : Real 78 102 : KEigenvalue::kRelativeError() const 79 : { 80 102 : const auto mean = kMean(_type); 81 102 : return mean > 0.0 ? kStandardDeviation(_type) / mean : 0.0; 82 : } 83 : 84 : #endif