https://mooseframework.inl.gov
Loading...
Searching...
No Matches
VectorTransientAbsorbingBC.C
Go to the documentation of this file.
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
13#include "Function.h"
14#include <complex>
15
17
20{
23 "First order transient absorbing boundary condition for vector variables.");
24 params.addParam<FunctionName>("admittance",
25 1 / (EM::mu_0 * EM::c),
26 "Real component of the intrinsic admittance of the infinite medium "
27 "(default is $\\sqrt{\\frac{\\epsilon_0}{\\mu_0}} = "
28 "\\frac{1}{\\mu_0 c}$, or the admittance of free space).");
29 params.deprecateParam("admittance", "admittance_real", "06/01/2027");
30 params.addParam<FunctionName>(
31 "admittance_imag",
32 "0",
33 "Imaginary component of the intrinsic admittance of the infinite medium.");
34 MooseEnum component("real imaginary");
35 params.addParam<MooseEnum>(
36 "component", component, "Variable field component (real or imaginary).");
37 params.addRequiredCoupledVar("coupled_field", "Coupled field variable.");
38 return params;
39}
40
42 : VectorIntegratedBC(parameters),
43
44 _admittance_real(getFunction("admittance_real")),
45 _admittance_imag(getFunction("admittance_imag")),
46
47 _component(getParam<MooseEnum>("component")),
48
49 _coupled_val(coupledVectorValue("coupled_field")),
50 _coupled_var_num(coupled("coupled_field")),
51
52 _u_dot(dot()),
53 _coupled_dot(coupledVectorDot("coupled_field")),
54 _du_dot_du(dotDu()),
55 _coupled_dot_du(coupledVectorDotDu("coupled_field"))
56{
57}
58
59Real
61{
62 // Initialize field_dot components
63 std::complex<double> field_dot_0(0, 0);
64 std::complex<double> field_dot_1(0, 0);
65 std::complex<double> field_dot_2(0, 0);
66
67 // Create E_dot for residual based on component parameter
68 if (_component == EM::REAL)
69 {
70 field_dot_0.real(_u_dot[_qp](0));
71 field_dot_0.imag(_coupled_dot[_qp](0));
72
73 field_dot_1.real(_u_dot[_qp](1));
74 field_dot_1.imag(_coupled_dot[_qp](1));
75
76 field_dot_2.real(_u_dot[_qp](2));
77 field_dot_2.imag(_coupled_dot[_qp](2));
78 }
79 else
80 {
81 field_dot_0.real(_coupled_dot[_qp](0));
82 field_dot_0.imag(_u_dot[_qp](0));
83
84 field_dot_1.real(_coupled_dot[_qp](1));
85 field_dot_1.imag(_u_dot[_qp](1));
86
87 field_dot_2.real(_coupled_dot[_qp](2));
88 field_dot_2.imag(_u_dot[_qp](2));
89 }
90 VectorValue<std::complex<double>> field_dot(field_dot_0, field_dot_1, field_dot_2);
91
92 // Complex admittance of the infinite medium
93 const std::complex<double> admittance(_admittance_real.value(_t, _q_point[_qp]),
95
96 // Calculate solution field contribution to BC residual
97 std::complex<double> p_dot_test =
98 EM::mu_0 * admittance *
99 (_test[_i][_qp].cross(_normals[_qp]) * _normals[_qp].cross(field_dot));
100
101 std::complex<double> res = -p_dot_test;
102
103 if (_component == EM::REAL)
104 return res.real();
105 else
106 return res.imag();
107}
108
109Real
111{
112 RealVectorValue prefix =
114
115 return -prefix * _normals[_qp].cross(_du_dot_du[_qp] * _phi[_j][_qp]);
116}
117
118Real
120{
121 if (jvar == _coupled_var_num)
122 {
123 // The coupled field enters through the imaginary part of the admittance, with a positive
124 // sign in the real component of the residual and a negative sign in the imaginary component
125 const Real sign = (_component == EM::REAL) ? 1.0 : -1.0;
126 RealVectorValue prefix = sign * EM::mu_0 * _admittance_imag.value(_t, _q_point[_qp]) *
127 _test[_i][_qp].cross(_normals[_qp]);
128
129 return prefix * _normals[_qp].cross(_coupled_dot_du[_qp] * _phi[_j][_qp]);
130 }
131 else
132 return 0.0;
133}
registerMooseObject("ElectromagneticsApp", VectorTransientAbsorbingBC)
virtual Real value(Real t, const Point &p) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void deprecateParam(const std::string &old_name, const std::string &new_name, const std::string &removal_date)
unsigned int _qp
unsigned int _i
unsigned int _j
const MooseArray< Point > & _q_point
static InputParameters validParams()
const MooseArray< Point > & _normals
const VectorVariablePhiValue & _phi
const VectorVariableTestValue & _test
First order transient absorbing boundary condition for nonlinear vector variables.
const MooseEnum _component
Variable field component (real or imaginary)
static InputParameters validParams()
const VectorVariableValue & _coupled_dot
Coupled vector field variable time derivative.
VectorTransientAbsorbingBC(const InputParameters &parameters)
virtual Real computeQpResidual() override
const VectorVariableValue & _u_dot
Vector field variable time derivative.
const VariableValue & _du_dot_du
Vector field variable dot du.
const VariableValue & _coupled_dot_du
Coupled vector field variable dot du.
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
const Function & _admittance_real
Real component of the intrinsic admittance of the infinite medium.
const Function & _admittance_imag
Imaginary component of the intrinsic admittance of the infinite medium.
const unsigned int _coupled_var_num
Coupled field vector variable id.
virtual Real computeQpJacobian() override
static const Real mu_0
Magnetic permeability of free space in SI units (H/m)
static const Real c
Speed of light in vacuum in SI units (m/s)