Line data Source code
1 : /****************************************************************************/ 2 : /* DO NOT MODIFY THIS HEADER */ 3 : /* */ 4 : /* MALAMUTE: MOOSE Application Library for Advanced Manufacturing UTilitiEs */ 5 : /* */ 6 : /* Copyright 2021 - 2024, Battelle Energy Alliance, LLC */ 7 : /* ALL RIGHTS RESERVED */ 8 : /****************************************************************************/ 9 : 10 : #include "StainlessSteelThermal.h" 11 : 12 : #include "libmesh/utility.h" 13 : #include "NonlinearSystemBase.h" 14 : #include "TimeIntegrator.h" 15 : 16 : #include "metaphysicl/raw_type.h" 17 : 18 : registerMooseObject("MalamuteApp", StainlessSteelThermal); 19 : registerMooseObject("MalamuteApp", ADStainlessSteelThermal); 20 : 21 : template <bool is_ad> 22 : InputParameters 23 116 : StainlessSteelThermalTempl<is_ad>::validParams() 24 : { 25 116 : InputParameters params = Material::validParams(); 26 116 : params.addClassDescription( 27 : "Calculates the thermal conductivity and the heat capacity as a function of temperature for " 28 : "AISI 304 stainless steel in base SI units"); 29 232 : params.addRequiredCoupledVar("temperature", "Coupled temperature variable"); 30 232 : params.addParam<Real>("thermal_conductivity_scale_factor", 31 232 : 1.0, 32 : "The scaling factor for stainless steel thermal conductivity"); 33 232 : params.addParam<Real>( 34 232 : "heat_capacity_scale_factor", 1.0, "The scaling factor for stainless steel heat capacity"); 35 116 : return params; 36 0 : } 37 : 38 : template <bool is_ad> 39 87 : StainlessSteelThermalTempl<is_ad>::StainlessSteelThermalTempl(const InputParameters & parameters) 40 : : Material(parameters), 41 87 : _temperature(coupledGenericValue<is_ad>("temperature")), 42 174 : _thermal_conductivity(declareGenericProperty<Real, is_ad>("thermal_conductivity")), 43 87 : _thermal_conductivity_dT(declareProperty<Real>("thermal_conductivity_dT")), 44 174 : _heat_capacity(declareGenericProperty<Real, is_ad>("heat_capacity")), 45 87 : _heat_capacity_dT(declareProperty<Real>("heat_capacity_dT")), 46 174 : _thermal_conductivity_scale_factor(getParam<Real>("thermal_conductivity_scale_factor")), 47 261 : _heat_capacity_scale_factor(getParam<Real>("heat_capacity_scale_factor")) 48 : { 49 87 : } 50 : 51 : template <bool is_ad> 52 : void 53 19796496 : StainlessSteelThermalTempl<is_ad>::setDerivatives(GenericReal<is_ad> & prop, 54 : Real dprop_dT, 55 : const ADReal & ad_T) 56 : { 57 19796496 : if (ad_T < 0) 58 0 : prop.derivatives() = 0; 59 : else 60 39592992 : prop.derivatives() = dprop_dT * ad_T.derivatives(); 61 19796496 : } 62 : 63 : template <> 64 : void 65 0 : StainlessSteelThermalTempl<false>::setDerivatives(Real &, Real, const ADReal &) 66 : { 67 0 : mooseError("Mistaken call of setDerivatives in a non-AD StainlessSteelThermal version"); 68 : } 69 : 70 : template <bool is_ad> 71 : void 72 609 : StainlessSteelThermalTempl<is_ad>::jacobianSetup() 73 : { 74 609 : _check_temperature_now = false; 75 : int number_nonlinear_it = 76 609 : _fe_problem.getNonlinearSystemBase(/*nl_sys_num=*/0).getCurrentNonlinearIterationNumber(); 77 609 : if (number_nonlinear_it == 0) 78 237 : _check_temperature_now = true; 79 609 : } 80 : 81 : template <bool is_ad> 82 : void 83 9900572 : StainlessSteelThermalTempl<is_ad>::computeQpProperties() 84 : { 85 : // thermal conductivity limits are more conservative, so check only against those 86 9900572 : if (_check_temperature_now) 87 : { 88 137 : if (_temperature[_qp] < 310.7) 89 98 : mooseDoOnce(mooseWarning("The temperature in ", 90 : _name, 91 : " is below the calibration lower range limit at a value of ", 92 : MetaPhysicL::raw_value(_temperature[_qp]))); 93 39 : else if (_temperature[_qp] > 1032.5) 94 2 : mooseError("The temperature in ", 95 2 : _name, 96 : " is above the calibration upper range limit at a value of ", 97 2 : MetaPhysicL::raw_value(_temperature[_qp])); 98 : 99 133 : _check_temperature_now = false; 100 : } 101 : // Allow fall through to calculate the thermal material properties 102 9900568 : computeThermalConductivity(); 103 9900568 : computeHeatCapacity(); 104 9900568 : } 105 : 106 : template <bool is_ad> 107 : void 108 9900568 : StainlessSteelThermalTempl<is_ad>::computeThermalConductivity() 109 : { 110 9900568 : _thermal_conductivity[_qp] = 111 9900568 : (0.0144 * _temperature[_qp] + 10.55) * _thermal_conductivity_scale_factor; // in W/(m-K) 112 9900568 : _thermal_conductivity_dT[_qp] = 0.0144 * _thermal_conductivity_scale_factor; 113 : 114 : if (is_ad) 115 9898248 : setDerivatives(_thermal_conductivity[_qp], _thermal_conductivity_dT[_qp], _temperature[_qp]); 116 9900568 : } 117 : 118 : template <bool is_ad> 119 : void 120 9900568 : StainlessSteelThermalTempl<is_ad>::computeHeatCapacity() 121 : { 122 9900568 : const Real nonad_temperature = MetaPhysicL::raw_value(_temperature[_qp]); 123 : 124 19798816 : _heat_capacity[_qp] = 2.484e-7 * Utility::pow<3>(_temperature[_qp]) - 125 19798816 : 7.321e-4 * Utility::pow<2>(_temperature[_qp]) + 0.840 * _temperature[_qp] + 126 : 253.7; // in J/(K-kg) 127 9900568 : _heat_capacity[_qp] *= _heat_capacity_scale_factor; 128 9900568 : _heat_capacity_dT[_qp] = 3.0 * 2.484e-7 * Utility::pow<2>(nonad_temperature) - 129 9900568 : 2.0 * 7.321e-4 * nonad_temperature + 0.840; 130 9900568 : _heat_capacity_dT[_qp] *= _heat_capacity_scale_factor; 131 : 132 : if (is_ad) 133 9898248 : setDerivatives(_heat_capacity[_qp], _heat_capacity_dT[_qp], _temperature[_qp]); 134 9900568 : } 135 : 136 : template class StainlessSteelThermalTempl<false>; 137 : template class StainlessSteelThermalTempl<true>;