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 "JouleHeatingSource.h" 11 : 12 : registerMooseObject("HeatTransferApp", JouleHeatingSource); 13 : 14 : InputParameters 15 19 : JouleHeatingSource::validParams() 16 : { 17 : InputParameters params = 18 19 : DerivativeMaterialInterface<JvarMapKernelInterface<HeatSource>>::validParams(); 19 38 : params.addCoupledVar("elec", "Electric potential for joule heating."); 20 38 : params.addParam<MaterialPropertyName>( 21 : "electrical_conductivity", 22 : "electrical_conductivity", 23 : "Material property providing electrical conductivity of the material."); 24 19 : params.addClassDescription("Calculates the heat source term corresponding to electrostatic Joule " 25 : "heating."); 26 19 : return params; 27 0 : } 28 : 29 10 : JouleHeatingSource::JouleHeatingSource(const InputParameters & parameters) 30 : : DerivativeMaterialInterface<JvarMapKernelInterface<HeatSource>>(parameters), 31 10 : _grad_elec(coupledGradient("elec")), 32 10 : _elec_var(coupled("elec")), 33 20 : _elec_cond(getMaterialProperty<Real>("electrical_conductivity")), 34 10 : _delec_cond_dT(getMaterialPropertyDerivative<Real>("electrical_conductivity", _var.name())), 35 20 : _delec_cond_darg(_coupled_moose_vars.size()) 36 : { 37 20 : for (unsigned int i = 0; i < _delec_cond_darg.size(); ++i) 38 10 : _delec_cond_darg[i] = &getMaterialPropertyDerivative<Real>("electrical_conductivity", 39 10 : _coupled_moose_vars[i]->name()); 40 : 41 10 : mooseDeprecated("The non-AD version of JouleHeatingSource will be deprecated in the near future " 42 : "(10/01/2025) in favor of exclusively using the AD version of " 43 : "JouleHeatingSource, since the ADJouleHeatingSource can calculate both " 44 : "electrostatic and electromagnetic Joule heating."); 45 10 : } 46 : 47 : void 48 10 : JouleHeatingSource::initialSetup() 49 : { 50 30 : validateNonlinearCoupling<Real>("electrical_conductivity"); 51 10 : } 52 : 53 : Real 54 1059200 : JouleHeatingSource::computeQpResidual() 55 : { 56 1059200 : return -_elec_cond[_qp] * _grad_elec[_qp] * _grad_elec[_qp] * _test[_i][_qp]; 57 : } 58 : 59 : Real 60 652800 : JouleHeatingSource::computeQpJacobian() 61 : { 62 652800 : return -_delec_cond_dT[_qp] * _grad_elec[_qp] * _grad_elec[_qp] * _phi[_j][_qp] * _test[_i][_qp]; 63 : } 64 : 65 : Real 66 608000 : JouleHeatingSource::computeQpOffDiagJacobian(unsigned int jvar) 67 : { 68 : const unsigned int cvar = mapJvarToCvar(jvar); 69 : 70 608000 : if (jvar == _elec_var) 71 608000 : return -2 * _elec_cond[_qp] * _grad_elec[_qp] * _grad_phi[_j][_qp] * _test[_i][_qp] - 72 608000 : (*_delec_cond_darg[cvar])[_qp] * _grad_elec[_qp] * _grad_elec[_qp] * _phi[_j][_qp] * 73 608000 : _test[_i][_qp]; 74 : 75 0 : return -(*_delec_cond_darg[cvar])[_qp] * _grad_elec[_qp] * _grad_elec[_qp] * _phi[_j][_qp] * 76 0 : _test[_i][_qp]; 77 : }