Skip to content
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

Merged
merged 29 commits into from
Mar 1, 2021
Merged

Conversation

bendudson
Copy link
Contributor

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).

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).
@bendudson bendudson added the work in progress Not ready for merging label Dec 5, 2020
@ZedThree
Copy link
Member

ZedThree commented Dec 7, 2020

Note, built docs are here: https://bout-dev--2165.org.readthedocs.build/en/2165/user_docs/coordinates.html

@bendudson bendudson mentioned this pull request Dec 7, 2020
bendudson and others added 6 commits December 7, 2020 15:14
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 <-> θ
@bendudson bendudson added documentation and removed work in progress Not ready for merging labels Dec 9, 2020
@bendudson bendudson changed the title WIP: Tidy up coordinate systems with explicit directions Tidy up coordinate systems with explicit directions Dec 9, 2020
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
Copy link
Contributor

@johnomotani johnomotani left a 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?

manual/sphinx/user_docs/coordinates.rst Outdated Show resolved Hide resolved
manual/sphinx/user_docs/coordinates.rst Outdated Show resolved Hide resolved
manual/sphinx/user_docs/coordinates.rst Outdated Show resolved Hide resolved
bendudson and others added 3 commits December 14, 2020 09:46
Co-authored-by: johnomotani <john.omotani@ukaea.uk>
Co-authored-by: johnomotani <john.omotani@ukaea.uk>
ZedThree
ZedThree previously approved these changes Jan 5, 2021
Copy link
Member

@ZedThree ZedThree left a 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! :)

Comment on lines +116 to +117
The sign of the poloidal field `{B_{\text{pol}}}` and toroidal field
`{B_{\text{tor}}}` can be either + or -.
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 -.

manual/sphinx/user_docs/coordinates.rst Outdated Show resolved Hide resolved
Co-authored-by: Peter Hill <zed.three@gmail.com>
ZedThree
ZedThree previously approved these changes Jan 5, 2021
Copy link
Contributor

@johnomotani johnomotani left a 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...

Comment on lines +116 to +117
The sign of the poloidal field `{B_{\text{pol}}}` and toroidal field
`{B_{\text{tor}}}` can be either + or -.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 -.

Comment on lines 275 to 285
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}
Copy link
Contributor

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 $B\cdot\nabla z = 0$? I think this should be the shift in \zeta-angle, etc.

Suggested change
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}

Copy link
Contributor Author

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 +/-)

Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor Author

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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`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)`.

Comment on lines 356 to 360
\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}
Copy link
Contributor

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

Suggested change
\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}

Comment on lines 392 to 401
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}
Copy link
Contributor

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

Suggested change
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}
Copy link
Contributor

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.
@johnomotani
Copy link
Contributor

Do we still need the 'Shifted radial derivatives' subsection? I guess it's for 'BOUT06-style' IncIntShear derivatives that we don't use any more (and should remove for v5?)? I've skipped checking that one...

johnomotani and others added 5 commits January 8, 2021 13:57
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>
Copy link
Contributor

@johnomotani johnomotani left a 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.

@bendudson bendudson merged commit 19c3997 into next Mar 1, 2021
@bendudson bendudson deleted the next-coordinates branch March 1, 2021 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants