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 "ADMatWaveReaction.h" 11 : #include "ElectromagneticEnums.h" 12 : #include "ElectromagneticConstants.h" 13 : #include "Function.h" 14 : #include <complex> 15 : 16 : registerMooseObject("ElectromagneticsApp", ADMatWaveReaction); 17 : 18 : InputParameters 19 316 : ADMatWaveReaction::validParams() 20 : { 21 316 : InputParameters params = ADVectorKernel::validParams(); 22 316 : params.addClassDescription( 23 : "Calculates the current source term in the Helmholtz wave equation using " 24 : "the dielectric formulation of the current."); 25 632 : params.addRequiredCoupledVar("E_real", "The real component of the electric field."); 26 632 : params.deprecateParam("E_real", "field_real", "10/01/2025"); 27 632 : params.addRequiredCoupledVar("field_real", "The real component of the electric field."); 28 632 : params.addRequiredCoupledVar("E_imag", "The imaginary component of the electric field."); 29 632 : params.deprecateParam("E_imag", "field_imag", "10/01/2025"); 30 632 : params.addRequiredCoupledVar("field_imag", "The imaginary component of the electric field."); 31 : 32 632 : params.addParam<MaterialPropertyName>( 33 : "wave_coef_real", 34 : "wave_equation_coefficient_real", 35 : "The real component of the coefficient for the Helmholtz wave equation."); 36 632 : params.addParam<MaterialPropertyName>( 37 : "wave_coef_imag", 38 : "wave_equation_coefficient_imaginary", 39 : "The imaginary component of the coefficient for the Helmholtz wave equation."); 40 : 41 632 : MooseEnum component("real imaginary"); 42 632 : params.addParam<MooseEnum>("component", component, "Component of field (real or imaginary)."); 43 316 : return params; 44 316 : } 45 : 46 160 : ADMatWaveReaction::ADMatWaveReaction(const InputParameters & parameters) 47 : : ADVectorKernel(parameters), 48 160 : _field_real(adCoupledVectorValue("field_real")), 49 160 : _field_imag(adCoupledVectorValue("field_imag")), 50 : 51 320 : _coef_real(getADMaterialProperty<Real>("wave_coef_real")), 52 320 : _coef_imag(getADMaterialProperty<Real>("wave_coef_imag")), 53 : 54 480 : _component(getParam<MooseEnum>("component")) 55 : { 56 160 : } 57 : 58 : ADReal 59 2186448 : ADMatWaveReaction::computeQpResidual() 60 : { 61 : // TODO: In the future, need to add an AD capability to std::complex 62 2186448 : if (_component == EM::REAL) 63 1093224 : return -_test[_i][_qp] * 64 1093224 : (_coef_real[_qp] * _field_real[_qp] - _coef_imag[_qp] * _field_imag[_qp]); 65 : else 66 1093224 : return -_test[_i][_qp] * 67 1093224 : (_coef_imag[_qp] * _field_real[_qp] + _coef_real[_qp] * _field_imag[_qp]); 68 : }