Magnetic field around electrical conductors

This program can be used to calculate magnetic fields of arbitrarily shaped conductor loops in the plane of the loop or of several long straight wires in a plane perpendicular to the wires. In the latter case, field lines can be displayed in the image.


Downloads


Operation

First select the size of the section you want to view (enter the width of the section in meters) and enter the desired current. Then select whether you want to calculate the magnetic field of a conductor loop or of long straight wires.

Firstly, "Conductor loop": Use the mouse to draw a conductor loop of the desired shape in the image (hold down the left mouse button while drawing). The loop is automatically closed when you release the mouse button. If you now move the mouse over the image, the currently calculated field strength B (= flux density) of the magnetic field at the location of the cursor is displayed. Then press the "Display magnetic field" button. The calculation of the image can take a few seconds to minutes, depending on how many pixels your section has and how long the conductor is. The coordinate system is selected as follows: x to the right, y upwards, z out of the screen. In the conductor loop, the magnetic field in the plane of the loop only has a z component. The color scale is selected so that yellow means positive Bz (out of the screen) and blue means negative Bz (into the screen). The brightness of the image can be varied using the arrow keys.

Secondly, "Perpendicular to straight wires": In this variant, the magnetic field of (infinitely long straight) conductors running parallel to the z-axis is calculated. Click with the mouse on a point in the image at which the conductor should penetrate the image plane(xy plane). Left-clicking means that the current flows in the positive z-direction(out of the screen) and right-clicking means that the current should flow in the negative z-direction(into the screen). The currently calculated amount of the field strength B (= flux density) is always displayed at the cursor. When all conductors have been drawn in, press the "Display magnetic field" button to calculate the image. The calculation is much faster than in the case above, as there is no need to integrate. The brightness of the image can be varied using the arrow buttons. The calculation assumes that the diameter of the wire is smaller than one pixel. Once the image has been calculated, you can click in the image with the mouse to draw field lines in it. An arrow on the field line indicates the direction of B. In certain cases, calculating a field line can take several seconds. To delete the field lines, simply recalculate the image.

The currently displayed image can be saved as a graphic file via the menu or printed directly.


Numerical realization

All calculations are based on the Biot Savart law. In the case of the conductor loop, it is integrated over the loop, whereby this is broken down into path elements that correspond approximately to the extent of a pixel. In the case of the wires, only the contributions of the individual wires need to be summed, as the integration over the infinitely long wire was previously carried out analytically. The magnetic field is calculated for each pixel and displayed in the appropriate color. To calculate the field lines, the cursor is followed from the direction of B in small steps (step size 1/1000 pixel). If the field line runs too far out into empty space and has not closed after 10 million steps, the calculation is stopped and the path is also calculated backwards from the cursor. Normally, however, the field line closes by itself and the calculation can be stopped at this moment. If B=0, no field line is calculated. In very unfavorable cases, a field line can erroneously become spiral-shaped due to numerical inaccuracy.