SCF Fock-build modes¶
vibe-qc offers two Fock-build modes for molecular SCF, the
strategy that constructs the J (Coulomb) and K (exchange) matrices each
iteration. Density fitting is a separate route: when density_fit=True, its
RI-J or RIJCOSX kernels supersede the four-index path and the mode is ignored.
Within that route, cosx=True selects COSX-K. The high-level
run_job(cosx=True) convenience also enables density fitting automatically.
For a worked resource comparison, including the 170-basis-function H2O2/cc-pVQZ timing and memory measurements, see Direct SCF or in-core integrals?.
Three modes¶
Mode |
Enum value |
Memory |
Best for |
|---|---|---|---|
|
|
- |
Default, picks based on system size |
|
|
O(n_bf⁴) |
Small systems whose dense tensor fits comfortably |
|
|
O(n_shells² + n_bf²) |
Large systems, bounded integral memory |
All molecular SCF drivers (RHF, UHF, RKS, UKS) support the mode via
identical scf_mode / scf_mode_auto_threshold fields on their
options struct. Range-separated RKS and UKS are a deliberate exception to
the requested mode: their attenuated-exchange kernel requires the direct
builder, as described below.
AUTO, the default¶
from vibeqc import RHFOptions, SCFMode
opts = RHFOptions()
# opts.scf_mode defaults to SCFMode.AUTO
# opts.scf_mode_auto_threshold defaults to 140 BF
When scf_mode = AUTO (the default), vibe-qc counts the number of
basis functions after the basis set is constructed and decides:
(n_{bf} \le 140) ->
CONVENTIONAL, the in-core 4-index ERI tensor is built once and the per-iteration cost is a tensor contraction.(n_{bf} > 140) ->
DIRECT, the in-core tensor would be multi-GB; switch to on-the-fly Schwarz-screened libint quartet evaluation that stays O(n_shells² + n_bf²) in memory.
The threshold is a resource policy, not a physical boundary. At the default cutoff, a dense 140-function tensor is already 2.862 GiB before any other process memory. To cap that tensor below 1 GiB, use 107, the largest basis count satisfying that limit:
from vibeqc import RHFOptions
opts = RHFOptions()
opts.scf_mode_auto_threshold = 107 # switch to DIRECT above about 1 GiB
CONVENTIONAL, the in-core path¶
from vibeqc import RHFOptions, SCFMode
opts = RHFOptions()
opts.scf_mode = SCFMode.CONVENTIONAL
The full 4-index electron-repulsion integral tensor (μν|λσ) is computed once at the start and reused across SCF iterations. Fast for small systems, but the tensor grows as n_bf⁴:
n_bf |
Full tensor size |
|---|---|
24 |
2.53 MiB |
95 |
621.42 MiB |
107 |
1000.06 MiB |
108 |
1.014 GiB |
170 |
6.223 GiB |
200 |
11.921 GiB |
250 |
29.104 GiB |
394 |
179.546 GiB |
These are \(n_\mathrm{bf}^4\times8\) bytes for the dense tensor alone. Add Fock, density, DIIS, eigensolver, runtime, and requested-output workspaces when sizing a job. Lower the AUTO cutoff when the tensor exceeds the workflow’s budget, or set DIRECT explicitly.
DIRECT, the integral-driven path¶
from vibeqc import RHFOptions, SCFMode
opts = RHFOptions()
opts.scf_mode = SCFMode.DIRECT
Instead of storing the ERI tensor, the direct Fock build considers the unique shell quartets on each SCF iteration and evaluates only those that survive screening. An 8-fold-symmetric loop skips the vast majority of quartets using the strict Cauchy-Schwarz bound:
[ |\langle \mu\nu | \lambda\sigma \rangle| ;\le; Q(s_\mu, s_\nu) \cdot Q(s_\lambda, s_\sigma) ]
where (Q(s_a, s_b)) is precomputed from the diagonal shell-pair integrals at construction time and reused across iterations.
Direct SCF options¶
All fields live on the per-method options struct (RHFOptions,
UHFOptions, RKSOptions, UKSOptions):
Field |
Default |
Description |
|---|---|---|
|
1e-10 |
Per-quartet skip bound; lower = fewer skipped quartets |
|
1e-7 |
Loose threshold for early SCF iterations (two-phase Schwarz screening) |
|
1e-3 |
Gradient-norm cutoff, switch from loose to tight below this |
|
|
Use a difference-density ΔP Fock build on the direct path |
|
8 |
Full-density rebuild every N iterations to limit recurrence error |
Two-phase Schwarz tightening¶
By default, the direct Fock build starts with the looser
schwarz_threshold_loose (1e-7) so the per-shell density envelope
catches mid-SCF quartets aggressively. Once the SCF gradient norm
drops below schwarz_threshold_tighten_at, the builder switches to
the tight schwarz_threshold and discards the incremental cache. An energy
difference across that threshold and cache change compares two different
numerical Fock maps, so it is excluded from convergence testing.
Häser and Ahlrichs analyse iteration-dependent screening and show that the
error in a screened difference-Fock update can inherit errors from earlier
increments (Eqs. 30-35). That analysis motivates the coarse-to-tight
refinement; it does not prescribe vibe-qc’s thresholds or transition policy.
Set
schwarz_threshold_loose <= schwarz_threshold to disable the
coarsening and use a uniform tight threshold throughout.
Incremental ΔP Fock build¶
When incremental_fock = True, the builder caches the previous
density D_prev and two-electron Fock matrix G_2e_prev. Each iteration
computes ΔD = D − D_prev and returns:
[ G_{2e}[D] = G_{2e}[D_\text{prev}] + G_{2e}[\Delta D] ]
This recurrence is Eq. 20 of Almlöf, Fægri, and Korsell. Their discussion on p. 389 also recommends a final energy-oriented iteration after a non-energy monitor is satisfied. The exact certification policy below is vibe-qc’s implementation of that principle, not a prescription quoted from the paper.
The direct kernel applies the published density-weighted Schwarz test to the difference density. For an incremental update with (s = \max |\Delta D| < 1), vibe-qc first screens (\Delta D / s), builds that normalized contribution, and multiplies the result by (s). This is a vibe-qc relative-error policy: the omitted part of an update scales to zero with its amplitude, instead of each small update being allowed the same absolute omission and accumulating a persistent drift floor. It is derived from the linearity of (G_{2e}); it is not a scaling formula prescribed by Almlöf et al. or Häser and Ahlrichs.
Amplitude normalization deliberately prevents a uniform rescaling of (\Delta D) from making the retained quartet set artificially sparser. Incremental builds still benefit when the change density becomes spatially localized, while accuracy no longer depends on how one density change is split across SCF iterations.
A full rebuild happens every incremental_fock_reset_freq iterations
(default 8) to limit error inherited from screened increments as well as
ordinary arithmetic accumulation. The reset interval is a vibe-qc
implementation policy, not a reset rule attributed to Almlöf et al. When the
two-phase screen changes to its tight threshold, the driver also discards the
incremental cache. Set
incremental_fock=False for a controlled full-build comparison.
from vibeqc import RHFOptions
opts = RHFOptions()
opts.incremental_fock = True
opts.incremental_fock_reset_freq = 8
Final full-Fock certification¶
Loose-screened and incremental builds are acceleration phases. A molecular direct SCF calculation enters a certified full-Fock phase when either:
the orbital gradient first satisfies
conv_tol_grad, making the row eligible for ordinary convergence; orthe restart monitor detects a high-gradient stall while a coarse Fock map is still active.
The driver then forces the configured tight Schwarz threshold, disables
incremental updates, resets the Fock builder, and clears extrapolation and
mixing state. The first tight, nonincremental full-density row has an energy
difference relative to the preceding coarse-map row. That cross-map value is
reported but cannot certify convergence. The following row provides an energy
difference between two comparable tight, nonincremental full-density builds.
Only then can the calculation converge, and both the original
conv_tol_energy and conv_tol_grad must pass unchanged.
Consequently, certification requires two comparable same-map rows. It does not relax either tolerance or infer an empirical energy-noise floor. A standard diagnostic identifies a gradient-triggered or stall-triggered move into this phase.
When density_fit or cosx is active¶
At the options-struct level, density_fit=True selects the DF J/K
infrastructure and causes it to ignore scf_mode. Inside that route,
cosx=True replaces fitted exchange with COSX-K. A low-level options object
with cosx=True but density_fit=False does not activate COSX; set both and
provide aux_basis. The high-level run_job(cosx=True) argument performs
those two steps and auto-selects an auxiliary basis when possible.
Range-separated hybrids force DIRECT¶
RKS and UKS range-separated hybrids need an erf-attenuated exchange build.
Only the direct builder currently implements that kernel, so these jobs force
DIRECT when density_fit=False, even if AUTO would choose conventional or
the options request CONVENTIONAL. Combining a range-separated hybrid with
density_fit=True currently raises an explicit unsupported-route error because
the required attenuated three-center integrals are not implemented.
Performance¶
On compute-small (i9-10885H, 4 threads), RHF direct / def2-SVP, same-box ORCA comparison:
This sweep uses def2-SVP throughout, so its H2O row has 24 basis functions. The H2O/6-31G* examples use 18 basis functions instead.
System |
n_bf |
vibe-qc (s) |
ORCA (s) |
Ratio |
|---|---|---|---|---|
H₂O |
24 |
2.0 |
15.0 |
0.13 |
glycine |
95 |
5.0 |
13.0 |
0.39 |
naphthalene |
180 |
31.1 |
45.1 |
0.69 |
n-decane |
250 |
226.3 |
67.2 |
3.37 |
n-hexadecane |
394 |
639.2 |
185.3 |
3.45 |
This historical sweep placed the speed crossover against ORCA near 200 BF on that host. The current AUTO policy switches at 140 BF because the CPU-time crossover is not a safe memory cutoff: the dense tensor is already 2.862 GiB at 140 BF. Energy agreement against ORCA was ≤ 2.4 µHa across all converged cells.
That wall-time crossover does not define a safe memory crossover. A matched one-core H2O2/cc-pVQZ case at 170 basis functions used 45.550 s wall time, 45.032 s active CPU time, and 6611.05 MiB peak RSS with vibe-qc’s conventional path. ORCA 6.1.1 used 52.669 s wall time, 51.232 s active CPU time, and 126.25 MiB peak RSS in the same allocation. The energy difference was \(1.53\times10^{-10}\) Ha. The worked tutorial derives the \(170^4\) allocation, separates the different-host direct validation, and defines a safe crossover sweep.
Component timing¶
Set component_timing = True on RHFOptions or RKSOptions to record
where a molecular restricted SCF spends its wall time. The option is off by
default. Enabling it does not change energies, densities or iteration counts.
opts = vq.RHFOptions()
opts.density_fit = True
opts.aux_basis = "def2-universal-jkfit"
opts.component_timing = True
result = vq.run_rhf(mol, basis, opts)
ct = result.component_timing
for phase in ct.phases:
print(phase.path, phase.inclusive_s, phase.exclusive_s, phase.calls)
print(ct.wall_s, ct.unclassified_s)
Phase paths join nested names with /. The inclusive time of a phase
contains its nested phases, while its exclusive time does not. The exclusive
times of all phases plus unclassified_s equal wall_s, which runs from
driver entry to return.
Phase |
Covers |
|---|---|
|
Integrals, XC grid, J/K builder, DF tensor and COSX caches, initial guess and orthogonalization |
|
One RHF |
|
Separate DF and COSX kernels, nested under the driver phase that called them |
|
RKS Coulomb, exchange and XC builds. |
|
DIIS-family extrapolation, Fock diagonalization or a second-order orbital step, and density construction |
|
The post-convergence Fock rebuild and the stability analysis |
ct.iterations repeats the phase table per SCF iteration. An iteration runs
from one loop start to the next, so it includes that iteration’s
diagonalization. For staged COSX grids, segment numbers the grid stages.
ct.memory holds tracked DF numeric-container sizes at construction
boundaries. df.live_tracked_bytes is the retained B tensor and Cholesky
factor. The metric-factor, pack, transform and unpack boundaries are recorded
as df.metric_factor_tracked_bytes, df.pack_tracked_bytes,
df.transform_tracked_bytes and df.unpack_tracked_bytes.
df.construction_tracked_peak_bytes is their maximum, including temporaries
only while they remain alive. These samples exclude BLAS/solver scratch,
container metadata and allocator retention; they are not process RSS.
Timers run only on the thread that called the driver. The G0 CPU profiling
harness in examples/regression/gpu_profile.py combines these records with
runtime provenance and process RSS; see the
G0 plan.
Bounded CPU profiling campaigns¶
The G0 harness can pin stability_check=False on every timed route with
submit --no-stability-check. Add --measure-stability for one separate
fresh-process driver run per case at that system’s largest thread count.
That run requests stability explicitly and reports the native
stability_wall_s separately from its total driver time. Unsupported
stability responses remain refusals in batch_status.json; they are not
zero-cost measurements or successful stability verdicts. These options do
not change the production driver’s default stability policy.
Raw records retain the native stability convergence flags, stop reasons,
matvec count, applied wall budget and separate restricted-spin channels.
The summary’s analysis column reports CONVERGED, UNCONVERGED,
NOT_CHECKED or NOT_RECORDED independently of timing admission. Earlier
records without solver diagnostics remain NOT_RECORDED; a timing PASS
does not certify a converged Hessian solve or a stable wavefunction.
Use --system-settings with an external JSON file mapping each system to
its scheduling entries. Entries inherit --warmup, --repeats and
--per-run-budget-s; threads is required. For example, the large-system
campaign can use:
{
"n-hexadecane": [
{"threads": 4, "warmup": 1, "repeats": 3, "per_run_budget_s": 3600},
{"threads": 1, "warmup": 0, "repeats": 1, "per_run_budget_s": 7200}
]
}
--compare-timing-off --timing-off-cases CASE_ID,... limits paired runs to
selected cases, such as one naphthalene method per resolved route. Without
--timing-off-cases, the comparison applies to every selected case.
AUTO deduplication occurs inside the measured runtime; the worker writes
batch_resolved.json with the actual cases, aliases and run schedule.
Submit with --python pointing to an immutable runtime launcher, and pair
--runtime-root with --runtime-artifact to pin its deployed vq bundle.
--mem-mb reserves the job’s memory through vq. Installed wheels without
Git metadata are identified by the deployed bundle’s source revision,
manifest digest and verification receipt. The harness checks the installed
package inventory, native module and interpreter against the manifest both
before and after each calculation, outside the measured SCF interval. Raw
provenance stays in the external evidence root.
After fetching the job, summarize with --batch-json pointing to its
batch_resolved.json, plus --expected-source-sha and
--expected-native-sha256. Missing planned runs remain incomplete; separate
stability runs cannot enter the SCF repeat or instrumentation comparison.
Keep all campaign inputs, raw output and operational configuration outside
the checkout. Publish only the redacted, measured summary after checking
its completeness and identity results.
Fixed-density CPU noise¶
examples/regression/gpu_noise.py measures CPU arithmetic noise before a
replacement kernel is compared. Stage it with gpu_profile.py and a direct
case from the G0 manifest in an external vq workspace. Use the same pinned
immutable runtime for fixture export and replay. The worker commands are:
"$RUNTIME_PYTHON" gpu_noise.py export case.json --out-dir evidence/fixture
"$RUNTIME_PYTHON" gpu_noise.py replay evidence/fixture/fixture.json \
--route df --threads 1 --repeats 3 --out-dir evidence/replay
"$RUNTIME_PYTHON" gpu_noise.py replay evidence/fixture/fixture.json \
--route df --threads 2 --repeats 3 --out-dir evidence/replay
"$RUNTIME_PYTHON" gpu_noise.py summarize evidence --threads 1,2 \
--expected-source-sha "$SOURCE_SHA" --expected-native-sha256 "$NATIVE_SHA256" \
--json-out noise-summary.json
Set OMP_NUM_THREADS for each process and set OPENBLAS_NUM_THREADS,
MKL_NUM_THREADS, VECLIB_MAXIMUM_THREADS and BLIS_NUM_THREADS to one
before launching it. Reserve N CPUs and sufficient memory through vq;
each replay invocation is a fresh process. Apply an explicit queue and
subprocess wall budget appropriate to the case, as for the timing campaign.
The accepted routes are direct, df, rijcosx and resolved auto.
Fixture export runs the direct SCF with the G0 recipe and stability disabled.
It requires convergence and the pinned residual target, then captures the
returned density of a second run capped at half the converged iteration
count. It also exports SAD and two small opposite symmetric perturbations
of the converged density. The perturbations preserve Tr(D S) and have
Frobenius norm 1e-7 * max(1, ||D||_F); they are not projected onto positive
semidefinite matrices. The native restart normalizer prepares the frozen inputs once; its changes
are recorded. The density path is retained throughout replay.
Archive and matrix hashes keep these exact inputs fixed across routes and
thread counts. No GPU dependencies are needed.
Direct replay disables incremental caching and fixes the tight Schwarz
threshold. COSX uses the FITTED final grid of the pinned level; its K is the
iterated exchange operator, excluding the post-SCF one-center correction.
The latter still needs a separate noise qualification. PBE has no K sample.
Vxc uses the native evaluate_rks_xc_potential interface when available.
It returns the production restricted XC matrix, nonlinear energy and observed
batch worker count at the supplied spin-summed density, without normalization
or a restart check. Finite symmetric indefinite perturbations are accepted;
the production pointwise density cutoffs still apply. VV10, when present,
uses the supplied grid rather than a separate coarse grid. The G0 cases
use PBE or PBE0 and do not include VV10.
Older runtimes fall back to the unpolarised RKS zero-iteration path with zero H, J and K, so the returned Fock matrix is Vxc without subtracting large terms. The harness checks that the supplied density is unchanged. The SCF restart interface refuses indefinite perturbations; these remain explicit incomplete rows until replayed with a runtime containing the direct interface. The recorded evaluator identity prevents combining the two paths as one noise measurement.
The summary reports worst pairwise matrix max-absolute errors in Hartree,
relative Frobenius errors, symmetry defects, and energy differences within
each thread count and between OMP=1 and N. J and K use Tr(D J)/2 and
-a_x Tr(D K)/4, with RHF a_x=1, PBE0 a_x=1/4 and PBE a_x=0.
For Vxc, Tr(D delta Vxc) is a separate diagnostic; the energy comparison
uses the nonlinear native E_xc. A zero reference norm yields relative
error zero only if both matrices vanish, otherwise JSON null.
MEASURED means the recorded input has at least three valid repeats at both
requested thread counts. It does not certify coverage of other systems,
methods, routes, spin conventions or hardware, or set a scientific tolerance.
Missing thread samples remain INCOMPLETE; mismatched input, runtime,
settings or sleep evidence are refused. Publish only redacted summaries.
The G0 operation contracts must combine these measured floors with explicit
scientific budgets before admitting a replacement implementation.
References¶
Almlöf, Fægri, Korsell, J. Comput. Chem. 3, 385 (1982), doi:10.1002/jcc.540030314. Difference-Fock recurrence (Eq. 20) and the final energy-oriented iteration recommendation (p. 389).
Häser & Ahlrichs, J. Comput. Chem. 10, 104 (1989), doi:10.1002/jcc.540100111. Cauchy-Schwarz screening and inherited screened-increment errors (Eqs. 30-35).
These references are cited automatically in the .bibtex and .references
output files when the requested mode is DIRECT or when AUTO resolves to
DIRECT.
Explicit native RHF evaluated-state export¶
For all-electron, unfitted conventional libint RHF, an optional terminal
capture connects the physical Fock, density, energy and actual native retained
metric to an owned FockBuild:
options = vibeqc.RHFOptions()
options.scf_mode = vibeqc.SCFMode.CONVENTIONAL
options.capture_evaluated_state = True
native = vibeqc.run_rhf(molecule, basis, options)
state = native.export_evaluated_state()
spectrum = state.solve_physical()
The existing native result API is unchanged. The exported state’s
mo_coeffs and occupations are metric natural orbitals that reconstruct its
physical density, including fractional, capped and NOITER states.
mo_energies are physical Fock Rayleigh quotients in that natural basis;
spectrum contains separately checked generalized eigenpairs and residuals.
A successful spectral solve does not make a stopped SCF state converged.
Natural-orbital export uses the shared dense Hermitian solver for the complete
retained density spectrum. It checks density eigenpair residuals at 1e-10,
orthogonality and AO density reconstruction before constructing a restart.
This density solve is distinct from solve_physical() and retains separate
spin spaces for UHF/UKS. A failed density solve raises SolverConvergenceError
with bounded diagnostics; no restart state is returned from a failed solve.
Every restart orbital, including zero-occupation columns, must remain in the
native retained AO space. Density reconstruction and metric orthogonality alone
do not establish this membership. These native exports require real orbital,
occupation, energy and AO-state arrays; complex states need a separately
admitted representation.
Pass state to QVF output or run_rhf(..., read_from=state) with a READ guess.
QVF carries natural occupations and evaluated source/density identities;
restarting the file reconstructs the density and evaluates it anew. It does
not restore a live integral builder or certify a correlation source.
Capture is opt-in and costs 8 * (4*n*n + n*r) persistent native bytes for
D, F, H, S and X, where n is AO dimension and r retained rank. It occurs
once at termination, adds no integral evaluation and retains no iteration
history. Explicit Python export creates an additional independent owned state
and natural-orbital workspace; it is a dense API, not a compact-memory claim.
Uncaptured results and unadmitted sources refuse export. The authoritative
selected MANTA molecular driver also admits unscreened exact direct RHF with
native optimization, no ECP and no +U. Use integral_engine=IntegralEngineOptions( backend="manta") with the same capture option; keep its direct/AUTO SCF mode.
It retains separate terminal J/K producer receipts, exact one-electron and
source identities, and checks the same evaluated density and full-build
confirmation before export. Stationarity remains separate: a confirmed
capped or NOITER state stays unconverged. The integral budget reserves the
additional native snapshot before constructing the provider.
The immutable producer_evaluation witness and producer_checks accompany
MANTA exports and QVF run fields. Density hashes and contraction execution
strategies are distinct from physical source identity. Restart reconstructs
the density under the explicitly selected provider; it does not restore a
MANTA builder or a screening certificate. Screened, fitted, BUPO, COSX, +U,
ECP, arbitrary external JK and alternative optimizer capture admissions
remain separate increments; existing calculation paths and defaults are
unchanged.
Explicit native UHF evaluated-state export¶
Conventional, all-electron, unfitted libint UHF uses the same terminal capture
contract as RHF. Enable UHFOptions.capture_evaluated_state, then call
native.export_evaluated_state() after run_uhf. The export owns one coupled
FockBuild with independent alpha and beta densities and physical Focks,
one energy/source identity, and the actual common overlap and retained X.
mo_coeffs_alpha, mo_coeffs_beta, occupations_alpha and
occupations_beta encode the two evaluated densities independently. Each
spin occupation lies in [0, 1]; electron_counts retains the native spin
populations. Fractional READ and stopped densities are preserved. Per-spin
mo_energies_alpha and mo_energies_beta are physical Rayleigh quotients;
state.solve_physical('alpha') or state.solve_physical('beta') supplies
the corresponding checked spectrum without asserting SCF convergence.
Determinant spin and stability diagnostics remain on the original native
result and are not copied onto fractional natural-orbital states.
Pass the export to QVF output or to run_uhf(..., read_from=state) with a
READ guess. Both spin occupation arrays and the evaluated identities travel
through QVF. Restart reconstructs the densities and evaluates them again.
Capture stores 8 * (6*n*n + n*r) native bytes for two D/F pairs and shared
H/S/X, once at termination. Python export adds its own dense storage and
natural-orbital workspace. Capture is disabled by default.
This first UHF source admission excludes direct/fitted/COSX, ECP, +U, MANTA/external JK, alternative optimizers, spin schedules, targeted atomic spins and configured multi-guess selection. Their existing APIs and provider choices are unchanged; an unadmitted capture explicitly refuses export. This interface does not certify correlation factors.
Explicit native RKS evaluated-state export¶
Set RKSOptions.capture_evaluated_state = True before run_rks, then call
native.export_evaluated_state(). The first admission is conventional,
unfitted, all-electron libint RKS with native optimization and libxc LDA or
PBE, without +U. Other functionals, ECP, direct/fitted/COSX, external XC/MANTA
and alternative optimizers remain explicitly unsupported by this export;
their existing calculation APIs are unchanged.
The export uses the same owned native bridge and restricted natural-orbital
restart interface as RHF. Its operator has kind ks. One-electron, Coulomb
and XC energies belong to the captured density; XC energy is not replaced by
half the trace of its potential. The producer supplies the XC potential trace
as a consistency check. The source receipt includes libxc version, functional
and a streaming SHA-256 of the actual quadrature points and weights. Changed
grids change the source identity without changing the AO/overlap frame.
state.solve_physical() solves the captured physical operator in the actual
retained metric. Natural orbitals and occupations reconstruct the evaluated
density for converged, capped, fractional READ and NOITER states. Pass state
to QVF output or run_rks(..., read_from=state) with a READ guess. Restart
reconstructs the density and evaluates it under the requested source; it does
not restore a live grid or provider. Convergence and source qualification are
not implied by successful serialization or a physical spectral solve.
Capture is off by default. Array storage is 8 * (4*n*n + n*r) native bytes,
plus bounded scalar/source metadata; Python export adds its owned arrays and
natural-orbital workspace. Quadrature hashing is linear in point count and
uses constant workspace, once at terminal capture. The final XC trace uses
already available matrices. No additional integral or XC evaluation is added,
and pure DFT retains J-only execution.
Embedding source term (experimental)¶
RHFOptions.embedding and RKSOptions.embedding take an EmbeddingSource:
the extra physical Hamiltonian of a projection-embedded subsystem. It holds a
one-body potential V_emb, the AO projector G_B = C_B C_B^T of the frozen
environment orbitals and an exclusion operator in a declared AO frame. With
EmbeddingExclusion.HUZINAGA the SCF solves
(F - S G_B F - F G_B S) C = S C e (Hegely et al. 2016, Eq. 11). With
EmbeddingExclusion.LEVEL_SHIFT the core Hamiltonian gains mu S G_B S
(Manby et al. 2012, Eq. 2), and the energy keeps Manby’s first-order term
mu tr(D S G_B S). The Huzinaga operator has no mu; supplying one refuses.
A projector that is not S-idempotent (for example a doubly occupied
density) refuses as well.
Both exclusions are parts of the physical embedded Hamiltonian, not SCF
accelerators. The returned fock includes them, and result.embedding
records tr(D V_emb), the level-shift energy, the Huzinaga expectation value
and the population of the excluded space. The solver level shift
(level_shift) stays a separate, inert accelerator. The electron count is
the molecule’s, so an embedded subsystem passes a molecule whose charge
removes the environment electrons.
The first admission is conventional, unfitted, all-electron libint RHF and
RKS with the native first-order optimizer. Direct, fitted and COSX builds,
ECP, +U, OpenTrustRegion, Newton, SOSCF, TRAH, the quadratic fallback, an
explicit stability check, the MANTA and symmetry routes and the low-level
run_rhf_scf_with_jk / run_rks_scf_with_jk entry points refuse an
embedding source. An embedded state is not exported as an evaluated
FockBuild yet. The fragment driver
vibeqc.fragment.projection.run_projection_embedding builds the source from a
whole-molecule low-level epoch; see
the fragment design.
Explicit native UKS evaluated-state export¶
Enable UKSOptions.capture_evaluated_state before run_uks, then call
native.export_evaluated_state(). The first admitted source is conventional,
unfitted, all-electron libint UKS with native optimization and libxc LDA or
PBE. The export carries both physical spin Fock matrices and densities, one
joint XC energy and potential trace, the actual quadrature receipt and the
shared native overlap and retained-rank transform. Its operator kind is ks.
Independent natural-orbital spaces and occupations reproduce each evaluated
spin density, including fractional READ and capped states. Use
state.solve_physical('alpha') or state.solve_physical('beta') to solve the
corresponding physical operator. QVF output and run_uks(..., read_from=state)
with a READ guess preserve the density pair; a successful spectral solve or
restart does not establish convergence or correlation-factor qualification.
The joint energy check includes the full XC functional energy, with both
spin-potential traces removed from the half-trace expression.
Native capture stores 8*(6*n*n+n*r) matrix bytes for AO size n and retained
rank r, plus bounded metadata. Capture is opt-in and occurs only for the
returned state. Python export owns an additional dense snapshot. Direct,
fitted, hybrid, COSX, ECP, +U, external XC/MANTA, alternative optimizers,
spin schedules, targeted spins and configured multi-guess selection refuse
this export until their sources are admitted. Their calculation APIs remain
unchanged.
Restricted open-shell HCORE solve¶
Molecular ROHF and ROKS use the shared dense one-electron operator solver for HCORE guesses. It retains the supplied overlap and canonical retained space, checks residuals and metric orthogonality, and supplies all retained roots. Each spin keeps the existing equal filling of degenerate frontier orbitals. This seed is separate from the physical spin Focks and constrained effective RO operator; their construction and canonicalization are unchanged.
Molecular ROHF terminal capture¶
run_rohf(..., capture_evaluated_state=True) retains a single immutable
result.fock_build containing both terminal spin densities and physical Focks,
the method energy, source conventions and actual retained overlap frame.
result.effective_fock_operator carries the same parent build identity with
role effective. It is not a third physical spin channel, and its spectrum
is not either spin’s physical spectrum. Separate UHF commutators do not
establish constrained ROHF stationarity.
This first capture admits only all-electron, unfitted direct-libint ROHF with integer-shell policy. Fitted/COSX, ECP and fractional-shell requests refuse capture; ROKS and MANTA RO capture require their own producer adapters. Capture adds no J/K calls or per-iteration snapshots and leaves SCF updates unchanged. The existing reporting orbitals and mutable result arrays are separate legacy views. They are not certified density factors for stopped states. Mutating them does not alter the captured evaluation. Default runner reporting and correlation admission remain separate work; explicit evaluated-state restart transport is described below.
For density-defining transport, call state = result.export_evaluated_state()
on an opted-in molecular ROHF capture. Pass this explicit state to
qvf_wf_data/write_qvf, or as read_from=state with a READ initial guess.
The QVF path is also a supported READ source. Both spin densities are factored
with the shared eigensolver in the captured retained space. Natural occupations
preserve mixed and stopped densities; the two spin bases may differ and do not
claim a new unrestricted determinant. The exported mo_energies_alpha/beta
are physical spin-Fock Rayleigh quotients, not Guest-Saunders or effective-RO
canonical eigenvalues. solve_physical(spin) supplies a separately checked
physical spectrum without asserting SCF stationarity.
The export owns immutable orbital arrays and shares the immutable captured
FockBuild. It uses the captured iteration/convergence status even if legacy
result fields were subsequently edited. Its native_capture_nbytes is zero:
this molecular Python capture does not allocate an additional native snapshot.
The QVF records the natural-orbital role, original restricted-open constraint,
and evaluated density/source identities. In-memory READ preserves the captured
spin densities; QVF reconstruction is limited by its coefficient encoding.
This explicit transport does not change default runner reporting or admit
natural-orbital states to correlation methods. ROKS and other unsupported
capture sources retain their refusals.