SCF Reference#
Choose the reference Hamiltonian, electron count and DF policy before tuning the SCF solver. Start from the minimal input, then add only the decisions needed for the system. The full list of omission values belongs in YAML defaults.
When No Extra Controls Are Needed#
For a closed-shell HF reference with a suitable native starting guess, the
method, convergence and iteration defaults need not be written.
Always specify scf.spin explicitly, including spin: 1 for a singlet.
Declaring the electronic state is an exception to omitting redundant defaults.
Do not add MINAO, tighter tolerances or larger iteration limits just because
those fields exist. Inspect a failed or unsuitable reference before choosing a
targeted change.
Use DF as the first choice for routine work, not only when a specially matched auxiliary basis is available. Native automatic auxiliary selection is a reasonable starting point. DF usually reduces calculation time and memory; its fitting error depends on the basis. Enable it explicitly because the current SCF software default is exact:
scf:
spin: 1
density_fit: true
This is a section fragment, not a complete calculation. Consider exact treatment for a small task where its cost is modest, or as a diagnostic comparison when results look unexpected. Otherwise start with DF; absence of a dedicated auxiliary basis is not by itself a reason to switch to exact integrals.
Decisions To Make For The Task#
Decision |
Add or change only when needed |
|---|---|
Electronic state |
Set molecular |
Reference method |
Use HF or explicit closed-shell RKS. The restricted HF factory can return ROHF for an open shell even without |
Approximation |
Start with |
Initial density |
Select an explicit guess when it serves the system or a controlled comparison; a checkpoint guess starts a new SCF, not an MPPT resume. |
Resources/convergence |
Bound threads and memory for the worker. Change convergence settings for a stated accuracy or convergence problem, not as a template ritual. |
spin accepts names such as singlet, doublet and triplet, or a positive
integer multiplicity. The supported type values are rhf, rohf and the
closed-shell rks combination described below.
Basis, ECP/GRPP representation and embedding belong to the molecular model. Changing the initial density does not change that final Hamiltonian.
Threads, Memory And A Staged Stop#
See parallelism controls and measured limits for manual recipes, benchmark results and the distinction between CPU activity and useful speedup.
Set one worker budget to control both OpenMP and BLAS:
parallelism:
threads: 32
This opt-in policy covers SCF, CASCI/CASSCF and their nested providers. N is the
smaller of threads and detected CPU availability: logical CPUs, inherited
affinity and visible Linux cgroup-v2 quotas. Fractional quotas round down to at
least one. No CPU/core/NUMA placement is changed. Use one numerical worker per
process because native library setters are process-global.
Phase |
Automatic OpenMP |
Automatic BLAS |
|---|---|---|
|
N |
1 |
|
N |
N |
|
1 |
N |
|
N |
1 |
|
N |
1 |
|
N |
1 |
In-core molecular DF in PySCF 2.15.0 admits N/N with independently controlled
pthread OpenBLAS and compiled serial OpenBLAS pools. Integral generation and
SciPy triangular solves run sequentially, so this path uses max(OMP, BLAS) <= N.
The native builder still selects memory/storage routes and stays lazy. Eigen
fallback restores the conservative policy before decomposition and keeps it
through the remaining build. Other versions, providers, outcore and MKL retain
the existing conservative policy. There are no hidden trial calculations. These
limits are allocation rules, not measured speed optima. Other frontend work
uses the bounded OpenMP-priority baseline. MPI and downstream solver policies
remain separately configured.
Optional overrides use positive integer limits:
parallelism:
threads: 32
phases:
df_build:
omp_num_threads: 4
blas_num_threads: 8
Priority for OpenMP is phase override → nonnegative stage omp_num_threads →
auto. Stage zero means one; stage -1 means auto within N. hcore and df_build
use the enclosing stage; active_solver uses CASSCF. If only one component is
specified, the admitted sequential DF route gives the other pool up to N;
other routes give it at most floor(N / specified_limit). Every pool must fit N.
A pair exceeding the multiplicative budget is admitted only when the actual
native in-core call selects the supported route. If that build falls back to an
unadmitted path, an incompatible explicit pair fails before that path computes;
auto selects conservative limits. Phase names and unknown keys are validated.
For example, with N=32, casscf.omp_num_threads: 32 gives admitted in-core DF
OpenMP=32 and BLAS=32. An explicit df_build.blas_num_threads: 1 still wins.
Other DF routes retain OpenMP=32/BLAS=1 under that stage setting. To select
OpenMP=1/BLAS=32 explicitly, set both values in the DF phase. Both modes use the
same route/backend admission; no separate DF-only user mode is required.
Loaded pools are controlled with threadpoolctl and PySCF runtime setters.
OpenMP-threaded OpenBLAS may share its setter with PySCF: auto then uses equal
floor(sqrt(N)) limits, and unequal explicit limits are rejected. Compiled serial
BLAS, including sequential MKL, remains at one. MKL domain limits are also
checked: an override exceeding the phase limit fails before numerical work.
Remove MKL_DOMAIN_NUM_THREADS before starting Python or reset explicit MKL
domain API overrides; these hidden settings are never silently overwritten.
Other setter mismatches fail before numerical work. Nested
phases and exceptions restore their enclosing limits; calculation exit restores
the caller’s thread environment and loaded runtime limits.
Selected DF export borrows a native view of the phase-controlled provider and shares its existing AO factors. Export does not rebuild the live provider or remove its phase controls; native Coulomb-provider validation still applies.
Existing logs/pyscf.log and inventoried logs/events.jsonl record the requested
configuration, effective budgets, backend paths/versions, setter readbacks,
selection reasons, inclusive phase times and hcore build counts. Readbacks are
limits, not CPU utilization; nested times must not be summed as exclusive work.
SCF, CASSCF and active-solver completion/failure events also report
cpu_self_seconds, cpu_children_seconds, cpu_total_seconds and cpu_per_wall.
These timers work with or without parallelism. Total CPU includes user and
system time of the worker and terminated children it has waited for, including
block2 launched through a waiting shell. cpu_per_wall is their CPU seconds
divided by wall seconds: for example, 23 means an average of 23 CPUs in use.
It measures time consumed, not useful work or placement on fixed cores.
Phase CPU totals are inclusive: a CASSCF timer already includes its solver calls.
Do not add nested rows together. Accounting belongs to one sequential worker;
unrelated children waited for concurrently would contribute to that interval.
Native PySCF CPU time for ... lines remain parent-process-only. Use the package
active_solver and casscf totals when assessing DMRG CPU utilization; native
near-zero parent CPU while waiting for block2 does not indicate an idle solver.
Omitting parallelism preserves the existing policy and checkpoint identity.
In that mode, omitted stage omp_num_threads means all logical CPUs through
multiprocessing.cpu_count(); zero becomes one and positive values are capped
by that count. Ambient OMP_NUM_THREADS is not its default, and BLAS limits are
left unchanged.
Stage max_memory is a decimal-MB PySCF hint, not a hard RSS limit. Set it when
the worker needs an explicit stage budget; omit it rather than repeating an
unchanged inherited budget. The native object’s memory normally comes from the
molecule. The global fallback applies only when object memory is unset/zero.
The ordinary CLI owns a run-local scratch directory and captures declared files.
For a saved input, stop before active-space work or integral export with:
pyscf2mppt reference.yaml --output-dir runs/reference --stop-after scf
Check convergence, electron count, the occupied/virtual ordering and the intended
orbital character. An SCF energy alone does not establish the intended reference.
Resume the same scientific input with --resume; changed input or resource
contents require a new output directory. See
managed resources and identity.
Restricted DFT Orbitals#
Choose RKS only for a deliberate KS-orbital reference. The currently supported combination is closed-shell singlet RKS + DF, with an explicit XC functional:
scf:
spin: 1
type: rks
xc: PBE0
density_fit: true
This fragment leaves the native grid unchanged. Add a grid override only for a specific integration-accuracy requirement. The supported levels and current default are in the defaults reference. HF rejects XC/grid fields; there is no implicit LDA fallback. ROKS, UKS, nonlocal correlation, dispersion suffixes, double hybrids and Laplacian-dependent functionals are unsupported here. Ordinary Libxc LDA/GGA, supported meta-GGA and hybrid expressions are resolved by PySCF.
RKS shares the initial-guess, embedding, DF and checkpoint path. A completed resume restores its saved XC/grid input without a kernel. A different XC requires a new run; a native checkpoint can optionally supply its starting density.
The later MPPT Hamiltonian uses physical hcore and full Coulomb integrals on the selected orbitals: it does not consume Vxc, the DFT total energy as a scalar constant or hybrid-scaled exchange. KS orbital energies are provenance, not MPPT denominators. CASCI/CASSCF initialized by RKS uses its own physical Hamiltonian and exact/DF setting. Existing small-system fixed-orbital FCI checks do not establish large-system numerical convergence.
Auxiliary Basis For Density Fitting#
scf.auxbasis, casscf.auxbasis and casci.auxbasis configure each stage
independently. Neither the DF flag nor its basis is inherited from SCF by an
active-space stage. Configure both applicable stages deliberately for a DF
workflow. The selected reference’s actual provider determines later export;
an explicit mppt.integral_mode is a consistency check, not a conversion switch.
Omit the auxiliary field when native automatic selection is appropriate. To choose an explicit atom-label mapping, merge a fragment such as:
scf:
density_fit: true
auxbasis:
O: [file, aux/O.nwchem]
O1: [file, aux/O1.nwchem]
H: [library, def2-universal-jkfit]
The paths are user-supplied resources, not bundled example files. O and O1
remain distinct keys. Each file contains the ordinary basis for its chemical
element: both oxygen files use O headers but are loaded separately before the
map reaches PySCF. Native label/element lookup applies to other atoms. A whole
auxiliary basis name remains accepted as a string; empty/malformed maps and
unsupported source kinds are rejected.
Managed CLI inputs resolve explicit files from the source YAML directory, capture their bytes and hashes and rewrite the effective resource paths. Library entries remain library references. Explicit auxiliary files are still needed to rebuild a DF object from saved arrays even when no SCF kernel is rerun. For fixed portable resources and aliases, see auxiliary resources and identity.
SCF Initial Guess#
The runtime caches the complete physical AO hcore before initial-guess use. SCF, active-space iterations and export reuse that matrix while the operator is unchanged, including ECP/GRPP and external point charges. Updating orbitals or density does not rebuild it. Each caller receives an independent matrix copy.
Changes to the built geometry, basis, pseudopotential or embedding invalidate
reuse; ordinary PySCF input edits still require rebuilding the molecule. The
cache is process-local, so a resumed process builds its first hcore again.
Arbitrary external Python get_hcore overrides retain their own semantics.
In the Python runtime helper install_hcore_cache,
hcore_cache_source_mean_field identifies an existing mean-field object that
supplies the cache. Reuse still requires matching provider and physical model.
Omit initial_guess when the native fresh-SCF initialization is suitable. Omission
and null remove the persisted key; an explicit method, including MINAO, remains
part of managed input identity. To request another native method:
scf:
initial_guess:
method: hcore
An explicit mapping requires method; an empty mapping does not mean MINAO.
Method |
Method-specific fields |
Starting density |
|---|---|---|
|
None |
Projected minimal atomic density. |
|
None |
Superposition of atomic Hartree-Fock densities. |
|
None |
Final mean-field instance’s |
|
None |
Native on-the-fly Huckel guess. |
|
None |
Native modified Huckel guess with the updated GWH rule. |
|
Optional |
Superposition of atomic potentials with an optional fitted source. |
|
Required |
Native PySCF checkpoint density. |
Methods are stripped/lowercased; the accepted 1e alias becomes hcore.
vsap, arbitrary chk-prefixed names, scalar shorthand, unknown fields and
fields from another method are rejected. There is no arbitrary inline-density
input. Missing native capability fails before the SCF kernel rather than
selecting another method silently.
SAP Fit Sources#
SAP fit data are neither orbital basis functions nor Coulomb DF auxiliary
functions. Omit sap_basis, or use null, to retain the native configured
source. An explicit common source applies to all atoms:
scf:
initial_guess:
method: sap
sap_basis: [library, sapgraspsmall]
Explicit source forms are [library, name], [file, path], or a nonempty
atom-label mapping of these pairs. Use the exact lowercase source tokens and
nonblank names/paths. A common file is loaded for every required element; a
per-label choice can mix resources:
scf:
initial_guess:
method: sap
sap_basis:
H1: [file, fits/hydrogen-sap.dat]
H: [library, sapgraspsmall]
Lookup tries the exact atom label, then its pure element. Here H1 uses the file
and other hydrogens use H. Every atom must be covered; missing entries are an
error, not a request for automatic completion. The H1 file must contain an H
fit. These example paths must be supplied by the user.
Library names resolve through PySCF’s ALIAS registry to bundled NWChem files,
without current-directory/pathname fallback. A same-named local file cannot
shadow a library source or an inherited native string source. Declare custom
fits with [file, path].
Files use the NWChem basis-format loader, not arbitrary autodetection. Each element fit must contain exactly one S shell and one or more exponent/coefficient pairs. Exponents must be finite and positive; coefficients finite and possibly signed. Extra coefficient columns, other angular momenta, empty or malformed data are rejected. The same loaded-data checks apply to library fits.
Fit contents and map coverage are checked before the molecular SCF kernel,
not by schema validation alone. Resolved fits are assigned to mf.sap_basis
before native SAP dispatch. A native in-memory default fit dictionary undergoes
the same checks; that native-object case does not enable inline fit arrays in YAML.
Native Checkpoint Guess#
Use a checkpoint guess for a new SCF calculation, not completed-stage resume:
scf:
initial_guess:
method: chkfile
path: references/start.chk
The input checkpoint path is required and nonblank. Omitted/null project
leaves projection to PySCF’s basis-set comparison. Explicit true requests
projection into the target basis; false reuses coefficients without projection.
Only actual YAML booleans or null are accepted, not strings/numbers. Add that
field only when the explicit projection choice is wanted.
The automatic choice is not a general atom-order or geometry compatibility check. Large geometry changes can give a poor guess; saved occupations can differ from the requested charge/spin. A native UHF checkpoint with different alpha/beta orbitals can also produce inconsistent ROHF orbital tags. Such a density is rejected before the kernel, not repaired by stripping tags or normalizing it.
The source checkpoint is read-only and distinct from output mf.chkfile.
Same-path, symlink and hard-link input/output aliases are rejected before
loading. Missing/unreadable files, absent SCF records or unusable densities are
fatal, without a silent MINAO fallback. MPPT’s scf.npz is not a native PySCF
checkpoint and cannot be used as this guess input.
Density And Hamiltonian Semantics#
An explicit guess is prepared on the final mean-field object after embedding,
DF wrapping and overlap linear-dependence handling. Validation uses the actual
mean-field family, including native RHF-to-ROHF promotion. RHF accepts AO density
shape (nao, nao); ROHF uses alpha/beta shape (2, nao, nao). Wrong shapes,
nonnumeric/nonfinite values are rejected. Inspect Hermiticity diagnostics
before trusting the starting density. With the warning-only frontend policy,
Hermiticity deviations warn without changing the array; conflicting orbital
tags remain a structural error.
When orbital tags exist, their mo_coeff/mo_occ must reconstruct the density
under native DF spin interpretation. For shared ROHF orbitals, positive
occupations define alpha occupancy and occupations equal to two define beta.
Inconsistent tags are rejected before tag-sensitive exchange uses them. The
accepted starting density reaches mf.kernel(dm0=D0) without rescaling,
occupation rewriting, tag stripping or repair.
The log identifies the method and actual AO-metric electron trace; ROHF also reports alpha/beta traces against the target counts. A count mismatch warns rather than normalizing or correcting spin automatically. Native MINAO/atomic and ROHF guesses need not start with the final target counts; a guess does not certify convergence or the final electron distribution.
hcore uses the final patched instance Hamiltonian, including embedding. Native
Gaussian SAP instead builds its guess from the module-level bare HF hcore and
does not include an instance embedding override. Subsequent SCF still uses its
configured ECP/GRPP, embedding and DF Hamiltonian. Selecting a guess adds no
DIIS, damping or level-shift controls.
Relative SAP/checkpoint files in CLI calculations resolve from the source YAML directory. Their captured copies, identity and resume rules are described in initial-guess resources and identity.
Accepted Aliases#
Write canonical keys in new inputs. Existing aliases remain accepted:
Alias |
Canonical SCF key |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|