2
$\begingroup$

I have a spherical vector wave for an electric field:

e[r_, θ_, ϕ_, t_] := (Sin[θ]/r) [Cos[r - t] - Sin[r - t]/r]

which points in the ϕ direction. In mathematics, I would simply append a unit vector $\hat{\phi}$ to the end of the equation. Likewise for other possible components pointing in the θ and r directions. Does Mathematica 11 have such unit vectors?

$\endgroup$
  • 3
    $\begingroup$ Wouldn't 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 as Grad[] 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$ – eyorble Feb 11 '18 at 0:30
  • $\begingroup$ Look at CoordinateTransformationData, friends, the related tutorial in the documentation... $\endgroup$ – José Antonio Díaz Navas Feb 11 '18 at 12:08
  • $\begingroup$ CoordinateTransformationData is not in the documentation center. But I did find some useful things in CoordinateTransform. $\endgroup$ – Michael B. Heaney Feb 11 '18 at 15:31
  • 2
    $\begingroup$ It's CoordinateTransformData (no "ation" between the "m" and the "D"). $\endgroup$ – Itai Seggev Mar 14 '18 at 22:21
  • 1
    $\begingroup$ You might be interested in this post about coordinate transformations in elliptical coordinates. mathematica.stackexchange.com/questions/149401/… $\endgroup$ – Jose Enrique Calderon Apr 1 at 3:22
7
$\begingroup$

Mathematica does all its computations in an orthonormal basis. You simply need to specify what coordinate system you're working in. So for your example, you just multiply by {0, 0, 1}:

e[r_, θ_, ϕ_, t_] := (Sin[θ]/r)[Cos[r - t] - Sin[r - t]/r] {0, 0, 1}

Apparently this is a pure wave in vacuum, as the divergence is zero:

Div[e[r, θ, ϕ, t], {r, θ, ϕ}, "Spherical"]
(* 0 *)

Similarly, a pure Coulomb electric field would be

 col[r_, θ_, ϕ_] := {1/r^2, 0, 0}
 Div[col[r, θ, ϕ], {r, θ, ϕ}, "Spherical"]
 (* 0 *)

I suggest you look at the the tutorials tutorial/VectorAnalysis and tutorial/ChangingCoordinateSystems and the functions linked therefrom for more.

$\endgroup$
3
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ Out of curiosity, how do these formulas compare to the formulas generated by TransformedField? $\endgroup$ – eyorble Feb 11 '18 at 23:49
  • $\begingroup$ Hopefully they are the same, but as a personal preference, I find most of the new MMA vector analysis functions a little kludgy. Too many inputs required for me. $\endgroup$ – Bill Watts Feb 12 '18 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.