vectoridl-programming-language

Plot a fieldline onto 2D magnetic field components in IDL


I would like to overplot a single fieldline at some radius or starting point, onto a contour of a magnetic field model without using the streamline function.

For example, here are the cartesian components of a dipole in the xz-plane:

  N=20
  
  z=(findgen(N)/(N-1))*10. - 5.
  x=z
  
  ; 2D arrays
  xx=rebin(reform(x, n, 1), n, n)
  zz=rebin(reform(z, 1, n), n, n)
  
  rr=sqrt(zz^2 + xx^2)
  
  mu=1.
  M=100.
  Bx=mu/(4.*!PI)*(3.*M*zz*xx/rr^5)
  Bz=mu/(4.*!PI)*(3.*M*zz^2/rr^5 - M/rr^3)
  
  B=sqrt(Bz^2 + Bx^2)

  ;s=STREAMLINE(Bx, Bz, x, z, XTITLE='X', YTITLE='Z')

The streamline function does show the dipole field as expected. I suppose I would have to iterate through the field at some starting point and calculate the tangent, but I'm not sure how to implement and plot the resultant line.

Many thanks for any help.


Solution

  • You can compute streamlines with PARTICLE_TRACE and do your own graphics however you want.