Skip to content

New corrections - #223

Open
rodrigoaramendes wants to merge 10 commits into
mainfrom
new-corrections
Open

rodrigoaramendes wants to merge 10 commits into
mainfrom
new-corrections

Conversation

@rodrigoaramendes

Copy link
Copy Markdown
Contributor

PCCD/AP1roG wavefunction with memoized seniority filtering and per-parameter-vector overlap caching.

The assignment methods (assign_nelec, assign_ranks, assign_exops, assign_refwfn, assign_s_type) are carried over unchanged from the reference PCCD implementation; only the overlap routines differ.

Differences from the "old" PCCD implementation

  1. The three near-identical seniority-filter blocks are factored into a single _apply_seniority_filter helper. Pure deduplication; no change in results.

  2. The filter is memoized. It is idempotent (rerunning it on an already-filtered array reselects the same rows) and upstream mutates exop_combinations[key] in place, so re-deriving the selection on every call is wasted work. Two separate key sets are kept because _olp filters against occ_indices(sd2) (the reference) while _olp_deriv filters against occ_indices(sd) (the target). generate_possible_exops is overridden so that if BaseCC's refresh_exops mechanism discards exop_combinations, the filter caches are dropped with it. Without that, a regenerated (unfiltered) key would be treated as already filtered.

  3. _olp(sd) / _olp_deriv(sd) are memoized per parameter vector. For fixed amplitudes these are pure functions of sd, and the same sd recurs many times within one objective or gradient evaluation (once as a projection-space element, again as an excitation neighbour of other elements inside integrate_sd_wfn). The caches are cleared from assign_params, assign_refwfn and clear_cache, so a cached value is only reused while the parameters that produced it are current.

  4. legacy_deriv_filter controls a genuine behavioural divergence. The reference _olp_deriv and _olp_double_derivative apply the "sen-o" filter unconditionally, ignoring s_type (only _olp dispatches on it). With legacy_deriv_filter = True (the default here), that behaviour is reproduced exactly. With False, the derivative honours s_type, which makes the gradient the actual derivative of the value this object returns, relevant only for s_type != "sen-o", since the two agree on the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant