Enforcing magnetic gauge choice in 3D

Hello !

I am trying to solve an eddy current problem (conductive sphere in homogeneous field) in 3D using potential formulation. All the tutorials I have seen use the problem’s symmetry to reduce the problem to 2D or solve for the electric field. I do not wish to do so.

I am having trouble understanding how I can enforce my gauge choice div(A) = 0. Should I be adding equations to the solver, how would I do that ?

For now, I am applying an homogeneous field using boundary conditions.

I installed FEniCSx using conda on Debian.

Here is a MWE illustrating the current solving code :

import ufl
from mpi4py import MPI
from petsc4py import PETSc
from ufl import dx, grad, inner
from dolfinx.fem.petsc import LinearProblem

mesh = dolfinx.mesh.create_box(
    MPI.COMM_WORLD,
    [[0, 0, 0], [10, 10, 10]],
    [5, 5, 5],
    dolfinx.mesh.CellType.tetrahedron,
)
f = dolfinx.fem.Constant(mesh, PETSc.ScalarType((0, 0, 0)))
        
x = ufl.SpatialCoordinate(mesh)
V = dolfinx.fem.VectorFunctionSpace(mesh, ('Lagrange', 4), dim=3)

A_source = dolfinx.fem.Function(V)

u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)

#how do i include div(A) = 0 equation ?
a =(inner(grad(u), grad(v))  - 1j * inner(u, v)) * dx
L = inner(f, v) * dx


problem = LinearProblem(
    a,
    L,
    u=A_source,
    bcs=[],
    petsc_options={
        "ksp_type": "cg",
        "ksp_atol": 1e-10,
        "ksp_max_it": 1000,
    },
)

problem.solve()

Any help is appreciated.
Thank you.

You can create a mixed formulation, see for instance: TEAM30/team30_A_phi.py at main · Wells-Group/TEAM30 · GitHub that does it for the 2D problem.