Infinite grid of resistors problem (xkcd.com/356/)
Install a CLI SPICE simulator such as ngspice or MacSpice (which also happens to run twice as fast):
brew install ngspiceor
brew install --cask macspicethen compile this Rust script that parses spice outputs
rustc parse_ngspice_output.rsthen run this python script (~40 seconds with the current configuration) to get some results and generate the plots.
python run.pyIf everything was a success you should have some .svg plots in your current directory.
If you want to get straight to a single figure you can just run this instead, passing a moderately big even number like 200
python infinite_grid.py 200 | ngspiceor
ln -s /Applications/MacSpice.app/Contents/MacOS/MacSpice /usr/local/bin
python infinite_grid.py 200 | MacSpicewhich, after processing a netlist of 79999 resistors, gives a i(v1) = -1.29315e+00 output, meaning an equivalent resistance of
0.77330549433 Ω.
