Electric Potential and Field of a Dipole
Electric Potential and Field of a Dipole
Compute the electric field of a dipole from its potential and verify that it is a vacuum solution by computing the divergence:
Vs = (p Cos[θ]) / r ^ 2Es = -Grad[Vs, {r, θ, φ}, "Spherical"]Div[Es, {r, θ, φ}, "Spherical"] == 0Compute the equivalent fields in Cartesian coordinates for p1 and visualize the equipotential surfaces and lines of force:
Vc = TransformedField[ "Spherical" -> "Cartesian", Vs, {r, θ, φ} -> {x, y, z}] /. p -> 1Ec = TransformedField["Spherical" -> "Cartesian", Es, {r, θ, φ} -> {x, y, z}] /. p -> 1equipotentials = ContourPlot3D[Vc, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, ContourStyle -> Table[{Opacity[.5], Hue[i / 10]}, {i, 7}], Contours -> {-50, -5, -1, 0, 1, 5, 50}, Mesh -> None];electricField = VectorPlot3D[Ec, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, VectorAspectRatio -> 1 / 4, VectorScaling -> Automatic];Show[equipotentials, electricField]