I just want to say a big thank you, Frédéric. I had tried to compute the magnetic field in 3D of a permanent magnet, without getting a sensical answer (here was my attempt: Magnetic field in 3D of a "permanent magnet"). When I get the time, I’ll try to use your code as a guide, to fix my code.
Have a good day.