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 "ADConductionCurrent.h" 11 : #include "ElectromagneticEnums.h" 12 : #include "ElectromagneticConstants.h" 13 : #include <complex> 14 : 15 : registerMooseObject("ElectromagneticsApp", ADConductionCurrent); 16 : 17 : InputParameters 18 114 : ADConductionCurrent::validParams() 19 : { 20 114 : InputParameters params = ADVectorKernel::validParams(); 21 114 : params.addClassDescription( 22 : "Calculates the current source term in the Helmholtz wave equation using " 23 : "the conduction formulation of the current."); 24 228 : params.addRequiredCoupledVar("E_real", "The real component of the electric field."); 25 228 : params.deprecateParam("E_real", "field_real", "10/01/2025"); 26 228 : params.addRequiredCoupledVar("field_real", "The real component of the electric field."); 27 228 : params.addRequiredCoupledVar("E_imag", "The imaginary component of the electric field."); 28 228 : params.deprecateParam("E_imag", "field_imag", "10/01/2025"); 29 228 : params.addRequiredCoupledVar("field_imag", "The imaginary component of the electric field."); 30 : 31 228 : params.addParam<MaterialPropertyName>( 32 228 : "conductivity_real", 1.0, "The real component of the material conductivity."); 33 228 : params.addParam<MaterialPropertyName>( 34 228 : "conductivity_imag", 0.0, "The imaginary component of the material conductivity."); 35 : 36 228 : params.addParam<MaterialPropertyName>( 37 : "ang_freq_real", "ang_freq", "The real component of the angular drive frequency."); 38 228 : params.addParam<MaterialPropertyName>( 39 228 : "ang_freq_imag", 0.0, "The imaginary component of the angular drive frequency."); 40 : 41 228 : params.addParam<MaterialPropertyName>( 42 : "permeability_real", "mu_vacuum", "The real component of the material permeability."); 43 228 : params.addParam<MaterialPropertyName>( 44 228 : "permeability_imag", 0.0, "The imaginary component of the material permeability."); 45 : 46 228 : MooseEnum component("real imaginary"); 47 228 : params.addParam<MooseEnum>("component", component, "Component of field (real or imaginary)."); 48 114 : return params; 49 114 : } 50 : 51 60 : ADConductionCurrent::ADConductionCurrent(const InputParameters & parameters) 52 : : ADVectorKernel(parameters), 53 60 : _field_real(adCoupledVectorValue("field_real")), 54 60 : _field_imag(adCoupledVectorValue("field_imag")), 55 : 56 120 : _cond_real(getADMaterialProperty<Real>("conductivity_real")), 57 120 : _cond_imag(getADMaterialProperty<Real>("conductivity_imag")), 58 : 59 120 : _omega_real(getADMaterialProperty<Real>("ang_freq_real")), 60 120 : _omega_imag(getADMaterialProperty<Real>("ang_freq_imag")), 61 : 62 120 : _mu_real(getADMaterialProperty<Real>("permeability_real")), 63 120 : _mu_imag(getADMaterialProperty<Real>("permeability_imag")), 64 : 65 180 : _component(getParam<MooseEnum>("component")) 66 : { 67 60 : } 68 : 69 : ADReal 70 62400 : ADConductionCurrent::computeQpResidual() 71 : { 72 : // TODO: In the future, need to add an AD capability to std::complex 73 124800 : ADReal mu_omega_real = _mu_real[_qp] * _omega_real[_qp] - _mu_imag[_qp] * _omega_imag[_qp]; 74 124800 : ADReal mu_omega_imag = _mu_real[_qp] * _omega_imag[_qp] + _mu_imag[_qp] * _omega_real[_qp]; 75 : 76 : ADRealVectorValue sigma_field_real = 77 62400 : _cond_real[_qp] * _field_real[_qp] - _cond_imag[_qp] * _field_imag[_qp]; 78 : ADRealVectorValue sigma_field_imag = 79 62400 : _cond_imag[_qp] * _field_real[_qp] + _cond_real[_qp] * _field_imag[_qp]; 80 : 81 62400 : if (_component == EM::REAL) 82 : { 83 31200 : return _test[_i][_qp] * -1.0 * 84 31200 : (mu_omega_imag * sigma_field_real + mu_omega_real * sigma_field_imag); 85 : } 86 : else 87 : { 88 31200 : return _test[_i][_qp] * (mu_omega_real * sigma_field_real - mu_omega_imag * sigma_field_imag); 89 : } 90 : }