Skip to content

Commit

Permalink
Use new binarization in the example BTAS and TA calculations.
Browse files Browse the repository at this point in the history
  • Loading branch information
bimalgaudel committed Feb 17, 2025
1 parent a08dd9d commit 89c4ace
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/eval/btas/scf_btas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SequantEvalScfBTAS final : public SequantEvalScf {
L"f{i1;a1} * t{a1;i1} + g{i1,i2;a1,a2} * "
L"(1/4 * t{a1,a2;i1,i2} + 1/2 t{a1;i1} * t{a2;i2})";
static auto const node =
eval_node<EvalExprBTAS>(parse_expr(energy_expr, Symmetry::antisymm));
binarize<EvalExprBTAS>(parse_expr(energy_expr, Symmetry::antisymm));

return evaluate(node, data_world_)->template get<double>();
}
Expand Down
4 changes: 1 addition & 3 deletions examples/eval/calc_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
#include <examples/eval/options.hpp>

#include <SeQuant/core/container.hpp>
#include <SeQuant/core/eval_node.hpp>
#include <SeQuant/core/optimize.hpp>
#include <SeQuant/domain/eval/eval.hpp>
#include <SeQuant/domain/mbpt/spin.hpp>

#include <range/v3/view.hpp>

#include <cstddef>
#include <iomanip>

namespace sequant::eval {

Expand Down Expand Up @@ -73,7 +71,7 @@ struct CalcInfo {
using ranges::views::transform;
auto trimmed = opt::tail_factor(expr);
return *trimmed | transform([st = optm_opts.single_term](auto expr) {
return eval_node<ExprT>(st ? optimize(expr) : expr);
return binarize<ExprT>(st ? optimize(expr) : expr);
}) | ranges::to_vector;
}
};
Expand Down
15 changes: 2 additions & 13 deletions examples/eval/ta/scf_ta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SequantEvalScfTA final : public SequantEvalScf {
L"f{i1;a1} * t{a1;i1} + g{i1,i2;a1,a2} * "
L"(1/4 * t{a1,a2;i1,i2} + 1/2 t{a1;i1} * t{a2;i2})";
static auto const node =
eval_node<EvalExprTA>(parse_expr(energy_expr, Symmetry::antisymm));
binarize<EvalExprTA>(parse_expr(energy_expr, Symmetry::antisymm));

return evaluate(node, data_world_)->template get<double>();
}
Expand Down Expand Up @@ -81,21 +81,10 @@ class SequantEvalScfTA final : public SequantEvalScf {
using ranges::views::transform;
using ranges::views::zip;

auto tnsr_to_bk_labels_sorted = [](Tensor const& tnsr) -> std::string {
auto bra_sorted = tnsr.bra() | ranges::to_vector;
auto ket_sorted = tnsr.ket() | ranges::to_vector;
ranges::sort(bra_sorted, Index::LabelCompare{});
ranges::sort(ket_sorted, Index::LabelCompare{});
return concat(bra_sorted, ket_sorted) | transform(&Index::label) |
transform([](auto&& lbl) { return sequant::to_string(lbl); }) |
intersperse(",") | join | ranges::to<std::string>;
};

auto rs = repeat_n(Tensor_t{}, info_.eqn_opts.excit) | ranges::to_vector;

for (auto&& [r, n] : zip(rs, nodes_)) {
auto const target_indices =
tnsr_to_bk_labels_sorted((*n.begin())->as_tensor());
auto const& target_indices = ranges::front(n)->annot();
auto st = info_.eqn_opts.spintrace;
auto cm = info_.optm_opts.reuse_imeds;
if (st && cm) {
Expand Down

0 comments on commit 89c4ace

Please sign in to comment.