Merge functionalities into old cc_<geminal>.py files from their _NEW counterpart - #201
Conversation
Copy class docstring additions from pccd_ap1rog_NEW: - document s_type attribute - document assign_s_type method - document _olp_double_derivative method Update PCCD.init: - add s_type keyword argument - add self.assign_s_type(s_type) Add assign_s_type method from pccd_ap1rog_NEW Add validation of allowed s_type values: - free - sen-o - sen-v - sen-ov (validation logic was missing in pccd_ap1rog_NEW) Merge sen-type overlap filtering logic from pccd_ap1rog_NEW into _olp Correct occupancy determinant used during excitation filtering: - replace sd with sd2 inside temp_olp inside `def _olp` - sd2 is the determinant being excited to generate sd1 - consistent with excitation logic and `pccd_ap1rog_NEW.py` implementation Change sd2 to sd in `def temp_olp` inside `def _olp_deriv` - consistent with `pccd_ap1rog_NEW.py` implementation Copied `_olp_double_deriv` function from `pccd_ap1rog_NEW.py` While merging code from pccd_ap1rog_NEW, retain the original `occ_indices(sd)` implementation in `_olp_deriv` and `_olp_double_derivative` (rather than changing to `sd2`) - add notes indicating that the correct determinant to use for occupancy filtering requires further investigation Preserve correct seniority-0 reference wavefunction validation: - **keep original slicing using nelec // 2** from `pccd_ap1rog.py` - do NOT adopt incorrect nspatial slicing from `pccd_ap1rog_NEW.py` Add implementation/documentation notes: - explain that pure PCCD generates only pair-double excitation operators - explain that s_type logic becomes active only when singles exist in exops - clarify relationship between exop structure and seniority filtering Remove stale commented-out debug print statements **Tests added:** test_assign_refwfn_sen_0_check test_assign_s_type test_assign_s_type_invalid test_init_s_type test_s_type_effect_on_pccd_overlap test_olp_double_derivative_shape test_olp_double_derivative_symmetric test_olp_double_derivative_zero_diagonal test_olp_double_derivative_finite_difference Add finite-difference validation of overlap Hessian Add Hessian symmetry test Add zero-diagonal structural Hessian test
Compare ap1rog_spin_NEW.py against the canonical ap1rog_spin.py implementation and confirm that no functional code differences were present requiring merge changes Add documentation and developer notes clarifying: - excitation-pool formulation of AP1roGSDSpin - role of singles, pair doubles, and seniority-filtered operators - interpretation of sen-o, sen-v, sen-ov, and free variants - dynamic enforcement of seniority filtering during overlap evaluation - assign_exops constructing only a static excitation operator pool - generation of compatible excitation combinations during overlap evaluation Also correct AP1roG typo in module docstring and replace outdated layered ansatz expression with implementation-consistent notation.
…entation Compare ap1rogsd_generalized_NEW.py against the canonical ap1rogsd_generalized.py implementation and confirm that no functional code differences required merging. Refine and expand documentation to better reflect the implemented excitation structure and overlap-generation workflow. Documentation updates include: - correct and modernize the AP1roGSDGeneralized ansatz expression - replace outdated layered excitation notation with excitation-pool formulation - document generalized single excitations and paired double excitations - clarify that generalized singles allow broken spin symmetry and spin-flip excitations - document sen-o, sen-v, sen-ov, and free seniority-filtering interpretations - clarify that seniority filtering is applied dynamically during overlap evaluation - add notes describing the static excitation-operator pool construction in assign_exops - clarify that overlap routines later generate compatible excitation combinations from the excitation pool Also correct minor AP1roG naming inconsistencies in docstrings.
Compare apg1ro_d_NEW.py against the canonical apg1ro_d.py implementation and
confirm that no functional code differences required merging beyond import consistency.
Refine and expand documentation to better reflect the implemented excitation structure and overlap-generation workflow.
Documentation updates include:
- modernize the APG1roD ansatz expression using excitation-pool notation
- clarify that the excitation operators are generalized doubles of the form tau_{i ibar}^{pq}
- document that occupied annihilators are restricted to paired occupied spin complements
- document that virtual creation indices are unrestricted generalized spin orbitals
- clarify distinction between pair-preserving and pair-breaking virtual excitations
- document possible spin-symmetry breaking and spin contamination
- clarify that inherited s_type filtering remains inactive because only double excitations are present
- add notes describing static excitation-pool construction and later overlap-generation workflow
Also improve terminology and mathematical consistency in docstrings.
Compare apg1ro_sd_NEW.py against the canonical apg1ro_sd.py implementation and confirm that no functional code differences required merging beyond import consistency. Refine and expand documentation to better reflect the implemented excitation structure and overlap-generation workflow. Documentation updates include: - modernize the APG1roSD ansatz expression using excitation-pool notation - replace outdated layered excitation notation with implementation-consistent operator-pool formulation - document generalized single excitations and generalized pair-annihilating double excitations - clarify that occupied annihilators in doubles remain restricted to paired occupied spin complements - clarify that virtual creation indices in doubles are unrestricted generalized spin orbitals - document distinction between pair-preserving and pair-breaking generalized doubles - clarify broken spin symmetry, spin-flip excitations, and possible spin contamination - document sen-o, sen-v, sen-ov, and free seniority-filtering interpretations for generalized singles - clarify that seniority filtering is applied dynamically during overlap evaluation - add notes describing static excitation-pool construction and later overlap-generation workflow Also improve terminology and mathematical consistency throughout the docstrings.
Compare apset1rog_d_NEW.py against the canonical apset1rog_d.py implementation and
confirm that no functional code differences required merging.
Refine and expand documentation to better reflect the implemented excitation
structure and overlap-generation workflow.
Documentation updates include:
- modernize the APset1roGD ansatz expression using excitation-pool notation
- clarify that excitation operators are set-restricted doubles of the form tau_{i ibar}^{ab}
- document that occupied annihilators are restricted to paired occupied spin complements
- document that virtual creation indices belong to two disjoint virtual spin-orbital sets
- clarify default alpha/beta virtual partitioning and spin-projection preservation
- document support for user-defined disjoint virtual excitation sets
- clarify distinction between APset1roGD and fully generalized APG1roD excitations
- clarify that inherited s_type filtering remains inactive because only double excitations are present
- add notes describing static excitation-pool construction and later overlap-generation workflow
Also improve terminology and mathematical consistency throughout the docstrings.
Compare apset1rog_sd_NEW.py against the canonical apset1rog_sd.py implementation and confirm that no functional code differences required merging. Refine and expand documentation to better reflect the implemented excitation structure and overlap-generation workflow. Documentation updates include: - modernize the APset1roGSD ansatz expression using excitation-pool notation - replace outdated layered excitation notation with implementation-consistent operator-pool formulation - document set-restricted spin-conserving singles and set-restricted doubles - clarify that occupied annihilators in doubles remain restricted to paired occupied spin complements - document that virtual creation indices belong to two disjoint virtual spin-orbital sets - clarify default alpha/beta virtual partitioning and spin-projection preservation - document support for user-defined disjoint virtual excitation sets - document sen-o, sen-v, sen-ov, and free seniority-filtering interpretations - clarify that seniority filtering is applied dynamically during overlap evaluation - add notes describing static excitation-pool construction and later overlap-generation workflow Also improve terminology and mathematical consistency throughout the docstrings.
Merge relevant functionality from pccd_ap1rog_NEW into old PCCD imple…
kzsigmond
left a comment
There was a problem hiding this comment.
The docstrings are on the longer side, and there is some repetition in a few places. I didn’t annotate every instance, but the main patterns I noticed are:
- Repeated description of the excitation pool (appearing both before and after the equation)
- Some inconsistency in orbital notation. At times general indices (e.g. pq) are used, while elsewhere the text refers to excitations from occupied to virtual orbitals. It might improve clarity to standardize notation, e.g. i, j for occupied, a, b for virtual, and p, q for general orbitals, as is commonly used in quantum chemistry.
- The description of the seniority restriction could likely be shortened. For end users, it is usually sufficient to know what is being restricted; the equations here don’t add much additional usability value and may be more useful at the developer or reference level.
One possible structure for the docstrings could be:
- Brief equation for the wavefunction, with concise explanation of symbols where needed (e.g. excitation pool definitions)
- Key behavioral details (e.g. single excitations can be restricted via
s_type,refwfnmust be a seniority-0 reference). This can stay fairly high-level since the detailed parameter behavior is already documented ins_typeandrefwfn - Pointer to the relevant paper for users who want the full formalism
The main goal of the docstrings is to explain the API and how to use it, rather than fully reproducing the level of detail of a paper. In fact, too much detail can sometimes obscure important usage constraints, such as the requirement that refwfn has seniority 0.
As a longer-term improvement (not necessary for this release), it might also be useful to add a separate reStructuredText page for geminal wavefunctions in the documentation. That could be a better place for the detailed discussion.
Changes as per review on the latest PR #201
|
The conflict in |
The class docstring has been rewritten following three-part structure: 1. A single ansatz equation with the excitation pool defined inline. 2. Removed repetitive description. 3. A pointer to the reference.
- Update docstring Remove long s_type descriptions from all wavefunction classes except base PCCD class. Update equations and their descriptions. Add a reference to the paper. - Mention `s_type` in attributes and `assign_s_type` in methods in docstrings of wavefunctions with doubles and singles (*_sd.py)
- Functionalities from all *_NEW.py files have been copied to the old corresponding .py files.
0f27187 to
a20f495
Compare
Co-authored-by: Krisztina Zsigmond <144738961+kzsigmond@users.noreply.github.com>
- fix array dimension issue - fix typo in `occ_indices`
Consolidating the legacy CC/geminal wavefunction implementations with their corresponding _NEW variants.
The primary goal of this PR is to:
This PR focuses mainly on review, consolidation, documentation cleanup, and targeted testing additions where functionality differences existed.
Main Changes in Files
pccd_ap1rog.pyMerged functionality from
_NEWinto the canonical implementation, including:s_typefunctionality and overlap filtering logic,_olp_double_derivative,The seniority-0 reference-wavefunction check from
_NEWwas not adopted because it incorrectly used slicing over:nspatialinstead ofnelec // 2.Important Note
The
_NEWimplementation of_olp_derivand_olp_double_derivativeuses:rather than:
This behavior was preserved for now because the implementation was used in calculations associated with the paper results. Further investigation is still needed to confirm whether this behavior is theoretically correct.
ap1rog_spin.pyap1rog_generalized.pyapg1ro_d.pyapg1ro_sd.pyapset1rog_d.pyapset1rog_sd.pyNo functional differences were found between the canonical and
_NEWimplementations (aside from parent import filenames, which were left unchanged since only old files are modified to accommodate the functionalities from their _NEW variants).For these files:
No new tests were added for these files because no functionality changes were introduced during the merge review. Additional tests can be included to improve test coverage through a separate branch.
Additional Notes
A major focus of this PR was improving consistency between:
Older layered operator expressions- a series of parentheses for doubles and single operators- could lead to confusion on the ordering of operators. So, those were replaced with excitation-pool formulations that more accurately reflect the implementation behavior.