ET_BHaHAHA: Einstein Toolkit Interface to the BHaHAHA Apparent Horizon Finder Library

ET_BHaHAHA Maintainers

March 5, 2026

Contents

1 Introduction
2 What ET_BHaHAHA Needs
3 Obtaining and Compiling ET_BHaHAHA
4 ET_BHaHAHA Parameters
4.1 Overall Thorn Parameters
4.2 Per-Horizon Parameters
4.3 BBH Mode Parameters
5 Provided Variables
6 Scheduling and MPI Synchronization
6.1 Storage
6.2 Scheduled Functions
6.3 MPI Synchronization Details
7 Physics Background and Numerical Methods
7.1 Apparent Horizons and MOTS
7.2 Hyperbolic Relaxation
7.3 Numerical Implementation Details within BHaHAHA
7.3.1 Metric Data Handling and Interpolation
7.3.2 Initial Data for Hyperbolic Relaxation
7.3.3 Pseudo-Time Evolution
7.3.4 Convergence and Stopping Conditions
7.3.5 Convergence Acceleration Techniques
7.4 Binary Black Hole (BBH) Mode in ET_BHaHAHA
7.5 Diagnostics Computation
8 Output Data
8.1 Horizon Diagnostics File
8.2 Horizon Surface Shape File
9 Monitoring ET_BHaHAHA’s Status
10 Visualization
11 Accuracy and Testing
12 Examples
12.1 Single Shifted Kerr Black Hole
12.2 Binary Black Hole Inspiral and Merger (BBH Mode)
12.3 Brill-Lindquist Distorted Horizons
13 Acknowledgements
14 License
15 Parameters
16 Interfaces
16.0.1 PUBLIC GROUPS
17 Schedule

Abstract

The ET_BHaHAHA thorn provides an Einstein Toolkit interface to the BHaHAHA (BlackHoles@Home Apparent Horizon Algorithm) library for finding apparent horizons in numerical relativity simulations. BHaHAHA implements a hyperbolic flow-based approach, recasting the elliptic partial differential equation (PDE) for a marginally outer trapped surface (MOTS) as a damped nonlinear wave equation. This method is robust, versatile, and performant, leveraging a multigrid-inspired refinement strategy, an over-relaxation technique, and OpenMP parallelization. The Einstein Toolkit interface thorn, ET_BHaHAHA, allows Cactus-based simulations to utilize these capabilities for black hole identification and characterization. It manages metric data interpolation, MPI synchronization of persistent horizon data using a pack/unpack strategy for Cactus global variables, and diagnostic output.

1 Introduction

Apparent horizons (AHs) are crucial for characterizing black holes and excising their interiors in numerical relativity (NR) simulations [6]. Connecting observational signatures to black hole physical parameters necessitates robust methods for identifying and tracking the BHs themselves within NR simulations. This is primarily accomplished using apparent horizon (AH) finding algorithms. An AH corresponds to the outermost marginally outer trapped surface (MOTS) of a BH, defined as a surface on which the expansion of outgoing null geodesics vanishes [234].

The BHaHAHA library [1] introduces the first open-source, infrastructure-agnostic library for AH finding in NR. It implements a hyperbolic flow-based approach, recasting the elliptic PDE for a MOTS as a damped nonlinear wave equation. This method preserves the full nonlinearity of the expansion equation \(\Theta =0\), avoiding the need for linearization or high-quality initial guesses, and is thus robust in practice.

The ET_BHaHAHA arrangement hosts the ET_BHaHAHA thorn, which serves as the Einstein Toolkit (ETK) [8] interface to the standalone BHaHAHA C library. Key responsibilities of ET_BHaHAHA include:

The BHaHAHA library itself incorporates several features to enhance performance and robustness, such as a multigrid-inspired refinement strategy, an over-relaxation technique, and OpenMP parallelization for the core computations. These features are leveraged by ET_BHaHAHA. An experimental ”BBH mode” is also available for automatically triggering common horizon searches during binary black hole merger simulations.

The hyperbolic relaxation system, central to BHaHAHA, evolves the horizon shape \(h(\theta , \phi )\) and an auxiliary ”velocity” \(v(\theta , \phi )\) in pseudo-time \(\tau \):

\begin {eqnarray} \partial _\tau h &=& v - \eta h \label {eq:hr_h_intro} \\ \partial _\tau v &=& -c^2 \Theta \label {eq:hr_v_intro} \end {eqnarray}

where \(\eta \) is a damping coefficient and \(c\) is the relaxation wave speed (set to 1 in BHaHAHA). The system relaxes towards a steady state where \(\Theta = 0\), the condition for a MOTS.

This thorn is inspired by AHFinderDirect [46] and aims to provide a similarly robust and efficient tool for the numerical relativity community.

2 What ET_BHaHAHA Needs

The ET_BHaHAHA thorn requires a 3+1 decomposed spacetime, providing components of the 3-metric \(\gamma _{ij}\) and extrinsic curvature \(K_{ij}\). These are typically provided by any ADM evolution thorn that populates the corresponding ADMBase grid functions.

ET_BHaHAHA inherits from and depends on several other Einstein Toolkit thorns and arrangements for its operation, summarized in Table 1.


Table 1: Implementations and Thorns typically inherited by ET_BHaHAHA.
Functionality / Data Typically Provided by Thorn(s) or Arrangement
ADM 3-metric, Extrinsic Curvature ADMBase (EinsteinBase)
Boundary Conditions Boundary (CactusBase)
Grid Information Grid (CactusBase), Carpet, CartGrid3D, CoordBase
Output Directory (IO::out_dir) IOUtil (CactusBase) via shares
Shared Parameters (maxntheta, etc.) SphericalSurface (EinsteinAnalysis) via shares
Metric Data Interpolation e.g., AEILocalInterp, LocalInterp, CarpetInterp
Driver / Parallel Grid Management e.g., Carpet (CarpetCode)
MPI Reductions e.g., CarpetReduce (CarpetCode), PUGHReduce (CactusPUGH)

