-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tidy up coordinate systems with explicit directions #2165
Conversation
Define the directions of the poloidal and toroidal angles more carefully, so that at each step the direction of each coordinate is clearer. The new calculations clarify what happens when the poloidal field is negative. For the standard coordinate system (where J can be >0 or <0), the metric tensor doesn't change from what it was before. The calculation of the field line pitch and integrated shear however has been clarified (in terms of which toroidal direction is used). A new coordinate system is defined, with the Y coordinate reversed for negative poloidal field. This always has a positive Jacobian, and some metric elements reverse sign, but has the same properties (being Clebsch).
Note, built docs are here: https://bout-dev--2165.org.readthedocs.build/en/2165/user_docs/coordinates.html |
Co-authored-by: Peter Hill <zed.three@gmail.com>
Co-authored-by: Peter Hill <zed.three@gmail.com>
Co-authored-by: Peter Hill <zed.three@gmail.com>
Accidentally left in factor of sigma_Btheta in metric tensor for J>0 field-aligned coordinates.
Should have Btor in e_phi direction, not e_zeta.
- In the standard BOUT++ coordinates, there is a factor of sigma_Btheta, so the sign of zShift doesn't change if Bpol is changed. - The modified coordinates with J > 0 do change sign with Bpol
Some confusion about signs in these angles, but I think this is ok now.
Missing braces, too many ticks
Should be the same for both field-aligned coordinate systems, just reversed y <-> θ
1. Distinguish Jacobian in orthogonal (psi, theta, zeta) coordinates from Jacobian in (x,y,z) coordinates, since these differ by a sign when Bpol < 0. 2. Use η for parallel coordinate rather than y in right-handed field-aligned coordinate system.
Clarify which coordinates the J refers to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of typos and a clarification in the review comments.
Another question: should the Laplacian and perpendicular Laplacian expressions be written in terms of metric components so that if we're in the xyz coords, they're implicitly using d/dy and g_{yz}, etc. with \sigma_{B\theta} included?
I think we're going to end up using the 'x\etaz' coordinates for simulations with negative Bp? In that case, would it be better to swap the names y<->\eta so that 'xyz' is the (always right-handed) coordinate system that we'll actually use?
Co-authored-by: johnomotani <john.omotani@ukaea.uk>
Co-authored-by: johnomotani <john.omotani@ukaea.uk>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, assuming @johnomotani is happy with the maths! :)
The sign of the poloidal field `{B_{\text{pol}}}` and toroidal field | ||
`{B_{\text{tor}}}` can be either + or -. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify, are the signs independent of each other? Or do they both need to be the same sign?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, they are independent, but that could be clearer in the text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sign of the poloidal field `{B_{\text{pol}}}` and toroidal field | |
`{B_{\text{tor}}}` can be either + or -. | |
The sign of the poloidal field `{B_{\text{pol}}}` and toroidal field | |
`{B_{\text{tor}}}` can be independently either + or -. |
Co-authored-by: Peter Hill <zed.three@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more minor comments...
The sign of the poloidal field `{B_{\text{pol}}}` and toroidal field | ||
`{B_{\text{tor}}}` can be either + or -. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sign of the poloidal field `{B_{\text{pol}}}` and toroidal field | |
`{B_{\text{tor}}}` can be either + or -. | |
The sign of the poloidal field `{B_{\text{pol}}}` and toroidal field | |
`{B_{\text{tor}}}` can be independently either + or -. |
The `\texttt{zShift}` is used to connect grid cells along the magnetic | ||
field. It is the `z` angle of a point on a field line relative to a | ||
reference location: | ||
|
||
.. math:: | ||
|
||
\begin{aligned} | ||
\texttt{zShift}\left(x, y\right) &= \int_{y = 0}^{y}\frac{{\boldsymbol{B}}\cdot\nabla z}{{\boldsymbol{B}}\cdot\nabla y} dy \\ | ||
&= \int_{\theta = 0}^{\theta}\frac{{\sigma_{B\theta}}{B_{\text{tor}}}{h_\theta}}{{B_{\text{pol}}}R} d\theta \\ | ||
&= {\sigma_{B\theta}} \int_{\theta = 0}^{\theta} \nu d\theta | ||
\end{aligned} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
z
is the field-aligned coordinate, so isn't
The `\texttt{zShift}` is used to connect grid cells along the magnetic | |
field. It is the `z` angle of a point on a field line relative to a | |
reference location: | |
.. math:: | |
\begin{aligned} | |
\texttt{zShift}\left(x, y\right) &= \int_{y = 0}^{y}\frac{{\boldsymbol{B}}\cdot\nabla z}{{\boldsymbol{B}}\cdot\nabla y} dy \\ | |
&= \int_{\theta = 0}^{\theta}\frac{{\sigma_{B\theta}}{B_{\text{tor}}}{h_\theta}}{{B_{\text{pol}}}R} d\theta \\ | |
&= {\sigma_{B\theta}} \int_{\theta = 0}^{\theta} \nu d\theta | |
\end{aligned} | |
The `\texttt{zShift}` is used to connect grid cells along the magnetic | |
field. It is the `\zeta` angle of a point on a field line relative to a | |
reference location: | |
.. math:: | |
\begin{aligned} | |
\texttt{zShift}\left(x, y\right) &= \int_{y = 0}^{y}\frac{{\boldsymbol{B}}\cdot\nabla \zeta}{{\boldsymbol{B}}\cdot\nabla y} dy \\ | |
&= \int_{\theta = 0}^{\theta}\frac{{\sigma_{B\theta}}{B_{\text{tor}}}{h_\theta}}{{B_{\text{pol}}}R} d\theta \\ | |
&= {\sigma_{B\theta}} \int_{\theta = 0}^{\theta} \nu d\theta | |
\end{aligned} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
B dot e_z = 0, but B dot nabla z is the toroidal field (with a +/-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about that:
- nabla z != nabla zeta, and B dot nabla zeta is the toroidal field (with a +/-)
- we can write \vec{B} = Bp / htheta * \vec{e}_y, and e_i dot \nabla x^j = delta_i^j, so e_y dot \nabla z = 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it B dot e_z that's !=0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, quite right sorry: B = nabla x cross nabla z
so B dot nabla z
must be zero
|
||
The `\texttt{ShiftAngle}` is then defined as the change in | ||
`\texttt{zShift}` between `y=0` and `y=2\pi`: It is the change in the | ||
`z` coordinate after one poloidal circuit in `y`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`z` coordinate after one poloidal circuit in `y`. | |
`z` coordinate after one poloidal circuit in `y` and is related to the | |
safety factor by `\mathtt{ShiftAngle} = 2\pi q(x)`. |
\begin{aligned} | ||
\boldsymbol{e}_x =& J_{x\eta z}\left(\nabla y \times \nabla z\right) = {\sigma_{B\theta}} {\boldsymbol{e}}_\psi + I{\boldsymbol{e}}_\zeta \\ | ||
\boldsymbol{e}_\eta =& J_{x\eta z}\left(\nabla z \times \nabla x\right) = {\sigma_{B\theta}} {\boldsymbol{e}}_\theta + \nu{\boldsymbol{e}}_\zeta \\ | ||
\boldsymbol{e}_z =& J_{x\eta z}\left(\nabla x \times \nabla y\right) = {\boldsymbol{e}}_\zeta | ||
\end{aligned} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need \eta instead of y in a couple of places
\begin{aligned} | |
\boldsymbol{e}_x =& J_{x\eta z}\left(\nabla y \times \nabla z\right) = {\sigma_{B\theta}} {\boldsymbol{e}}_\psi + I{\boldsymbol{e}}_\zeta \\ | |
\boldsymbol{e}_\eta =& J_{x\eta z}\left(\nabla z \times \nabla x\right) = {\sigma_{B\theta}} {\boldsymbol{e}}_\theta + \nu{\boldsymbol{e}}_\zeta \\ | |
\boldsymbol{e}_z =& J_{x\eta z}\left(\nabla x \times \nabla y\right) = {\boldsymbol{e}}_\zeta | |
\end{aligned} | |
\begin{aligned} | |
\boldsymbol{e}_x =& J_{x\eta z}\left(\nabla \eta \times \nabla z\right) = {\sigma_{B\theta}} {\boldsymbol{e}}_\psi + I{\boldsymbol{e}}_\zeta \\ | |
\boldsymbol{e}_\eta =& J_{x\eta z}\left(\nabla z \times \nabla x\right) = {\sigma_{B\theta}} {\boldsymbol{e}}_\theta + \nu{\boldsymbol{e}}_\zeta \\ | |
\boldsymbol{e}_z =& J_{x\eta z}\left(\nabla x \times \nabla \eta\right) = {\boldsymbol{e}}_\zeta | |
\end{aligned} |
The `\texttt{zShift}` quantity is the `z` angle of a point on a field | ||
line relative to a reference location. This is a scalar which doesn't | ||
change if the sign of the `\eta` coordinate is reversed: | ||
|
||
.. math:: | ||
|
||
\begin{aligned} | ||
\texttt{zShift}\left(x, \eta\right) = \int_{\eta = 0}^{\eta}\frac{{\boldsymbol{B}}\cdot\nabla z}{{\boldsymbol{B}}\cdot\nabla \eta} d\eta = | ||
\int_{\theta = 0}^{{\sigma_{B\theta}}\theta}\frac{{\sigma_{B\theta}}{B_{\text{tor}}}{h_\theta}}{{B_{\text{pol}}}R} d\theta | ||
\end{aligned} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to comment above: \zeta-angle instead of z-angle
The `\texttt{zShift}` quantity is the `z` angle of a point on a field | |
line relative to a reference location. This is a scalar which doesn't | |
change if the sign of the `\eta` coordinate is reversed: | |
.. math:: | |
\begin{aligned} | |
\texttt{zShift}\left(x, \eta\right) = \int_{\eta = 0}^{\eta}\frac{{\boldsymbol{B}}\cdot\nabla z}{{\boldsymbol{B}}\cdot\nabla \eta} d\eta = | |
\int_{\theta = 0}^{{\sigma_{B\theta}}\theta}\frac{{\sigma_{B\theta}}{B_{\text{tor}}}{h_\theta}}{{B_{\text{pol}}}R} d\theta | |
\end{aligned} | |
The `\texttt{zShift}` quantity is the `\zeta` angle of a point on a field | |
line relative to a reference location. This is a scalar which doesn't | |
change if the sign of the `\eta` coordinate is reversed: | |
.. math:: | |
\begin{aligned} | |
\texttt{zShift}\left(x, \eta\right) = \int_{\eta = 0}^{\eta}\frac{{\boldsymbol{B}}\cdot\nabla \zeta}{{\boldsymbol{B}}\cdot\nabla \eta} d\eta = | |
\int_{\theta = 0}^{{\sigma_{B\theta}}\theta}\frac{{\sigma_{B\theta}}{B_{\text{tor}}}{h_\theta}}{{B_{\text{pol}}}R} d\theta | |
\end{aligned} |
@@ -226,9 +427,9 @@ magnetic field `{\boldsymbol{b}}_0` is given by | |||
|
|||
\begin{aligned} | |||
\partial^0_{||}f \equiv {\boldsymbol{b}}_0 \cdot\nabla f = | |||
\frac{1}{\sqrt{g_{yy}}}{\frac{\partial f}{\partial y}} = \frac{{B_{\text{pol}}}}{B{h_\theta}}{\frac{\partial f}{\partial y}}\end{aligned} | |||
\frac{1}{JB}{\frac{\partial f}{\partial y}} = \frac{{B_{\text{pol}}}}{B{h_\theta}}{\frac{\partial f}{\partial y}}\end{aligned} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The middle expression (with J) is fine, but the final one should be |B_pol| for the (x,eta,z) coords. Maybe we need to define something like \sigma_y = \{\sigma_{B\theta} for xyz | +1 for x\eta z\}
to use in places like this? I'll have a stab at this in a new set of comments (just to group that set of changes into one thread).
Keep track of correct signs for both x,y,z and x,eta,z coordinates. This commit goes through 'Differential operators in field-aligned coordinates', 'J x B in field-aligned coordinates' and 'Parallel current' sections.
Do we still need the 'Shifted radial derivatives' subsection? I guess it's for 'BOUT06-style' |
Co-authored-by: Peter Hill <zed.three@gmail.com>
Co-authored-by: Ben Dudson <bd512@york.ac.uk> Co-authored-by: Peter Hill <zed.three@gmail.com>
Next coordinates sigma y
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bendudson I think we can merge this if you're happy with it.
Define the directions of the poloidal and toroidal angles more carefully, so that at each step the direction of each coordinate is clearer.
The new calculations clarify what happens when the poloidal field is negative. For the standard coordinate system (where J can be >0 or <0), the metric tensor doesn't change from what it was before. The calculation of the field line pitch and integrated shear however has been clarified (in terms of which toroidal direction is used).
A new coordinate system is defined, with the Y coordinate reversed for negative poloidal field. This always has a positive Jacobian, and some metric elements reverse sign, but has the same properties (being Clebsch).