Magnetic vector potential in 2D cylindrical coordinates - Ampere law does not hold

I am solving field of coil with uniform current density in 2D r-z plane (problem is rotationaly symmetrical). I am solving A_phi component of magnetic vector potential with boundary condition of A_phi=0 on boundary, i.e. magnetic flux density is parallel to boundary.

When I calculate integral of B on the domain boundary I do not obtain the total current inside domain, Ampere law does not hold.

My sample code is attached. I would be very grateful for advice on what is wrong with my model.

coil2D_Aphi.py (3.5 KB)

1 Like