The metric data is expected to be provided on a Cartesian grid, potentially with adaptive mesh refinement (AMR) as managed by Carpet. ET_BHaHAHA then interpolates this data onto its internal spherical grid.

3 Obtaining and Compiling ET_BHaHAHA

The ET_BHaHAHA thorn is part of the ET_BHaHAHA arrangement for the Einstein Toolkit. The core apparent horizon finding capabilities are provided by the BHaHAHA library, which is generated using NRPy+ [910] and is included within the thorn’s source tree (src/BHaHAHA/). The thorn ET_BHaHAHA itself is written in C.

To compile ET_BHaHAHA, ensure that the ET_BHaHAHA arrangement is part of your Cactus checkout. The compilation process is standard for Einstein Toolkit thorns and uses the main Cactus make system. The README file within the thorn’s main directory provides instructions for regenerating the BHaHAHA library if needed. The BHaHAHA library components and the ETK interface code are compiled using gcc by default, as specified in the Makefiles (src/BHaHAHA/Makefile and src/make.code.defn). These files also indicate support for OpenMP (CFLAGS include -fopenmp -std=gnu99 -O2 -march=native), which is enabled if detected by the compiler. No special external libraries beyond a C compiler supporting C99 (GNU extensions are used, e.g. __typeof__) and OpenMP are strictly required by ET_BHaHAHA itself, as its core dependencies (like GSL for table utilities or ADMBase functionality) are handled by the Einstein Toolkit’s build system when those thorns are active.

4 ET_BHaHAHA Parameters

The behavior of the ET_BHaHAHA thorn is controlled by several parameters defined in its param.ccl file. These parameters can be broadly categorized. Parameters are referred to by their param.ccl names.

4.1 Overall Thorn Parameters

max_num_horizons

(Type: CCTK_INT, Default: 3)
Specifies the maximum number of apparent horizons that the thorn will attempt to find and track. This determines the size of various internal arrays. This parameter must be set to be at least as large as the number of horizons you intend to find. In BBH mode, it must be 3. The hardcoded limit is 100 (BHAHAHA_MAX_HORIZONS_SUPPORTED). Range: 0:100

find_every

(Type: CCTK_INT, Default: 1, Steerable: ALWAYS)
This integer parameter controls the execution frequency of the main horizon finding routine BHaHAHA_find_horizons. The finder will run when the current Cactus iteration cctk_iteration is an integer multiple of find_every. If set to 0, ET_BHaHAHA will be disabled globally. Individual horizon search cadences can override this via find_every_individual. Range: 0:*

bah_verbosity_level

(Type: CCTK_INT, Default: 1, Steerable: ALWAYS)
Controls the amount of diagnostic information printed to standard output during the horizon search.

Range: 0:2

max_Ntheta

(Type: CCTK_INT, Default: 32)
The maximum number of grid points used to sample the \(\theta \) (polar) direction on ET_BHaHAHA’s internal spherical surfaces. This corresponds to the highest resolution in the multigrid hierarchy if multigrid is enabled. It must match the last entry in bah_Ntheta_array_multigrid. Range: 2:128 (even values only)

max_Nphi

(Type: CCTK_INT, Default: 64)
The maximum number of grid points used to sample the \(\phi \) (azimuthal) direction on ET_BHaHAHA’s internal spherical surfaces. This corresponds to the highest resolution in the multigrid hierarchy. It must match the last entry in bah_Nphi_array_multigrid. Range: 2:256 (even values only)

bah_num_resolutions_multigrid

(Type: CCTK_INT, Default: 3)
Specifies the number of multigrid levels used in the horizon search. The actual resolutions for each level are defined in bah_Ntheta_array_multigrid and bah_Nphi_array_multigrid. Range: 1:16 (practical limit related to array sizes of bah_Ntheta_array_multigrid)

bah_Ntheta_array_multigrid[16]

(Type: CCTK_INT ARRAY, Default: -100 for all, Steerable: ALWAYS)
An array defining the number of \(\theta \) points for each multigrid level, starting from the coarsest. The number of entries actually used is determined by bah_num_resolutions_multigrid. Example: [8, 16, 32]. The last entry must equal max_Ntheta. Poison value -100 indicates an unset entry. Range (for each element used): 2: * (even values only, up to max_Ntheta)

bah_Nphi_array_multigrid[16]

(Type: CCTK_INT ARRAY, Default: -100 for all, Steerable: ALWAYS)
An array defining the number of \(\phi \) points for each multigrid level, starting from the coarsest. The number of entries used is determined by bah_num_resolutions_multigrid. Example: [16, 32, 64]. The last entry must equal max_Nphi. Poison value -100 indicates an unset entry. Range (for each element used): 2: * (even values only, up to max_Nphi)

bah_enable_eta_varying_alg_for_precision_common_horizon

(Type: CCTK_INT, Default: 0)
Enables a specialized algorithm where the damping parameter \(\eta \) varies to achieve high precision, particularly for common horizon finding. For general-purpose use, this should be disabled (0). Range: 0:1

sync_data_across_ranks_after_each_search__warning_slow

(Type: CCTK_INT, Default: 0)
If set to 1, all persistent horizon data (centers, radii, shapes) will be synchronized across all MPI ranks after each horizon search sequence using MPI reductions. This allows for restarting a simulation with a different number of MPI ranks while maintaining consistent horizon history. However, this can significantly slow down the simulation (potentially by a factor of \(>\)2x for ET_BHaHAHA) as all ranks must wait for the slowest horizon search. If 0 (default), only minimal synchronization required for the thorn’s logic (e.g., for BBH mode) is performed at the beginning of a find, and rank 0 might have stale data for horizons owned by other ranks for checkpointing purposes. BHaHAHA is generally robust enough to recover from a lost horizon if this is disabled. Range: 0:1

interpolator_name

