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