Message Boards Message Boards

GROUPS:

How to define Grad function?

Posted 2 months ago
545 Views
|
1 Reply
|
2 Total Likes
|

Hi!! I am working on a helical coordinate system. I know the scale factor of the coordinate system, but don't know how to define gradient term with Mathematica. Although we know Mathematica has inbuilt grad term for different coordinate system, example:

Grad [f [r, \[Theta], z], {r, \[Theta], z}, "Cylindrical"]

components of gradient terms in my case are enter image description here

here orthogonal coordinates and scale factor are enter image description here

Helical co-ordinates can be considered on a cone or on a cylinder, take a cylinder:

Here one has with slope k

(* \[CurlyPhi] as parametric angle, this gives the arc length, k is \
the slope *)
With[{\[Theta] = 270 \[Degree]},
 With[{k = 3/2},
  With[{r = 3},
   With[{uml = 1},
    ParametricPlot3D[{r Cos[\[Theta] + \[CurlyPhi]], 
      r Sin[\[Theta] + \[CurlyPhi]], (\[CurlyPhi]/(2 \[Pi])) k}, {\
\[CurlyPhi], 0, uml 2 \[Pi]}]
    ]
   ]
  ]
 ]

ArcLength is clear because the cylinder is developable, but

Clear[k, \[CurlyPhi], x, y, z, r, \[Theta], s]
ArcLength[{r Cos[\[Theta] + \[Phi]], 
  r Sin[\[Theta] + \[Phi]], (\[Phi]/(2 \[Pi])) k}, {\[Phi], 
  0, \[CurlyPhi]}]

(Sqrt[k^2 + 4 \[Pi]^2 r^2] \[CurlyPhi])/(2 \[Pi])

So

Clear[\[CurlyPhi]]
\[CurlyPhi] = 2 \[Pi] s/Sqrt[k^2 + 4 \[Pi]^2 r^2];

(* co-ordinate transformation *)
Clear[k, x, y, z, r, \[Theta], s]
x = r Cos[\[Theta] + 2 \[Pi] s/Sqrt[k^2 + 4 \[Pi]^2 r^2]];
y = r Sin[\[Theta] + 2 \[Pi] s/Sqrt[k^2 + 4 \[Pi]^2 r^2]];
z = s k/Sqrt[k^2 + 4 \[Pi]^2 r^2];

Clear[k, x, y, z, r, \[Theta], s]
r = Sqrt[x^2 + y^2] ;
(* \[Theta]=ArcTan[x,y]-2 \[Pi] s/Sqrt[k^2+4 \[Pi]^2 r^2] *)
\[Theta] = ArcTan[x, y] - 2 \[Pi] z/k;
s = Sqrt[k^2 + 4 \[Pi]^2 (x^2 + y^2)] z/k;

Test it a bit

(* k=3/2; {x,y,z}={7,4,8} \[Rule] {r,\[Theta],s}={Sqrt[65],-((32 \
\[Pi])/3)+ArcTan[4/7],16/3 Sqrt[9/4+260 \[Pi]^2]} *)

In[141]:= Clear[x, y, z, \[CurlyPhi]]
{r Cos[\[Theta] + \[CurlyPhi]], 
  r Sin[\[Theta] + \[CurlyPhi]], (\[CurlyPhi]/(2  \[Pi])) k} /. {r -> 
   Sqrt[65], \[Theta] -> -((32 \[Pi])/3) + 
    ArcTan[4/7], \[CurlyPhi] -> 
   2 \[Pi] (16/3 Sqrt[9/4 + 260 \[Pi]^2])/
     Sqrt[(3/2)^2 + 4 \[Pi]^2  65], k -> 3/2}

Out[142]= {7, 4, 8}

base vectore er, eth, es are non-orthogonal, of course

In[194]:= (* non-orthogonal base vectors er, eth, es *)
Clear[er]
er = D[x, r] {1, 0, 0} + D[y, r] {0, 1, 0} + D[z, r] {0, 0, 1}

Out[195]= {Cos[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]] + (
  8 \[Pi]^3 r^2 s Sin[(2 \[Pi] s)/Sqrt[
     k^2 + 4 \[Pi]^2 r^2] + \[Theta]])/(k^2 + 4 \[Pi]^2 r^2)^(
  3/2), -((8 \[Pi]^3 r^2 s Cos[(2 \[Pi] s)/Sqrt[
      k^2 + 4 \[Pi]^2 r^2] + \[Theta]])/(k^2 + 4 \[Pi]^2 r^2)^(3/2)) +
   Sin[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]], -((
  4 k \[Pi]^2 r s)/(k^2 + 4 \[Pi]^2 r^2)^(3/2))}

