Compressed restart from Mulliken shell charges and atomic multipoles (C/Python API, spin support, tests) #291
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds a lightweight restart mechanism that seeds SCF from Mulliken shell charges together with atomic dipole and quadrupole moments. Provides C and Python APIs (including spin-resolved support), wires the guess into wavefunction initialization, and adds tests and a Python example. Default behavior is unchanged unless a guess is explicitly provided.
Motivation
Key changes
Wavefunction seeding from compact restart data:
wfn%qsh,wfn%dpat,wfn%qpat, and derivewfn%qatviaget_qat_from_qsh.src/tblite/api/calculator.f90(check_wavefunctionand call site).Result container extended to hold restart guess:
charges_guess_shell [nsh, nspin],dpat_guess [3, nat, nspin],qmat_guess [6, nat, nspin].src/tblite/api/result.f90.C API:
tblite_set_result_shell_charges_and_moments_guess(...)(closed-shell).tblite_set_result_shell_charges_and_moments_guess_spin(...)(spin-resolved).include/tblite/result.h, implementations insrc/tblite/api/result.f90.Python API:
Result.set("shell-charges-and-moments-guess", (qsh, dpat, qmat)).python/tblite/interface.pyandpython/tblite/library.py.Tests and example:
test_calc_restart_compressedintest/api/main.c: compares energy from compressed restart vs. full run (closed-shell).restart_from_charges.py: demonstrates compressed restart and compares to a full wavefunction restart; includes a spin-polarized path.API additions
tblite_set_result_shell_charges_and_moments_guess(error, res, qsh, nsh, dpat, nat, qmat, nat2)tblite_set_result_shell_charges_and_moments_guess_spin(error, res, qsh, nsh, dpat, nat, qmat, nat2, nspin)Result.set("shell-charges-and-moments-guess", (qsh, dpat, qmat))qsh:(nsh,)or(2, nsh)dpat:(nat, 3)/(3, nat)or(2, nat, 3)/(2, 3, nat)qmat:(nat, 6)/(6, nat)or(2, nat, 6)/(2, 6, nat)Behavior and validation
qshalso requires providingdpatandqmat; otherwise, a fatal error is raised via the context.nat,nsh) and active spin count.Backward compatibility
Affected files
src/tblite/api/calculator.f90(consume guess, seedwfn)src/tblite/api/result.f90(store and set guess; C bindings)include/tblite/result.h(C API declarations)python/tblite/interface.py(setter wiring)python/tblite/library.py(shape normalization, C calls)test/api/main.c(new compressed-restart test)Tests
test_calc_restart_compressedverifies energy agreement (closed-shell) when restarting from(qsh, dpat, qmat).Notes