← The C17 & WL15 Library
Conventions · Authoritative Specification (qtaim.conventions.v1)

Authoritative Conventions, Seven Principles & Triple-Stack Contract

Every C17 translation unit (include/QTAIM.h, modular src/*.c, and the drop-in single-file amalgamation QTAIM.c), Wolfram Language 15 reference module (QTAIM.wl), ForeignFunctionLoad C-ABI bridge (QTAIMC.wl), out-of-source evaluated Wolfram Notebook, QTAIM-WFX-3.0 parser, in-memory host bridges across DIRAC, Dalton, OpenMolcas, PySCF, and CP2K, and HTML article on this site consults the root CONVENTIONS.md specification. Automated CTest and site-build gates parse its embedded JSON contract on every build so architectural principles, units, signs, high-shell orderings, automatic 𝐤-mesh rules, crystal topology, and parallel reductions never drift across layers.

Under audit (4 December 2026).An internal audit by an AI agent reports the problems below on this page. They are not yet corrected or independently confirmed. Please do not rely on these statements meanwhile.

1. Triple-Stack Architecture, Single-File Amalgamation, & Three-Tier BLAS/LAPACK

Official library implementations, bindings, tests, and worked examples in QTAIM are organized as a strict Triple Stack:

Stack 1 · ISO C17 + Amalgamation

Modular src/*.c files compile under -std=c17 -Werror=vla (gcc, clang, AppleClang, icx) and /std:c17 (MSVC) across Windows, Linux, macOS, and the BSDs with zero VLAs, zero C99 _Complex, zero <threads.h>, and zero mutable globals. CMake also emits a drop-in two-file amalgamation build/amalgamation/{QTAIM.h,QTAIM.c} for one-file embedding in external quantum-chemistry codes.

Stack 2 · Wolfram Language 15 Native

wolfram/QTAIM.wl states every algorithm in side-effect-free mathematical expressions mirroring QTAIM.h function for function, serving simultaneously as the human- and LLM-readable reference specification and as a 50-digit arbitrary-precision (WorkingPrecision -> 50) oracle under CTest wolfram_seats scheduling.

Stack 3 · WL15 Calling C + Build Notebook

wolfram/QTAIMC.wl loads libqtaim directly via ForeignFunctionLoad against the unmodified C17 ABI and generates the pre-evaluated notebook build/notebooks/QTAIM_TripleStack.nb strictly in the out-of-source CMake build directory—never inside git source folders.

No other programming languages are introduced into library implementations, bindings, tests, or examples without explicit approval. External quantum-chemistry packages—DIRAC, Dalton, OpenMolcas, PySCF, and CP2K—embed the CMake-synchronized amalgamation (cmake --build build --target sync_host_amalgamation) directly via iso_c_binding or ctypes, calling qtaim_wfn_create_raw_prims, qtaim_wfn_set_active_2rdm, and qtaim_wfn_set_edf_primitives in memory without requiring intermediate disk .wfx files while preserving exact bit-parity with exported QTAIM-WFX-3.0 streams. Linear algebra inside Stack 1 resolves automatically across three preprocessor tiers in src/qtaim_linalg.c with universal 64-bit integer slot compatibility across both LP64 (OpenBLAS, Netlib) and ILP64 (MKL, 64-bit Fortran host runtimes): Tier 1 links host system BLAS/LAPACK; Tier 2 optionally fetches Reference-LAPACK via CMake (-DQTAIM_FETCH_LAPACK=ON); and Tier 3 provides a built-in pure-C17 mathlib (cache-tiled dgemm, Cholesky, Householder+QL dsyev, zero-_Complex real-2n×2n Hermitian eigensolver, and real-4n×4n quaternion Kramers eigensolver) tested on every build via -DQTAIM_FORCE_INTERNAL_MATHLIB=1.

2. The Seven Enshrined Architectural Principles

  1. Do not compute what you can project (maximal symmetry + explicit C1 + full-orbit unfolding): by default (QTAIM_SYM_MAXIMAL), exploit the maximal molecular point group, Kramers time-reversal pair symmetry, or 3D crystallographic space group (1..230 and Wyckoff site stabilizers) so only symmetry-inequivalent centers, shells, critical-point seeds, and basin rays are evaluated, reconstructing full molecular or unit-cell orbits algebraically when requested for human inspection while always supporting explicit QTAIM_SYM_C1 ("the dumb way") and verifying Symmetry == C1 in CTest. Off in 1.7.1: symmetry shortcuts are off until the symmetry can be proven for the whole wavefunction. For molecules QTAIM_SYM_MAXIMAL integrates every atom, as QTAIM_SYM_C1 does, no mirror plane is taken from a wavefunction (no attractor symmetrisation, no ascent guard, no mirror seeds in the critical-point search) and the zero-flux mirror disk of the surface solver (§6.5) is never taken; crystals keep the octant rule and the torus topology only where the cubic group maps the lattice, the atoms and the 𝐤 set (with its weights and occupations) onto themselves, and the crystal constructors refuse cells whose lattice sums would be cut short, and constants that are not positive finite numbers, with no default cell in their place. In 1.6.0 and 1.7.0 a symmetry was accepted after the density agreed at two points near the centre of the nuclei, which can copy one atom onto an inequivalent one.
  2. Analytic derivatives and analytic integrals over finite differences and quadrature: evaluate spatial AO/spinor/Bloch jets, McMurchie–Davidson one- and two-electron Gaussian integrals (S,T,Vne,(μν|κλ), Boys–Hermite φe,𝐄e,𝐄ν), Melnikov zero-flux transport derivatives, and SA-GASSCF Z-vector response gradients analytically; reserve finite differences strictly for validation tests.
  3. Pure functions with zero side effects: wavefunction, symmetry, and crystal handles are immutable after construction (const qtaim_wfn *, const qtaim_crystal *), performing zero hidden I/O and mutating zero global state.
  4. Bit-deterministic parallelism: serial (0), OpenMP (1), native OS threads (2, Windows _WIN32 and POSIX pthread), and custom host thread-pool callbacks (3) accumulate in fixed index order so thread count and backend never alter IEEE-754 results.
  5. Unforced physical honesty: always report raw unforced N(ΩA), raw ∑AN(ΩA)−N, raw L(ΩA)=K(ΩA)−G(ΩA), raw ∑AEIQA(ΩA)−E, and raw Euler characteristics (χ(ℝ3)=1 for isolated molecules; χ(𝕋3)=0 for 3D periodic crystals).
  6. Scale-relative conditioning and analytical cliff regularizers: scale all rank, Löwdin canonical-orthogonality, and Sylvester-inertia tolerances with the spectral norm (tol⋅smax, never unit floors), and apply analytical regularizers at physical singularities (Compton horizons, state-averaged conical intersections, and coordinate axes).
  7. Exact telescopic ℒchem↠ℒBO limit recovery: sending c→∞, Ma→∞, 𝐄,𝐁,𝐀→𝟎, and lattice period L→∞ recovers clamped-nucleus Born–Oppenheimer QTAIM and 3D punctured-Maxwell IQA continuously to machine precision.

3. Gaussian Atomic Units, Electromagnetic Coupling, & Punctured-Maxwell IQA

All equations, C17 APIs, Wolfram packages, and scene files use Gaussian Hartree atomic units (ℏ=1,me=1,|e|=1,4πε0=1, c=α−1=137.035999084, 𝛑=−i∇+𝐀/c; the library’s magnetic inputs, B_z_au in C and BzAU in Wolfram, are this 𝐁 divided by c, in the unit ℏ/(|e|a02)). For total charge density ρtot(𝐫)=∑CZCδ(𝐫−𝐑C)−ρ(𝐫), electrostatic fields and local three-dimensional Interacting Quantum Atoms (IQA) potential energies satisfy:

Poisson equation, electric field sign, & punctured 3D IQA potential energy −∇2φ(𝐫)=4πρtot(𝐫), 𝐄(𝐫)=−∇φ(𝐫), φe(𝐫)=−∫ρ(𝐫′)|𝐫−𝐫′|d3𝐫′≤0 VIQA(ΩA) = 18π ∫ΩA [ 2𝐄Anuc⋅𝐄reg,A + |𝐄reg,A|2 − ∑B≠A|𝐄Bnuc|2 + ∑νλν|𝐄ν|2 ] d3𝐫 = Vpot(ΩA) − ΔVsurf(ΩA)

with outward normal 𝐧A, regular field 𝐄reg,A=∑B≠A𝐄Bnuc+𝐄e, and ∑AEIQA(ΩA)=EBO at every geometry.

4. Reduced Density Matrices, Kinetic Densities, & ℒ vs L

Canonical normalizations, signs, and script distinctions
Quantity Definition & sign convention Invariant / check
1-RDM density ρ(𝐫) Spin-summed diagonal ∑ini|ψi(𝐫)|2 (+ optional <EDF> core ρcore) ∫ρ(𝐫)d3𝐫=N
McWeeny 2-RDM ρ2(𝐫1,𝐫2) Spin-summed pair density with factor 1/2 in Vee ∬ρ2d3𝐫1d3𝐫2=N(N−1)
XC cumulant ρxc(𝐫1,𝐫2) ρ2(𝐫1,𝐫2)−ρ(𝐫1)ρ(𝐫2)=∑νλνgν(𝐫1)gν*(𝐫2) λ(A)+12∑B≠Aδ(A,B)=N(ΩA)
Kinetic densities G,K G=12∑ini|𝛑ψi|2≥0, K=12∑iniRe(ψi*𝛑2ψi) K(𝐫)−G(𝐫)=−14∇2ρ(𝐫)
Script ℒ vs upright L ℒ (ℒBO, ℒchem) is a 3D/4D density; L(ΩA)=∫ΩAℒd3𝐫 Raw unforced L(ΩA) always reported

5. Spherical & Cartesian GTOs (s…i, Keith 1..84), Kato Cusps, & Periodic Crystals

  1. Real Spherical Harmonics (cart = 0, primary default through ℓ=6): shells s,p,d,f,g,h,i carry (1,3,5,7,9,11,13) algebraic Schlegel–Frisch solid harmonics (Jensen GTO vs ETO Benchmark), while Cartesian shells (cart = 1) carry (1,3,6,10,15,21,28) components mapped bijectively to Keith primitive types 1..84 in QTAIM-WFX-3.0.
  2. Periodic crystal mirror zero-flux theorem, 3-torus topology (χ(𝕋3)=0), & automatic Γ-centered 𝐤-selector: on any crystallographic mirror plane σn with normal 𝐧 (σn𝐧=−𝐧), space-group invariance ρ(σn𝐫)=ρ(𝐫) forces pointwise ∇ρ(𝐫)⋅𝐧=0 to machine precision (∼10−18) before any numerical ODE surface tracing. In monoatomic BCC Li (Im3¯m, #229), the six square {100} Wigner–Seitz faces (Wyckoff 6b, D4h) and diagonal {110} σd planes satisfy pointwise ∇ρ⋅𝐧=0 everywhere, whereas at the eight hexagonal {111} bond midpoints (Wyckoff 8c, site symmetry 3¯m=D3d lacking σh), the three in-plane C2′ dyads and the inversion-antisymmetric net face integral vanish to 10−18 while off-dyad points capture physical ∼4.7×10−5a.u. D3d trigonal zero-flux surface puckering, with primitive-cell critical points (n,b,r,c)=(1,7,12,6) and χ(𝕋3)=1−7+12−6=0. In heteroatomic Rock-Salt LiH (Fm3¯m), the curved ionic zero-flux wall deforms toward Li+ (q(Li)≈+0.99) while meeting {100} and {110} symmetry planes orthogonally, checked in the Fm3¯m wedge mode and in explicit C1 mode, which agree to within the quadrature error. Since 1.7.1 QTAIM_SYM_MAXIMAL (one octant times eight) and the cubic torus sites are used only where the cubic group maps the lattice, every atom and the 𝐤 set, with its weights and band occupations, onto themselves; otherwise the full sphere is integrated, rBCP is NaN, and qtaim_crystal_torus_topology returns QTAIM_ERR_UNSUPPORTED. The constructors return NULL where the lattice sums of the model would be cut short (BCC Li at a≤5.728312bohr, rock-salt LiH at a≤7.137742bohr) and for a constant that is not a positive finite number. Still open in 1.7.1: rock-salt LiH above a=22/3≈12.70bohr gives wrong basin populations with QTAIM_OK, and qtaim_crystal_torus_topology returns QTAIM_OK with n−b+r−c≠0 for large cells (constants tried from 18 bohr for rock-salt LiH and from 25.5 bohr for BCC Li).
  3. Automatic 𝐤-point selector (QTAIM_KGRID_AUTO) & geometry-only ("caveman") entry points: qtaim_select_kgrid_auto infers periodic dimensionality d∈{0,1,2,3} from lattice vectors and atomic coordinates (clamping vacuum slab/wire axes with >12bohr vacuum gap to Nj=1), sets odd Γ-centered counts Nj=max(1,⌈Rk|𝐛j|/(2π)⌉) (Rkins=30bohr) on non-orthogonal Bravais lattices so Nyquist boundary faces never break space-group zero-flux mirrors, and upgrades metallic gaps (Δεgap≤0.02Ha) automatically to Rkmet=50bohr with Fermi–Dirac smearing, while qtaim_wfn_from_caveman accepts bare atomic numbers and coordinates. qtaim_crystal_from_caveman returns one of the two built-in models, BCC Li for one atom and rock-salt LiH otherwise, with its lattice constant taken from the cell volume; the atoms and the shape of the cell are not used, and since 1.7.1 a cell that the model refuses, a slab or a wire included, gives NULL.

6. 𝒢4+MF,4+MF,0|MB,MB Schwinger–Bader Core, Isomorphic Gibbs/Dyadics, & Sector Plugins

Across C17 (src/qtaim_ga44_plugin.c) and Wolfram Language 15 (QTAIM.wl and QTAIMC.wl), QTAIM pairs classic 3D Gibbs vectors and 3×3 dyadics side-by-side with the non-degenerate split super-Clifford algebra 𝒢4+MF,4+MF,0|MB,MB≅𝒢4,4,0⊗𝒢MF,MF,0⊗WMB,MB:

7. Automated Enforcement across C17, WL15, Notebooks, & HTML

Between sentinel markers at the bottom of CONVENTIONS.md sits the machine-readable qtaim.conventions.v1 JSON block, verified on every build by five automated gates:

References

Provenance tags indicate whether the primary text ([read]) or bibliographic record ([record]) was checked directly during preparation.

Comments, questions or contributions? Please open an issue or a pull request on GitHub.