| 1 |
.. _sec:coordtransforms: |
| 2 |
|
| 3 |
Coordinate transforms |
| 4 |
===================== |
| 5 |
|
| 6 |
Particle positions and vectors defined on the particles can be plotted |
| 7 |
in non-cartesian coordinate systems. The coordinate system can be set |
| 8 |
via the :ref:`sec:menu-o`, via the ``change coordinate system`` |
| 9 |
option. The actual coordinate transformations are defined in a |
| 10 |
standalone Fortran module called ``geometry.f90`` and the precise |
| 11 |
details can be determined by looking in this file. For reference, |
| 12 |
however the transformations are given below. |
| 13 |
|
| 14 |
Cylindrical Polar Coordinates |
| 15 |
------------------------------ |
| 16 |
|
| 17 |
For cylindrical coordinates the transformations are: |
| 18 |
|
| 19 |
.. math:: |
| 20 |
|
| 21 |
\begin{array}{lclp{1cm}lcl} |
| 22 |
R & = & \sqrt{x^2 + y^2} & & x & = & R\cos\phi \\ |
| 23 |
\phi & = & \tan^{-1}{(y/x)} &; & y & = & R\sin\phi \\ |
| 24 |
z & = & z & & z & = & z\\ |
| 25 |
\end{array} |
| 26 |
|
| 27 |
where vectors transform according to: |
| 28 |
|
| 29 |
.. math:: |
| 30 |
|
| 31 |
\begin{array}{lclp{1cm}lcl} |
| 32 |
v_R & = & v_x \frac{x}{R} + v_y \frac{y}{R} & & v_x & = & v_R \cos\phi - v_\phi \sin\phi \\ |
| 33 |
v_\phi & = & v_x \left(\frac{-y}{R}\right) + v_y \left(\frac{x}{R}\right) &; &v_y & = & v_R \sin\phi + v_\phi \cos\phi \\ |
| 34 |
v_z & = & v_z & & v_z & = & v_z. \\ |
| 35 |
\end{array} |
| 36 |
|
| 37 |
In the case where these vectors are velocities, the :math:`v_{\phi}` |
| 38 |
component corresponds to :math:`v_{\phi} = r\dot{\phi}`. At the origin |
| 39 |
we assume :math:`\phi = 0`, implying :math:`\cos\phi = 1` and therefore |
| 40 |
:math:`\frac{x}{R} = 1` and :math:`\frac{y}{R} = 0`. This ensures the |
| 41 |
transformations are reversible everywhere. |
| 42 |
|
| 43 |
Spherical Polar Coordinates |
| 44 |
---------------------------- |
| 45 |
|
| 46 |
For spherical coordinates the transformations are: |
| 47 |
|
| 48 |
.. math:: |
| 49 |
|
| 50 |
\begin{array}{lclp{1cm}lcl} |
| 51 |
r & = & \sqrt{x^2 + y^2 + z^{2}} & & x & = & r\cos\phi\sin\theta\\ |
| 52 |
\phi & = & \tan^{-1}{(y/x)} &; & y & = & r\sin\phi\sin\theta \\ |
| 53 |
\theta & = & \cos^{-1}(z/r) & & z & = & r\cos\theta \\ |
| 54 |
\end{array} |
| 55 |
|
| 56 |
where vectors transform according to: |
| 57 |
|
| 58 |
.. math:: |
| 59 |
|
| 60 |
\begin{array}{lclp{1cm}lcl} |
| 61 |
v_r & = & v_x \frac{x}{r} + v_y \frac{y}{r} + v_{z}\frac{z}{r} & & v_x & = & v_r \cos\phi\sin\theta- v_\phi \sin\phi + v_\theta \cos\phi\cos\theta \\ |
| 62 |
v_\phi & = & v_x \left(\frac{-y}{\sqrt{x^2 + y^{2}}}\right) + v_y \left(\frac{x}{\sqrt{x^2 + y^{2}}}\right) &; &v_y & = & v_r \sin\phi\sin\theta + v_\phi \cos\phi + v_{\theta} \sin\phi\cos\theta \\ |
| 63 |
v_\theta & = & v_{x}\frac{xz}{r \sqrt{x^{2} + y^{2}}} + v_{y}\frac{yz}{r \sqrt{x^{2} + y^{2}}} - v_{z}\frac{(x^{2} + y^{2})}{r\sqrt{x^{2} + y^{2}}} & & v_z & = & v_r \cos\theta - v_\theta \sin\theta. \\ |
| 64 |
\end{array} |
| 65 |
|
| 66 |
In the case where these vectors are velocities, the components |
| 67 |
:math:`v_{\phi}` and :math:`v_{\theta}` correspond to |
| 68 |
:math:`v_{\phi} = r\sin{\theta}\dot{\phi}` and |
| 69 |
:math:`v_{\theta} = r\dot{\theta}` respectively. |
| 70 |
|
| 71 |
Toroidal Coordinates |
| 72 |
--------------------- |
| 73 |
|
| 74 |
Toroidal coordinates represent a local frame of reference inside a |
| 75 |
torus. The coordinate transformations are given by |
| 76 |
|
| 77 |
.. math:: |
| 78 |
|
| 79 |
\begin{array}{lclp{1cm}lcl} |
| 80 |
r & = & \sqrt{[(x^2 + y^2)^{1/2} - R]^{2} + z^{2}} & & x & = & (r\cos\theta + R) \cos\phi \\ |
| 81 |
\theta & = & \tan^{-1} \left[\frac{z}{(\sqrt{x^{2} + y^{2}} - R)}\right] &; & y & = & (r\cos\theta + R)\sin\phi \\ |
| 82 |
\phi & = & \tan^{-1}(y/x) & & z & = & r\sin\theta \\ |
| 83 |
\end{array} |
| 84 |
|
| 85 |
where :math:`R` is the radius of the torus. The use of the inverse |
| 86 |
tangent in :math:`\theta` instead of :math:`\theta = \sin^{-1}(z/r)` is |
| 87 |
necessary to get the quadrant correct (via the ``atan2`` function). |
| 88 |
Vectors transform according to: |
| 89 |
|
| 90 |
.. math:: |
| 91 |
|
| 92 |
\begin{array}{lclp{2cm}lcl} |
| 93 |
v_r & = & v_x \frac{x(r_{cyl} - R)}{r r_{cyl}} + v_y \frac{y(r_{cyl} - R)}{r r_{cyl}} + v_{z} \frac{z}{r} & & v_x & = & v_r \cos\theta\cos\phi- v_\theta \sin\theta\cos\phi - v_\phi\sin\phi \\ |
| 94 |
v_\theta & = & v_x \frac{-zx}{r r_{cyl}} + v_y\frac{-zy}{r r_{cyl}} + v_{z}\frac{(r_{cyl} - R)}{r} &; &v_y & = & v_r \cos\theta\sin\phi - v_\theta \sin\theta\sin\phi + v_\phi\cos\phi \\ |
| 95 |
v_\phi & = & v_{x} \left(\frac{-y}{r_{cyl}}\right) + v_{y} \left(\frac{x}{r_{cyl}}\right) & & v_z & = & v_{r}\sin\theta + v_{\theta} \cos\theta \\ |
| 96 |
\end{array} |
| 97 |
|
| 98 |
where we have defined, for convenience, |
| 99 |
|
| 100 |
.. math:: r_{\rm cyl} = \sqrt{x^{2} + y^{2}} = r\cos\theta + R. \nonumber |
| 101 |
|
| 102 |
and the velocities :math:`v_\theta` and :math:`v_\phi` correspond to |
| 103 |
:math:`r \dot{\theta}` and :math:`r_{\rm cyl} \dot{\phi}`, respectively. |
| 104 |
The torus radius :math:`R` is a parameter in the ``geometry`` module and |
| 105 |
is set to :math:`1` by default. |
| 106 |
|
| 107 |
Flared Cylindrical Polar Coordinates |
| 108 |
------------------------------------- |
| 109 |
|
| 110 |
For flared cylindrical coordinates the transformations are: |
| 111 |
|
| 112 |
.. math:: |
| 113 |
|
| 114 |
\begin{array}{lclp{1cm}lcl} |
| 115 |
R & = & \sqrt{x^2 + y^2} & & x & = & R\cos\phi \\ |
| 116 |
\phi & = & \tan^{-1}{(y/x)} &; & y & = & R\sin\phi \\ |
| 117 |
z' & = & z \left(R_{\rm ref}/{R}\right)^\beta & & z & = & z' (R/R_{\rm ref})^\beta \\ |
| 118 |
\end{array} |
| 119 |
|
| 120 |
where :math:`R_{\rm ref}` is the reference radius and :math:`\beta` is |
| 121 |
the flaring index, both parameters that can be set by the user. Vectors |
| 122 |
transform according to: |
| 123 |
|
| 124 |
.. math:: |
| 125 |
|
| 126 |
\begin{array}{lclp{1cm}lcl} |
| 127 |
v_R & = & v_x \frac{x}{R} + v_y \frac{y}{R} & & v_x & = & v_R \cos\phi - v_\phi \sin\phi \\ |
| 128 |
v_\phi & = & v_x \left(\frac{-y}{R}\right) + v_y \left(\frac{x}{R}\right) &; &v_y & = & v_R \sin\phi + v_\phi \cos\phi \\ |
| 129 |
v_{z'} & = & -\beta \frac{xz}{R^2} \left(\frac{R_{\rm ref}}{R}\right)^\beta v_x -\beta \frac{yz}{R^2} \left(\frac{R_{\rm ref}}{R}\right)^\beta v_y + \left(\frac{R_{\rm ref}}{R}\right)^\beta v_z & & v_z & = & \beta \frac{z'}{R} \left(\frac{R}{R_{\rm ref}}\right)^\beta v_R + \left(\frac{R}{R_{\rm ref}}\right)^\beta v_{z'}. \\ |
| 130 |
\end{array} |
| 131 |
|
| 132 |
In the case where these vectors are velocities, the :math:`v_{\phi}` |
| 133 |
component corresponds to :math:`v_{\phi} = r\dot{\phi}`. |
| 134 |
|
| 135 |
Logarithmic Flared Cylindrical Polar Coordinates |
| 136 |
------------------------------------------------- |
| 137 |
|
| 138 |
For logarithmic flared cylindrical coordinates the transformations are: |
| 139 |
|
| 140 |
.. math:: |
| 141 |
|
| 142 |
\begin{array}{lclp{1cm}lcl} |
| 143 |
d & = & \log_{10} ( \sqrt{x^2 + y^2} ) & & x & = & R\cos\phi \\ |
| 144 |
\phi & = & \tan^{-1}{(y/x)} &; & y & = & R\sin\phi \\ |
| 145 |
z' & = & z \left(R_{\rm ref}/{R}\right)^\beta & & z & = & z' (R/R_{\rm ref})^\beta \\ |
| 146 |
\end{array} |
| 147 |
|
| 148 |
where :math:`R_{\rm ref}` is the reference radius and :math:`\beta` is |
| 149 |
the flaring index, both parameters that can be set by the user. Vectors |
| 150 |
transform according to: |
| 151 |
|
| 152 |
.. math:: |
| 153 |
|
| 154 |
\begin{array}{lclp{1cm}lcl} |
| 155 |
v_d & = & v_x \frac{x}{R}f^{-1} + v_y \frac{y}{R}f^{-1} & & v_x & = & f v_d \cos\phi - v_\phi \sin\phi \\ |
| 156 |
v_\phi & = & v_x \left(\frac{-y}{R}\right) + v_y \left(\frac{x}{R}\right) &; &v_y & = & f v_d \sin\phi + v_\phi \cos\phi \\ |
| 157 |
v_{z'} & = & -\beta \frac{xz}{R^2} \left(\frac{R_{\rm ref}}{R}\right)^\beta v_x -\beta \frac{yz}{R^2} \left(\frac{R_{\rm ref}}{R}\right)^\beta v_y + \left(\frac{R_{\rm ref}}{R}\right)^\beta v_z & & v_z & = & \beta \frac{z'}{R} \left(\frac{R}{R_{\rm ref}}\right)^\beta f v_d + \left(\frac{R}{R_{\rm ref}}\right)^\beta v_{z'}. \\ |
| 158 |
\end{array} |
| 159 |
|
| 160 |
where :math:`R \equiv 10^d` and correspondingly :math:`d = \log_{10} R` |
| 161 |
and :math:`f \equiv R \ln (10)`. |