@@ -10,13 +10,15 @@ Current carrying wires get boundary conditions, and in this case a single value
For permanent magnets we can use the equations for point source [magnetic dipoles](https://en.wikipedia.org/wiki/Magnetic_moment):


Magnetic dipoles get boundary conditions and a magnetization vector m, which can be applied to a magnetic region at any angle and magnitude within the XY plane. The dirac delta term is applied only if calculating magnetic field strength [inside a magnetic material](https://en.wikipedia.org/wiki/Magnetic_moment#Internal_magnetic_field_of_a_dipole).
The rest is surprisingly simple and can be implemented in about 100 lines of code in Python. We can make a numpy array that computes the effect of any dipoles or current carrying wires on every location of a uniformly spaced grid of "elements." Each element is assigned a field strength in X and Y, and a material property such as air, magnet, or wire. By iterating across every field-producing element's effect on every other element, we can create vector fields representing magnetic field strength H like the one below, which shows a permanent magnet (red bounding box) with m pointing in -X, and a current carrying wire (green bounding box) with current flowing out of the page.


Examining the results above, there are some innacuracies and limitations worth noting for improvement:
1) First let's note that there appears to be divergence on the left and right bounds of the permanent magnet where the field changes direction. I initially assumed that this was incorrect, but it turns out [H fields are indeed divergent](https://en.wikipedia.org/wiki/Magnetic_field#H-field_and_magnetic_materials) at the boundary of a magnet, and [Gauss's law for magnetism](https://en.wikipedia.org/wiki/Gauss%27s_law_for_magnetism) applies to magnetic flux density B, but not field strength H. This should really be apparent from the fact that H = B/u_0 - M, where the magnetization vector M is just a uniform vector field that sources from one side of the magnet and sinks into the other, as shown in the image linked to above.