(Type: CCTK_STRING, Default: "Hermite polynomial interpolation")
Specifies the name of the Cactus interpolator to be used for interpolating metric data from the simulation grid to ET_BHaHAHA’s internal spherical grid. ”Hermite polynomial interpolation” is highly recommended as it often leads to faster overall convergence in BHaHAHA for comparable accuracy. ”Lagrange polynomial interpolation” is an alternative. Range: Any valid Cactus interpolator name.

interpolator_pars

(Type: CCTK_STRING, Default: "order=3")
A string containing parameters for the chosen interpolator, passed to Util_TableCreateFromString(). For ”Hermite polynomial interpolation”, ”order=3” is recommended. For ”Lagrange polynomial interpolation”, ”order=4” is recommended. Range: Any string accepted by the selected interpolator’s parameter table creation.

4.2 Per-Horizon Parameters

These parameters are arrays, indexed from 0 to max_num_horizons-1.

find_every_individual[101]

(Type: CCTK_INT ARRAY, Default: -1 for all, Steerable: ALWAYS)
Allows overriding the global find_every for individual horizon i. If set to -1, uses global find_every. If \(\ge 1\), specifies the search cadence for this horizon. If 0, finding for this horizon is disabled. Range (for each element): -1, 0, 1:*

bah_max_search_radius[101]

(Type: CCTK_REAL ARRAY, Default: 1.5 for all, Steerable: ALWAYS)
The maximum coordinate radius of the spherical shell where ET_BHaHAHA will search for horizon i, relative to its current guessed center. This defines the outer boundary of the interpolation region for metric data. This parameter persists throughout the simulation for each horizon. Range (for each element): 0:* (must be positive)

bah_Nr_interp_max[101]

(Type: CCTK_INT ARRAY, Default: 48 for all, Steerable: ALWAYS)
Maximum number of radial points on ET_BHaHAHA’s internal 3D spherical grid for interpolating metric components for horizon i. The actual number of points used will be determined adaptively by bah_radial_grid_cell_centered_set_up based on the current search radii, but will not exceed this value. Recommended range is 48-64. Increasing this value mainly increases the cost of the initial interpolation from the ETK grid. Range (for each element): 4:*

bah_M_scale[101]

(Type: CCTK_REAL ARRAY, Default: 1.0 for all, Steerable: ALWAYS)
Characteristic mass scale for horizon i, in code units. Used to make tolerances and damping dimensionless. Use puncture bare masses or expected irreducible masses. Range (for each element): 0:* (must be positive)

bah_cfl_factor[101]

(Type: CCTK_REAL ARRAY, Default: 0.98 for all, Steerable: ALWAYS)
CFL factor for the hyperbolic relaxation solver for horizon i. This controls the pseudo-timestep. A value of 0.98 is robust. Range (for each element): 0:1.0 (must be positive, \(\le 1.05\) technically for SSPRK3 but \(\le 1.0\) is safer)

bah_max_iterations[101]

(Type: CCTK_INT ARRAY, Default: 10000 for all, Steerable: ALWAYS)
Maximum hyperbolic relaxation steps before the horizon search for horizon i is terminated, even if convergence criteria are not met. For typical tracking, 1000-10000 is sufficient. Range (for each element): 0:*

bah_Theta_L2_times_M_tolerance[101]

(Type: CCTK_REAL ARRAY, Default: 1e-2 for all, Steerable: ALWAYS)
Convergence criterion based on the area-weighted \(L_2\) norm of \(\Theta \times M_{scale}\) for horizon i. A value of \(10^{-2}\) is recommended to balance speed and accuracy for typical horizon tracking, often deferring to the \(L_{\infty }\) norm. Convergence requires both L2 and Linf criteria to be met. Range (for each element): 0:*

bah_Theta_Linf_times_M_tolerance[101]

(Type: CCTK_REAL ARRAY, Default: 1e-5 for all, Steerable: ALWAYS)
Convergence criterion based on the \(L_{\infty }\) norm (maximum absolute value) of \(\Theta \times M_{scale}\) for horizon i. A value of \(10^{-5}\) is recommended as a typical target for accuracy. Range (for each element): 0:*

bah_eta_damping_times_M[101]

(Type: CCTK_REAL ARRAY, Default: 7.0 for all, Steerable: ALWAYS)
The dimensionless damping parameter \(\eta \times M_{scale}\) for the hyperbolic relaxation for horizon i. A value of 7.0 is highly recommended. Range (for each element): 0:*

bah_KO_strength[101]

(Type: CCTK_REAL ARRAY, Default: 0.0 for all, Steerable: ALWAYS)
Strength of the Kreiss-Oliger dissipation applied during the hyperbolic relaxation for horizon i. This usually hinders convergence or accuracy for apparent horizon finding, so it is disabled (0.0) by default. Range (for each element): 0:*

bah_initial_grid_x_center[101]

(Type: CCTK_REAL ARRAY, Default: 0.0 for all, Steerable: ALWAYS)
The initial x-coordinate for the center of ET_BHaHAHA’s spherical search grid for horizon i. This is used at \(t=0\) or if a horizon is lost and needs a reset. Subsequently, the center is extrapolated. Range (for each element): *:*

bah_initial_grid_y_center[101]

(Type: CCTK_REAL ARRAY, Default: 0.0 for all, Steerable: ALWAYS)
The initial y-coordinate for the center of ET_BHaHAHA’s spherical search grid for horizon i. Range (for each element): *:*

bah_initial_grid_z_center[101]

(Type: CCTK_REAL ARRAY, Default: 0.0 for all, Steerable: ALWAYS)
The initial z-coordinate for the center of ET_BHaHAHA’s spherical search grid for horizon i. Range (for each element): *:*

4.3 BBH Mode Parameters

These parameters control the behavior when ET_BHaHAHA is run in its experimental Binary Black Hole (BBH) mode.

bah_BBH_mode_enable

(Type: CCTK_INT, Default: 0)
Enable (1) or disable (0) the BBH mode. When enabled, ET_BHaHAHA will manage the activation/deactivation of searches for two individual inspiralling black holes and a common horizon. Requires max_num_horizons = 3. Range: 0:1

bah_BBH_mode_inspiral_BH_idxs[2]

(Type: CCTK_INT ARRAY, Default: [0,0])
An array of two integers specifying the zero-offset horizon indices for the two inspiralling black holes. Example: [0,1]. These indices must be unique and different from bah_BBH_mode_common_horizon_idx. Range (for each element): 0:2 (Indices must be distinct and within \(0 \dots \text {\texttt {max\_num\_horizons}}-1\); typically \(0,1,2\) if \(\text {\texttt {max\_num\_horizons}}=3\))

bah_BBH_mode_common_horizon_idx

(Type: CCTK_INT, Default: 2)
The zero-offset horizon index for the common (merged) horizon. Example: 2. This index must be unique and different from those in bah_BBH_mode_inspiral_BH_idxs. Range: 0:2 (Index must be distinct and within \(0 \dots \text {\texttt {max\_num\_horizons}}-1\))

5 Provided Variables

The ET_BHaHAHA thorn declares several variables in its interface.ccl to store persistent horizon data. These variables are primarily used internally for tracking horizon evolution across time steps and for MPI synchronization, but advanced users or other thorns might find them useful. All variables are public. The index for horizon-specific variables (e.g., x_center_m1[h]) is 0-based in C, ranging from 0 to max_num_horizons-1.

bah_prev_horizons (Group)

(Type: CCTK_REAL ARRAY, Size: max_num_horizons*max_Ntheta*max_Nphi, Distribution: CONSTANT)
This group holds the shapes \(h(\theta , \phi )\) of previously found horizons. It is a single flat 1D array, but logically contains three sets of surfaces for each of the max_num_horizons. For a given horizon index hidx (0 to max_num_horizons-1), the shape data for \(h(\theta \_j, \phi \_k)\) is accessed with an offset: hidx * max_Ntheta * max_Nphi + itheta * max_Nphi + iphi (assuming \(\phi \) varies fastest, though the actual C indexing macro IDX2 uses itheta + NUM_THETA * iphi).

These are used for extrapolating an initial guess for the current time step. All ranks maintain a copy, synchronized by BHaHAHA_sync_persistent_across_ranks.

bah_coord_info (Group)

(Type: CCTK_REAL SCALAR, Distribution: CONSTANT, Effectively arrays of size max_num_horizons)
Stores scalar information from previous horizon finds for each horizon. Each member is a Cactus scalar grid function that behaves as an array of size max_num_horizons.

Synchronized by BHaHAHA_sync_persistent_across_ranks.

bah_guess (Group)

(Type: CCTK_INT SCALAR, Distribution: CONSTANT, Effectively an array of size max_num_horizons)

Synchronized by BHaHAHA_sync_persistent_across_ranks.

bah_is_horizon_active (Group)

(Type: CCTK_INT SCALAR, Distribution: CONSTANT, Effectively an array of size max_num_horizons)

Synchronized by BHaHAHA_sync_persistent_across_ranks.

6 Scheduling and MPI Synchronization

The ET_BHaHAHA thorn schedules its main driver function and manages storage for its interface.ccl variables as defined in schedule.ccl.

6.1 Storage

The following grid function groups are declared for storage:

Memory for these variables is allocated by the Cactus framework.

6.2 Scheduled Functions

BHaHAHA_find_horizons

Scheduled at CCTK_ANALYSIS with options: global-early.
This is the main C language driver function for ET_BHaHAHA. It is responsible for:

  1. Checking if a horizon search is due based on find_every and find_every_individual.

  2. Performing initial setup at cctk_iteration == 0, including initializing persistent variables and BBH mode flags.

  3. Synchronizing persistent data across MPI ranks using BHaHAHA_sync_persistent_across_ranks (see Section 6.3 below).

  4. Populating the BHaHAHA parameter structure (bhahaha_params_and_data_struct) for each active horizon, including reading persistent data from Cactus GFs (via read_persistent_data_store_to_bhahaha_params_and_data).

  5. Applying robustness improvements (e.g., adjusting CFL, multigrid resolutions for first finds).

  6. Extrapolating initial guesses for horizon centers and search radii using bah_xyz_center_r_minmax.

  7. Executing BBH mode logic for activating/deactivating common and individual horizon searches.

  8. For each active horizon:

    • Setting up the radial interpolation grid using bah_radial_grid_cell_centered_set_up.

    • Calling BHaHAHA_interpolate_metric_data to interpolate ADM metric components from the ETK grid to the BHaHAHA spherical grid. This is done only on the MPI rank owning the horizon.

    • Invoking the core BHaHAHA solver (bah_find_horizon) on the owning MPI rank.

    • Processing results: if successful, updating persistent Cactus GFs using write_persistent_from_bhahaha_params_and_data and outputting diagnostics using bah_diagnostics_file_output. If failed, setting flags to ensure a robust guess next time.

  9. Optionally, performing a final synchronization of all persistent data if sync_data_across_ranks_after_each_search__warning_slow is enabled.

The global-early option is chosen to be consistent with AHFinderDirect, aiming to find horizons early in the analysis phase.

6.3 MPI Synchronization Details

Persistent horizon data (previous shapes, centers, radii, active flags) needs to be consistent across all MPI ranks for robust tracking and BBH mode operation. ET_BHaHAHA employs a custom MPI synchronization strategy implemented in BHaHAHA_sync_persistent_across_ranks.c:

This synchronization occurs at the beginning of BHaHAHA_find_horizons (if running in parallel) and optionally at the end if sync_data_across_ranks_after_each_search__warning_slow is enabled.

7 Physics Background and Numerical Methods

The ET_BHaHAHA thorn interfaces with the BHaHAHA library, which implements a specific set of methods for finding apparent horizons. The core physics and numerics are detailed in [1].

7.1 Apparent Horizons and MOTS