In[196]:= Clear[eth]
eth = D[x, \[Theta]] {1, 0, 0} + D[y, \[Theta]] {0, 1, 0} + 
  D[z, \[Theta]] {0, 0, 1}

Out[197]= {-r Sin[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]], 
 r Cos[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]], 0}

In[198]:= Clear[es]
es = D[x, s] {1, 0, 0} + D[y, s] {0, 1, 0} + D[z, s] {0, 0, 1}

Out[199]= {-((
  2 \[Pi] r Sin[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]])/
  Sqrt[k^2 + 4 \[Pi]^2 r^2]), (
 2 \[Pi] r Cos[(2 \[Pi] s)/Sqrt[
    k^2 + 4 \[Pi]^2 r^2] + \[Theta]])/Sqrt[
 k^2 + 4 \[Pi]^2 r^2], k/Sqrt[k^2 + 4 \[Pi]^2 r^2]}

In[200]:= er . eth // Simplify

Out[200]= -((8 \[Pi]^3 r^3 s)/(k^2 + 4 \[Pi]^2 r^2)^(3/2))

In[201]:= er . es // Simplify

Out[201]= -((4 \[Pi]^2 r s)/(k^2 + 4 \[Pi]^2 r^2))

In[202]:= es . eth // Simplify

Out[202]= (2 \[Pi] r^2)/Sqrt[k^2 + 4 \[Pi]^2 r^2]

from this one has the jacobi determinant

(* {er,eth,es} = jac . {e1,e2,e3} *)

In[205]:= Clear[jac]
jac = {{Cos[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]] + (
     8 \[Pi]^3 r^2 s Sin[(2 \[Pi] s)/Sqrt[
        k^2 + 4 \[Pi]^2 r^2] + \[Theta]])/(k^2 + 4 \[Pi]^2 r^2)^(
     3/2), -((
      8 \[Pi]^3 r^2 s Cos[(2 \[Pi] s)/Sqrt[
         k^2 + 4 \[Pi]^2 r^2] + \[Theta]])/(k^2 + 4 \[Pi]^2 r^2)^(
      3/2)) + Sin[(2 \[Pi] s)/Sqrt[
       k^2 + 4 \[Pi]^2 r^2] + \[Theta]], -((
     4 k \[Pi]^2 r s)/(k^2 + 4 \[Pi]^2 r^2)^(
     3/2))}, {-r Sin[(2 \[Pi] s)/Sqrt[
       k^2 + 4 \[Pi]^2 r^2] + \[Theta]], 
    r Cos[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]], 
    0}, {-((2 \[Pi] r Sin[(2 \[Pi] s)/Sqrt[
        k^2 + 4 \[Pi]^2 r^2] + \[Theta]])/Sqrt[
     k^2 + 4 \[Pi]^2 r^2]), (
    2 \[Pi] r Cos[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]])/
    Sqrt[k^2 + 4 \[Pi]^2 r^2], k/Sqrt[k^2 + 4 \[Pi]^2 r^2]}};

In[211]:= (* {e1,e2,e3}=ijac . {er, eth, es} *)
ijac = Inverse[jac] // Simplify

Out[211]= {{Cos[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]], -(
   Sin[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]]/r), (
  4 \[Pi]^2 r s Cos[(2 \[Pi] s)/Sqrt[
     k^2 + 4 \[Pi]^2 r^2] + \[Theta]])/(
  k^2 + 4 \[Pi]^2 r^2)}, {Sin[(2 \[Pi] s)/Sqrt[
    k^2 + 4 \[Pi]^2 r^2] + \[Theta]], 
  Cos[(2 \[Pi] s)/Sqrt[k^2 + 4 \[Pi]^2 r^2] + \[Theta]]/r, (
  4 \[Pi]^2 r s Sin[(2 \[Pi] s)/Sqrt[
     k^2 + 4 \[Pi]^2 r^2] + \[Theta]])/(
  k^2 + 4 \[Pi]^2 r^2)}, {0, -((2 \[Pi])/k), Sqrt[
  k^2 + 4 \[Pi]^2 r^2]/k}}

