I am trying to formulate the following equation in NGSolve.
\int {\mu (\nabla v) \cdot (\nabla u)d\Omega } + \int {\mu v({\bf \vec n} \cdot {\bf \vec H}_s )d\Gamma } - \int {\mu (\vec \nabla v) \cdot {\bf \vec H}_s d\Omega }
I started with
u = fes.TrialFunction()
v = fes.TestFunction()
mu_d = {"air" : 1, "magnetic" : 100}
mu = CoefficientFunction([mu_d[mat] for mat in mesh.GetMaterials()])
Hs = CoefficientFunction((0, 1))
a = BilinearForm(fes)
a += mu*grad(u)*grad(v)*dx
f = LinearForm(fes)
f += mu*v*InnerProduct(n,Hs)*ds(mesh.Boundaries('out'))
f += -mu*InnerProduct(grad(v),Hs)*dx
a.Assemble()
f.Assemble();
gfu = GridFunction(fes)
gfu.vec.data = a.mat.Inverse(fes.FreeDofs()) * f.vec
But I am not sure how to write second and third term in a correct way.
The obtained result seems to be similar with what I solved with FreeFEM++.
Am I doing ok?