Thank you for your time, I will just try to clarify my problem one last time.
You will find below the code of the Linear solution.
Concerning the linear solution, the weak formulation has been simplified, so the equation might be not clear, sorry for that. However, this simulation has been validated both with a commercial solver and another FEA api.
My problem is not about the weak formulation but the way to carry on a NonLinear simulation, the NonLinearity coming from the nu expression which depend on B and thus on u.
The Nonlinear simulation is thus the same as the linear one but with nu(
The question is : How would you perform a Non linear algorithm iterating on nu ?
You'll find below the linear code that worked for me ...
stator = Circle(center=(0, 0), radius=10, bc="bc_rect_ext" )
rotor = Circle(center=(0, 0), radius=6)
circle_airgap = Circle(center=(0, 0), radius=7.5)
magnet1 = Circle(center=(0, 0), radius=7)
magnet_f = magnet1-rotor
airgap = circle_airgap-(magnet1)
stator_f = stator-circle_airgap
# change domain name and maxh
magnet_f.Mat("magnet").Maxh(0.5)
rotor.Mat("fer1").Maxh(0.5)
stator_f.Mat("fer2").Maxh(0.5)
airgap.Mat("air").Maxh(0.5)
###
geo.Add(magnet_f)
geo.Add(rotor)
geo.Add(stator_f)
geo.Add(airgap)
mesh = Mesh(geo.GenerateMesh(maxh=0.1))
Draw(mesh)
# FEM
fes = H1(mesh, order=3, dirichlet='bc_rect_ext')
u, v = fes.TnT()
mu_r = {"air": 1, "magnet": 1.1, "fer1": 1000, "fer2": 1000}
# Definition des permeabilites
mu0 = 4*pi*1e-7
nu_coef = [1/(mu0*mu_r[mat]) for mat in mesh.GetMaterials()]
nu = CoefficientFunction(nu_coef)
a = BilinearForm(fes)
a += nu*(grad(u)*grad(v))*dx
M=80000
f = LinearForm(fes)
j = CoefficientFunction(10*1e3)
Mx = CoefficientFunction(M*cos(atan2(y,x))*1e0)
My = CoefficientFunction(0)
f += (Mx*grad(v)[1]-My*grad(v)[0]) * dx("magnet")
with TaskManager():
a.Assemble()
f.Assemble()
# Solve the linear system
gfa = GridFunction(fes)
gfa.vec.data = a.mat.Inverse(fes.FreeDofs()) * f.vec