0

I am modeling a Helmholtz Coil as two dipoles from far away and I want to plot the magnetic field.

$$\mathbf{B}(\mathbf{r}) = \frac{\mu_0 |\mathbf{m}|}{4\pi r^3}\left(2\cos\theta\,\hat{\mathbf{r}} + \sin\theta\,\hat{\boldsymbol{\theta}}\right)\, .$$

I am struggling to plot the magnetic field in spherical coordinates in Python. Can somebody show me an easy way to plot 3D functions in spherical coordinates?

nicoguaro
  • 8,500
  • 6
  • 23
  • 49
  • Since your function is of the form $f(\theta,\phi)/r^3$, you could simply plot $f(\theta,\phi)$ using a colormap, either on the surface of a sphere embedded in 3d space or in an unwrapped 2D plot (think MATLAB's imagesc command). – smh Jun 22 '20 at 20:41
  • 1
    The configuration of a Helmholtz coil is axisymmetric, jut plot the field in 2D and show the axis of symmetry. Something like this http://hyperphysics.phy-astr.gsu.edu/hbase/magnetic/helmholtz.html but with point dipoles. – Maxim Umansky Jun 22 '20 at 21:04
  • Taking into account @MaximUmansky comment, I suggest that you check this answer: https://scicomp.stackexchange.com/questions/18760/visually-appealing-ways-to-plot-singular-vector-fields-with-matplotlib-or-other/27270#27270 – nicoguaro Jun 23 '20 at 00:35

0 Answers0