MagWire ======= As a first example how to use the modules and concepts that we have seen so far, we will develop two python classes that allow the calculation of magnetic fields generated by an arbitrary eletric current geometry. This is done by exploiting the law of Biot-Savart. The source code including some examples is available `here <./source/magwire/>`_. The frist class Wire is found in wire.py. It represents a continuous path for an electrical current (i.e. a wire). The path is specified as a sequence of 3D coordinates. The member property discretized_path returns the original path with linearly interpolated segments shorter than the specified discretization length. .. literalinclude:: ./source/magwire/wire.py :language: python :linenos: The second class BiotSavart performs the actual calculations. An arbitrary number Wire class instances can be added to define the current distribution in space. The member function CalculateB accepts a list of 3D coordinates and returns a list of 3D vectors corresponding to the B field at those points .. literalinclude:: ./source/magwire/biotsavart.py :language: python :linenos: solenoid_demo.py demonstrates the calculation and plotting of B fields generated by a simple solenoid. .. literalinclude:: ./source/magwire/solenoid_demo.py :language: python :linenos: