You need to be careful in using MMA's coordinate transform function. MMA's formulas are for converting a single point vector from one coordinate system to another. From what I am reading, you are more interested in the electric field vector {er, eth, ephi}
which is similar to a velocity vector {vr, vtheta, vphi}
and the like. None of the components of those vectors are angles as some components of spherical and cylindrical coordinates. The point conversions MMA uses going from Cylindrical and Spherical to Cartesian and back are.
(* Point Conversions *)
CylToCart[{ρ_,ϕ_,z_}]:={ρ Cos[ϕ],ρ Sin[ϕ],z};
SphToCart[{r_,θ_,ϕ_}]:={r Sin[θ] Cos[ϕ],r Sin[θ] Sin[ϕ],r Cos[θ]};
CartToCyl[{x_,y_,z_}]:={Sqrt[x^2+y^2],ArcTan[x,y],z};
CartToSph[{x_,y_,z_}]:={Sqrt[x^2+y^2+z^2],ArcTan[z,Sqrt[x^2+y^2]],ArcTan[x,y]};
Now we can convert E field, velocity, force, etc. vectors from Cartesian to Spherical and back.
(* Vector Component Conversons *)
(* Spherical *)
arSphToCart[ar_]:=SphToCart[{ar,θ,ϕ}];
aθSphToCart[aθ_]:=SphToCart[{aθ,θ+π/2,ϕ}];
aϕSphToCart[aϕ_]:=SphToCart[{aϕ,π/2,ϕ+π/2}];
aSphToCart[{ar_,aθ_,aϕ_}]:=arSphToCart[ar]+aθSphToCart[aθ]+aϕSphToCart[aϕ];
aCartToSph[{ax_,ay_,az_}]:={Sin[θ] (ax Cos[ϕ]+ay Sin[ϕ])+az Cos[θ],Cos[θ] (ax Cos[ϕ]+ay Sin[ϕ])-az Sin[θ],ay Cos[ϕ]-ax Sin[ϕ]};
And Cylindrical to Cartesian and back.
(* Cylindrical *)
aρCylToCart[aρ_]:=CylToCart[{aρ,ϕ,0}];
aϕCylToCart[aϕ_]:=CylToCart[{aϕ,ϕ+π/2,0}];
azCylToCart[az_]:=CylToCart[{0,0,az}];
aCylToCart[{aρ_,aϕ_,az_}]:=aρCylToCart[aρ]+aϕCylToCart[aϕ]+azCylToCart[az];
aCartToCyl[{ax_,ay_,az_}]:={ax Cos[ϕ]+ay Sin[ϕ],ay Cos[ϕ]-ax Sin[ϕ],az};
I do not know of any way to tell MMA what coordinate system a particular vector is using. As long as you are consistent, you can perform dot and cross products without conversion. For operations that include derivatives such as Div
and Grad
, you probably need to convert to Cartesian, operate, and then convert back.
As long as you are consistent, and you know what coordinate system a vector is using, you can use {0,0,1}
for a spherical unit vector in the phi direction.
phihat={0,0,1}
suffice, as a vector of length 1 in the phi direction, assuming same coordinate ordering as in the function? Many functions such asGrad[]
take a coordinate chart name as an option, wherein you can specific spherical coordinates, but as far as I know the unit vectors are not fundamentally different between systems so long as they're consistent within them and converted properly when the coordinate system is changed. $\endgroup$CoordinateTransformationData
, friends, the related tutorial in the documentation... $\endgroup$CoordinateTransformData
(no "ation" between the "m" and the "D"). $\endgroup$