66#include < SeQuant/core/expr.hpp>
77#include < SeQuant/core/math.hpp>
88#include < SeQuant/core/optimize.hpp>
9+ #include < SeQuant/core/parse.hpp>
910#include < SeQuant/core/rational.hpp>
1011#include < SeQuant/core/space.hpp>
1112#include < SeQuant/core/tensor_canonicalizer.hpp>
@@ -943,6 +944,7 @@ ExprPtr closed_shell_spintrace(
943944 const ExprPtr& expression,
944945 const container::svector<container::svector<Index>>& ext_index_groups,
945946 bool full_expansion) {
947+ std::wcout << " Original: " << deparse (expression) << " \n " ;
946948 // Symmetrize and expression
947949 // Partially expand the antisymmetrizer and write it in terms of S operator.
948950 // See symmetrize_expr(expr) function for implementation details. We want an
@@ -966,6 +968,8 @@ ExprPtr closed_shell_spintrace(
966968 };
967969 auto expr = partially_or_fully_expand (expression);
968970
971+ std::wcout << " Partially expanded: " << deparse (expr) << " \n " ;
972+
969973 // Index tags are cleaned prior to calling the fast canonicalizer
970974 detail::reset_idx_tags (expr); // This call is REQUIRED
971975 expand (expr); // This call is REQUIRED
@@ -977,6 +981,8 @@ ExprPtr closed_shell_spintrace(
977981 }
978982 simplify (expr, opts); // full simplify to combine terms before count_cycles
979983
984+ std::wcout << " Simplified: " << deparse (expr) << " \n " ;
985+
980986 // Lambda for spin-tracing a product term
981987 // For closed-shell case, a spin-traced result is a product term scaled by
982988 // 2^{n_cycles}, where n_cycles are counted by the lambda function described
@@ -985,6 +991,7 @@ ExprPtr closed_shell_spintrace(
985991 // substituted with either one of the index (because the two vectors should be
986992 // permutations of each other to count cycles). All tensors must be nonsymm.
987993 auto trace_product = [&ext_index_groups](const Product& product) {
994+ std::wcout << " Tracing " << deparse (product) << " \n " ;
988995 // Remove S if present in a product
989996 Product temp_product{};
990997 temp_product.scale (product.scalar ());
@@ -1025,6 +1032,7 @@ ExprPtr closed_shell_spintrace(
10251032 (t->as <Tensor>().label () != L" A" &&
10261033 t->as <Tensor>().label () != L" S" ))) {
10271034 const Tensor& tensor = t->as <Tensor>();
1035+ std::wcout << " Collecting bra indices of " << tensor.label () << " \n " ;
10281036 bra_idx.insert (bra_idx.end (), tensor.bra ().begin (),
10291037 tensor.bra ().end ());
10301038 }
@@ -1038,13 +1046,34 @@ ExprPtr closed_shell_spintrace(
10381046 assert (idx_pair.size () == 2 );
10391047 const auto & what = idx_pair[0 ];
10401048 const auto & with = idx_pair[1 ];
1049+ std::wcout << " Replacing " << what.full_label () << " ("
1050+ << what.space ().qns ().to_int32 () << " )"
1051+ << " with " << with.full_label () << " \n " ;
10411052 std::replace (product_bras.begin (), product_bras.end (), what, with);
10421053 std::replace (product_kets.begin (), product_kets.end (), what, with);
10431054 };
10441055
1056+ for (const auto & idx : product_bras) {
1057+ std::wcout << idx.full_label () << " , " ;
1058+ }
1059+ std::wcout << std::endl;
1060+ for (const auto & idx : product_kets) {
1061+ std::wcout << idx.full_label () << " , " ;
1062+ }
1063+ std::wcout << std::endl;
1064+
10451065 // Substitute indices from external index list
10461066 ranges::for_each (ext_index_groups, substitute_ext_idx);
10471067
1068+ for (const auto & idx : product_bras) {
1069+ std::wcout << idx.full_label () << " , " ;
1070+ }
1071+ std::wcout << std::endl;
1072+ for (const auto & idx : product_kets) {
1073+ std::wcout << idx.full_label () << " , " ;
1074+ }
1075+ std::wcout << std::endl;
1076+
10481077 auto n_cycles = count_cycles (product_kets, product_bras);
10491078
10501079 auto result = std::make_shared<Product>(product);
0 commit comments