From 043a4b9001d11f0a21a22529bd9fa13c6dda2b30 Mon Sep 17 00:00:00 2001 From: btyrcha Date: Mon, 9 Nov 2026 15:00:26 +0100 Subject: [PATCH 1/3] propSAPT's own preconditioned conjugate-gradient solver for the CPSCF equations `prop_sapt.cpscf_solver.conjugate_gradient` solves H x = b for several right-hand sides, taking the products of all unconverged vectors in one call, each vector converging on its own. It starts from b / diagonal and stops at a relative residual below `r_convergence`, as Psi4's `p4util.cg_solver` does, and warns when a vector has not converged or meets a direction of non-positive curvature. Unit tests on small dense systems, no SCF. Co-Authored-By: Claude Opus 5.5 --- prop_sapt/cpscf_solver.py | 176 +++++++++++++++++++++++++++++++++++++ tests/test_cpscf_solver.py | 145 ++++++++++++++++++++++++++++++ 2 files changed, 321 insertions(+) create mode 100644 prop_sapt/cpscf_solver.py create mode 100644 tests/test_cpscf_solver.py diff --git a/prop_sapt/cpscf_solver.py b/prop_sapt/cpscf_solver.py new file mode 100644 index 0000000..54129f3 --- /dev/null +++ b/prop_sapt/cpscf_solver.py @@ -0,0 +1,176 @@ +"""Preconditioned conjugate-gradient solver of the CPSCF equations. + +`conjugate_gradient` solves H x = b for several right-hand sides b at once, where H is +symmetric positive definite and known only through its products with vectors: for the +CPSCF equations, the orbital Hessian of a monomer (see +`helper_SAPT.orbital_hessian_product`). Each iteration takes the products of all +unconverged vectors in one call, which for the CPSCF equations is one J/K build for the +whole batch. Each vector converges on its own. +""" + +import time +import warnings +from collections.abc import Callable, Mapping, Sequence + +import numpy as np +import psi4 + +HessianProduct = Callable[[list[np.ndarray]], list[np.ndarray]] + + +def conjugate_gradient( + rhs: Sequence[np.ndarray], + hessian_product: HessianProduct, + diagonal: np.ndarray, + r_convergence: float, + maxiter: int, + title: str = "CPSCF", +) -> list[np.ndarray]: + """ + Solves H x = b for every b in `rhs` with the preconditioned conjugate-gradient method. + + The preconditioner divides by `diagonal`, and the start is the preconditioned + right-hand side, b / `diagonal`: for the CPSCF equations, the uncoupled solution. A + vector has converged when its relative residual ||b - H x|| / ||b|| is below + `r_convergence`. A zero right-hand side has the solution zero. The progress is + printed to Psi4's output file. + + Args: + rhs (Sequence[np.ndarray]): Right-hand sides b, arrays of the shape of + `diagonal`. They are not changed. + hessian_product (Callable[[list[np.ndarray]], list[np.ndarray]]): Takes a list of + arrays x and returns the products H x, in the same order. + diagonal (np.ndarray): Positive approximation of the diagonal of H, e.g. the + orbital energy differences. + r_convergence (float): Relative residual below which a vector has converged. + maxiter (int): Maximum number of iterations, each one `hessian_product` call. + title (str, optional): Name of the solve in the output. Defaults to "CPSCF". + + Returns: + list[np.ndarray]: The solutions x, in the order of `rhs`. + + Warns: + RuntimeWarning: Raised if a vector has not converged in `maxiter` iterations, or + has met a direction in which H is not positive definite. Its last iterate is + returned. + """ + + t_start = time.time() + b = [np.asarray(vector, dtype=np.float64) for vector in rhs] + for vector in b: + if vector.shape != diagonal.shape: + raise ValueError( + f"{title}: right-hand side of shape {vector.shape}, " + f"expected {diagonal.shape}." + ) + if not b: + return [] + + b_norm = [np.linalg.norm(vector) for vector in b] + residual = [0.0] * len(b) + x = [vector / diagonal for vector in b] + r, z, p, rz = {}, {}, {}, {} + + active = [i for i, norm in enumerate(b_norm) if norm > 0.0] + for i, product in zip(active, _products(hessian_product, x, active, title)): + r[i] = b[i] - product + residual[i] = np.linalg.norm(r[i]) / b_norm[i] + active = [i for i in active if residual[i] >= r_convergence] + + for i in active: + z[i] = r[i] / diagonal + p[i] = z[i] + rz[i] = np.vdot(r[i], z[i]) + + _print_header(title, len(b), r_convergence, maxiter) + _print_row("Guess", residual, len(active), t_start) + + # vectors stopped at a direction of non-positive curvature + stopped = [] + iteration = 0 + while active and iteration < maxiter: + iteration += 1 + unconverged = [] + for i, product in zip(active, _products(hessian_product, p, active, title)): + curvature = np.vdot(p[i], product) + if not curvature > 0.0: + stopped.append(i) + continue + + alpha = rz[i] / curvature + x[i] = x[i] + alpha * p[i] + r[i] = r[i] - alpha * product + residual[i] = np.linalg.norm(r[i]) / b_norm[i] + if residual[i] < r_convergence: + continue + + z[i] = r[i] / diagonal + rz_new = np.vdot(r[i], z[i]) + p[i] = z[i] + (rz_new / rz[i]) * p[i] + rz[i] = rz_new + unconverged.append(i) + + active = unconverged + _print_row(f"{iteration:d}", residual, len(active), t_start) + + psi4.core.print_out(" " + "-" * 56 + "\n") + + if active: + _warn( + f"{title}: {len(active)} of {len(b)} vectors did not converge in " + f"{maxiter} iterations (largest relative residual " + f"{max(residual[i] for i in active):.2e}, convergence {r_convergence:.1e})." + ) + if stopped: + _warn( + f"{title}: {len(stopped)} of {len(b)} vectors stopped at a direction in " + "which the Hessian is not positive definite (largest relative residual " + f"{max(residual[i] for i in stopped):.2e})." + ) + + return x + + +def _products( + hessian_product: HessianProduct, + vectors: Sequence[np.ndarray] | Mapping[int, np.ndarray], + active: list[int], + title: str, +) -> list[np.ndarray]: + """The products of H with the `active` ones of `vectors`, in one call.""" + + if not active: + return [] + + products = hessian_product([vectors[i] for i in active]) + if len(products) != len(active): + raise ValueError( + f"{title}: the Hessian product returned {len(products)} vectors " + f"for {len(active)}." + ) + + return products + + +def _print_header(title: str, count: int, r_convergence: float, maxiter: int): + psi4.core.print_out( + f"\n {title}: preconditioned conjugate gradient\n" + f" Equations = {count:11d}\n" + f" Convergence = {r_convergence:11.3e}\n" + f" Maxiter = {maxiter:11d}\n\n" + f" {'Iter':>5} {'Residual mean':>14} {'Residual max':>13} " + f"{'Remaining':>10} {'Time [s]':>9}\n" + " " + "-" * 56 + "\n" + ) + + +def _print_row(label: str, residual: list[float], remaining: int, t_start: float): + psi4.core.print_out( + f" {label:>5} {np.mean(residual):14.3e} {np.max(residual):13.3e} " + f"{remaining:10d} {time.time() - t_start:9.1f}\n" + ) + + +def _warn(message: str): + psi4.core.print_out(f"\n Warning: {message}\n") + warnings.warn(message, RuntimeWarning, stacklevel=3) diff --git a/tests/test_cpscf_solver.py b/tests/test_cpscf_solver.py new file mode 100644 index 0000000..b27c134 --- /dev/null +++ b/tests/test_cpscf_solver.py @@ -0,0 +1,145 @@ +"""propSAPT's conjugate-gradient solver of the CPSCF equations, on small dense systems +with no SCF.""" + +import numpy as np +import pytest + +from prop_sapt.cpscf_solver import conjugate_gradient + +SHAPE = (3, 5) + + +# elements of the arrays of `SHAPE` that H does not couple to the others +DECOUPLED = 3 + + +class DenseHessian: + """A symmetric positive definite H on arrays of `SHAPE`, diagonally dominant like an + orbital Hessian, that records how many vectors each product call gets. It does not + couple the first `DECOUPLED` elements, so it is diagonal on them.""" + + def __init__(self, seed=3, sign=1.0): + rng = np.random.default_rng(seed) + n = np.prod(SHAPE) + self.diagonal = rng.uniform(0.5, 3.0, SHAPE) + coupling = 0.2 * rng.standard_normal((n, n)) + coupling[:DECOUPLED] = 0.0 + self.matrix = sign * (np.diag(self.diagonal.ravel()) + coupling @ coupling.T) + self.calls = [] + + def __call__(self, vectors): + self.calls.append(len(vectors)) + return [(self.matrix @ v.ravel()).reshape(SHAPE) for v in vectors] + + def solve(self, b): + return np.linalg.solve(self.matrix, b.ravel()).reshape(SHAPE) + + +def right_hand_sides(count, seed=5): + rng = np.random.default_rng(seed) + return [rng.standard_normal(SHAPE) for _ in range(count)] + + +def solve(hessian, rhs, r_convergence=1e-12, maxiter=100): + return conjugate_gradient(rhs, hessian, hessian.diagonal, r_convergence, maxiter) + + +def test_solutions(): + hessian = DenseHessian() + rhs = right_hand_sides(3) + + solutions = solve(hessian, rhs) + + assert len(solutions) == 3 + for x, b in zip(solutions, rhs): + assert x.shape == SHAPE + np.testing.assert_allclose(x, hessian.solve(b), rtol=0, atol=1e-10) + + +def test_converges_to_the_threshold(): + """Every solution has a relative residual below the threshold.""" + + hessian = DenseHessian() + rhs = right_hand_sides(3) + + for r_convergence in (1e-4, 1e-8): + for x, b in zip(solve(hessian, rhs, r_convergence), rhs): + residual = np.linalg.norm(b - hessian([x])[0]) / np.linalg.norm(b) + assert residual < r_convergence + + +def test_batch_matches_single_solves(): + """Solving together changes no vector's iterates, and each product call gets the + vectors that have not converged: the first all of them, the k-th as many as the + single solves that take more than k calls.""" + + # the first is solved by the start, b / diagonal + easy = np.zeros(SHAPE) + easy.flat[:DECOUPLED] = 1.0 + rhs = [easy] + right_hand_sides(2) + single_calls = [] + single = [] + for b in rhs: + hessian = DenseHessian() + single.append(solve(hessian, [b], r_convergence=1e-10)[0]) + single_calls.append(len(hessian.calls)) + + hessian = DenseHessian() + batch = solve(hessian, rhs, r_convergence=1e-10) + + for x_batch, x_single in zip(batch, single): + np.testing.assert_array_equal(x_batch, x_single) + assert single_calls[0] == 1 < min(single_calls[1:]) + expected = [sum(n > k for n in single_calls) for k in range(max(single_calls))] + assert hessian.calls == expected + + +def test_right_hand_sides_unchanged(): + rhs = right_hand_sides(2) + copies = [b.copy() for b in rhs] + + solve(DenseHessian(), rhs) + + for b, copy in zip(rhs, copies): + np.testing.assert_array_equal(b, copy) + + +def test_zero_right_hand_side(): + """A zero right-hand side has the solution zero and takes no products.""" + + hessian = DenseHessian() + rhs = right_hand_sides(1) + [np.zeros(SHAPE)] + + x, x_zero = solve(hessian, rhs) + + np.testing.assert_array_equal(x_zero, np.zeros(SHAPE)) + np.testing.assert_allclose(x, hessian.solve(rhs[0]), rtol=0, atol=1e-10) + assert all(count == 1 for count in hessian.calls) + + +def test_no_right_hand_sides(): + hessian = DenseHessian() + + assert solve(hessian, []) == [] + assert hessian.calls == [] + + +def test_wrong_shape_rejected(): + with pytest.raises(ValueError, match="right-hand side of shape"): + solve(DenseHessian(), [np.ones((5, 3))]) + + +def test_not_converged_warns(): + with pytest.warns(RuntimeWarning, match="2 of 2 vectors did not converge in 2"): + solve(DenseHessian(), right_hand_sides(2), maxiter=2) + + +def test_not_positive_definite_warns(): + """A vector that meets a direction of negative curvature stops, with a warning.""" + + hessian = DenseHessian(sign=-1.0) + + with pytest.warns(RuntimeWarning, match="not positive definite"): + solve(hessian, right_hand_sides(1)) + + assert len(hessian.calls) == 2 From 81f55b29fc91944cbf3b26e64d33764852394979 Mon Sep 17 00:00:00 2001 From: btyrcha Date: Mon, 9 Nov 2026 15:00:26 +0100 Subject: [PATCH 2/3] CPSCF solves use propSAPT's solver, and Psi4 supplies only the orbital-Hessian products `cpscf_batch` solves H t = -omega with `conjugate_gradient`, where H is the positive definite orbital Hessian of the new `orbital_hessian_product`. That wraps `cphf_Hx`, which returns -H, and swaps in the CPSCF J/K object for each product. `p4util.cg_solver` and `Matrix.apply_denominator` are no longer used. The amplitudes agree with the old solver to 4e-13 for He-H2 (RHF and PBE0, SCF and DF J/K), with the same iterations. Tests: the amplitudes solve their equations, the Hessian is symmetric and positive, and the J/K restore after a failure now fails the Hessian product instead of the solver. Co-Authored-By: Claude Opus 5.5 --- prop_sapt/helper_SAPT_DF.py | 106 +++++++++++++++++++++--------------- tests/test_cpscf_type.py | 30 +++++++--- tests/test_dimer.py | 42 +++++++++++++- 3 files changed, 125 insertions(+), 53 deletions(-) diff --git a/prop_sapt/helper_SAPT_DF.py b/prop_sapt/helper_SAPT_DF.py index 1e54925..ededbfa 100644 --- a/prop_sapt/helper_SAPT_DF.py +++ b/prop_sapt/helper_SAPT_DF.py @@ -55,8 +55,9 @@ import numpy as np import opt_einsum as oe import psi4 -from psi4.driver.p4util import message_box, cg_solver, OptionsState, OptionsStateCM +from psi4.driver.p4util import message_box, OptionsState, OptionsStateCM +from .cpscf_solver import conjugate_gradient from .options import PROPSAPT_OPTIONS, check_cpscf_type, check_df_basis_cpscf @@ -576,23 +577,29 @@ def cpscf_batch( Coupled perturbed HF or KS calculations for several perturbations of one monomer. Solves the CPSCF equations of `monomer` for every (ov) matrix in `perturbations` - in one conjugate-gradient run. Each iteration builds the Hessian products of all - unconverged vectors with one J/K call, which costs much less than a call per - vector. Each vector converges on its own, to the same amplitudes as `cpscf`. + in one conjugate-gradient run (`prop_sapt.cpscf_solver`). Each iteration builds + the Hessian products of all unconverged vectors with one J/K call, which costs + much less than a call per vector. Each vector converges on its own, to the same + amplitudes as `cpscf`. - The J and K matrices come from the J/K object of the monomer SCF, or from - `cpscf_jk` if it is set (see `build_cpscf_jk`). + The amplitudes t of a perturbation omega solve H t = -omega, with H the orbital + Hessian of `orbital_hessian_product`; uncoupled, they are + omega / (eps_occ - eps_vir). The J and K matrices come from the J/K object of + the monomer SCF, or from `cpscf_jk` if it is set (see `build_cpscf_jk`). Args: monomer (str): "A" or "B". perturbations (list[np.ndarray]): (ov) perturbation matrices. - r_convergence (float | None, optional): Residual convergence threshold. - Defaults to the `r_convergence` option. + r_convergence (float | None, optional): Convergence threshold of the + relative residual. Defaults to the `r_convergence` option. maxiter (int | None, optional): Maximum number of iterations. Defaults to the `cpscf_maxiter` option. Returns: list[np.ndarray]: The (vo) amplitudes, in the order of `perturbations`. + + Warns: + RuntimeWarning: Raised if some amplitudes have not converged. """ self._check_cpscf(monomer) @@ -607,32 +614,52 @@ def cpscf_batch( # NOTE: Changed the monomer naming scheme: # 'monomer' refers now to the one that returned amplitudes are for. - occ, vir, wfn = ( - ("a", "r", self.wfnA) if monomer == "A" else ("b", "s", self.wfnB) + occ, vir = ("a", "r") if monomer == "A" else ("b", "s") + + amplitudes = conjugate_gradient( + [-np.asarray(pert_ov) for pert_ov in perturbations], + lambda vectors: self.orbital_hessian_product(monomer, vectors), + self.eps(vir) - self.eps(occ, dim=2), + r_convergence=r_convergence, + maxiter=maxiter, + title=f"CPSCF of monomer {monomer}", ) - no = self.sizes[occ] - nv = self.sizes[vir] - - # Get the orbital energy differences - eps_ov = psi4.core.Matrix.from_array(self.eps(occ, dim=2) - self.eps(vir)) - - # apply hessian func to every active vector in one call - def _hess_x(x_vec, act_mask): - active = [x for x, on in zip(x_vec, act_mask) if on] - products = iter(wfn.cphf_Hx(active) if active else []) - return [next(products) if on else False for on in act_mask] - - # preconditioner - applies denominator (for faster convergence) - def _apply_precon(x_vec, act_mask): - preconditioned = [] - for x, on in zip(x_vec, act_mask): - if on: - p = x.clone() - p.apply_denominator(eps_ov) - preconditioned.append(p) - else: - preconditioned.append(False) - return preconditioned + + # We want to return (vo) matrices + return [t.T for t in amplitudes] + + def orbital_hessian_product( + self, monomer: str, vectors: list[np.ndarray] + ) -> list[np.ndarray]: + """ + Products of the orbital Hessian of `monomer` with (ov) `vectors`, the left-hand + side of its CPSCF equations (see `cpscf_batch`). + + The Hessian is the symmetric positive definite one of a real singlet + perturbation: for RHF, + H_{ar,a'r'} = (eps_r - eps_a) delta_{aa'} delta_{rr'} + + 4 (ar|a'r') - (ar'|a'r) - (aa'|rr'), + and for RKS the exchange-correlation kernel too. Its J and K matrices come from + the J/K object of the monomer SCF, or from `cpscf_jk` if it is set (see + `build_cpscf_jk`). Psi4's `cphf_Hx` gives the products, with the opposite sign. + + Args: + monomer (str): "A" or "B". + vectors (list[np.ndarray]): (ov) vectors. + + Returns: + list[np.ndarray]: The (ov) products, in the order of `vectors`. + """ + + self._check_cpscf(monomer) + + if len(vectors) == 0: + return [] + + wfn = self.wfnA if monomer == "A" else self.wfnB + matrices = [ + psi4.core.Matrix.from_array(np.ascontiguousarray(x)) for x in vectors + ] # `cphf_Hx` takes the J and K matrices from the wavefunction's J/K object swap_jk = self.cpscf_jk is not None @@ -640,22 +667,13 @@ def _apply_precon(x_vec, act_mask): scf_jk = wfn.jk() wfn.set_jk(self.cpscf_jk) - # solve cpscf try: - x_vec, _ = cg_solver( - [psi4.core.Matrix.from_array(pert_ov) for pert_ov in perturbations], - _hess_x, - _apply_precon, - printlvl=2, - maxiter=maxiter, - rcond=r_convergence, - ) + products = wfn.cphf_Hx(matrices) finally: if swap_jk: wfn.set_jk(scf_jk) - # We want to return (vo) matrices - return [np.array(x).reshape(no, nv).T for x in x_vec] + return [-np.asarray(product) for product in products] def build_cpscf_jk( self, cpscf_type: str | None, df_basis: str | None = None diff --git a/tests/test_cpscf_type.py b/tests/test_cpscf_type.py index d196557..c16ba4c 100644 --- a/tests/test_cpscf_type.py +++ b/tests/test_cpscf_type.py @@ -6,7 +6,6 @@ import pytest from psi4.driver.p4util import OptionsState -import prop_sapt.helper_SAPT_DF as helper_module from prop_sapt import ( calc_densities, calc_sapt_energy, @@ -175,20 +174,35 @@ def solve(df_basis): np.testing.assert_allclose(value, reference, rtol=0, atol=1e-10 * scale) -def test_scf_jk_restored_after_failed_solve(prepare_dimer, monkeypatch): - """A failing solve leaves the monomer SCF's J/K object on the wavefunction.""" +class FailingHx: + """Wraps a monomer wavefunction whose Hessian products fail, recording the name of + its J/K object at the failure.""" - mol = prepare_dimer + def __init__(self, wfn): + self.wfn = wfn + self.jk_names = [] + + def __getattr__(self, name): + return getattr(self.wfn, name) + + def cphf_Hx(self, x_vec): + self.jk_names.append(self.wfn.jk().name()) + raise RuntimeError("Hessian product failed") - def failing_solver(*args, **kwargs): - raise RuntimeError("solver failed") - monkeypatch.setattr(helper_module, "cg_solver", failing_solver) +def test_scf_jk_restored_after_failed_solve(prepare_dimer, monkeypatch): + """A Hessian product that fails on the CPSCF J/K object leaves the monomer SCF's + J/K object on the wavefunction.""" + + mol = prepare_dimer + failing = FailingHx(mol.wfnA) + monkeypatch.setattr(mol, "wfnA", failing) - with pytest.raises(RuntimeError, match="solver failed"): + with pytest.raises(RuntimeError, match="Hessian product failed"): with mol.use_cpscf_type("DF", DF_BASIS): mol.cpscf_batch("A", [np.ones((mol.sizes["a"], mol.sizes["r"]))]) + assert failing.jk_names == ["MemDFJK"] assert mol.wfnA.jk().name() == "DirectJK" assert mol.cpscf_jk is None assert mol._cpscf_key is None diff --git a/tests/test_dimer.py b/tests/test_dimer.py index a4f811e..2d9a3a2 100644 --- a/tests/test_dimer.py +++ b/tests/test_dimer.py @@ -3,7 +3,7 @@ import pytest from .he_h2 import HE_H2 -from prop_sapt import Dimer +from prop_sapt import Dimer, get_propsapt_options from prop_sapt.helper_SAPT_DF import jk_memory_doubles HE_H = """ @@ -192,6 +192,46 @@ def test_cpscf_rejects_unknown_monomer(prepare_dimer): prepare_dimer.cpscf_batch("C", []) +@pytest.mark.parametrize("monomer", ["A", "B"]) +def test_cpscf_amplitudes_solve_their_equations(prepare_dimer, monomer): + """The amplitudes t of a perturbation omega solve H t = -omega, with H the orbital + Hessian, to the convergence threshold (with room for the difference between the + solver's updated residual and the recomputed one).""" + + perturbations = random_perturbations(prepare_dimer, monomer, 2) + + amplitudes = prepare_dimer.cpscf_batch(monomer, perturbations) + products = prepare_dimer.orbital_hessian_product(monomer, [t.T for t in amplitudes]) + + r_convergence = get_propsapt_options()["r_convergence"] + for product, omega in zip(products, perturbations): + residual = np.linalg.norm(product + omega) / np.linalg.norm(omega) + assert residual < 10 * r_convergence + + +@pytest.mark.parametrize("monomer", ["A", "B"]) +def test_orbital_hessian_symmetric_positive(prepare_dimer, monomer): + """The orbital Hessian, the one part of a CPSCF solve that the quantum-chemistry + code does, is symmetric and positive: u.Hv = v.Hu and v.Hv > 0.""" + + u, v = random_perturbations(prepare_dimer, monomer, 2) + + Hu, Hv = prepare_dimer.orbital_hessian_product(monomer, [u, v]) + + assert np.vdot(u, Hv) == pytest.approx(np.vdot(v, Hu), rel=1e-10) + assert np.vdot(u, Hu) > 0 + assert np.vdot(v, Hv) > 0 + + +def test_orbital_hessian_product_of_nothing(prepare_dimer): + assert prepare_dimer.orbital_hessian_product("A", []) == [] + + +def test_cpscf_rejects_wrong_shape(prepare_dimer): + with pytest.raises(ValueError, match="right-hand side of shape"): + prepare_dimer.cpscf_batch("A", [np.ones((2, 2))]) + + def test_basisset_is_the_dimers(prepare_dimer): """The dimer's basis set is the one it was built with, not the one the `BASIS` option names now: cubes, point evaluation and fragment operators use it.""" From a63a0a724b4172703e818244bc97a1a919822cca Mon Sep 17 00:00:00 2001 From: btyrcha Date: Mon, 9 Nov 2026 15:00:26 +0100 Subject: [PATCH 3/3] changelog and AI usage log for the CPSCF solver Co-Authored-By: Claude Opus 5.5 --- AI-USAGE.md | 9 +++++++++ CHANGELOG.md | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/AI-USAGE.md b/AI-USAGE.md index 2c2e2ea..adec6ee 100644 --- a/AI-USAGE.md +++ b/AI-USAGE.md @@ -150,6 +150,11 @@ The short version, for disclosures; the log below has the detail. - Explained when the version changes; a release workflow check that `CITATION.cff` and the install commands match the tag, `main` set to `0.5.0.dev0`, and a release checklist in `CONTRIBUTING.md`. +### 2026-11-09 + +- Re-audited where the package depends on Psi4 (objects, internal APIs, AO-basis inputs and outputs) for a roadmap item, and compared the integral, response and grid features of two other quantum-chemistry codes; recorded the findings and a staged plan in the development roadmap. +- propSAPT's own conjugate-gradient CPSCF solver in place of Psi4's internal one, with Psi4 supplying only the orbital-Hessian products; a warning for unconverged solves, solver unit tests and Hessian tests, checked against the old solver to 4e-13. + ### 2026-11-14 - Added the second-order properties preprint (arXiv:2611.07993) to the citations: `CITATION.cff` (under `references`, schema-validated), the README, and a new Citing section in the docs with BibTeX entries for both papers. @@ -161,3 +166,7 @@ The short version, for disclosures; the log below has the detail. - Fixed density file names that collided on case-insensitive file systems (`Ind`/`ind`, `Disp`/`disp`): a file-name helper with a collision check in `prop_sapt.artifacts`, `Ind`/`Disp` files named `ind-total`/`disp-total`, with tests, an example, docs and a changelog entry. - Rebased the TREXIO export PR onto `main` after the 0.5.0 release (its changelog entries moved to the Unreleased section) and after the density file-name fix, naming the TREXIO files like the cubes through `density_file_names`, with a test of the collision check. - Addressed the Copilot review of the TREXIO PR: documented that the bundle's cube and TREXIO entries record the files requested, which are written after it, and made `export_trexio` refuse a `relative_cutoff` outside [0, 1), with tests. + +### 2026-11-19 + +- Rebased the CPSCF solver PR onto `main` after the 0.5.0 release and the TREXIO export (its changelog entry moved to the Unreleased section). diff --git a/CHANGELOG.md b/CHANGELOG.md index 36cd811..91d0f86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,12 @@ requests of the private repository propSAPT was developed in before it was publi - `density_natural_orbitals`: the natural orbitals of the density changes, a few of which usually carry most of a change, in the spirit of NOCV. +### Changed + +- propSAPT solves the CPSCF equations with its own conjugate-gradient solver, with the + same results. A solve that has not converged in `cpscf_maxiter` iterations now warns, + where it used to go on silently. + ### Fixed - The cube and `.npy` files of the `Ind` and `Disp` densities are now named