An apparent horizon is defined as the outermost marginally outer trapped surface (MOTS). A MOTS is a 2-surface where the expansion \(\Theta \) of outgoing null geodesics vanishes. In the ADM 3+1 formalism [5], where the line element is \begin {equation} ds^2 = -\alpha ^2 dt^2 + \gamma _{ij} (dx^i + \beta ^i dt) (dx^j + \beta ^j dt), \label {eq:adm_line_element} \end {equation} with \(\alpha \) the lapse, \(\beta ^i\) the shift, and \(\gamma _{ij}\) the spatial 3-metric, the expansion for a surface \(F(x^k)=r-h(\theta ,\phi )=0\) is [1]: \begin {equation} \Theta = \frac {1}{\lambda } (\partial _i F \partial _j \gamma ^{ij} + \gamma ^{ij} \partial _i \partial _j F) - \frac {1}{\lambda ^3} \partial _k \lambda \gamma ^{kj} \partial _j F + s^k \partial _k (\ln \sqrt {\gamma }) - K + s^i s^j K_{ij} = 0, \label {eq:MOTS_expansion_detail} \end {equation} where \(s\_i = \partial _i F / \lambda \) is the unit normal, \(\lambda = \sqrt {\gamma ^{kl}\partial _k F \partial _l F}\), \(\gamma = \det (\gamma _{ij})\), \(K_{ij}\) is the extrinsic curvature, and \(K = \gamma ^{ij}K_{ij}\).

7.2 Hyperbolic Relaxation

BHaHAHA recasts the elliptic PDE (2) into a hyperbolic system by introducing a pseudo-time \(\tau \) evolution for the surface shape \(h(\theta , \phi )\) and an auxiliary ”velocity” field \(v(\theta , \phi )\):

\begin {eqnarray} \partial _\tau h &=& v - \eta h \label {eq:hr_h_detail_main} \\ \partial _\tau v &=& -c^2 \Theta \label {eq:hr_v_detail_main} \end {eqnarray}

where \(\eta \) is a damping coefficient (units of \(1/M\), related to bah_eta_damping_times_M), and \(c\) is the relaxation wave speed (dimensionless, set to 1 in BHaHAHA). As \(\tau \rightarrow \infty \), the system is driven towards a steady state where \(\partial _\tau v = 0 \implies \Theta = 0\).

7.3 Numerical Implementation Details within BHaHAHA

The BHaHAHA library’s numerical implementation, leveraged by ET_BHaHAHA, involves several key steps:

7.3.1 Metric Data Handling and Interpolation

7.3.2 Initial Data for Hyperbolic Relaxation

The initial guess \(h(0, \theta , \phi )\) for the hyperbolic relaxation is determined by ET_BHaHAHA (within BHaHAHA_find_horizons.c before calling the library’s bah_initial_data.c):

The initial auxiliary field is set to \(v(0, \theta , \phi ) = \eta h(0, \theta , \phi )\) by bah_initial_data.c to start near the \(\partial _\tau h = 0\) condition.

7.3.3 Pseudo-Time Evolution

The hyperbolic system (Eqs. ??-??) is evolved using a third-order Strong Stability Preserving Runge-Kutta (SSPRK3) scheme [16] by bah_MoL_step_forward_in_time.c. The pseudo-timestep \(\Delta \tau \) is determined by a CFL condition (via bah_cfl_limited_timestep_based_on_h_equals_r.c) based on the wave speed \(c=1\) and the proper grid spacings on the evolving surface \(h\). Angular derivatives of \(h\) (via bah_rhs_eval.c) needed for \(\Theta \) are recomputed at each SSPRK3 substep.

7.3.4 Convergence and Stopping Conditions

The pseudo-time evolution stops when the dimensionless expansion \(M\_{\text {scale}}\Theta \) satisfies user-defined tolerances for both its \(L_\infty \) and area-weighted \(L_2\) norms (controlled by parameters bah_Theta_Linf_times_M_tolerance and bah_Theta_L2_times_M_tolerance), or when bah_max_iterations is reached. \(M\_{\text {scale}}\) is a user-provided characteristic mass for the horizon.

7.3.5 Convergence Acceleration Techniques

7.4 Binary Black Hole (BBH) Mode in ET_BHaHAHA

When the parameter bah_BBH_mode_enable = 1, ET_BHaHAHA activates specialized logic for binary black hole merger simulations, typically requiring max_num_horizons = 3.

  1. Initial Phase: Horizon searches are active for two individual inspiralling BHs (whose indices are given by bah_BBH_mode_inspiral_BH_idxs). The search for a common horizon (index bah_BBH_mode_common_horizon_idx) is initially inactive.

  2. Common Horizon Activation: The thorn monitors the separation distance between the centroids of the two inspiral BHs and their last known maximum radii. If the condition \((\text {distance}(BH\_1, BH\_2) + r\_{\text {max},1} + r\_{\text {max},2}) \le (2.0 \times \text {\texttt {bah\_max\_search\_radius}}[\text {common\_idx}])\) is met, and both individual BHs have been successfully found previously, the common horizon search is activated. The initial guess for the common horizon’s center is set to the center-of-mass of the two inspiral BHs (weighted by their respective bah_M_scale values). A full sphere guess is forced for its first few attempts.

  3. Deactivation of Individual BHs: Once the common horizon is consistently found (i.e., use_fixed_radius_guess_on_full_sphere[common_idx] == 0) and remains active, searches for the individual inspiral BHs are deactivated.

To improve robustness for initial common horizon finds, if the common horizon has not been found successfully for three consecutive attempts, ET_BHaHAHA adjusts parameters for the common horizon search: the CFL factor is reduced by 10%, a fixed-radius guess is enforced, and if at least two multigrid levels are used, the coarsest multigrid resolution is temporarily increased to match that of the second level, with the maximum iterations doubled.

7.5 Diagnostics Computation

Upon convergence, various physical diagnostics are computed by the BHaHAHA library from the found MOTS \(h(\theta , \phi )\), including:

