COCAL — Compact Object CALculator#
COCAL is a numerical-relativity solver for stationary, axisymmetric and triaxial compact objects — here, rapidly rotating neutron stars computed in the Waveless (WL) formulation of Einstein’s equations with a piecewise-polytropic equation of state (peos), solved by self-consistent field (SCF) iteration on multi-domain spherical-coordinate patches.
This repository is a C++/ Kokkos port and modernization
of the original Fortran COCAL code, targeting host (OpenMP), NVIDIA GPU (CUDA)
and AMD GPU (HIP) execution from a single source. The original Fortran lives
under reference/legacy-fortran/ as a frozen reference.
Documentation links#
Note
Status. Active modernization. The C++ solver builds and runs on host and
GPU and reproduces the reference physics to 1e-12 (see
Regression gates). Internals are being re-architected
incrementally behind that gate; see
docs/superpowers/specs/2026-06-25-cocal-modernization-design.md.
Layout#
Path |
What |
|---|---|
|
The C++/Kokkos solver library, grouped by module |
|
The solver executable ( |
|
Unit (smoke) + end-to-end gates |
|
Build + run helpers (Kokkos installs, compute-node builds) |
|
SLURM GPU regression gate |
|
Sample parameter / EOS inputs ( |
|
Frozen original Fortran ( |
|
Design spec, testing guide, architecture notes |
Building and running#
You are given an sw-build (the prebuilt Kokkos installs); you point your
config.sh at your copy of it and compile COCAL. See Installing KCOCAL
for the full guide. The short version:
cp config.template.sh config.sh # once: then set COCAL_KOKKOS_ROOT + account
export COCAL_KOKKOS_VARIANT=hopper90 # cpu | cpu35 | hopper90 | mi100
./scripts/submit.sh build # compile pRNS_WL against the Kokkos install
# wait for that job to finish -- they share a build tree (SETUP.md)
./scripts/submit.sh run # recompile incrementally and solve
The backend is chosen entirely by which Kokkos install you build against — there is no separate CUDA switch:
Variant |
Backend |
Hardware |
|---|---|---|
|
Serial + OpenMP |
any host |
|
Serial + OpenMP, N threads |
any host — |
|
CUDA |
RTX 4080 / L40S / Ada |
|
CUDA |
H100 / H200 / Hopper |
|
HIP |
AMD Instinct MI100 |
config.sh is the one file you edit — copy it from the tracked
config.template.sh template, then set COCAL_KOKKOS_ROOT to your copy of
sw-build and COCAL_SLURM_ACCOUNT to your allocation; every field has a
comment showing the command to find its value on your cluster. Your config.sh
is gitignored, so your paths never get committed and a pull never clobbers them. (The
compiler and Kokkos arch flags per backend live in
scripts/cocal_build_env.sh; you only touch that to add a new GPU arch.)
The physics of a run is set with plain env vars — COCAL_ROT_LAW (UR/DR)
and COCAL_NUM_SOL_SEQ:
export COCAL_ROT_LAW=DR COCAL_NUM_SOL_SEQ=35
./scripts/submit.sh run
Warning
Do not compile on a login node — the heavy Kokkos translation units
exhaust its per-user memory and the compiler is killed. submit.sh always
builds on a compute node.
Regression gates#
Three gates, fastest first — see Testing and regression gates.
Fast unit — numerics golden tests:
ctest --test-dir build -L fast.End-to-end (host/GPU) — full bar-C run vs the checked-in physics baseline at 1e-12:
bash tests/e2e/run_e2e.sh.GPU e2e via SLURM —
sbatch ci/slurm_e2e_gpu.sbatch.
Host CI (.github/workflows/ci.yml) runs gate 1 on every push.
License#
MIT © The COCAL Collaboration. The physics and original algorithms originate with Kōji Uryū and collaborators; please cite the COCAL papers when using this code (see Citation).
Contributing#
See Contributing to COCAL. In short: keep the regression gates green,
format-as-you-touch (.clang-format), and never refactor without the e2e
gate.
Quick Start Guide
Gallery Examples
Development