Recently I have been trying to code Maxwell's equations over a closed surface and have been facing some trouble defining the boundary conditions for the magnetic field.
The equation for the normal of the magnetic field at the boundary is $B_1 = B_2$ where $B_1$ is on one side of the boundary, and $B_2$ is on the other side, and the distance between them is infinitesimally small.
Logically, we would then define the Dirichlet condition in NDSolve as such:
DirichletCondition[Bfx[x,y,z,t] == Bfx[x+10^-12,y,z,t], x== 0.5 || x== -0.5]
This code means that at the edges of my conductor, the $x$ component of the magnetic field a small distance apart should be equal.
However, this code would then give the error:
NDSolve::fembpw: The boundary condition {DirichletCondition[True,True]} cannot be parsed and will be ignored.
as well as the "arguments should be ordered consistently" error.
Some alternatives I have tried include equating the spatial derivatives of the magnetic field at the boundary to be zero, but since Maxwell's equations do not have such a high differential order, it will not be solved.
DirichletCondition[D[Bx[x,y,z,t],x]==0,x==0.5||x==-0.5]
Another method is Neumann values, but considering that I am solving for only three or six functions ($E$ field in $x$, $y$, $z$ and $B$ field in $x$, $y$, $z$), adding this extra Neumann value will cause the system to become over determined.
I would really appreciate it if someone who has experience in dealing with normal boundary conditions to give their advice.
Edit2 Now there are issues with zero pivot, which i found to be very hard to troubleshoot. Is there anything I should be looking out for? Here is the code
In[153]:= Needs["NDSolve`FEM`"];
w = 0.1;
h = 0.2;
th = 0.01;
\[Mu]0 = 4 \[Pi]*10^7;
\[Mu]c = 1.3*10^6;
m = {0, 0, 1};
\[Alpha] = 10^-6;
\[Beta] = 10^-6;
Pd[t_] := {Sin[t], Cos[t], 0};
\[Sigma] = 5.98*10^-7;
region = Cuboid[{-w/2, -w/2, h - 0.00001}, {w/2, w/2, h + th + 3}];
regionMesh = ToElementMesh[region];
Hm[x_, y_, z_, t_] :=
1/(4 \[Pi]) ((3 ( m . ({x, y, z} - Pd[t])) ({x, y, z} - Pd[t]))/
Sqrt[(x - Sin[t])^2 + (y - Cos[t])^2 + z^2]^5 - m/
Sqrt[(x - Sin[t])^2 + (y - Cos[t])^2 + z^2]^3);
mu[x_, y_, z_] :=
If[-w/2 < x < w/2 || -w/2 < y < w/2 ||
h < z < h + th, \[Mu]c, \[Mu]0] ;
Out[55]= (1.07907 z (x -
Sin[t]))/(z^2 + (y - Cos[t])^2 + (x - Sin[t])^2)^(5/2)
In[72]:= Monitor[sol = NDSolve[
{
Thread[
Curl[{Efx[x, y, z, t], Efy[x, y, z, t], Efz[x, y, z, t]}, {x, y,
z}] == D[
mu[x, y,
z]*(Hm[x, y, z, t] + {Hix[x, y, z, t], Hiy[x, y, z, t],
Hiz[x, y, z, t]}) ,
t] + \[Alpha] Laplacian[{Efx[x, y, z, t], Efy[x, y, z, t],
Efz[x, y, z, t]}, {x, y, z}]],
Thread[
Curl[
mu[x, y,
z]*(Hm[x, y, z, t] + {Hix[x, y, z, t], Hiy[x, y, z, t],
Hiz[x, y, z, t]}), {x, y,
z}] == \[Mu]0 \[Sigma] {Efx[x, y, z, t], Efy[x, y, z, t],
Efz[x, y, z, t]} + \[Alpha] Laplacian[{Hix[x, y, z, t],
Hiy[x, y, z, t], Hiz[x, y, z, t]}, {x, y, z}]],
DirichletCondition[
Hix[x, y, z,
t] == -Hm[x, y, z, t][[1]], (z == h ||
z == h + th ) && (x == -w/2 || x == w/2)],
DirichletCondition[
Hiy[x, y, z,
t] == -Hm[x, y, z, t][[2]], (z == h ||
z == h + th) && (y == -w/2 || y == w/2)],
DirichletCondition[
Hiz[x, y, z, t] == -Hm[x, y, z, t][[3]], (z == h || z == h + th)],
DirichletCondition[
Efx[x, y, z, t] ==
0, ((z == h || z == h + th) && (y == -w/2 || y == w/2)) || (z ==
h || z == h + th)],
DirichletCondition[
Efy[x, y, z, t] ==
0, ((z == h || z == h + th) && (x == -w/2 || x == w/2)) || (z ==
h || z == h + th)],
DirichletCondition[
Efz[x, y, z, t] ==
0, ((z == h || z == h + th) && (y == -w/2 ||
y == w/2)) || ((z == h || z == h + th) && (x == -w/2 ||
x == w/2))],
(*
DirichletCondition[D[Hix[x,y,z,t],x]==0, h<z<h+th && (x==w/2 ||
x==-w/2)],
DirichletCondition[D[Hiy[x,y,z,t],y]==0, h<z<h+th && (y==w/2 ||
y==-w/2)],
DirichletCondition[D[Hiz[x,y,z,t],z]==0, z==h||z==h+th],*)
Efx[x, y, z, 0] == 0,
Efy[x, y, z, 0] == 0,
Efz[x, y, z, 0] == 0,
Hix[x, y, z, 0] == 0,
Hiy[x, y, z, 0] == 0,
Hiz[x, y, z, 0] == 0
}, {Efx, Efy, Efz, Hix, Hiy, Hiz},
{x, y, z} \[Element] regionMesh, {t, 0, 1}, MaxStepSize -> 0.01,
StepMonitor :> (p = t)
], p]
I tried to change up some conditions. So now my perpendicular magnetic field is zero at the boundaries and my tangential electric fields are zero at the boundaries as well. The conditions for the DirichletConditions may be a bit erroneous so I tried splitting it up into individual conditions but it didnt quite work either.
Now the main issue Im
Its a bit long but here goes:
DirichletCondition[
Hix[x, y, z,
t] == \[Minus]Hm[x, y, z, t][[1]], (z ==
h) && (x == \[Minus]w/2)],
DirichletCondition[
Hix[x, y, z,
t] == \[Minus]Hm[x, y, z, t][[1]], (z == h) && (x == w/2)],
DirichletCondition[
Hix[x, y, z,
t] == \[Minus]Hm[x, y, z, t][[1]], (z ==
h + th) && (x == \[Minus]w/2)],
DirichletCondition[
Hix[x, y, z,
t] == \[Minus]Hm[x, y, z, t][[1]], (z == h + th) && (x == w/2)],
DirichletCondition[
Hiy[x, y, z,
t] == \[Minus]Hm[x, y, z, t][[2]], (z ==
h) && (y == \[Minus]w/2)],
DirichletCondition[
Hiy[x, y, z,
t] == \[Minus]Hm[x, y, z, t][[2]], (z == h) && (y == w/2)],
DirichletCondition[
Hiy[x, y, z,
t] == \[Minus]Hm[x, y, z, t][[2]], (z ==
h + th) && (y == \[Minus]w/2)],
DirichletCondition[
Hiy[x, y, z,
t] == \[Minus]Hm[x, y, z, t][[2]], (z == h + th) && (y == w/2)],
DirichletCondition[
Hiz[x, y, z, t] == \[Minus]Hm[x, y, z, t][[3]], (z == h)],
DirichletCondition[
Hiz[x, y, z, t] == \[Minus]Hm[x, y, z, t][[3]], (z == h + th)],
DirichletCondition[
Efx[x, y, z, t] == 0, (z == h) && (y == \[Minus]w/2)],
DirichletCondition[Efx[x, y, z, t] == 0, (z == h) && (y == w/2)],
DirichletCondition[
Efx[x, y, z, t] == 0, (z == h + th) && (y == \[Minus]w/2)],
DirichletCondition[
Efx[x, y, z, t] == 0, (z == h + th) && (y == w/2)],
DirichletCondition[
Efy[x, y, z, t] == 0, (z == h) && (x == \[Minus]w/2)],
DirichletCondition[Efy[x, y, z, t] == 0, (z == h) && (x == w/2)],
DirichletCondition[
Efy[x, y, z, t] == 0, (z == h + th) && (x == \[Minus]w/2)],
DirichletCondition[
Efy[x, y, z, t] == 0, (z == h + th) && (x == w/2)],
DirichletCondition[
Efz[x, y, z, t] == 0, (z == h) && (y == \[Minus]w/2)],
DirichletCondition[Efz[x, y, z, t] == 0, (z == h) && (y == w/2)],
DirichletCondition[
Efz[x, y, z, t] == 0, (z == h + th) && (y == \[Minus]w/2)],
DirichletCondition[Efz[x, y, z, t] == 0, (z == h + th) && (y == w/2)],
```