These are handled by functions such as bah_diagnostics_area_centroid_and_Theta_norms.c, bah_diagnostics_min_max_mean_radii_wrt_centroid.c, and bah_diagnostics_proper_circumferences.c.

8 Output Data

The ET_BHaHAHA thorn, through the BHaHAHA library function bah_diagnostics_file_output.c, produces two main types of ASCII output files per found horizon, stored in the directory specified by the Cactus parameter IO::out_dir. These files are designed to be gnuplot-friendly.

8.1 Horizon Diagnostics File

8.2 Horizon Surface Shape File

9 Monitoring ET_BHaHAHA’s Status

The verbosity of ET_BHaHAHA is controlled by the bah_verbosity_level parameter:

Error messages from BHaHAHA are converted to descriptive strings by bah_error_message() and reported via CCTK_VWarn or CCTK_VInfo, often indicating failure to find a horizon and the reason.

10 Visualization

The output files from ET_BHaHAHA are formatted for easy visualization, primarily with gnuplot.

11 Accuracy and Testing

The BHaHAHA library and its ET_BHaHAHA interface have undergone several tests to assess accuracy and robustness, as detailed in [1].

The default tolerance for ET_BHaHAHA (bah_Theta_Linf_times_M_tolerance = 1e-5) is typically sufficient for most production NR simulations, as accuracy is often limited by metric interpolation error rather than the horizon finder’s intrinsic precision.

12 Examples

Example parameter files for using ET_BHaHAHA can be found in the ET_BHaHAHA/par/ directory.

12.1 Single Shifted Kerr Black Hole

The parameter file shifted_kerr_schild.par sets up a single, spinning Kerr black hole using the ShiftedKerrSchild initial data thorn. Key ET_BHaHAHA parameters in this file:

ActiveThorns = "ET_BHaHAHA"
ET_BHaHAHA::max_num_horizons = 1
ET_BHaHAHA::bah_verbosity_level = 2
ET_BHaHAHA::bah_max_search_radius[0] = 1.5
# BHaHAHA::bah_M_scale[0] = 1.0 (Matches ShiftedKerrSchild::BH_mass)

12.2 Binary Black Hole Inspiral and Merger (BBH Mode)

The parameter file GW150914_baikalvacuum.par simulates a GW150914-like binary black hole system using TwoPunctures initial data and evolved with BaikalVacuum. This example demonstrates the BBH mode of ET_BHaHAHA. Key ET_BHaHAHA parameters for BBH mode:

ActiveThorns = "ET_BHaHAHA"
BHaHAHA::max_num_horizons = 3
BHaHAHA::bah_BBH_mode_enable = 1
BHaHAHA::bah_BBH_mode_common_horizon_idx = 2
BHaHAHA::bah_BBH_mode_inspiral_BH_idxs = [0, 1]
BHaHAHA::find_every = 44 # Search cadence
# Per-horizon parameters (indices 0, 1 for inspiral; 2 for common)
BHaHAHA::bah_M_scale = [0.5538, 0.4461, 1.0]
BHaHAHA::bah_initial_grid_x_center[0] =  4.461538
BHaHAHA::bah_initial_grid_x_center[1] = -5.538461
BHaHAHA::bah_max_search_radius = [0.6, 0.5, 1.4]

This setup tracks the two inspiralling black holes. When they get close enough, ET_BHaHAHA automatically starts searching for the common horizon.

12.3 Brill-Lindquist Distorted Horizons

Files like brill_lindquist_highly_distorted_horizon.par (and variants with different mass scales, e.g., -1e-5.par, -1e8.par) set up two Brill-Lindquist punctures with a small separation, resulting in a highly distorted common apparent horizon. These test robustness and scale invariance. BBH mode is disabled, so three horizons (common, and two small individual ones near punctures) are sought independently.

13 Acknowledgements

The ET_BHaHAHA thorn was developed by Zachariah B. Etienne. The underlying BHaHAHA library, also primarily developed by Zachariah B. Etienne, benefitted from input and contributions from Thiago Assumpção, Leonardo Rosa Werneck, and Samuel D. Tootle, as detailed in [1]. Special thanks to Jonathan Thornburg, whose AHFinderDirect thorn has been a cornerstone of apparent horizon finding in the numerical relativity community and served as a template and high standard for BHaHAHA and ET_BHaHAHA. Thanks also to Roland Haas for valuable input during the development of the BHaHAHA library.

This research made use of the resources of the High Performance Computing Center at Idaho National Laboratory, which is supported by the Office of Nuclear Energy of the U.S. Department of Energy and the Nuclear Science User Facilities under Contract No. DE-AC07-05ID14517. In addition, it made use of the Falcon supercomputer, operated by the Idaho C3+3 Collaboration. Z.B.E. gratefully acknowledges support from NSF awards PHY-2110352/2508377, PHY-2409654, OAC-2004311/2227105, OAC-2411068, and AST-2108072/2227080, as well as NASA awards ISFM-80NSSC18K0538, TCAN-80NSSC18K1488, and ATP-80NSSC22K1898. TA is thankful for support from NSF grants OAC-2229652 and AST-2108269. L.R.W. gratefully acknowledges support from NASA award LPS-80NSSC24K0360. Z.B.E. and ST received additional support from NASA award ATP-80NSSC22K1898 and the University of Idaho P3-R1 Initiative.

14 License

The ET_BHaHAHA thorn is licensed under the BSD 2-Clause License:

BSD 2-Clause License

Copyright (c) 2025, Zachariah Etienne
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

References

[1]   Z. B. Etienne, T. Assumpção, L. R. Werneck, S. D. Tootle, BHAHAHA: A Fast, Robust Apparent Horizon Finder Library for Numerical Relativity, arXiv:2505.15912 [gr-qc] (2025).

[2]   R. Penrose, Gravitational Collapse and Space-Time Singularities, Phys. Rev. Lett., 14 (1965), 57–59.

