Repository navigation
Psi4 becomes a backend: Psi4Backend runs the SCFs and builds the integrals, the SAPT core reads its arrays - #14
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…PT consumes its data The dimer keeps the backend as `backend`, and its Psi4 objects (`wfnA`, `wfnB`, `mints`, `dimer_wfn`, `jk`, ...) are read-only attributes delegating to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d operations helper_SAPT keeps the tensor fold-in and the zero matrices of empty pairs, and no longer imports Psi4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s come from the backend calc_sapt_energy now also stops Psi4's timer it starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prop_sapt.log keeps the logger and installs the handler at import, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQETDeuKdGz7YP8cz9M
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQETDeuKdGz7YP8cz9M
nao_aux counted the Cartesian functions of the fitting basis on main and its (spherical) functions on this branch; the new name says which it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQETDeuKdGz7YP8cz9M
…t density Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQETDeuKdGz7YP8cz9M
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQETDeuKdGz7YP8cz9M
The backend timed only itself, so Psi4's module time left out the SAPT setup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQETDeuKdGz7YP8cz9M
The import test's docstring says what it checks: imports only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQETDeuKdGz7YP8cz9M
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQETDeuKdGz7YP8cz9M
Also drops two claims that were wrong: that the backend's handler is the only code writing to Psi4's output (cubes and forces print basis sets there), and that the default Backend.timer() is None. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZeFQETDeuKdGz7YP8cz9M
btyrcha
requested
a balanced review from Copilot
and removed request for
Copilot
November 26, 2026 07:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
prop_sapt/backends/base.py, with no Psi4 import:MonomerReferenceholds a monomer's orbitals, orbital energies, occupation, nuclear potential and SCF energy.Backendbase class holds the dimer's overlap, DF factorQpq, nuclear repulsion and fragments.clean_scratchandtimerhooks.C, the sign ofVand of the Hessian, and the DF factorization.Psi4Backend. Newprop_sapt/backends/psi4_backend.pyruns the monomer SCFs and builds the integrals, in the same order as before.psi4_energy,jk_memory_doubles,changed_psi4_optionsand the Psi4 output handler move there.helper_SAPTandsinfinitytake a backend and read only its data, sohelper_SAPT_DF.pyno longer imports Psi4.compute_jkstays in the helper, with the fold-in and the zero-fill, so the finite-field "matched integrals" mode still patches it.Dimer(...)keeps its signature. It builds aPsi4Backendand keeps it asdimer.backend.wfnA,wfnB,dimer_wfn,mints,jkand the other Psi4 attributes return the backend's objects and are now read-only: assigning to them raisesAttributeError.nao_auxis nownaux, the number of functions of the SAPT fitting basis (the rows ofQpq):nao_auxcounted Cartesian functions also where the basis is spherical (285 against 222 for He–H2 in aug-cc-pVQZ-RI).calc_sapt_energy,calc_propertyand the runner clean Psi4's scratch files through the backend.calc_sapt_energyis timed throughbackend.timer()(Psi4'ststart/tstop) and now writes thetstopit was missing.Dimer.__init__is wrapped whole inPsi4Backend.timer(), as onmain, so Psi4's module time still covers the SAPT setup. The backend doesn't time itself.tests/test_imports.pychecks that only a listed set of Psi4-facing modules imports psi4: the backend,molecule, the analysis modules, the runner, the CLI, artifacts and finite field. The SAPT core is not on the list, which shrinks in the next steps. The test checks imports only: the density driver still uses the dimer's Psi4 objects for cube files and for the deprecated.npywavefunction dump.dimer.backendin the usage guide, and a changelog entry.Smaller changes:
Psi4Backendrejects an RKS reference without a functional.Dimeralways passes the default functional, so users won't hit this.compute_jkchecks the shapes of all pairs before building any J/K.nvirt_Bcomes from monomer B's own orbitals; the value is the same as before.helper_SAPTand the densities assume are equal.Psi4Backend.compute_jkclears the J/K object's inputs also when a build fails. Before, they stayed for the next build, which returned their J and K matrices too;mainhas the same bug.get_psi4_molecule(),get_psi4_basisset()and the methods built on them raise the same clear error as the Psi4 attributes.Out of scope (steps 1.4 and 1.5): the NumPy test backend. The analysis modules (
evaluate,partition,cubes,forces,checks), artifacts, the TREXIO export, finite field and the runner's Psi4 setup still use the dimer's Psi4 objects.make_cubekeeps its owntstart/tstop.Tested:
Psi4Backend: its data, the dipoles, the compatibility attributes,sinfinityrebuilt from a dimer's backend,compute_jkagainstJ_A/K_B, and the SCF JK restored after a failed CPSCF-type product;compute_jkskipping empty pairs;compute_jkfolding the tensor into either side, against the J/K of the explicit density (a wrong right-side fold fails it);nauxcounts, and the Psi4 getters of a dimer with another backend.test_log.pynow expect the backend module.-W.mainon all 80 arrays; the later commits change no computed array. It covers the SAPT energy with both responses, the dipole, the densities and the intermediates. A single-threadedmainreproduces itself bitwise.main's only in four ways:tstop.🤖 Generated with Claude Code