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 "GraphiteElectricalConductivity.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", GraphiteElectricalConductivity); 19 : registerMooseObject("MalamuteApp", ADGraphiteElectricalConductivity); 20 : 21 : template <bool is_ad> 22 : InputParameters 23 116 : GraphiteElectricalConductivityTempl<is_ad>::validParams() 24 : { 25 116 : InputParameters params = Material::validParams(); 26 116 : params.addClassDescription( 27 : "Calculates the electrical conductivity as a function of temperature for " 28 : "AT 101 stainless steel in base SI units"); 29 232 : params.addRequiredCoupledVar("temperature", "Coupled temperature variable"); 30 232 : params.addParam<Real>("electrical_conductivity_scale_factor", 31 232 : 1.0, 32 : "The scaling factor for graphite electrical conductivity"); 33 116 : return params; 34 0 : } 35 : 36 : template <bool is_ad> 37 87 : GraphiteElectricalConductivityTempl<is_ad>::GraphiteElectricalConductivityTempl( 38 : const InputParameters & parameters) 39 : : Material(parameters), 40 87 : _temperature(coupledGenericValue<is_ad>("temperature")), 41 174 : _electrical_conductivity(declareGenericProperty<Real, is_ad>("electrical_conductivity")), 42 87 : _electrical_conductivity_dT(declareProperty<Real>("electrical_conductivity_dT")), 43 261 : _electrical_conductivity_scale_factor(getParam<Real>("electrical_conductivity_scale_factor")) 44 : { 45 87 : } 46 : 47 : template <bool is_ad> 48 : void 49 2513504 : GraphiteElectricalConductivityTempl<is_ad>::setDerivatives(GenericReal<is_ad> & prop, 50 : Real dprop_dT, 51 : const ADReal & ad_T) 52 : { 53 2513504 : if (ad_T < 0) 54 0 : prop.derivatives() = 0; 55 : else 56 5027008 : prop.derivatives() = dprop_dT * ad_T.derivatives(); 57 2513504 : } 58 : 59 : template <> 60 : void 61 0 : GraphiteElectricalConductivityTempl<false>::setDerivatives(Real &, Real, const ADReal &) 62 : { 63 0 : mooseError("Mistaken call of setDerivatives in a non-AD GraphiteElectricalConductivity version"); 64 : } 65 : 66 : template <bool is_ad> 67 : void 68 327 : GraphiteElectricalConductivityTempl<is_ad>::jacobianSetup() 69 : { 70 327 : _check_temperature_now = false; 71 : int number_nonlinear_it = 72 327 : _fe_problem.getNonlinearSystemBase(/*nl_sys_num=*/0).getCurrentNonlinearIterationNumber(); 73 327 : if (number_nonlinear_it == 0) 74 144 : _check_temperature_now = true; 75 327 : } 76 : 77 : template <bool is_ad> 78 : void 79 2513620 : GraphiteElectricalConductivityTempl<is_ad>::computeQpProperties() 80 : { 81 2513620 : if (_check_temperature_now) 82 : { 83 70 : if (_temperature[_qp] < 291.7) 84 2 : mooseDoOnce(mooseWarning("The temperature in ", 85 : _name, 86 : " is below the calibration lower range limit at a value of ", 87 : MetaPhysicL::raw_value(_temperature[_qp]))); 88 68 : else if (_temperature[_qp] > 1873.6) 89 2 : mooseDoOnce(mooseWarning("The temperature in ", 90 : _name, 91 : " is above the calibration upper range limit at a value of ", 92 : MetaPhysicL::raw_value(_temperature[_qp]))); 93 : 94 66 : _check_temperature_now = false; 95 : } 96 : // Allow fall through to calculate the material properties 97 2513616 : computeElectricalConductivity(); 98 2513616 : } 99 : 100 : template <bool is_ad> 101 : void 102 2513616 : GraphiteElectricalConductivityTempl<is_ad>::computeElectricalConductivity() 103 : { 104 2513616 : GenericReal<is_ad> electrical_resistivity = -2.705e-15 * Utility::pow<3>(_temperature[_qp]) + 105 2513616 : 1.263e-11 * Utility::pow<2>(_temperature[_qp]) - 106 2513616 : 1.836e-8 * _temperature[_qp] + 1.813e-5; // in Ohm/m 107 : 108 5027120 : _electrical_conductivity[_qp] = 1.0 / electrical_resistivity; 109 2513616 : _electrical_conductivity[_qp] *= _electrical_conductivity_scale_factor; 110 : 111 : // Apply the chain rule to calculate the derivative 112 2513504 : const Real non_ad_temperature = MetaPhysicL::raw_value(_temperature[_qp]); 113 2513616 : const Real conductivity_dT_inner = 3.0 * -2.705e-15 * Utility::pow<2>(non_ad_temperature) + 114 2513616 : 2.0 * 1.263e-11 * non_ad_temperature - 1.836e-8; 115 2513616 : _electrical_conductivity_dT[_qp] = 116 2513616 : -1.0 * conductivity_dT_inner / 117 2513616 : Utility::pow<2>(MetaPhysicL::raw_value(electrical_resistivity)) * 118 2513616 : _electrical_conductivity_scale_factor; 119 : 120 : if (is_ad) 121 2513504 : setDerivatives( 122 : _electrical_conductivity[_qp], _electrical_conductivity_dT[_qp], _temperature[_qp]); 123 2513616 : } 124 : 125 : template class GraphiteElectricalConductivityTempl<false>; 126 : template class GraphiteElectricalConductivityTempl<true>;