Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "ThermalSolidPropertiesFunctorMaterial.h" 11 : #include "ThermalSolidProperties.h" 12 : #include "SolidPropertiesNames.h" 13 : 14 : registerMooseObject("SolidPropertiesApp", ThermalSolidPropertiesFunctorMaterial); 15 : 16 : InputParameters 17 86 : ThermalSolidPropertiesFunctorMaterial::validParams() 18 : { 19 86 : InputParameters params = FunctorMaterial::validParams(); 20 172 : params.addRequiredParam<MooseFunctorName>("temperature", "Temperature"); 21 172 : params.addRequiredParam<UserObjectName>("sp", "The name of the user object for solid properties"); 22 172 : params.addParam<bool>("use_constant_density", false, "Use constant density evaluated at 'T_ref'"); 23 172 : params.addParam<Real>( 24 : "T_ref", 25 : "Temperature at which to evaluate density if 'use_constant_density' is set to 'true'"); 26 86 : params.addParam<std::string>(SolidPropertiesNames::specific_heat, 27 : SolidPropertiesNames::specific_heat, 28 : "Name to be used for the isobaric specific heat"); 29 86 : params.addParam<std::string>(SolidPropertiesNames::thermal_conductivity, 30 : SolidPropertiesNames::thermal_conductivity, 31 : "Name to be used for the thermal conductivity"); 32 86 : params.addParam<std::string>(SolidPropertiesNames::density, 33 : SolidPropertiesNames::density, 34 : "Name to be used for the density"); 35 86 : params.addParam<std::string>(SolidPropertiesNames::specific_internal_energy, 36 : SolidPropertiesNames::specific_internal_energy, 37 : "Name to be used for the specific internal energy"); 38 86 : params.addClassDescription("Computes solid thermal properties as a function of temperature"); 39 86 : return params; 40 0 : } 41 : 42 48 : ThermalSolidPropertiesFunctorMaterial::ThermalSolidPropertiesFunctorMaterial( 43 48 : const InputParameters & parameters) 44 : : FunctorMaterial(parameters), 45 48 : _temperature(getFunctor<ADReal>("temperature")), 46 96 : _sp(getUserObject<ThermalSolidProperties>("sp")) 47 : { 48 96 : if (getParam<bool>("use_constant_density")) 49 : { 50 48 : if (isParamValid("T_ref")) 51 : { 52 44 : const Real T_ref = getParam<Real>("T_ref"); 53 66 : addFunctorProperty<ADReal>(getParam<std::string>(SolidPropertiesNames::density), 54 18 : [this, T_ref](const auto & /*r*/, const auto & /*t*/) -> ADReal 55 18 : { return _sp.rho_from_T(T_ref); }); 56 : } 57 : else 58 2 : paramError("T_ref", 59 : "The parameter 'T_ref' is required if 'use_constant_density' is set to 'true'."); 60 : } 61 : else 62 : { 63 48 : if (isParamValid("T_ref")) 64 2 : paramError("T_ref", 65 : "The parameter 'T_ref' may not be specified if 'use_constant_density' is set to " 66 : "'false'."); 67 : else 68 66 : addFunctorProperty<ADReal>(getParam<std::string>(SolidPropertiesNames::density), 69 18 : [this](const auto & r, const auto & t) -> ADReal 70 18 : { return _sp.rho_from_T(_temperature(r, t)); }); 71 : } 72 : 73 132 : addFunctorProperty<ADReal>(getParam<std::string>(SolidPropertiesNames::specific_heat), 74 36 : [this](const auto & r, const auto & t) -> ADReal 75 36 : { return _sp.cp_from_T(_temperature(r, t)); }); 76 132 : addFunctorProperty<ADReal>(getParam<std::string>(SolidPropertiesNames::thermal_conductivity), 77 36 : [this](const auto & r, const auto & t) -> ADReal 78 36 : { return _sp.k_from_T(_temperature(r, t)); }); 79 132 : addFunctorProperty<ADReal>(getParam<std::string>(SolidPropertiesNames::specific_internal_energy), 80 36 : [this](const auto & r, const auto & t) -> ADReal 81 36 : { return _sp.e_from_T(_temperature(r, t)); }); 82 220 : }