LCOV - code coverage report
Current view: top level - src/materials - ElectricalConductivity.C (source / functions) Hit Total Coverage
Test: idaholab/moose heat_transfer: #31405 (292dce) with base fef103 Lines: 31 32 96.9 %
Date: 2025-09-04 07:53:51 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          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 "ElectricalConductivity.h"
      11             : #include "libmesh/quadrature.h"
      12             : #include "libmesh/utility.h"
      13             : 
      14             : registerMooseObject("HeatTransferApp", ElectricalConductivity);
      15             : registerMooseObject("HeatTransferApp", ADElectricalConductivity);
      16             : 
      17             : template <bool is_ad>
      18             : InputParameters
      19         466 : ElectricalConductivityTempl<is_ad>::validParams()
      20             : {
      21         466 :   InputParameters params = Material::validParams();
      22         932 :   params.addCoupledVar("temperature", 293.0, "Coupled variable for temperature.");
      23         932 :   params.addParam<std::string>("base_name", "Material property base name.");
      24         932 :   params.addParam<Real>("reference_resistivity",
      25         932 :                         1.68e-8,
      26             :                         "Electrical resistivity of the material at reference temperature "
      27             :                         "(default is copper resistivity in ohm-m).");
      28         932 :   params.addParam<Real>("temperature_coefficient",
      29         932 :                         0.00386,
      30             :                         "Coefficient for calculating dependence of resistivity on temperature "
      31             :                         "(with copper as the default material).");
      32         932 :   params.addParam<Real>("reference_temperature",
      33         932 :                         293.0,
      34             :                         "Reference temperature for Electrical resistivity in Kelvin.");
      35         466 :   params.addClassDescription("Calculates resistivity and electrical conductivity as a function of "
      36             :                              "temperature, using copper for parameter defaults.");
      37         466 :   return params;
      38           0 : }
      39             : 
      40             : template <bool is_ad>
      41         363 : ElectricalConductivityTempl<is_ad>::ElectricalConductivityTempl(const InputParameters & parameters)
      42             :   : Material(parameters),
      43         363 :     _ref_resis(getParam<Real>("reference_resistivity")),
      44         726 :     _temp_coeff(getParam<Real>("temperature_coefficient")),
      45         726 :     _ref_temp(getParam<Real>("reference_temperature")),
      46         363 :     _has_temp(isCoupled("temperature")),
      47         363 :     _T(_has_temp ? coupledGenericValue<is_ad>("temperature") : genericZeroValue<is_ad>()),
      48         726 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      49         363 :     _electric_conductivity(
      50         363 :         declareGenericProperty<Real, is_ad>(_base_name + "electrical_conductivity")),
      51         726 :     _delectric_conductivity_dT(declareProperty<Real>(_base_name + "electrical_conductivity_dT"))
      52             : {
      53         363 : }
      54             : 
      55             : template <bool is_ad>
      56             : void
      57     1564000 : ElectricalConductivityTempl<is_ad>::computeQpProperties()
      58             : {
      59     1564000 :   const auto & temp_qp = _T[_qp];
      60             : 
      61     3768800 :   const auto resistivity = _ref_resis * (1.0 + _temp_coeff * (temp_qp - _ref_temp));
      62     1564000 :   const Real dresistivity_dT = _ref_resis * _temp_coeff;
      63     2666400 :   _electric_conductivity[_qp] = 1.0 / resistivity;
      64     1564000 :   _delectric_conductivity_dT[_qp] =
      65     1564000 :       -1.0 / Utility::pow<2>(MetaPhysicL::raw_value(resistivity)) * dresistivity_dT;
      66     1564000 : }
      67             : 
      68             : template class ElectricalConductivityTempl<false>;
      69             : template class ElectricalConductivityTempl<true>;

Generated by: LCOV version 1.14