:: :: :: :: :: ::

**Introduction:** In one of the XKCD comics, titled "Nerd Sniping," there is an interesting problem presented as a way to involuntarily distract certain types of people (physicists, mathematicians, etc). Being an electrical engineer, I wanted to try and solve this problem in a more typical engineering way than to use math and symbolic manipulation: Successive Approximation! I'll start with the simplest case (see image below) and add more and more resistors to try and approximate an infinite grid of resistors.

**Notation:** The simplest grid (with the fewest resistors) is shown below this paragraph. It has six nodes and seven resistors, arranged with three nodes across and two nodes vertically. We take the number of nodes in the longest side as our characteristic id number, so we call this circuit grid_3.

If we add another layer of nodes all around the existing circuit, we end up with this grid, with five nodes on the longest side.

**Solution Method:** I thought it would be interesting to try and use circuit simulation to find the equivalent resistance. While I have experience with the more "graphical" circuit simulation tools such as made by Cadence and Synopsys, I had never before worked with SPICE from the command line, so I thought I would try to do the simulations with HSPICE. In the simplest circuit above, a 1 volt DC power supply is connected to the grid of seven resistors. Both the nodes and resistors are labeled, which will come in handy later when writing the HSPICE input file.

We can generalize the circuit generation scheme with the following python script. It should be called with a single argument: the number of nodes on the longest side. It generates a circuit file suitable for simulation with HSPICE, as explained in the next section.

#!/usr/bin/env python # # Infinite Resistor Grid Approximation Generator # Generates degenerate cases of an "infinite" grid of resistors. # Designed to be used with HSPICE, maybe others. # # Matthew Beckler - matthew at mbeckler dot org # For more details, visit http://www.mbeckler.org/resistor_grid/ import sys import numpy if len(sys.argv) < 2: print "Usage: %s long_side" % sys.argv[0] sys.exit(1) long_side = int(sys.argv[1]) short_side = long_side - 1 if long_side < 3 or long_side % 2 == 0: print "long_side must be odd and >= 3!" sys.exit(1) array = numpy.zeros((short_side, long_side)) node_id = 1 # start at 1 so we still have 0 (ground) gnd_node_y = short_side / 2 + 1 gnd_node_x = (long_side + 1) / 2 + 1 vin_node_y = short_side / 2 vin_node_x = (long_side - 1) / 2 vin_node_id = 0 # to be changed for y in range(1, short_side + 1): for x in range(1, long_side + 1): if y == gnd_node_y and x == gnd_node_x: this_node_id = 0 else: this_node_id = node_id node_id += 1 if y == vin_node_y and x == vin_node_x: vin_node_id = this_node_id array[y-1,x-1] = this_node_id #print array print "EXAMPLE PSpice" resistor_id = 0 for y in range(1, short_side + 1): for x in range(1, long_side + 1): # add horizontal resistor from here to the right if x + 1 <= long_side: print "R%d %d %d 1" % (resistor_id, array[y-1,x-1], array[y-1,x]) resistor_id += 1 # add vertical resistor from here downward if y + 1 <= short_side: print "R%d %d %d 1" % (resistor_id, array[y-1,x-1], array[y,x-1]) resistor_id += 1 print "VIN %d 0 DC 1" % vin_node_id print ".OP" print ".END"

Here is another look at the annotated schematic for the grid 3 circuit. The rather simple HSPICE circuit file is shown after the schematic. In SPICE, node 0 is the ground node. Here, I have defined the seven resistors and the DC voltage supply. The .OP line tells HSPICE to find the operating point (DC steady-state) of the circuit.

EXAMPLE Resistor Grid 3 wide R0 1 2 1 R1 1 4 1 R2 2 3 1 R3 2 5 1 R4 3 0 1 R5 4 5 1 R6 5 0 1 VIN 1 0 DC 1 .OP .END

Here is some sample output from simulating this circuit:

matthew@ugc000 ~ $ hspice grid_3.cir -- trimmed -- **** voltage sources subckt element 0:vin volts 1.0000 current -714.2857m power 714.2857m -- trimmed --

The information we are looking for is in the voltage sources section. We see that the current was 714 milliamps, or 0.714 amps. Since our voltage was one volt, we can use Ohm's Law to find the equivalent resistance:

This equivalent resistance is 1.4 ohms for a grid that is 3 nodes wide by 2 nodes tall.

**Simulation Results:**

We repeat for larger simulations, with the results shown in the table below.

Nodes in Long Side | Num Resistors | Current (A) | Resistance (Ω) |
---|---|---|---|

3 | 7 | 0.7143 | 1.400 |

5 | 31 | 1.0667 | 0.9375 |

7 | 71 | 1.1818 | 0.8462 |

9 | 127 | 1.2279 | 0.8144 |

11 | 199 | 1.2505 | 0.7997 |

13 | 287 | 1.2632 | 0.7916 |

15 | 391 | 1.2710 | 0.7868 |

17 | 511 | 1.2761 | 0.7836 |

19 | 647 | 1.2796 | 0.7815 |

21 | 799 | 1.2822 | 0.7799 |

31 | 1799 | 1.2883 | 0.7762 |

41 | 3199 | 1.2904 | 0.7750 |

51 | 4999 | 1.2915 | 0.7743 |

101 | 19999 | 1.2928 | 0.7735 |

151 | 44999 | 1.2931 | 0.7733 |

201 | 79999 | 1.2931 | 0.7733 |

251 | 124999 | * | * |

501 | 499999 | * | * |

The equivalent resistance value approaches 0.7733 Ω. We plot the number of resistors and the equivalent resistance against the number of nodes along the longest side:

**Conclusions:** After looking for other solutions online, it appears that the correct, exact answer is 4/pi - 0.5, which is the same as the answer found here. Apparently it involves some 2D Fourier series analysis, which I'll save for another day.

**Comments? Suggestions? Dissenting opinions?** Email Me

*Copyright © 2004 - 2023, Matthew L. Beckler, CC BY-SA 3.0Last modified: 2009-12-16 01:50:11 PM (EST)*