[3]   J. M. M. Senovilla, Trapped Surfaces, Int. J. Mod. Phys. D, 20 (2011), 2139. arXiv:1107.1344 [gr-qc]

[4]   J. Thornburg, A Fast Apparent-Horizon Finder for 3-Dimensional Cartesian Grids in Numerical Relativity, Class. Quantum Grav., 21 (2004), 743–766. arXiv:gr-qc/0306056

[5]   R. Arnowitt, S. Deser, C. W. Misner, The Dynamics of General Relativity, In: Witten L. (eds) Gravitation: An Introduction to Current Research. John Wiley & Sons, New York (1962). Reprinted in Gen. Rel. Grav. 40 (2008), 1997–2027. arXiv:gr-qc/0405109

[6]   J. Thornburg, Event and Apparent Horizon Finders for 3+1 Numerical Relativity, Living Rev. Relativ., 10 (2007), 3. arXiv:gr-qc/0512169

[7]   The Cactus Code, http://cactuscode.org/.

[8]   F. Löffler, J. Faber, E. Bentivegna, T. Bode, P. Diener, R. Haas, I. Hinder, B. C. Mundim, C. D. Ott, E. Schnetter, G. Allen, M. Campanelli, and P. Laguna, The Einstein Toolkit: A community computational infrastructure for relativistic astrophysics, Class. Quantum Grav., 29 (2012), 115001. arXiv:1111.3344 [gr-qc].

[9]   NRPy: Numerical Relativity in Python, https://nrpyplus.net/.

[10]   Z. B. Etienne, et al., NRPy+ GitHub Repository, https://github.com/nrpy/nrpy.

[11]   E. Schnetter, S. H. Hawley, I. Hawke, Evolutions in 3D numerical relativity using fixed mesh refinement, Class. Quantum Grav., 21 (2004), 1465. arXiv:gr-qc/0310042

[12]   Carpet: Adaptive Mesh Refinement for the Cactus Framework, http://www.carpetcode.org/.

[13]   J. D. Brown, Covariant formulations of spherical harmonic P N formalisms in numerical relativity, Phys. Rev. D, 80 (2009), 084042. arXiv:0908.3814 [gr-qc].

[14]   P. J. Montero and I. Cordero-Carrión, Reference-metric subsystem for BSSN-inspired equations in spherical coordinates, Phys. Rev. D, 85 (2012), 124037. arXiv:1204.5377 [gr-qc].

[15]   T. W. Baumgarte, P. J. Montero, I. Cordero-Carrión, and E. Müller, Numerical relativity in spherical coordinates: A new reference-metric BSSN formulation, Phys. Rev. D, 87 (2013), 044026. arXiv:1211.6632 [gr-qc].

[16]   S. Gottlieb, C.-W. Shu, and E. Tadmor, Strong Stability-Preserving High-Order Time Discretization Methods, SIAM Review, 43 (2001), 89–112.

[17]   M. Alcubierre, J. A. González, D. Núñez, and J. A. Percival, Quasi-local characterization of a Kerr black hole’s spin, Phys. Rev. D, 72 (2005), 044004. arXiv:gr-qc/0411149.

[18]   H. K. Hui and L.-M. Lin, A multigrid apparent horizon solver for binary black hole spacetimes, Class. Quantum Grav., 42 (2025), 055008. arXiv:2404.16511 [gr-qc].

15 Parameters




bah_bbh_mode_common_horizon_idx
Scope: restricted  INT



Description: BBH mode: Horizon indices (zero-offset) for two inspiralling BHs. E.g., if the common horizon has index 2, then set bah_BBH_mode_common_horizon_idx=2



Range   Default: 2
0:2
0, 1, or 2.






bah_bbh_mode_enable
Scope: restricted  INT



Description: 0 = disable; 1 = enable



Range  Default: (none)
0:1
0=disable, 1=enable






bah_bbh_mode_inspiral_bh_idxs
Scope: restricted  INT



Description: BBH mode: Horizon indices (zero-offset) for two inspiralling BHs. E.g., if the inspiralling BHs have indices 0,1 then set BHaHAHA::bah_BBH_mode_inspiral_BH_idxs = [0,1]



Range  Default: (none)
0:2
0, 1, or 2.






bah_cfl_factor
Scope: restricted  REAL



Description: Courant-Friedrichs-Lewy (CFL) factor to set timestep within BHaHAHA hyperbolic relaxation. 0.98 robust default, even for new horizon formation (e.g., common horizons).



Range   Default: 0.98
0:1.0
Positive values up to 1.0 accepted.






bah_enable_eta_varying_alg_for_precision_common_horizon
Scope: restricted  INT



Description: Enable eta-varying algorithm for high-precision common horizon finding. For general-purpose horizon finding, leave this disabled.



Range  Default: (none)
0:1
0=disable; 1=enable






bah_eta_damping_times_m
Scope: restricted  REAL



Description: Hyperbolic relaxation exponential damping parameter.



Range   Default: 7.0
0:*
7.0 highly recommended, seems best in GW150914 gallery example.






bah_initial_grid_x_center
Scope: restricted  REAL



Description: Initial x locations of horizon grid centers



Range   Default: 0.0
*:*
Any value allowed






bah_initial_grid_y_center
Scope: restricted  REAL



Description: Initial y locations of horizon grid centers



Range   Default: 0.0
*:*
Any value allowed






bah_initial_grid_z_center
Scope: restricted  REAL



Description: Initial z locations of horizon grid centers



Range   Default: 0.0
*:*
Any value allowed






bah_ko_strength
Scope: restricted  REAL



Description: Hyperbolic relaxation Kreiss-Oliger dissipation parameter. This usually hurts more than it helps, so is disabled (0.0) by default.



Range   Default: 0.0
0:*
0.0 strongly recommended






bah_m_scale
Scope: restricted  REAL



Description: Mass scale for each horizon.



