SpECTRE Documentation Coverage Report
Current view: top level - PointwiseFunctions/GeneralRelativity - KerrSchildCoords.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 18.8 % 16 3
Test Date: 2026-10-22 17:29:42
Legend: Lines:     hit not hit

            Line data    Source code
       1            0 : // Distributed under the MIT License.
       2              : // See LICENSE.txt for details.
       3              : 
       4              : #pragma once
       5              : 
       6              : #include <limits>
       7              : 
       8              : #include "DataStructures/Tensor/TypeAliases.hpp"
       9              : 
      10              : /// \cond
      11              : namespace PUP {
      12              : class er;
      13              : }  // namespace PUP
      14              : /// \endcond
      15              : 
      16              : namespace gr {
      17              : /*!
      18              :  * \brief Contains helper functions for transforming tensors in Kerr
      19              :  * spacetime to Kerr-Schild coordinates.
      20              :  *
      21              :  * Consider the Kerr-Schild form of the Kerr metric in Cartesian
      22              :  * coordinates \f$ (t, x, y, z)\f$,
      23              :  *
      24              :  * \f{align*}
      25              :  * ds^2 = -dt^2 + dx^2 + dy^2 + dz^2 + \dfrac{2Mr^3}{r^4 + a^2 z^2}
      26              :  * \left[dt + \dfrac{r(x\,dx + y\,dy)}{r^2 + a^2} +
      27              :  * \dfrac{a(y\,dx - x\,dy)}{r^2 + a^2} + \dfrac{z}{r}dz\right]^2,
      28              :  * \f}
      29              :  *
      30              :  * where \f$r\f$ is the function defined through
      31              :  *
      32              :  * \f{align*}
      33              :  * r^2(x, y, z) = \frac{x^2 + y^2 + z^2 - a^2}{2} +
      34              :  * \sqrt{\left(\frac{x^2 + y^2 + z^2 - a^2}{2}\right)^2 + a^2 z^2}.
      35              :  * \f}
      36              :  *
      37              :  * Depending on the physical context, the following coordinate transformations
      38              :  * are usually adopted:
      39              :  *
      40              :  * - \em Spherical \em coordinates, defined by the usual transformation
      41              :  *
      42              :  *   \f{align*}
      43              :  *   x &= r_\text{sph}\sin\theta\cos\phi,\\
      44              :  *   y &= r_\text{sph}\sin\theta\sin\phi,\\
      45              :  *   z &= r_\text{sph}\cos\theta.
      46              :  *   \f}
      47              :  *
      48              :  *   Note that \f$r_\text{sph} \neq r\f$, so the
      49              :  *   horizon of a Kerr black hole is \em not at constant \f$r_\text{sph}\f$.
      50              :  *
      51              :  * - \em Oblate \em spheroidal \em coordinates,
      52              :  *
      53              :  *   \f{align*}
      54              :  *   x &= \sqrt{r^2 + a^2}\sin\vartheta\cos\phi,\\
      55              :  *   y &= \sqrt{r^2 + a^2}\sin\vartheta\sin\phi,\\
      56              :  *   z &= r\cos\vartheta.
      57              :  *   \f}
      58              :  *
      59              :  *   Notice that \f$r\f$ is that defined in the Kerr-Schild form of the Kerr
      60              :  *   metric, so the horizon is at constant \f$r\f$. (As it will be noted below,
      61              :  *   \f$r\f$ corresponds to the Boyer-Lindquist radial coordinate.) Also, note
      62              :  *   that the azimuthal angle \f$\phi\f$ is the same as the corresponding
      63              :  *   angle in spherical coordinates, whereas the zenithal angle
      64              :  *   \f$\vartheta\f$ differs from the corresponding angle \f$\theta\f$.
      65              :  *
      66              :  * - \em Kerr \em coordinates (sometimes also referred to as
      67              :  *   "Kerr-Schild coordinates"), defined by
      68              :  *
      69              :  *   \f{align*}
      70              :  *   x &= (r \cos\varphi - a \sin\varphi)\sin\vartheta =
      71              :  *   \sqrt{r^2 + a^2}\sin\vartheta\cos\left(\varphi +
      72              :  *   \tan^{-1}(a/ r)\right),\\
      73              :  *   y &= (r \sin\varphi + a \cos\varphi)\sin\vartheta =
      74              :  *   \sqrt{r^2 + a^2}\sin\vartheta\sin\left(\varphi +
      75              :  *   \tan^{-1}(a/ r)\right),\\
      76              :  *   z &= r \cos\vartheta.
      77              :  *   \f}
      78              :  *
      79              :  *   These are the coordinates used in the gr::KerrSchildCoords class.
      80              :  *   Notice that \f$r\f$ and \f$\vartheta\f$ are the same as those in
      81              :  *   spheroidal coordinates, whereas the azimuthal angle
      82              :  *   \f$\varphi \neq \phi\f$.
      83              :  *
      84              :  *   \note Kerr's original "advanced Eddington-Finkelstein" form of his metric
      85              :  *   is retrieved by performing the additional transformation \f$t = u - r\f$.
      86              :  *   Note that Kerr's choice of the letter \f$u\f$ for the time coordinate
      87              :  *   is not consistent with the convention of denoting the advanced time
      88              :  *   \f$v = t + r\f$ (in flat space), and the retarded time \f$u = t - r\f$
      89              :  *   (in flat space). Finally, note that Kerr's original metric has the sign
      90              :  *   of \f$a\f$ flipped.
      91              :  *
      92              :  *   The Kerr coordinates have been used in the hydro community to evolve the
      93              :  *   GRMHD equations. They are the intermediate step in getting the Kerr metric
      94              :  *   in Boyer-Lindquist coordinates. The relation between both is
      95              :  *
      96              :  *   \f{align*}
      97              :  *   dt_\text{BL} &=
      98              :  *   dt - \frac{2M r\,dr}{r^2 - 2Mr + a^2}, \\
      99              :  *   dr_\text{BL} &= dr,\\
     100              :  *   d\theta_\text{BL} &= d\vartheta,\\
     101              :  *   d\phi_\text{BL} &= d\varphi - \frac{a\,dr}{r^2-2Mr + a^2}.
     102              :  *   \f}
     103              :  *
     104              :  *   The above transformation makes explicit that \f$r\f$ is the Boyer-Lindquist
     105              :  *   radial coodinate, \f$ r = r_\text{BL}\f$. Likewise,
     106              :  *   \f$\vartheta = \theta_\text{BL}\f$.
     107              :  *
     108              :  *   \note Sometimes (especially in the GRMHD community), the Kerr coordinates
     109              :  *   as defined above are referred to as "spherical Kerr-Schild" coordinates.
     110              :  *   These should not be confused with the true spherical coordinates defined
     111              :  *   in this documentation.
     112              :  *
     113              :  *   The Kerr metric in Kerr coodinates is sometimes used to write analytic
     114              :  *   initial data for hydro simulations. In this coordinate system, the
     115              :  *   metric takes the form
     116              :  *
     117              :  *   \f{align*}
     118              :  *   ds^2 &= -(1 - B)\,dt^2 + (1 + B)\,dr^2 + \Sigma\,d\vartheta^2 +
     119              :  *   \left(r^2 + a^2 + B a^2\sin^2\vartheta\right)\sin^2\vartheta\,d\varphi^2\\
     120              :  *   &\quad + 2B\,dt\,dr - 2aB\sin^2\vartheta\,dt\,d\varphi -
     121              :  *   2a\left(1 + B\right)\sin^2\vartheta\,dr\,d\varphi,
     122              :  *   \f}
     123              :  *
     124              :  *   where \f$B = 2M r/ \Sigma\f$ and \f$\Sigma = r^2 + a^2\cos^2\vartheta\f$.
     125              :  *   Using the additional relations
     126              :  *
     127              :  *   \f{align*}
     128              :  *   \sin\vartheta &= \sqrt{\frac{x^2 + y^2}{r^2 + a^2}},\quad
     129              :  *   \cos\vartheta = \frac{z}{r},\\
     130              :  *   \sin\varphi &= \frac{y r - x a}{\sqrt{(x^2 + y^2)(r^2 + a^2)}},\quad
     131              :  *   \cos\varphi = \frac{x r + y a}{\sqrt{(x^2 + y^2)(r^2 + a^2)}},
     132              :  *   \f}
     133              :  *
     134              :  *   the Jacobian of the transformation to Cartesian Kerr-Schild coordinates is
     135              :  *
     136              :  *   \f{align*}
     137              :  *   \dfrac{\partial(x, y, z)}{\partial(r, \vartheta, \varphi)} &=
     138              :  *   \left(\begin{array}{ccc}
     139              :  *   \dfrac{xr + ya}{r^2 + a^2} &
     140              :  *   \dfrac{xz}{r}\sqrt{\dfrac{r^2 + a^2}{x^2 + y^2}} & -y\\
     141              :  *   \dfrac{yr - ax}{r^2 + a^2} &
     142              :  *   \dfrac{yz}{r}\sqrt{\dfrac{r^2 + a^2}{x^2 + y^2}} & x\\
     143              :  *   \dfrac{z}{r} & - r\sqrt{\dfrac{x^2 + y^2}{r^2 + a^2}} & 0
     144              :  *   \end{array}\right),
     145              :  *   \f}
     146              :  *
     147              :  *   which can be used to transform tensors between both coordinate systems.
     148              :  */
     149            1 : class KerrSchildCoords {
     150              :  public:
     151            0 :   KerrSchildCoords() = default;
     152            0 :   KerrSchildCoords(const KerrSchildCoords& /*rhs*/) = default;
     153            0 :   KerrSchildCoords& operator=(const KerrSchildCoords& /*rhs*/) = default;
     154            0 :   KerrSchildCoords(KerrSchildCoords&& /*rhs*/) = default;
     155            0 :   KerrSchildCoords& operator=(KerrSchildCoords&& /*rhs*/) = default;
     156            0 :   ~KerrSchildCoords() = default;
     157              : 
     158            0 :   KerrSchildCoords(double bh_mass, double bh_dimless_spin);
     159              : 
     160              :   /// Transforms a spatial vector from Kerr (or "spherical Kerr-Schild")
     161              :   /// coordinates to Cartesian Kerr-Schild coordinates. If applied on points
     162              :   /// on the z-axis, the vector to transform must have a vanishing
     163              :   /// \f$v^\vartheta\f$ in order for the transformation to be single-valued.
     164              :   template <typename DataType>
     165            1 :   tnsr::I<DataType, 3, Frame::Inertial> cartesian_from_spherical_ks(
     166              :       const tnsr::I<DataType, 3, Frame::NoFrame>& spatial_vector,
     167              :       const tnsr::I<DataType, 3, Frame::Inertial>& cartesian_coords) const;
     168              : 
     169              :   /// Kerr-Schild \f$r^2\f$ in terms of the Cartesian coordinates.
     170              :   template <typename DataType>
     171            1 :   Scalar<DataType> r_coord_squared(
     172              :       const tnsr::I<DataType, 3, Frame::Inertial>& cartesian_coords) const;
     173              : 
     174              :   // NOLINTNEXTLINE(google-runtime-references)
     175            0 :   void pup(PUP::er& /*p*/);
     176              : 
     177              :  private:
     178            0 :   friend bool operator==(const KerrSchildCoords& lhs,
     179              :                          const KerrSchildCoords& rhs);
     180              : 
     181              :   // The spatial components of the Jacobian of the transformation from
     182              :   // Kerr coordinates to Cartesian coordinates (x, y, z).
     183              :   template <typename DataType>
     184            0 :   tnsr::Ij<DataType, 3, Frame::NoFrame> jacobian_matrix(
     185              :       const DataType& x, const DataType& y, const DataType& z) const;
     186              : 
     187            0 :   double spin_a_ = std::numeric_limits<double>::signaling_NaN();
     188              : };
     189              : 
     190            0 : bool operator!=(const KerrSchildCoords& lhs, const KerrSchildCoords& rhs);
     191              : 
     192              : }  // namespace gr
        

Generated by: LCOV version 2.0-1