u/Arbitrary_Pseudonym

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 :)

u/Arbitrary_Pseudonym — 7 days ago

So I was given a few months of unlimited Codex credits and decided to use it to vibe-code something I've always wanted: A nice little sandbox for moving around magnets and visualizing the fields they generate.

The visual here is just two free-to-move magnets in the center of a k=2 circular Halbach array (they generate super uniform, straight-line fields that apply torque, but not force).

I got to a point where I'm happy enough with how fast it does the tracing (native multicore on the CPU, and with an nvidia GPU + pycuda installed, GPU-accelerated with lots of lines being traced) so I went ahead and added force/torque calculations.

The entire reason it's not potato-slow is because it relies entirely on dipole approximations and does not attempt to sample the field anywhere except for where the lines trace towards. With a GPU the UI operates at ~1fps while rendering hundreds of magnets and tens of thousands of field lines (as long as the lines aren't too long) and with a CPU it starts to chug around 20-30 magnets with a hundred-ish traces, but with only a few magnets it does line tracing in real time even on less-good CPUs.

The force/torque calculations are currently all done with Bullet instead of relying on Blender's native physics engine though. The LLM keeps telling me that Blender doesn't have a nice API to hook into for simply shoving magnet data into and getting force vector data out, and I can't seem to find that either, so I was hoping y'all might know. I want to make this thing operate as Blender-native as possible before I throw it up on github for others to play with.

u/Arbitrary_Pseudonym — 18 days ago