{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\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 notebook features a module that sets up Shifted Kerr-Schild initial data as per [Etienne et al., 2017 GiRaFFE](https://arxiv.org/pdf/1704.00599.pdf). The module confirms the expected order convergence to zero of the Hamiltonian and momentum constraint violations while utilizing Shifted Kerr-Schild coordinates to promote stability within the black hole horizon during the evolution of hydrodynamic, MHD, and FFE fields.\n", "\n", "**Notebook Status:** Validated \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-Exact_Initial_Data.ipynb)).\n", "\n", "### NRPy+ Source Code for this module: [BSSN/ShiftedKerrSchild.py](../edit/BSSN/ShiftedKerrSchild.py)\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\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": [ "\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", "\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": [ "\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": [ "\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", "
\n", "First, we define $\\rho^{2}$ as\n", "\n", "
\n", "\n", "$$ \\rho^2 = r_{\\rm KS} + a^{2}\\cos^{2}(\\theta) $$\n", "\n", "
\n", "\n", "And we then define the Kerr-Schild lapse $\\alpha$ from equation (A.1)\n", "\n", "
\n", "\n", "$$ \\alpha = \\frac{1}{\\sqrt{1 + \\frac{2Mr_{\\rm KS}}{\\rho^2}}} $$\n", "\n", "
\n", "\n", "And the shift $\\beta$ from equations (A.2) & (A.3)\n", "\n", "
\n", "\n", "$$ \\beta^{r_{\\rm KS}} = \\alpha^2\\frac{2Mr_{\\rm KS}}{\\rho^2} $$\n", "\n", "
\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", "alpha = 1/(sp.sqrt(1 + 2*M*rKS/rho2))\n", "\n", "# Initialize the shift vector, \\beta^i, to zero.\n", "betaU = ixp.zerorank1()\n", "# beta^r = alpha^2*2Mr/rho^2\n", "betaU[0] = alpha*alpha*2*M*rKS/rho2\n", "\n", "# Time derivative of shift vector beta^i, B^i, is zero.\n", "BU = ixp.zerorank1()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\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", "
\n", "\n", "$$ \\gamma_{r_{\\rm KS}r_{\\rm KS}} = 1 + \\frac{2Mr_{\\rm KS}}{\\rho^2} $$\n", "\n", "
\n", "\n", "$$ \\gamma_{r_{\\rm KS}\\phi} = -a\\gamma_{r_{\\rm KS}r_{\\rm KS}}\\sin^2(\\theta) $$\n", "\n", "
\n", "\n", "$$ \\gamma_{\\theta\\theta} = \\rho^2 $$\n", "\n", "
\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", "gammaDD = ixp.zerorank2()\n", "\n", "# gammaDD{rKS rKS} = 1 +2M*rKS/rho^2\n", "gammaDD[0][0] = 1 + 2*M*rKS/rho2\n", "\n", "# gammaDD{rKS phi} = -a*gammaDD{r r}*sin^2(theta)\n", "gammaDD[0][2] = gammaDD[2][0] = -a*gammaDD[0][0]*sp.sin(th)**2\n", "\n", "# gammaDD{theta theta} = rho^2\n", "gammaDD[1][1] = rho2\n", "\n", "# gammaDD{phi phi} = (rKS^2 + a^2 + 2Mr/rho^2*a^2*sin^2(theta))*sin^2(theta)\n", "gammaDD[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": [ "\n", "\n", "# Step 3: The extrinsic curvature $K_{ij}$ \\[Back to [top](#toc)\\]\n", "$$\\label{extrinsic_curvature}$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\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", "
\n", "\n", "$$ A = \\left(a^{2}\\cos(2\\theta) + a^{2} + 2r_{\\rm KS}^{2}\\right) $$\n", "\n", "
\n", "\n", "$$ B = A + 4Mr_{\\rm KS} $$\n", "\n", "
\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": [ "\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", "
\n", "\n", "$$ K_{r_{\\rm KS}\\theta} = \\frac{D}{AB}\\left[8a^{2}Mr_{\\rm KS}\\sin(\\theta)\\cos(\\theta)\\right] $$\n", "\n", "
\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", "KDD = 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", "KDD[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", "KDD[0][1] = KDD[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", "KDD[0][2] = KDD[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", "
\n", "\n", "$$ K_{\\theta\\phi} = \\frac{D}{AB}\\left[-8a^{3}Mr_{\\rm KS}\\sin^{3}(\\theta)\\cos(\\theta)\\right] $$\n", "\n", "
\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", "KDD[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", "KDD[1][2] = KDD[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", "KDD[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": [ "\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 ShiftedKerrSchild tutorial and NRPy+ BSSN.ShifedKerrSchild module.\n", "ALL TESTS PASS\n" ] } ], "source": [ "# Step 3: Code Validation against BSSN.ShiftedKerrSchild NRPy+ module\n", "\n", "import BSSN.ShiftedKerrSchild as sks\n", "sks.ShiftedKerrSchild()\n", "\n", "def compare(q1, q2, q1name, q2name):\n", " if sp.simplify(q1 - q2) != 0:\n", " print(\"Error: \"+q1name+\" - \"+q2name+\" = \"+str(sp.simplify(q1 - q2)))\n", " sys.exit(1) \n", "\n", "print(\"Consistency check between ShiftedKerrSchild tutorial and NRPy+ BSSN.ShifedKerrSchild module.\")\n", "compare(alpha, sks.alpha, \"alpha\", \"sks.alpha\")\n", "for i in range(DIM):\n", " compare(betaU[i], sks.betaU[i], \"betaU\"+str(i), \"sks.betaU\"+str(i))\n", " compare(BU[i], sks.BU[i], \"BU\"+str(i), \"sks.BU\"+str(i))\n", " for j in range(DIM):\n", " compare(gammaDD[i][j], sks.gammaDD[i][j], \"gammaDD\"+str(i)+str(j), \"sks.gammaDD\"+str(i)+str(j))\n", " compare(KDD[i][j], sks.KDD[i][j], \"KDD\"+str(i)+str(j), \"sks.KDD\"+str(i)+str(j))\n", "print(\"ALL TESTS PASS\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\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": 1, "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 (ipykernel)", "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.11.1" } }, "nbformat": 4, "nbformat_minor": 4 }