Hello
I am trying to solve a simple magnetostatic problem through a curl curl equation with Coulomb gauge.
\nabla \times \nabla \times \mathbf{A} = \mu_0 \mathbf{J} and \nabla \cdot \mathbf{A} = 0 on \Omega.
with homogeneous essential conditions on the exterior boundary \hat{\mathbf{n}} \times \mathbf{A} = 0 on \partial \Omega.
I have a simple domain, which has a circular coil (rectangular cross-section) in a cube. (I could not upload pictures here. Sorry.)
I adopted Lagrange multipliers for the Coulomb gauge and a mixed element like following. (I guess this combination of element orders is stable.)
el_u = basix.ufl.element('N1curl', domain.basix_cell(), 2)
el_p = basix.ufl.element('CG', domain.basix_cell(), 1)
el = basix.ufl.mixed_element([el_u, el_p])
W = dolfinx.fem.functionspace(domain, el)
u, p = ufl.TrialFunctions(W)
v, q = ufl.TestFunctions(W)
I wrote a bilinear form and a rhs linear form as following. Earlier, I create a ufl expression j_expr for the current density for the coil.
a = (
# The stiffness matrix for the curl curl equation.
ufl.dot(ufl.curl(u), ufl.curl(v)) * ufl.dx +
# Lagrangian multipliers p for the Coulomb gauge.
ufl.dot(ufl.grad(p), v) * ufl.dx +
# Enforce the Coulomb gauge weakly.
ufl.dot(u, ufl.grad(q)) * ufl.dx
)
L = ufl.dot(j_expr, v) * ufl.dx
One thing I learned is that I might not want to use ufl.div(u) for N1curl since the normal components may not be continuous and its (weak) divergence may not be defined on facets. So, I used ufl.dot(ufl.grad(p), v) instead of p * ufl.div(v).
I applied homogeneous boundary conditions for both of vector potential u and Lagrange multipliers p like following and tried the preonly solver option (to make sure my variational formulation has some wrong with it.).
domain.topology.create_connectivity(2, 3)
boundary_facets = dolfinx.mesh.exterior_facet_indices(domain.topology)
boundary_dofs = dolfinx.fem.locate_dofs_topological(
W,
domain.topology.dim - 1,
boundary_facets
)
w_D = dolfinx.fem.Function(W)
w_D.x.array[:] = 0.
bc = dolfinx.fem.dirichletbc(w_D, boundary_dofs)
opts = {
"ksp_type": "preonly",
"pc_type": "lu",
"pc_factor_mat_solver_type": "mumps"
}
prob = dolfinx.fem.petsc.LinearProblem(a, L, bcs=[bc], petsc_options=opts)
Unfortunately, this formulation gives an unphysical answer. (Actually, all infs). What could be a problem in this approach?
Best,