{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<script async src=\"https://www.googletagmanager.com/gtag/js?id=UA-59152712-8\"></script>\n",
    "<script>\n",
    "  window.dataLayer = window.dataLayer || [];\n",
    "  function gtag(){dataLayer.push(arguments);}\n",
    "  gtag('js', new Date());\n",
    "\n",
    "  gtag('config', 'UA-59152712-8');\n",
    "</script>\n",
    "\n",
    "# [Shifted Kerr-Schild Solution](https://arxiv.org/pdf/1704.00599.pdf) Initial Data\n",
    "\n",
    "## Authors: George Vopal & Zach Etienne\n",
    "### Formatting improvements courtesy Brandon Clark\n",
    "\n",
    "## This module sets up Shifted Kerr-Schild initial data [Etienne et al., 2017 GiRaFFE](https://arxiv.org/pdf/1704.00599.pdf).\n",
    "\n",
    "**Notebook Status:** <font color='green'><b> Validated </b></font>\n",
    "\n",
    "**Validation Notes:** This module has been validated to exhibit convergence to zero of the Hamiltonian and momentum constraint violations at the expected order to the exact solution (see plots at bottom of [the exact initial data validation start-to-finish tutorial notebook](Tutorial-Start_to_Finish-BSSNCurvilinear-Setting_up_Exact_Initial_Data.ipynb)).\n",
    "\n",
    "### NRPy+ Source Code for this module: [BSSN/ShiftedKerrSchild.py](../edit/BSSN/ShiftedKerrSchild.py)\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "## Introduction:\n",
    "Shifted Kerr-Schild coordinates are similar to the trumpet spacetime, in that $r=0$ maps to some finite radius surface in Kerr-Schild coordinates. The radial shift $r_0$ both reduces the black hole's coordinate size and causes the very strongly-curved spacetime fields at $r<r_{0}$ to vanish deep inside the horizon, which aids in numerical stability, e.g., when evolving hydrodynamic, MHD, and FFE fields inside the horizon."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc'></a>\n",
    "\n",
    "# Table of Contents:  \n",
    "$$\\label{toc}$$\n",
    "\n",
    "1. [Step 1](#initialize_nrpy): Set up the needed NRPy+ infrastructure and declare core gridfunctions\n",
    "1. [Step 2](#kerr_schild_lapse): The Kerr-Schild Lapse, Shift, and 3-Metric\n",
    "    1. [Step 2.a](#define_rho): Define $\\rho^{2}$, $\\alpha$, $\\beta^{r}$, $\\beta^{\\theta}$, $\\beta^{\\phi}$, $\\gamma_{r\\theta}$, $\\gamma_{\\theta\\phi}$\n",
    "    1. [Step 2.b](#nonzero_gamma): Define and construct nonzero components of $\\gamma_{ij}$\n",
    "1. [Step 3](#extrinsic_curvature): The extrinsic curvature $K_{ij}$\n",
    "    1. [Step 3.a](#abc): Define useful quantities $A$, $B$, $C$\n",
    "    1. [Step 3.b](#nonzero_k): Define and construct nonzero components of $K_{ij}$\n",
    "1. [Step 4](#code_validation): Code Validation against `BSSN.ShiftedKerrSchild` NRPy+ module\n",
    "1. [Step 5](#latex_pdf_output): Output this notebook to $\\LaTeX$-formatted PDF file"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='initialize_nrpy'></a>\n",
    "\n",
    "# Step 1: Set up the needed NRPy+ infrastructure and declare core gridfunctions \\[Back to [top](#toc)\\]\n",
    "$$\\label{initialize_nrpy}$$\n",
    "\n",
    "First, we will import the core modules from Python/NRPy+ and specify the main gridfunctions we will need.\n",
    "\n",
    "**Input for initial data**:\n",
    "\n",
    "* The black hole mass $M$.\n",
    "* The black hole spin parameter $a$\n",
    "* The radial offset $r_0$\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-03-07T17:06:11.813901Z",
     "iopub.status.busy": "2021-03-07T17:06:11.812847Z",
     "iopub.status.idle": "2021-03-07T17:06:12.137334Z",
     "shell.execute_reply": "2021-03-07T17:06:12.137835Z"
    }
   },
   "outputs": [],
   "source": [
    "# Step P0: Load needed modules\n",
    "import sympy as sp             # SymPy: The Python computer algebra package upon which NRPy+ depends\n",
    "import NRPy_param_funcs as par # NRPy+: Parameter interface\n",
    "import indexedexp as ixp       # NRPy+: Symbolic indexed expression (e.g., tensors, vectors, etc.) support\n",
    "import BSSN.ADM_Exact_Spherical_or_Cartesian_to_BSSNCurvilinear as AtoB\n",
    "\n",
    "# All gridfunctions will be written in terms of spherical coordinates (r, th, ph):\n",
    "r,th,ph = sp.symbols('r th ph', real=True)\n",
    "\n",
    "thismodule = \"ShiftedKerrSchild\"\n",
    "\n",
    "DIM = 3\n",
    "par.set_parval_from_str(\"grid::DIM\",DIM)\n",
    "\n",
    "# Input parameters:\n",
    "M, a, r0 = par.Cparameters(\"REAL\", thismodule,\n",
    "                           [\"M\", \"a\", \"r0\"],\n",
    "                           [1.0, 0.9,  1.0])\n",
    "\n",
    "# Auxiliary variables:\n",
    "rho2 = sp.symbols('rho2', real=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='kerr_schild_lapse'></a>\n",
    "\n",
    "# Step 2: The Kerr-Schild Lapse, Shift, and 3-Metric \\[Back to [top](#toc)\\]\n",
    "$$\\label{kerr_schild_lapse}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='define_rho'></a>\n",
    "\n",
    "## Step 2.a: Define $\\rho^{2}$, $\\alpha$, $\\beta^{r_{\\rm KS}}$, $\\beta^{\\theta}$, $\\beta^{\\phi}$, $\\gamma_{r_{\\rm KS}\\theta}$, $\\gamma_{\\theta\\phi}$ \\[Back to [top](#toc)\\]\n",
    "$$\\label{define_rho}$$\n",
    "\n",
    "The relationship between the Kerr-Schild radius $r_{\\rm KS}$ and the radial coordinate used on our numerical grid $r$, is given by\n",
    "\n",
    "$$\n",
    "r_{\\rm KS} = r + r_0,\n",
    "$$\n",
    "where $r_0\\ge 0$ is the radial shift.\n",
    "\n",
    "Notice that the radial shift has no impact on Jacobians since $\\frac{\\partial{r_{\\rm KS}}}{\\partial{r}}=1$. $r_0$ must be set to a value less than the horizon radius $R$, but not so close to $R$ that finite-difference stencils from outside the horizon cross $r=0$. Thus $r_0$ must be set with consideration of the numerical grid structure in mind, as nonzero values of $r_0$ will shrink the coordinate size of the black hole by exactly $r_0$.\n",
    "\n",
    "All of these equations are as defined in the appendix of the original GiRaFFE paper ([Etienne et al., 2017 GiRaFFE](https://arxiv.org/pdf/1704.00599.pdf)).\n",
    "<br>\n",
    "First, we define $\\rho^{2}$ as\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ \\rho^2 = r_{\\rm KS} + a^{2}\\cos^{2}(\\theta) $$\n",
    "\n",
    "<br>\n",
    "\n",
    "And we then define the Kerr-Schild lapse $\\alpha$ from equation (A.1)\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ \\alpha = \\frac{1}{\\sqrt{1 + \\frac{2Mr_{\\rm KS}}{\\rho^2}}} $$\n",
    "\n",
    "<br>\n",
    "\n",
    "And the shift $\\beta$ from equations (A.2) & (A.3)\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ \\beta^{r_{\\rm KS}} = \\alpha^2\\frac{2Mr_{\\rm KS}}{\\rho^2} $$\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ \\beta^{\\theta} = \\beta^{\\phi} = \\gamma_{r_{\\rm KS}\\theta} = \\gamma_{\\theta\\phi} = 0 $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-03-07T17:06:12.144231Z",
     "iopub.status.busy": "2021-03-07T17:06:12.143222Z",
     "iopub.status.idle": "2021-03-07T17:06:12.198719Z",
     "shell.execute_reply": "2021-03-07T17:06:12.199238Z"
    }
   },
   "outputs": [],
   "source": [
    "# Step 1: Define rho^2, alpha, beta^(r_{KS}), beta^(theta), beta^(phi), gamma_{r_{KS}theta}, gamma_{theta\\phi}\n",
    "\n",
    "# r_{KS} = r + r0\n",
    "rKS = r+r0\n",
    "\n",
    "# rho^2 = rKS^2 + a^2*cos^2(theta)\n",
    "rho2 = rKS*rKS + a*a*sp.cos(th)**2\n",
    "\n",
    "# alpha = 1/sqrt{1 + M*rKS/rho^2}\n",
    "alphaSph = 1/(sp.sqrt(1 + 2*M*rKS/rho2))\n",
    "\n",
    "# Initialize the shift vector, \\beta^i, to zero.\n",
    "betaSphU = ixp.zerorank1()\n",
    "# beta^r = alpha^2*2Mr/rho^2\n",
    "betaSphU[0] = alphaSph*alphaSph*2*M*rKS/rho2\n",
    "\n",
    "# Time derivative of shift vector beta^i, B^i, is zero.\n",
    "BSphU = ixp.zerorank1()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='nonzero_gamma'></a>\n",
    "\n",
    "## Step 2.b: Define and construct nonzero components $\\gamma_{r_{\\rm KS}r_{\\rm KS}}$, $\\gamma_{r_{\\rm KS}\\phi}$, $\\gamma_{\\theta\\theta}$, $\\gamma_{\\phi\\phi}$ \\[Back to [top](#toc)\\]\n",
    "$$\\label{nonzero_gamma}$$\n",
    "\n",
    "From equations (A.4)-(A.7) of [Etienne et al., 2017](https://arxiv.org/pdf/1704.00599.pdf) we define the nonzero components of the 3-metric:\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ \\gamma_{r_{\\rm KS}r_{\\rm KS}} = 1 + \\frac{2Mr_{\\rm KS}}{\\rho^2} $$\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ \\gamma_{r_{\\rm KS}\\phi} = -a\\gamma_{r_{\\rm KS}r_{\\rm KS}}\\sin^2(\\theta) $$\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ \\gamma_{\\theta\\theta} = \\rho^2 $$\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ \\gamma_{\\phi\\phi} = \\left(r_{\\rm KS}^2 + a^2 + \\frac{2Mr_{\\rm KS}}{\\rho^2}a^{2}\\sin^{2}(\\theta)\\right)\\sin^{2}(\\theta) $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-03-07T17:06:12.240611Z",
     "iopub.status.busy": "2021-03-07T17:06:12.239995Z",
     "iopub.status.idle": "2021-03-07T17:06:12.242333Z",
     "shell.execute_reply": "2021-03-07T17:06:12.242807Z"
    }
   },
   "outputs": [],
   "source": [
    "# Step 2: Define and construct nonzero components gamma_{r_{KS}r_{KS}}$, gamma_{r_{KS}phi},\n",
    "#         gamma_{thetatheta}, gamma_{phiphi}\n",
    "\n",
    "# Initialize \\gamma_{ij} to zero.\n",
    "gammaSphDD = ixp.zerorank2()\n",
    "\n",
    "# gammaDD{rKS rKS} = 1 +2M*rKS/rho^2\n",
    "gammaSphDD[0][0] = 1 + 2*M*rKS/rho2\n",
    "\n",
    "# gammaDD{rKS phi} = -a*gammaDD{r r}*sin^2(theta)\n",
    "gammaSphDD[0][2] = gammaSphDD[2][0] = -a*gammaSphDD[0][0]*sp.sin(th)**2\n",
    "\n",
    "# gammaDD{theta theta} = rho^2\n",
    "gammaSphDD[1][1] = rho2\n",
    "\n",
    "# gammaDD{phi phi} = (rKS^2 + a^2 + 2Mr/rho^2*a^2*sin^2(theta))*sin^2(theta)\n",
    "gammaSphDD[2][2] = (rKS*rKS + a*a + 2*M*rKS*a*a*sp.sin(th)**2/rho2)*sp.sin(th)**2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='extrinsic_curvature'></a>\n",
    "\n",
    "# Step 3: The extrinsic curvature $K_{ij}$ \\[Back to [top](#toc)\\]\n",
    "$$\\label{extrinsic_curvature}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='abc'></a>\n",
    "\n",
    "## Step 3.a: Define useful quantities $A$, $B$, $C$ \\[Back to [top](#toc)\\]\n",
    "$$\\label{abc}$$\n",
    "\n",
    "From equations (A.8)-(A.10) of [Etienne et al., 2017](https://arxiv.org/pdf/1704.00599.pdf) we define the following expressions which will help simplify the nonzero extrinsic curvature components:\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ A = \\left(a^{2}\\cos(2\\theta) + a^{2} + 2r_{\\rm KS}^{2}\\right) $$\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ B = A + 4Mr_{\\rm KS} $$\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ D = \\sqrt{\\frac{2Mr_{\\rm KS}}{a^{2}\\cos^{2}(\\theta) + r_{\\rm KS}^2} + 1} $$\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-03-07T17:06:12.252188Z",
     "iopub.status.busy": "2021-03-07T17:06:12.251520Z",
     "iopub.status.idle": "2021-03-07T17:06:12.254264Z",
     "shell.execute_reply": "2021-03-07T17:06:12.253722Z"
    }
   },
   "outputs": [],
   "source": [
    "# Step 3: Define useful quantities A, B, C\n",
    "\n",
    "# A = (a^2*cos^2(2theta) + a^2 + 2r^2)\n",
    "A = (a*a*sp.cos(2*th) + a*a + 2*rKS*rKS)\n",
    "\n",
    "# B = A + 4M*rKS\n",
    "B = A + 4*M*rKS\n",
    "\n",
    "# D = \\sqrt(2M*rKS/(a^2cos^2(theta) + rKS^2) + 1)\n",
    "D = sp.sqrt(2*M*rKS/(a*a*sp.cos(th)**2 + rKS*rKS) + 1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='nonzero_k'></a>\n",
    "\n",
    "## Step 3.b: Define and construct nonzero components of $K_{ij}$ \\[Back to [top](#toc)\\]\n",
    "$$\\label{nonzero_k}$$\n",
    "\n",
    "We will now express the extrinsic curvature $K_{ij}$ in spherical polar coordinates.\n",
    "\n",
    "From equations (A.11) - (A.13) of [Etienne et al., 2017](https://arxiv.org/pdf/1704.00599.pdf) we define the following:\n",
    "\n",
    "$$ K_{r_{\\rm KS}r_{\\rm KS}} = \\frac{D(A + 2Mr_{\\rm KS})}{A^{2}B}\\left[4M\\left(a^{2}\\cos(2\\theta) + a^{2} - 2r_{\\rm KS}^{2}\\right)\\right] $$\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ K_{r_{\\rm KS}\\theta} = \\frac{D}{AB}\\left[8a^{2}Mr_{\\rm KS}\\sin(\\theta)\\cos(\\theta)\\right] $$\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ K_{r_{\\rm KS}\\phi} = \\frac{D}{A^2}\\left[-2aM\\sin^{2}(\\theta)\\left(a^{2}\\cos(2\\theta) + a^{2} - 2r_{\\rm KS}^{2}\\right)\\right] $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-03-07T17:06:12.280933Z",
     "iopub.status.busy": "2021-03-07T17:06:12.280225Z",
     "iopub.status.idle": "2021-03-07T17:06:12.282362Z",
     "shell.execute_reply": "2021-03-07T17:06:12.282833Z"
    }
   },
   "outputs": [],
   "source": [
    "# Step 4: Define the extrinsic curvature in spherical polar coordinates\n",
    "# Establish the 3x3 zero-matrix\n",
    "KSphDD = ixp.zerorank2()\n",
    "\n",
    "# *** Fill in the nonzero components ***\n",
    "# *** This will create an upper-triangular matrix ***\n",
    "# K_{r r} = D(A+2Mr)/(A^2*B)[4M(a^2*cos(2theta) + a^2 - 2r^2)]\n",
    "KSphDD[0][0] = D*(A+2*M*rKS)/(A*A*B)*(4*M*(a*a*sp.cos(2*th)+a*a-2*rKS*rKS))\n",
    "\n",
    "# K_{r theta} = D/(AB)[8a^2*Mr*sin(theta)cos(theta)]\n",
    "KSphDD[0][1] = KSphDD[1][0] = D/(A*B)*(8*a*a*M*rKS*sp.sin(th)*sp.cos(th))\n",
    "\n",
    "# K_{r phi} = D/A^2[-2aMsin^2(theta)(a^2cos(2theta)+a^2-2r^2)]\n",
    "KSphDD[0][2] = KSphDD[2][0] =  D/(A*A)*(-2*a*M*sp.sin(th)**2*(a*a*sp.cos(2*th)+a*a-2*rKS*rKS))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And from equations (A.14) - (A.17) of [Etienne et al., 2017](https://arxiv.org/pdf/1704.00599.pdf) we define the following expressions to complete the upper-triangular matrix $K_{ij}$:\n",
    "\n",
    "$$ K_{\\theta\\theta} = \\frac{D}{B}\\left[4Mr_{\\rm KS}^{2}\\right] $$\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ K_{\\theta\\phi} = \\frac{D}{AB}\\left[-8a^{3}Mr_{\\rm KS}\\sin^{3}(\\theta)\\cos(\\theta)\\right] $$\n",
    "\n",
    "<br>\n",
    "\n",
    "$$ K_{\\phi\\phi} = \\frac{D}{A^{2}B}\\left[2Mr_{\\rm KS}\\sin^{2}(\\theta)\\left(a^{4}(r_{\\rm KS}-M)\\cos(4\\theta) + a^{4}(M + 3r_{\\rm KS}) + 4a^{2}r_{\\rm KS}^{2}(2r_{\\rm KS} - M) + 4a^{2}r_{\\rm KS}\\cos(2\\theta)\\left(a^{2} + r_{\\rm KS}(M + 2r_{\\rm KS})\\right) + 8r_{\\rm KS}^{5}\\right)\\right] $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-03-07T17:06:12.302725Z",
     "iopub.status.busy": "2021-03-07T17:06:12.302024Z",
     "iopub.status.idle": "2021-03-07T17:06:12.304233Z",
     "shell.execute_reply": "2021-03-07T17:06:12.304765Z"
    }
   },
   "outputs": [],
   "source": [
    "# K_{theta theta} = D/B[4Mr^2]\n",
    "KSphDD[1][1] = D/B*(4*M*rKS*rKS)\n",
    "\n",
    "# K_{theta phi} = D/(AB)*(-8*a^3*Mr*sin^3(theta)cos(theta))\n",
    "KSphDD[1][2] = KSphDD[2][1] = D/(A*B)*(-8*a**3*M*rKS*sp.sin(th)**3*sp.cos(th))\n",
    "\n",
    "# K_{phi phi} = D/(A^2*B)[2Mr*sin^2(theta)(a^4(M+3r)\n",
    "#   +4a^2r^2(2r-M)+4a^2r*cos(2theta)(a^2+r(M+2r))+8r^5)]\n",
    "KSphDD[2][2] = D/(A*A*B)*(2*M*rKS*sp.sin(th)**2*(a**4*(rKS-M)*sp.cos(4*th)\\\n",
    "                        + a**4*(M+3*rKS)+4*a*a*rKS*rKS*(2*rKS-M)\\\n",
    "                        + 4*a*a*rKS*sp.cos(2*th)*(a*a + rKS*(M + 2*rKS)) + 8*rKS**5))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='code_validation'></a>\n",
    "\n",
    "# Step 4: Code Validation against `BSSN.ShiftedKerrSchild` NRPy+ module \\[Back to [top](#toc)\\]\n",
    "$$\\label{code_validation}$$\n",
    "\n",
    "Here, as a code validation check, we verify agreement in the SymPy expressions for Shifted Kerr-Schild initial data between\n",
    "\n",
    "1. this tutorial and \n",
    "2. the NRPy+ [BSSN.ShiftedKerrSchild](../edit/BSSN/ShiftedKerrSchild.py) module."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-03-07T17:06:12.379383Z",
     "iopub.status.busy": "2021-03-07T17:06:12.343451Z",
     "iopub.status.idle": "2021-03-07T17:06:13.822242Z",
     "shell.execute_reply": "2021-03-07T17:06:13.821544Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Consistency check between Brill-Lindquist tutorial and NRPy+ BSSN.BrillLindquist module. ALL SHOULD BE ZERO.\n",
      "alphaSph - sks.alphaSph = 0\n",
      "betaSphU[0] - sks.betaSphU[0] = 0\n",
      "BSphU[0] - sks.BaSphU[0] = 0\n",
      "gammaSphDD[0][0] - sks.gammaSphDD[0][0] = 0\n",
      "KSphDD[0][0] - sks.KSphDD[0][0] = 0\n",
      "gammaSphDD[0][1] - sks.gammaSphDD[0][1] = 0\n",
      "KSphDD[0][1] - sks.KSphDD[0][1] = 0\n",
      "gammaSphDD[0][2] - sks.gammaSphDD[0][2] = 0\n",
      "KSphDD[0][2] - sks.KSphDD[0][2] = 0\n",
      "betaSphU[1] - sks.betaSphU[1] = 0\n",
      "BSphU[1] - sks.BaSphU[1] = 0\n",
      "gammaSphDD[1][0] - sks.gammaSphDD[1][0] = 0\n",
      "KSphDD[1][0] - sks.KSphDD[1][0] = 0\n",
      "gammaSphDD[1][1] - sks.gammaSphDD[1][1] = 0\n",
      "KSphDD[1][1] - sks.KSphDD[1][1] = 0\n",
      "gammaSphDD[1][2] - sks.gammaSphDD[1][2] = 0\n",
      "KSphDD[1][2] - sks.KSphDD[1][2] = 0\n",
      "betaSphU[2] - sks.betaSphU[2] = 0\n",
      "BSphU[2] - sks.BaSphU[2] = 0\n",
      "gammaSphDD[2][0] - sks.gammaSphDD[2][0] = 0\n",
      "KSphDD[2][0] - sks.KSphDD[2][0] = 0\n",
      "gammaSphDD[2][1] - sks.gammaSphDD[2][1] = 0\n",
      "KSphDD[2][1] - sks.KSphDD[2][1] = 0\n",
      "gammaSphDD[2][2] - sks.gammaSphDD[2][2] = 0\n",
      "KSphDD[2][2] - sks.KSphDD[2][2] = 0\n"
     ]
    }
   ],
   "source": [
    "# First we import reference_metric, which is\n",
    "#   needed since BSSN.ShiftedKerrSchild calls\n",
    "#   BSSN.ADM_Exact_Spherical_or_Cartesian_to_BSSNCurvilinear, which\n",
    "#   depends on reference_metric:\n",
    "import reference_metric as rfm   # NRPy+: Reference metric support\n",
    "rfm.reference_metric()\n",
    "\n",
    "import BSSN.ShiftedKerrSchild as sks\n",
    "sks.ShiftedKerrSchild()\n",
    "\n",
    "# It is SAFE to ignore the warning(s) from re-initializing parameters.\n",
    "print(\"Consistency check between Brill-Lindquist tutorial and NRPy+ BSSN.BrillLindquist module. ALL SHOULD BE ZERO.\")\n",
    "print(\"alphaSph - sks.alphaSph = \"+str(sp.simplify(alphaSph - sks.alphaSph)))\n",
    "for i in range(DIM):\n",
    "    print(\"betaSphU[\"+str(i)+\"] - sks.betaSphU[\"+str(i)+\"] = \"+\\\n",
    "          str(sp.simplify(betaSphU[i] - sks.betaSphU[i])))\n",
    "    print(\"BSphU[\"+str(i)+\"] - sks.BaSphU[\"+str(i)+\"] = \"+str(sp.simplify(BSphU[i] - sks.BSphU[i])))\n",
    "    for j in range(DIM):\n",
    "        print(\"gammaSphDD[\"+str(i)+\"][\"+str(j)+\"] - sks.gammaSphDD[\"+str(i)+\"][\"+str(j)+\"] = \"+\\\n",
    "             str(sp.simplify(gammaSphDD[i][j] - sks.gammaSphDD[i][j])))\n",
    "        print(\"KSphDD[\"+str(i)+\"][\"+str(j)+\"] - sks.KSphDD[\"+str(i)+\"][\"+str(j)+\"] = \"+\\\n",
    "              str(sp.simplify(KSphDD[i][j] - sks.KSphDD[i][j])))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='latex_pdf_output'></a>\n",
    "\n",
    "# Step 5: Output this notebook to $\\LaTeX$-formatted PDF \\[Back to [top](#toc)\\]\n",
    "$$\\label{latex_pdf_output}$$\n",
    "\n",
    "The following code cell converts this Jupyter notebook into a proper, clickable $\\LaTeX$-formatted PDF file. After the cell is successfully run, the generated PDF may be found in the root NRPy+ tutorial directory, with filename\n",
    "[Tutorial-ADM_Initial_Data-ShiftedKerrSchild.pdf](Tutorial-ADM_Initial_Data-ShiftedKerrSchild.pdf) (Note that clicking on this link may not work; you may need to open the PDF file through another means.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-03-07T17:06:13.828601Z",
     "iopub.status.busy": "2021-03-07T17:06:13.827094Z",
     "iopub.status.idle": "2021-03-07T17:06:17.317622Z",
     "shell.execute_reply": "2021-03-07T17:06:17.318457Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Created Tutorial-ADM_Initial_Data-ShiftedKerrSchild.tex, and compiled LaTeX\n",
      "    file to PDF file Tutorial-ADM_Initial_Data-ShiftedKerrSchild.pdf\n"
     ]
    }
   ],
   "source": [
    "import cmdline_helper as cmd    # NRPy+: Multi-platform Python command-line interface\n",
    "cmd.output_Jupyter_notebook_to_LaTeXed_PDF(\"Tutorial-ADM_Initial_Data-ShiftedKerrSchild\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}