Numerical Methods in GR

  • Ian Hawke

The aim

Numerics:

  1. given model,
  2. find observable
  3. to given accuracy
  4. using minimum resources.

ETK:

  1. within GR,
  2. find GW signal from binary merger
  3. to 1 radian phase accuracy
  4. using minimum CPU time.

Hammond+, 2205.11377.

The models

  1. EFEs $\implies$ wave equation $$ \partial_{tt} \phi = c^2 \nabla^2 \phi; $$
  2. Charge conservation $\implies$ advection $$ \partial_t \phi + \nabla_k \left( \phi v^k \right) = 0; $$
  3. $\nabla_a T^{ab} \; \implies$ balance laws $$ \partial_t q + \nabla_k f^{(k)}(q) = s(q); $$
  4. Exchange $\implies$ relaxation $$ \dot{q} = \tau^{-1} s(q). $$

Split out time

Method of Lines (thorn MoL):

  1. start from spacetime;
  2. discretize space, giving ODEs;
  3. solve ODEs.

(Dis)advantages:

  • MoL simplifies coupling;
  • causality restricts $\Delta t$;
  • width of stencil affects cost;
  • accuracy, efficiency issues.

Fields as data

To represent $\phi(x)$ as finite data:

  1. Finite differences. Points $x_i$, $$ \phi_i = \phi(x_i). $$
  2. Finite volumes. Cells $[x_{i-1/2}, x_{i+1/2}]$, $$ \hat{\phi}_i = \frac{1}{\Delta x} \int_{x_{i-1/2}}^{x_{i+1/2}} \text{d} x \, \phi(x). $$
  3. Finite elements. Basis functions $P_m(x)$, $$ \phi(x) = \sum_m \hat{\phi}_m P_m(x). $$

ETK works best with FD and FV.

Finite differencing

Approximate:

  1. fields $\phi$ as point values $\phi_i = \phi(x_i)$;
  2. polynomial interpolation gives $\hat{\phi}(x)$ from $\{\phi_i\}$;
  3. derivative from $\partial_x \phi \simeq \partial_x \hat{\phi}$.

See Kranc, NRPy.

Example:

$$ \begin{aligned} && \partial_t \phi + \partial_x (v \phi) & = 0 \\ \rightarrow && \partial_t \phi_i & = \frac{-v \left( \phi_{i+1} - \phi_{i-1} \right)}{2 \, \Delta x}. \end{aligned} $$

Order of accuracy

Finite differencing errors $\propto \Delta x^p = N^{-p}$:

$$ \partial_t \phi_i + \frac{v \left( \phi_{i+1} - \phi_{i-1} \right)}{2 \, \Delta x} = \mathcal{O} \left( \Delta x^2 \right). $$

$\Delta x$ "small": higher order usually better. However, costs increase:

$$ \partial_x \phi \simeq \frac{-\phi_{i+2} + \phi_{i-2} + 8 (\phi_{i+1} - \phi_{i-1})}{12 \, \Delta x}. $$

Usual to plot convergence with $N$ or $\Delta x$. Really resource (eg CPU time) that matters.

Phase errors

Finite differencing errors:

  1. dissipation, reducing amplitude;
  2. dispersion, changing phase.

Phase error dependence on $\Delta x$ can be estimated.

For 1kHz wave for 1s, 1% phase error:

$2^{\textrm{nd}}$ order $4^{\textrm{th}}$ order $6^{\textrm{th}}$ order
$10$m $265$m $784$m

Phase errors dependence on $\Delta x$ can be estimated.

For 10kHz wave for 1s, 0.01% phase error:

$2^{\textrm{nd}}$ order $4^{\textrm{th}}$ order $6^{\textrm{th}}$ order
$0.3$m $47$m $247$m

Spectral

Higher order is better: use all information. Mode expand:

$$ \phi = \sum_i \hat{\phi}_i \sin \left(\frac{2 \pi i x}{L} \right). $$

Then $\partial_x \phi \simeq D \hat{\phi}$.

Spectral error $\sim \exp(-p N)$.

Accuracy of full evolution often constrained.

ETK has spectral initial data (TwoPunctures, LORENE), no evolution.

Discontinuities

Any high order method shows Gibbs' oscillations at jumps.

No convergence with resolution.

