Quarkonium-System

2. Models and solver

One interface

The fitter, the solver and the error analysis must not know which model they are working on. So a model has one real job: given a channel and parameters, return matrices.

--8<-- "src/models/model.hpp:model"

ChannelMatrices holds H, S, an optional first-order matrix W, an optional fixed orthonormaliser X (models C and D build (H) in such a basis), and optionally (\partial H/\partial\theta_a).

Caching

During a fit, (H(\theta)) is rebuilt thousands of times, but (\langle p^2\rangle), (\langle1/r\rangle), (\langle r\rangle) never change: only their coefficients do. MatrixCache stores each matrix under a key (kind, (l), (l’), power, parameter). Matrices that depend on a non-linear parameter ((\sigma), (\mu_s)) go into a second map that is cleared when it grows past 256 entries. One cache per thread, no locking.

Dual numbers { #dual-numbers }

(H) is a sum of (scalar prefactor) × (matrix). The prefactors are awkward functions of the parameters, such as (\alpha_s\tau^3/m_1m_2) with (\tau(\sigma)). Differentiating them by hand invites bugs that only show up as a fit that converges badly. Instead the prefactors are computed with a tiny forward-mode dual number, a value carrying its gradient:

--8<-- "src/models/dual.hpp:dual"

Every arithmetic rule is the corresponding rule of calculus. The code that builds (H) is written once; the derivative comes out. For the few matrices that depend on a parameter themselves, the derivative matrix is passed alongside ((\partial_\tau) of a smeared potential is a Gaussian).

In the Godfrey–Isgur models (\theta) sits inside momentum integrals, so there the code uses central differences, and the fitter tells the model which parameters are free (restrict_derivatives) so nothing else is computed.

Parameters

A ParamSet knows for each parameter whether it is free, fixed or tied to another (equal quark masses), its bounds, and its transform. The minimiser only ever sees the unconstrained vector (u) ((\ln\theta) for positive ones); bounds are checked, not clipped, so a minimum on a boundary is visible rather than silently produced.

Refusing bad physics

build throws when asked for something that would give a basis-dependent answer: a smeared contact term narrower than the finest Gaussian ((\sigma r_1>1)), or a relativistic kinetic energy with a point Coulomb potential. A fit treats such a trial point as a failed step.

Gradients of masses

--8<-- "src/solve/spectrum.cpp:gradient"

This is Feynman–Hellmann plus, for a first-order term, the derivative of the eigenvector. Every gradient is tested against finite differences of the masses.