.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/relativity/spacetime_geometry/plot_curvature_engine_validation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_relativity_spacetime_geometry_plot_curvature_engine_validation.py: Validating the curvature engine: Einstein's vacuum field equations ================================================================================ Einstein's field equations, :math:`G_{\mu\nu} = 8\pi T_{\mu\nu}`, reduce to :math:`G_{\mu\nu} = 0` in vacuum (no matter or energy present). Schwarzschild and Kerr describe the vacuum spacetime *outside* a mass, so their Einstein tensors must vanish identically everywhere outside the horizon -- despite the metrics themselves being far from flat. This example uses physicskit.relativity's numerical (finite-difference) curvature engine to verify this directly for both metrics at several radii, and shows how the same engine reveals genuine matter content (a nonzero Einstein tensor) for a charged Reissner-Nordstrom black hole, whose electromagnetic field sources spacetime curvature even in the "vacuum" region outside the horizon. .. GENERATED FROM PYTHON SOURCE LINES 16-27 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from physicskit.relativity.core.tensors import ( einstein_tensor, kerr_metric_bl, reissner_nordstrom_metric, schwarzschild_metric, ) .. GENERATED FROM PYTHON SOURCE LINES 28-30 Schwarzschild and Kerr: vacuum, so G_munu = 0 everywhere outside the horizon -------------------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 30-42 .. code-block:: Python print("Schwarzschild vacuum check (max |G_munu| at each radius):") for r in [4.0, 6.0, 10.0, 50.0]: coords = np.array([0.0, r, np.pi / 3.0, 0.5]) G = einstein_tensor(schwarzschild_metric, coords, {"M": 1.0}) print(f" r={r:>5.1f}M: max|G_munu| = {np.max(np.abs(G)):.2e}") print("\nKerr vacuum check (max |G_munu| at each radius, a=0.8):") for r in [3.0, 5.0, 10.0, 50.0]: coords = np.array([0.0, r, np.pi / 3.0, 0.5]) G = einstein_tensor(kerr_metric_bl, coords, {"M": 1.0, "a": 0.8}) print(f" r={r:>5.1f}M: max|G_munu| = {np.max(np.abs(G)):.2e}") .. rst-class:: sphx-glr-script-out .. code-block:: none Schwarzschild vacuum check (max |G_munu| at each radius): r= 4.0M: max|G_munu| = 2.23e-06 r= 6.0M: max|G_munu| = 8.25e-08 r= 10.0M: max|G_munu| = 1.56e-05 r= 50.0M: max|G_munu| = 5.47e-04 Kerr vacuum check (max |G_munu| at each radius, a=0.8): r= 3.0M: max|G_munu| = 1.34e-06 r= 5.0M: max|G_munu| = 5.75e-07 r= 10.0M: max|G_munu| = 1.37e-05 r= 50.0M: max|G_munu| = 9.33e-04 .. GENERATED FROM PYTHON SOURCE LINES 43-46 Reissner-Nordstrom: a charged black hole's electromagnetic field DOES source curvature, even outside the horizon -------------------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 46-52 .. code-block:: Python print("\nReissner-Nordstrom (Q=0.5M): the electromagnetic stress-energy sources G_munu != 0") for r in [3.0, 5.0, 10.0]: coords = np.array([0.0, r, np.pi / 3.0, 0.5]) G = einstein_tensor(reissner_nordstrom_metric, coords, {"M": 1.0, "Q": 0.5}) print(f" r={r:>5.1f}M: max|G_munu| = {np.max(np.abs(G)):.4f} (nonzero: matter/field IS present)") .. rst-class:: sphx-glr-script-out .. code-block:: none Reissner-Nordstrom (Q=0.5M): the electromagnetic stress-energy sources G_munu != 0 r= 3.0M: max|G_munu| = 0.0278 (nonzero: matter/field IS present) r= 5.0M: max|G_munu| = 0.0100 (nonzero: matter/field IS present) r= 10.0M: max|G_munu| = 0.0025 (nonzero: matter/field IS present) .. GENERATED FROM PYTHON SOURCE LINES 53-64 Mapping the vacuum check over the full (r, theta) plane ------------------------------------------------------------ The discrete radii above are single points along one check; evaluating :func:`~physicskit.relativity.core.tensors.einstein_tensor` over a full grid of :math:`(r,\theta)` shows the vacuum identity :math:`G_{\mu\nu}=0` holds everywhere outside the horizon for both Schwarzschild and Kerr (down to the finite-difference engine's numerical noise floor), while the Reissner-Nordstrom charge sources a smooth, radius-dependent (and here, theta-independent, since :math:`Q` couples only through :math:`r`) curvature everywhere -- not just at the three sampled radii above. .. GENERATED FROM PYTHON SOURCE LINES 64-94 .. code-block:: Python r_grid = np.linspace(4.0, 20.0, 20) theta_grid = np.linspace(0.15, np.pi - 0.15, 20) # stay off the polar coordinate singularity def _max_G_map(metric_func, params): G_map = np.zeros((len(theta_grid), len(r_grid))) for i, th in enumerate(theta_grid): for j, r in enumerate(r_grid): coords = np.array([0.0, r, th, 0.5]) G_map[i, j] = np.max(np.abs(einstein_tensor(metric_func, coords, params))) return G_map G_schwarzschild = _max_G_map(schwarzschild_metric, {"M": 1.0}) G_kerr = _max_G_map(kerr_metric_bl, {"M": 1.0, "a": 0.8}) G_reissner_nordstrom = _max_G_map(reissner_nordstrom_metric, {"M": 1.0, "Q": 0.5}) fig, axes = plt.subplots(1, 3, figsize=(15, 4.5)) for ax, G_map, title in zip( axes, [G_schwarzschild, G_kerr, G_reissner_nordstrom], ["Schwarzschild (vacuum)", "Kerr, a=0.8M (vacuum)", "Reissner-Nordstrom, Q=0.5M"], ): im = ax.pcolormesh(r_grid, theta_grid, np.log10(G_map + 1.0e-300), shading="auto", cmap="viridis") plt.colorbar(im, ax=ax, label=r"$\log_{10}\max|G_{\mu\nu}|$") ax.set_xlabel("r [M]") ax.set_ylabel(r"$\theta$ [rad]") ax.set_title(title) plt.tight_layout() plt.show() .. image-sg:: /api/gallery/relativity/spacetime_geometry/images/sphx_glr_plot_curvature_engine_validation_001.png :alt: Schwarzschild (vacuum), Kerr, a=0.8M (vacuum), Reissner-Nordstrom, Q=0.5M :srcset: /api/gallery/relativity/spacetime_geometry/images/sphx_glr_plot_curvature_engine_validation_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.015 seconds) .. _sphx_glr_download_api_gallery_relativity_spacetime_geometry_plot_curvature_engine_validation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_curvature_engine_validation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_curvature_engine_validation.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_curvature_engine_validation.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_