Tuesday 4 July 2017

How to display magnetic field lines in IDL?

It is a common problem in visualization of magnetic fields. If we assume that the potential $A$ of the magnetic field is knows, the field lines are, by definition, iso-$A$ curves. The quickest way to display them is by using the CONTOUR procedure. If the potential field is given as a 2D variable potential, then:
IDL> CONTOUR, potential, levels = levels, /xs, /ys
gives:

However, the information here is not complete without showing the actual direction of the field along the lines. It is easy to do it in IDL:

IDL> CONTOUR, potential, levels = levels, /xs, /ys
IDL> CONTOUR, potential, levels = levels, /xs, /ys, path_xy = c
IDL> FOR i = 1, N_ELEMENTS(c)/2-1, 50 DO $     ARROW, c[0, i-1], c[1, i-1], c[0, i], c[1, i], /norm, /solid, hsize = 5         

produces:
It is much better now, but the arrow heads from different field lines make it crowded. If we are interested in individual field lines, we can add color to this:


No comments:

Post a Comment