Skip to content

Conversation

@ABesharat
Copy link
Contributor

This PR fixed normalization factor (nf) issue (symbolically and numerically) for A and S operators, making them consistent with the SeQuant manuscript.
now S has nf = 1/factorial(ket_size)
and A has nf = 1/(factorial(ket_size) * factorial(bra_size))

Affected functions:
expand_A_op
symmetrize_expr
S_maps
closed_shell_CC_spintrace_v1 and v2
column_symmetrize_ta and btas
particle_antisymmetrize_ta and btas

and their corresponding tests (test_spin.cpp, test_eval_ta.cpp, test_eval_btas.cpp)

@ABesharat ABesharat force-pushed the azam/feature/addNormFactor branch from 9c92c78 to 88535ca Compare January 21, 2026 17:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes the normalization factor implementation for A (antisymmetrizer) and S (symmetrizer) operators to align with the SeQuant manuscript. The key changes are:

Purpose:

  • S operators now have normalization factor nf = 1/factorial(ket_size)
  • A operators now have normalization factor nf = 1/(factorial(bra_size) * factorial(ket_size))

Changes:

  • Updated symbolic expansion functions (expand_A_op, symmetrize_expr, S_maps) to apply the new normalization factors
  • Updated numerical evaluation functions (column_symmetrize_ta/btas, particle_antisymmetrize_ta/btas) to apply matching normalization
  • Updated the tensor::A() function to pre-multiply by factorial to compensate for normalization in expansion
  • Updated all affected tests to reflect the new expected values
  • Removed the factorize_S function from the codebase
  • Removed unnecessary normalization code from closed_shell_CC_spintrace_v2

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit/test_spin.cpp Updated test expectations for A and S operator expansions with new normalization factors; added new test cases for symmetrization
tests/unit/test_mbpt.cpp Updated latex output expectations for operator tensor forms; added test for S operator action
tests/unit/test_eval_ta.cpp Updated numerical tests for antisymmetrization and symmetrization with correct normalization factors
tests/unit/test_eval_btas.cpp Updated numerical tests for antisymmetrization with correct normalization factors
SeQuant/domain/mbpt/spin.hpp Removed declaration of factorize_S function
SeQuant/domain/mbpt/spin.cpp Added normalization factor application in expand_A_op, symmetrize_expr, and S_maps; removed factorize_S implementation; removed redundant normalization from closed_shell_CC_spintrace_v2
SeQuant/domain/mbpt/op.cpp Added factorial multiplication to tensor::A() function; added spinfree basis validation to tensor::S()
SeQuant/core/eval/backends/tiledarray/result.hpp Added normalization factor application in column_symmetrize_ta and particle_antisymmetrize_ta
SeQuant/core/eval/backends/btas/result.hpp Added normalization factor application in column_symmetrize_btas and particle_antisymmetrize_btas

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

simplify(expanded_A);
REQUIRE(p6_result == p7_result);
REQUIRE(p6_result == expanded_A);
// REQUIRE(p6_result == expanded_A);
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test requirement has been commented out: REQUIRE(p6_result == expanded_A);. This suggests that the relationship between composed A operators and a single A3 operator may no longer hold with the new normalization factors. This could indicate an inconsistency in how normalization factors are applied when composing operators versus using a single higher-rank operator. Please verify that this is intentional and document why this relationship no longer holds, or fix the normalization to maintain this invariant.

Suggested change
// REQUIRE(p6_result == expanded_A);
// Note:
// Under the current normalization conventions for antisymmetrizers,
// the operator obtained by composing lower-rank A operators (used to
// build p6_result) is not algebraically identical to the single A3
// operator applied once (expanded_A); they can differ by an overall
// normalization factor. Therefore we intentionally do not assert equality
// between p6_result and expanded_A here. If the normalization of A3 is
// later adjusted so that a product of A operators and a single A3 become
// strictly equivalent, an additional test comparing these two expressions
// should be added at this point.

Copilot uses AI. Check for mistakes.
}

ExprPtr S(std::int64_t K) {
if (get_default_context().spbasis() != SPBasis::Spinfree) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

@evaleev evaleev force-pushed the azam/feature/addNormFactor branch from e2b4ef7 to a18d5f6 Compare January 25, 2026 21:05
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.

4 participants