Quarkonium-System

How the code was written

These pages retell the construction of the engine, in the order in which one can actually build it: each layer can be written and tested using only the layers below it. The excerpts are taken from the sources when this site is built, so they are the code that runs.

The shape of the problem

The whole program is one pipeline,

parameters θ ──► matrices H(θ), S ──► eigenvalues, vectors ──► masses μ(θ) ──► χ² ──► θ̂
                      ▲                                              │
                      └──────────── dH/dθ ───────────────────────────┘

and almost every design decision follows from wanting that loop to be exact, fast and testable:

need decision
exact matrix elements closed forms wherever they exist; each checked against quadrature
exact derivatives Feynman–Hellmann, with (dH/d\theta) from the same expressions that build (H)
fast refits (thousands of them) cache every matrix that does not depend on the parameters
four model families, one fitter an abstract Model that only returns matrices
fits that fail without crashing a sweep numerical failures are values, not exceptions
reproducible results fixed seeds, own random-number transforms, every record carries its settings

Layers

flowchart BT
  core --> math --> basis --> me
  core --> linalg
  me --> models
  spin --> models
  linalg --> solve
  models --> solve --> obs
  solve --> fit
  data --> fit
  stats --> fit
  fit --> report
  obs --> report
  report --> analysis
  me --> few
  linalg --> few
  analysis --> api
  few --> api
  api --> capi
  api --> apps

An arrow reads “is used by”. There are about 22 000 lines in src/ and 5 600 in tests/.

Ground rules chosen at the start

--8<-- "src/core/error.hpp:result"

Wrong input or a programming error throws.

History

The first version computed meson fits and was analysed by Python scripts. It grew by releases: widths and a pre-registered selection rule (1.0), a sign fix in S–D mixing (1.1), complex-range bases and the one-loop potential (1.2), a physics-based model error (1.3), baryons and tetraquarks (1.4). Version 1.5 introduced the request interface and the bindings; 1.6–1.8 moved selection, sweeps and report from Python into C++; 2.0 removed Python and merged the programs into qs; 2.1 added five bodies. The changelog has the details.

The chapters

  1. Numerics: special functions, quadrature, basis, matrix elements, eigenproblem
  2. Models and solver
  3. Data and fit
  4. N bodies
  5. Analysis pipeline
  6. Interfaces
  7. Testing, and bugs worth remembering