Range   Default: 1.0
0:*
”Estimate of the mass of each horizon, used for bah_Theta_Linf_times _M_tolerance AND bah_eta_damping_time s_M. I would use e.g., the puncture bare masses or expected irreducible masses here.”






bah_max_iterations
Scope: restricted  INT



Description: Maximum hyperbolic relaxation steps before ending the horizon search.



Range   Default: 10000
0:*
Zero (disable) or positive integer; recommended: 1000–10000. Once horizon found, shouldn’t need more than ˜100 at lowest resolution. For precision horizon finding (3-horizon Brill-Lindquist for example), this parameter might need to be set in the 1e9 range






bah_max_search_radius
Scope: restricted  REAL



Description: Input spherical grid(s): maximum radius to search, for all time.



Range   Default: 1.5
0:*
All positive values accepted.






bah_nphi_array_multigrid
Scope: restricted  INT



Description: Multigrid Nphi array.



Range   Default: -100
-100
poison value
2:*:2
only allow even values >=2






bah_nr_interp_max
Scope: restricted  INT



Description: Maximum number of radial points for grid(s): Number of points sampling radial direction.



Range   Default: 48
4:*
All values > 4 accepted. Recommended: 48 – 64. Increasing this will increase ET interpolation overhead (usually the largest cost), but BHaHAHA itself will remain about the same speed.






bah_ntheta_array_multigrid
Scope: restricted  INT



Description: Multigrid Ntheta array.



Range   Default: -100
-100
poison value
2:*:2
only allow even values >=2






bah_num_resolutions_multigrid
Scope: restricted  INT



Description: Number of resolutions provided in bah_N{theta,phi}_array_multigrid[] arrays



Range   Default: 3
-100
poison value
1:*
anything else






bah_theta_l2_times_m_tolerance
Scope: restricted  REAL



Description: Primary convergence criterion: area-weighted L2 norm of residual function Theta on horizon.



Range   Default: 1e-2
0:*
1e-2 recommended, for speed vs accuracy balance






bah_theta_linf_times_m_tolerance
Scope: restricted  REAL



Description: Secondary convergence criterion: L-infinity norm of Theta, time mass scale.



Range   Default: 1e-5
0:*
1e-5 recommended






bah_verbosity_level
Scope: restricted  INT



Description: 0 = essential only; 1 = physical summary of found horizon; 2 = full algorithmic details



Range   Default: 1
0:2
0, 1, or 2.






find_every
Scope: restricted  INT



Description: Search cadence for all horizons.



Range   Default: 1
disable BHaHAHA
1:*
any integer >= 1






find_every_individual
Scope: restricted  INT



Description: Search cadence for individual apparent horizons. (overrides find_every if >= 1).



Range   Default: -1
-1
use find_every
disable BHaHAHA on this horizon
1:*
any integer >= 1






interpolator_name
Scope: restricted  STRING



Description: Which interpolator should I use



Range  Default: Hermite polynomial interpolation
.+
Any nonempty string






interpolator_pars
Scope: restricted  STRING



Description: Parameters for the interpolator



Range  Default: order=3
.*
”Any string that Util_TableSetFromStr ing() will take”






max_nphi
Scope: restricted  INT



Description: Maximum number of points that will sample the phi direction. For typical horizon finding, leave this to default value of 64.



Range   Default: 64
2:256:2
only allow even values between 2 and 256






max_ntheta
Scope: restricted  INT



Description: Maximum number of points that will sample the theta direction. For typical horizon finding, leave this to default value of 32.



Range   Default: 32
2:128:2
only allow even values between 2 and 128






max_num_horizons
Scope: restricted  INT



Description: Maximum number of horizons for this simulation.



Range   Default: 3
0:*
Zero or any positive number.






sync_data_across_ranks_after_each_search__warning_slow
Scope: restricted  INT



Description: Enables restart from a different number of MPI ranks. WARNING: Slows BHaHAHA by >2x



Range  Default: (none)
0:1
Zero (no) or one (yes).






maxnphi
Scope: shared from SPHERICALSURFACE INT






maxntheta
Scope: shared from SPHERICALSURFACE INT






nsurfaces
Scope: shared from SPHERICALSURFACE INT



16 Interfaces

General

Implements:

bhahaha

Inherits:

admbase

boundary

grid

Grid Variables

16.0.1 PUBLIC GROUPS




  Group Names     Variable Names     Details    




bah_prev_horizons   compact 0
prev_horizon_m1   dimensions 1
prev_horizon_m2   distribution CONSTANT
prev_horizon_m3   group type ARRAY
  size MAX_NUM_HORIZONS*MAX_NTHETA*MAX_NPHI
  timelevels 1
  vararray_size max_num_horizons
  variable type REAL




bah_coord_info   compact 0
t_m1   dimensions 0
r_min_m1   distribution CONSTANT
r_max_m1   group type SCALAR
x_center_m1   timelevels 1
y_center_m1   vararray_size max_num_horizons
z_center_m1   variable type REAL




bah_guess   compact 0
use_fixed_radius_guess_on_full_sphere  dimensions 0
  distribution CONSTANT
  group type SCALAR
  timelevels 1
  vararray_size max_num_horizons
  variable type INT




bah_is_horizon_active   compact 0
bah_horizon_active   dimensions 0
  distribution CONSTANT
  group type SCALAR
  timelevels 1
  vararray_size max_num_horizons
  variable type INT




17 Schedule

This section lists all the variables which are assigned storage by thorn EinsteinAnalysis/ET_BHaHAHA. Storage can either last for the duration of the run (Always means that if this thorn is activated storage will be assigned, Conditional means that if this thorn is activated storage will be assigned for the duration of the run if some condition is met), or can be turned on for the duration of a schedule function.

Storage

 

Always:  
bah_prev_horizons  
bah_coord_info  
bah_guess  
bah_is_horizon_active  
   

Scheduled Functions

CCTK_ANALYSIS

  bhahaha_find_horizons

  driver function for bhahaha

 

  Language: c
  Options: global-early
  Type: function