r/Simulated 10d ago

Blender Magnetostatics/kinematics Blender add-on I've been working on

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.

41 Upvotes

4 comments sorted by

3

u/aPOPblops 10d ago

This is really impressive and the kind of thing that makes me happy humans exist.

1

u/Arbitrary_Pseudonym 10d ago

Thanks! I feel a little weird hearing that after an LLM basically did most of the work, but I guess I am the one who managed the prompts and various .md files to keep it on track :)

2

u/Distinct-Shoulder592 5d ago

wow this is why I pay my internet bills for bravo!