# Plotting a vector field on a cylinder

Assume a parametric equation for a cylinder

$$\mathrm{cyl} (\theta, z) = (r \cos\theta, r \sin\theta,z)$$

and a vector field given by

$$\mathrm{vecField} (\theta, z)=\frac{\sin(\alpha)}{r}\partial_\theta \mathrm{cyl} + \cos(\alpha)\partial_z \mathrm{cyl},$$

where $$\partial_\theta \mathrm{cyl},\partial_z \mathrm{cyl}$$ are the tangent vectors of the cylindrical surface which can be calculated as $$(-\sin\theta,\cos\theta,0)$$ and $$(0,0,1)$$, respectively. The equation for the vector field becomes

$$\mathrm{vecField} (\theta, z)=(-\sin\theta \sin(\alpha)/r, \cos\theta \sin(\alpha)/r, \cos(\alpha))$$

where $$\alpha = \pi/3$$.

How can one plot the vector field on the cylindrical surface with Mathematica?

• Commented Apr 16 at 20:09

First define the cylinder:

r = 1;
pos[th_, z_] :=  {r  Cos[th], r  Sin[th], z};


Then define both base vectors and the vectors of the vector field:

eth[th_, z_] := {-Sin[th], Cos[th], 0};
ez = {0, 0, 1};

vecs = Table[
Arrow[{pos[th, z],
pos[th, z] + 0.4 (Sin[th]/r  eth[th, z] + Cos[th]  ez)}], {z, 0,
2, 0.5}, {th, 0, 2 Pi, Pi/8}];


Finally, draw the graphics:

Graphics3D[{vecs, Cylinder[{{0, 0, 0}, {0, 0, 2}}]}]


Clear[x, y, r];
field = {-Sin[θ] Sin[α]/r, Cos[θ] Sin[α]/r, Cos[α]};
field2 = TransformedField["Cylindrical" -> "Cartesian",
field, {r, θ, z} -> {x, y, zz}];

α = π/3; r = 1;
VectorPlot3D[field2, {x, -1, 1}, {y, -1, 1}, {z, -1, 1},
VectorScaling -> Automatic,
VectorPoints ->
Flatten[Table[{r Cos[θ], r Sin[θ], z}, {θ, 0, 2 π, π/16}, {z, -1, 1, .1}], 1]]


## Updated

Alternatively,

SliceVectorPlot3D[field2,
x^2 + y^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}]