Use piecewise polynomial reconstruction (eg WENO) to avoid oscillations.

  • Converges with resolution.
  • Formally first order at jumps.
  • Much more expensive.
  • Data dependent - hard to analyse.
  • Extension to higher dimensions an issue.

See GRHydro, IllinoisGRMHD, Spritz, WhiskyTHC.

Parallel compute

Classic CPU (Carpet etc): split domain.

  • Each CPU fast, high memory.
  • Need ghostzones, linked to stencil size.
  • Communication is bottleneck.
  • Problem for higher order schemes.

GPUs (CarpetX etc): create tasks.

  • Each GPU slow, low memory.
  • $N_{\textrm{GPU}} \gg N_{\textrm{CPU}}$.
  • Overload GPUs via pipeline.
  • Task based approach hides communication.

Nonlinearity

Formally need to work with weak form

$$ \begin{aligned} && \partial_t \phi + \nabla_k f^{(k)}(\phi) & = 0 \\ \implies && \frac{\text{d}}{\text{d}t} \int_V \phi + \oint_{\partial V} \hat{n}_k f^{(k)}(\phi) & = 0. \end{aligned} $$

Discrete version, 1d:

$$ \frac{\text{d}}{\text{d}t} \hat{\phi}_i + \frac{1}{\Delta x} \left[ f_{i+1/2} - f_{i-1/2} \right] = 0. $$

Finding the flux $f_{k \pm 1/2}$ depends on the model (for fluids see GRHydro etc).

Consistency

Using the right weak form is essential.

$$ \begin{aligned} && \partial_t q^n + \frac{n}{n+1} \partial_x q^{n+1} & = 0 \\ \implies && \partial_t q + q \partial_x q & = 0. \end{aligned} $$

Strong solutions agree when continuous; inconsistent at shocks.

Can use entropy pairs, path-consistent methods for complex cases. Links to SummationByParts.

Spectral element

Want high order, low communication. Apply weak form to basis expansion $q(x, t) \sim \hat{q}_m(t) P_m(x)$, getting

$$ M \partial_t \hat{q} + S^T f(\hat{q}) = - \left[ F \right]_{i-1/2}^{i+1/2}. $$
  • Spectral accuracy with modes.
  • Only communication through RHS.
  • Expensive, complex.
  • (Solvable?) issues with shocks.

No code in ETK (?) - see Spectre.

Mesh refinement

Errors $\sim \Delta x^p$, but also local.

Refine mesh where errors large (Carpet(X)).

Boundaries need interpolation - source of error.

Physics not Cartesian: overlapping patches complex, but help (Llama, BH@Home).

Stiff sources

For $\dot{q} = -\tau^{-1} f(q)$,

  • $$ q^{\color{green}{n+1}} = q^{\color{green}{n}} - \frac{\Delta t}{\tau} f(q^{\color{green}{n}}). $$ Explicit: fast, unstable for $\tau \lesssim \Delta t$.
  • $$ q^{\color{red}{n+1}} = q^{\color{red}{n}} - \frac{\Delta t}{\tau} f(q^{\color{red}{n+1}}). $$ Implicit: slow, stable $ \forall \tau$.

Stable does not mean accurate!

IMEX methods can be added to MoL.

Toy heat

The Cattaneo model for heat is stiff:

$$ \begin{aligned} \partial_t T & = \partial_x q, \\ \partial_t q & = - \tau^{-1} \left( q - \kappa \partial_x T \right). \end{aligned} $$

For $\tau \ll 1$ write $q = \kappa \partial_x T + \mathcal{O}(\tau)$, finding

$$ \partial_t T = \kappa \partial_{xx} T + \tau \kappa^3 \partial_x^{(4)} T. $$

Solve heat equation explicitly whilst $\Delta t \gtrsim \kappa \Delta x^2 / 2$.

Adaptive Model

Changing model can reduce costs by

  1. reducing size of state vector;
  2. increasing allowed timestep.

Choose model adaptively to improve numerics while capturing physics.

Examples:

Asymptotic preserving models and schemes are needed.

Summary

The ETK is optimized for

  • finite difference/volume methods
  • using block-structured mesh refinement
  • on CPUs
  • for computing gravitational waves.

CarpetX should add GPU support.

Adaptive and hybrid methods becoming common, but complex.

Uncertainty quantification a key buzzword - lots of formal (non-GR) work to understand.

Hammond+; Most+.

Further reading