https://github.com/Statici/magnetic_sandbox
Full transparency: This is fully vibe-coded and, in many ways, has a good deal of slop in it as a result, but IMPORTANTLY, it does work and is accurate enough to be quite a lot of fun to play around with! I'm also usually adding to it every other day or so because I have free Codex credits, so there are going to be "improvements" over time.
I made it simply because I was annoyed that every other magnetic simulation thing out there has always felt fundamentally inadequate, whether because they just didn't simulate anything interesting, because their UIs were bad, or because they were just horrible performance-wise. The paid-for software isn't really great either, because they're not aimed for simply messing around; they go for rigorous numerical accuracy at fine-grained resolution, which...for my purposes, meh.
Feel free to toy around with it, incorporate it into whatever, fork it, sell stuff built with it, all of the above is fine :)