The Magnet Toy

  • netherpro
    28th May Member 3 Permalink
    THE ELECTRIC-MAGNET TOY — Classical Electromagnetism for The Powder Toy
    ======================================================================

     

    By netherpro

    Windows: https://starcatcher.us/TPT/mods/The-Magnet-Toy/The-Magnet-Toy.zip
    macOS: https://starcatcher.us/TPT/mods/The-Magnet-Toy/The-Magnet-Toy.dmg
    Linux: https://starcatcher.us/TPT/mods/The-Magnet-Toy/The-Magnet-Toy%20linux64.zip

     

    WHY I MADE THIS
    ----------------------------------------------------------------------

     

    The Powder Toy dev team once rejected magnetic fields:

     

      "Realistic magnets must simulate a magnetic field with poles.
       It is unclear if this is doable in a simulation like Powder Toy.
       What is absolutely rejected is just making a copy+paste of Newtonian
       Gravity and making it only apply to metallic powders. This is boring
       and uninteresting."

     

    I read this and thought: challenge accepted.

     

    This is not a copy-paste of Newtonian gravity. It is a full classical
    electromagnetism simulation with FFT-based Poisson field solvers, real
    physical coupling between electric and magnetic phenomena. If the
    official game won't do it, the modding community will.



    WHAT IT DOES
    ----------------------------------------------------------------------

     

    Magnetic Fields
      - FFT field solver: real-time Poisson equation in frequency domain
        (3x zero-padded, fftw3f)
      - Permanent magnets (MAGN), electromagnets (ELMG), monopoles (MGPN)
      - 13 conductors detect changing flux and spark (Faraday induction)
      - 4 ferromagnetics become magnetized by contact with internal diffusion
      - B-field breakage: strong fields shatter BMTL into BRMT

     

    Electric Fields
      - Second FFT solver (ElecFFT) for electric potential
      - Electrode plates (POSC): single element, temp polarity
      - Fixed charges (FIXC): persistent charge sources
      - 24 conductors accept charge from POSC, FIXC, ELEC, PROT
      - Charge diffusion between neighbors: a charged wire charges the whole
        circuit

     

    Electro-Magnetic Coupling
      - Coulomb force: F = -q * grad(V), matching ELEC/PROT coefficient
      - Lorentz force: charged particles rotate in B-field, energy-conserving
      - Dielectrophoresis: uncharged conductors pulled toward stronger |E|
      - Gravity-weighted: light particles respond more than heavy ones

     

    Tools
      - PMAG / NMAG: paint positive/negative magnetic field sources
      - PELC / NELC: paint positive/negative electric field sources
      - Sidebar toggle buttons for all field displays



    TECHNICAL NOTES
    ----------------------------------------------------------------------

     

    Both MagFFT and ElecFFT solve the Poisson equation in frequency domain:

     

      laplacian(phi) = -source   -->   phi_hat(k) = source_hat(k) / (k^2 + 1)

     

    Using a 3x zero-padded grid to eliminate wraparound artifacts. Same
    approach used in real computational physics, adapted for a cellular
    automaton.

     

    This is not Newtonian gravity repurposed. It is a genuine electromagnetic
    field simulation with divergence-free magnetic fields, scalar electric
    potential with proper gradient forces, Lorentz coupling, and Faraday
    induction.



    LINKS
    ----------------------------------------------------------------------

     

    Branch:       the-electric-magnet-toy
    License:      GPLv3 (inherited from TPT)



    BUILD IT YOURSELF
    ----------------------------------------------------------------------

     

      cd The-Magnet-Toy
      git checkout the-electric-magnet-toy
      meson setup build-static -Dstatic=prebuilt --buildtype=release
      ninja -C build-static

     

    Requires: fftw3f, meson, ninja, MSVC or GCC.



    It turns out realistic electromagnetism IS doable
    in The Powder Toy. And it's anything but boring.
    Edited 5 times by netherpro. Last: 31st May
  • ALumpOfPowderToy
    29th May Member 0 Permalink

    actually really impressive

    i'll check it out when i have the time

  • Tadpole1
    29th May Member 0 Permalink

    I love it,finally someone who had the right idea

    Anyway the menus is a little bit broken.

    Edited once by Tadpole1. Last: 29th May
  • netherpro
    30th May Member 0 Permalink

    @Tadpole1 (View Post)

     The newer version can be downloaded from github release with a more stable menu Release v.1.8.0 · T307-coder/The-Magnet-Toy