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 "OpenMCMaterialDensity.h" 22 : #include "openmc/capi.h" 23 : 24 : registerMooseObject("CardinalApp", OpenMCMaterialDensity); 25 : 26 : InputParameters 27 46 : OpenMCMaterialDensity::validParams() 28 : { 29 46 : auto params = OpenMCMaterialSearch::validParams(); 30 46 : params.addClassDescription("Searches for criticality using material density in units of kg/m3"); 31 46 : return params; 32 0 : } 33 : 34 24 : OpenMCMaterialDensity::OpenMCMaterialDensity(const InputParameters & parameters) 35 24 : : OpenMCMaterialSearch(parameters) 36 : { 37 : // a material in OpenMC must always have some nuclides in it or macroscopic data, 38 : // so we don't need to have any checks on whether the material is void 39 : 40 : // apply additional checks on the minimum and maximum values - both must be positive. 41 : // we don't need to check for negative 'maximum' because we already require maximum > minimum 42 : // and if we enforce non-negative minimum this will require maximum to also be non-negative. 43 22 : if (_minimum < 0.0) 44 4 : paramError("minimum", 45 2 : "The 'minimum' density (" + std::to_string(_minimum) + ") must be positive!"); 46 20 : } 47 : 48 : void 49 92 : OpenMCMaterialDensity::updateOpenMCModel(const Real & density) 50 : { 51 92 : _console << "OpenMC will run with next guess for density = " << density << " [kg/m3] ..." 52 92 : << std::endl; 53 : const char * units = "g/cc"; 54 92 : int err = openmc_material_set_density( 55 92 : _material_index, density * _openmc_problem->densityConversionFactor(), units); 56 92 : catchOpenMCError(err, "set material density to " + std::to_string(density)); 57 92 : } 58 : 59 : #endif