and now the gradient transforms by chain-rule and base vector transformation

In[292]:= (* gradient: chain rule and base vector transformation *)
Clear[er, eth, es, x, y, z]
(* grad f = *)
Collect[((Defer[D[f, r]] D[r, x] + 
       Defer[D[f, \[Theta]]] D[\[Theta], x] + 
       Defer[D[f, s]] D[s, x]) ijac[[1]] . {er, eth, es}
    + (Defer[D[f, r]] D[r, y] + Defer[D[f, \[Theta]]] D[\[Theta], y] +
        Defer[D[f, s]] D[s, y]) ijac[[2]] . {er, eth, es}
    + (Defer[D[f, r]] D[r, z] + Defer[D[f, \[Theta]]] D[\[Theta], z] +
        Defer[D[f, s]] D[s, z]) ijac[[3]] . {er, eth, es}) // 
  FullSimplify, {er, eth, es}]

Out[293]= er (\!\(
\*SubscriptBox[\(\[PartialD]\), \(r\)]f\) + (
    4 \[Pi]^2 Sqrt[x^2 + y^2] z \!\(
\*SubscriptBox[\(\[PartialD]\), \(s\)]f\))/(
    k Sqrt[k^2 + 4 \[Pi]^2 (x^2 + y^2)])) + 
 eth (-((2 \[Pi] Sqrt[k^2 + 4 \[Pi]^2 (x^2 + y^2)] \!\(
\*SubscriptBox[\(\[PartialD]\), \(s\)]f\))/
     k^2) + ((4 \[Pi]^2)/k^2 + 1/(x^2 + y^2)) \!\(
\*SubscriptBox[\(\[PartialD]\), \(\[Theta]\)]f\)) + 
 es ((4 \[Pi]^2 Sqrt[x^2 + y^2] z \!\(
\*SubscriptBox[\(\[PartialD]\), \(r\)]f\))/(
    k Sqrt[k^2 + 
      4 \[Pi]^2 (x^2 + y^2)]) + (((k^2 + 4 \[Pi]^2 (x^2 + y^2))^2 + 
       16 \[Pi]^4 (x^2 + y^2) z^2) \!\(
\*SubscriptBox[\(\[PartialD]\), \(s\)]f\))/(
    k^4 + 4 k^2 \[Pi]^2 (x^2 + y^2)) - (
    2 \[Pi] Sqrt[k^2 + 4 \[Pi]^2 (x^2 + y^2)] \!\(
\*SubscriptBox[\(\[PartialD]\), \(\[Theta]\)]f\))/k^2)

In[296]:= (* with other words *) 
Clear[r]
%293 /. {x^2 + y^2 -> r^2, Sqrt[x^2 + y^2] -> r}

Out[297]= er (\!\(
\*SubscriptBox[\(\[PartialD]\), \(r\)]f\) + (4 \[Pi]^2 r z \!\(
\*SubscriptBox[\(\[PartialD]\), \(s\)]f\))/(
    k Sqrt[k^2 + 4 \[Pi]^2 r^2])) + 
 eth (-((2 \[Pi] Sqrt[k^2 + 4 \[Pi]^2 r^2] \!\(
\*SubscriptBox[\(\[PartialD]\), \(s\)]f\))/
     k^2) + ((4 \[Pi]^2)/k^2 + 1/r^2) \!\(
\*SubscriptBox[\(\[PartialD]\), \(\[Theta]\)]f\)) + 
 es ((4 \[Pi]^2 r z \!\(
\*SubscriptBox[\(\[PartialD]\), \(r\)]f\))/(
    k Sqrt[k^2 + 
      4 \[Pi]^2 r^2]) + (((k^2 + 4 \[Pi]^2 r^2)^2 + 
       16 \[Pi]^4 r^2 z^2) \!\(
\*SubscriptBox[\(\[PartialD]\), \(s\)]f\))/(
    k^4 + 4 k^2 \[Pi]^2 r^2) - (2 \[Pi] Sqrt[k^2 + 4 \[Pi]^2 r^2] \!\(
\*SubscriptBox[\(\[PartialD]\), \(\[Theta]\)]f\))/k^2)

because still the subscript boxes appear in a code snippet, a picture:

Attachment

Attachments:
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract