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 "EnergyBinBase.h" 22 : #include "EnergyGroupStructures.h" 23 : 24 : InputParameters 25 3521 : EnergyBinBase::validParams() 26 : { 27 3521 : auto params = emptyInputParameters(); 28 7042 : params.addParam<std::vector<Real>>( 29 : "energy_boundaries", 30 : "The energy boundaries to use to form energy bins. The boundaries must be provided " 31 : "in ascending order in terms of energy."); 32 7042 : params.addParam<MooseEnum>( 33 : "group_structure", 34 7042 : getEnergyGroupsEnum(), 35 : "The energy group structure to use from a list of popular group structures."); 36 7042 : params.addParam<bool>( 37 : "reverse_bins", 38 7042 : false, 39 : "Whether the bins should be output in reverse order. This is useful for comparing " 40 : "deterministic transport codes with Cardinal, where the convention is that energy " 41 : "groups are arranged in descending order (i.e. group 1 is fast, group 2 is thermal)."); 42 : 43 3521 : return params; 44 0 : } 45 : 46 376 : EnergyBinBase::EnergyBinBase(const ParallelParamObject * moose_object, 47 376 : const InputParameters & parameters) 48 752 : : _reverse_bins(moose_object->getParam<bool>("reverse_bins")) 49 : { 50 752 : if (moose_object->isParamValid("energy_boundaries") == 51 752 : moose_object->isParamValid("group_structure")) 52 4 : moose_object->mooseError( 53 : "You have either set both 'energy_boundaries' and 'group_structure' or have not " 54 : "specified a bin option. Please specify either 'energy_boundaries' or " 55 : "'group_structure'."); 56 : 57 744 : if (moose_object->isParamValid("energy_boundaries")) 58 864 : _energy_bnds = moose_object->getParam<std::vector<Real>>("energy_boundaries"); 59 744 : if (moose_object->isParamValid("group_structure")) 60 252 : _energy_bnds = this->getGroupBoundaries(moose_object->getParam<MooseEnum>("group_structure") 61 : .getEnum<energyfilter::GroupStructureEnum>()); 62 : 63 : // Two boundaries are required at minimum to form energy bins. 64 372 : if (_energy_bnds.size() < 2) 65 2 : moose_object->paramError("energy_boundaries", 66 : "At least two energy values are required to create energy bins!"); 67 : 68 : // Check to make sure none of the boundaries are negative. 69 1444 : for (const auto & bnd : _energy_bnds) 70 1076 : if (bnd < 0.0) 71 2 : moose_object->paramError("energy_boundaries", 72 : "Energy group boundaries must be positive to create energy bins!"); 73 : 74 : // Sort the boundaries so they're monotonically decreasing. 75 368 : std::sort(_energy_bnds.begin(), 76 : _energy_bnds.end(), 77 1380 : [](const Real & a, const Real & b) { return a < b; }); 78 : 79 : // Check for duplicate entries. 80 368 : if (std::adjacent_find(_energy_bnds.begin(), _energy_bnds.end()) != _energy_bnds.end()) 81 2 : moose_object->paramError( 82 : "energy_boundaries", 83 : "You have added duplicate energy boundaries! Each group boundary must be unique to " 84 : "create energy bins."); 85 366 : } 86 : 87 : std::vector<double> 88 84 : EnergyBinBase::getGroupBoundaries(energyfilter::GroupStructureEnum group_structure) 89 : { 90 : using namespace energyfilter; 91 : using namespace groupstructures; 92 84 : switch (group_structure) 93 : { 94 : case CASMO_2: 95 84 : return std::vector<double>(S_CASMO_2, S_CASMO_2 + 3); 96 : case CASMO_4: 97 0 : return std::vector<double>(S_CASMO_4, S_CASMO_4 + 5); 98 : case CASMO_8: 99 0 : return std::vector<double>(S_CASMO_8, S_CASMO_8 + 9); 100 : case CASMO_16: 101 0 : return std::vector<double>(S_CASMO_16, S_CASMO_16 + 17); 102 : case CASMO_25: 103 0 : return std::vector<double>(S_CASMO_25, S_CASMO_25 + 26); 104 : case CASMO_40: 105 0 : return std::vector<double>(S_CASMO_40, S_CASMO_40 + 41); 106 : case VITAMINJ_42: 107 0 : return std::vector<double>(S_VITAMINJ_42, S_VITAMINJ_42 + 43); 108 : case SCALE_44: 109 0 : return std::vector<double>(S_SCALE_44, S_SCALE_44 + 45); 110 : case MPACT_51: 111 0 : return std::vector<double>(S_MPACT_51, S_MPACT_51 + 52); 112 : case MPACT_60: 113 0 : return std::vector<double>(S_MPACT_60, S_MPACT_60 + 61); 114 : case MPACT_69: 115 0 : return std::vector<double>(S_MPACT_69, S_MPACT_69 + 70); 116 : case CASMO_70: 117 0 : return std::vector<double>(S_CASMO_70, S_CASMO_70 + 71); 118 : case XMAS_172: 119 0 : return std::vector<double>(S_XMAS_172, S_XMAS_172 + 173); 120 : case VITAMINJ_175: 121 0 : return std::vector<double>(S_VITAMINJ_175, S_VITAMINJ_175 + 176); 122 : case SCALE_252: 123 0 : return std::vector<double>(S_SCALE_252, S_SCALE_252 + 253); 124 : case TRIPOLI_315: 125 0 : return std::vector<double>(S_TRIPOLI_315, S_TRIPOLI_315 + 316); 126 : case SHEM_361: 127 0 : return std::vector<double>(S_SHEM_361, S_SHEM_361 + 362); 128 : case CCFE_709: 129 0 : return std::vector<double>(S_CCFE_709, S_CCFE_709 + 710); 130 : case UKAEA_1102: 131 0 : return std::vector<double>(S_UKAEA_1102, S_UKAEA_1102 + 1103); 132 : case ECCO_1968: 133 0 : return std::vector<double>(S_ECCO_1968, S_ECCO_1968 + 1969); 134 0 : default: 135 0 : mooseError("Internal error: unknown GroupStructureEnum."); 136 : } 137 : 138 : return std::vector<double>(); 139 : } 140 : 141 : #endif