Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: ccache -p && ccache -z && cmake --build . && ccache -s
run: ccache -p && ccache -z && cmake --build . -j 2 && ccache -s

- name: Test
if: ${{ !matrix.valgrind }}
Expand Down
42 changes: 19 additions & 23 deletions SeQuant/domain/mbpt/models/cc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ std::vector<ExprPtr> CC::λ(size_t commutator_rank) {
auto hbar = mbpt::lst(H(), T(N, skip_singles), commutator_rank - 1,
{.unitary = unitary()});

const auto One = ex<Constant>(1);
auto lhbar = simplify((One + Λ(N)) * hbar);
auto lhbar = simplify((1 + Λ(N)) * hbar);

const auto op_connect = concat(default_op_connections(),
OpConnections<OpType>{{OpType::h, OpType::A},
Expand Down Expand Up @@ -139,26 +138,26 @@ std::vector<ExprPtr> CC::λ(size_t commutator_rank) {
return result;
}

std::vector<ExprPtr> CC::t_pt(size_t rank, size_t order,
std::optional<size_t> nbatch) {
std::vector<ExprPtr> CC::(size_t rank, size_t order,
std::optional<size_t> nbatch) {
SEQUANT_ASSERT(order == 1 &&
"sequant::mbpt::CC::t_pt(): only first-order perturbation is "
"sequant::mbpt::CC::(): only first-order perturbation is "
"supported now");
SEQUANT_ASSERT(rank == 1 &&
"sequant::mbpt::CC::t_pt(): only one-body perturbation "
"sequant::mbpt::CC::(): only one-body perturbation "
"operator is supported now");
SEQUANT_ASSERT(ansatz_ == Ansatz::T && "unitary ansatz is not yet supported");

// construct h1_bar
// truncate h1_bar at rank 2 for one-body perturbation
// operator and at rank 4 for two-body perturbation operator
const auto h1_truncate_at = rank == 1 ? 2 : 4;
const auto h1_bar = mbpt::lst(H_pt(rank, {.order = order, .nbatch = nbatch}),
const auto h1_bar = mbpt::lst((rank, {.order = order, .nbatch = nbatch}),
T(N), h1_truncate_at);

// construct [hbar, T(1)]
const auto hbar_pert =
mbpt::lst(H(), T(N), 3) * T_pt(N, {.order = order, .nbatch = nbatch});
mbpt::lst(H(), T(N), 3) * (N, {.order = order, .nbatch = nbatch});

// [Eq. 34, WIREs Comput Mol Sci. 2019; 9:e1406]
const auto expr = simplify(h1_bar + hbar_pert);
Expand All @@ -175,21 +174,21 @@ std::vector<ExprPtr> CC::t_pt(size_t rank, size_t order,

std::vector<ExprPtr> result(N + 1);
for (auto p = N; p >= 1; --p) {
const auto freq_term = ex<Variable>(L"ω") * P(nₚ(p)) *
T_pt_(p, {.order = order, .nbatch = nbatch});
const auto freq_term =
L"ω" * P(nₚ(p)) * op::tʼ(p, {.order = order, .nbatch = nbatch});
result.at(p) =
this->ref_av(P(nₚ(p)) * expr, op_connect) - this->ref_av(freq_term);
}
return result;
}

std::vector<ExprPtr> CC::λ_pt(size_t rank, size_t order,
std::optional<size_t> nbatch) {
std::vector<ExprPtr> CC::λʼ(size_t rank, size_t order,
std::optional<size_t> nbatch) {
SEQUANT_ASSERT(order == 1 &&
"sequant::mbpt::CC::λ_pt(): only first-order perturbation is "
"sequant::mbpt::CC::λʼ(): only first-order perturbation is "
"supported now");
SEQUANT_ASSERT(rank == 1 &&
"sequant::mbpt::CC::λ_pt(): only one-body perturbation "
"sequant::mbpt::CC::λʼ(): only one-body perturbation "
"operator is supported now");
SEQUANT_ASSERT(ansatz_ == Ansatz::T && "unitary ansatz is not yet supported");

Expand All @@ -200,18 +199,16 @@ std::vector<ExprPtr> CC::λ_pt(size_t rank, size_t order,
// truncate h1_bar at rank 2 for one-body perturbation
// operator and at rank 4 for two-body perturbation operator
const auto h1_truncate_at = rank == 1 ? 2 : 4;
const auto h1_bar = mbpt::lst(H_pt(rank, {.order = order, .nbatch = nbatch}),
const auto h1_bar = mbpt::lst((rank, {.order = order, .nbatch = nbatch}),
T(N), h1_truncate_at);

// construct [hbar, T(1)]
const auto hbar_pert =
mbpt::lst(H(), T(N), 3) * T_pt(N, {.order = order, .nbatch = nbatch});
mbpt::lst(H(), T(N), 3) * (N, {.order = order, .nbatch = nbatch});

// [Eq. 35, WIREs Comput Mol Sci. 2019; 9:e1406]
const auto One = ex<Constant>(1);
const auto expr =
simplify((One + Λ(N)) * (h1_bar + hbar_pert) +
Λ_pt(N, {.order = order, .nbatch = nbatch}) * hbar);
const auto expr = simplify((1 + Λ(N)) * (h1_bar + hbar_pert) +
Λʼ(N, {.order = order, .nbatch = nbatch}) * hbar);

// connectivity:
// t and t1 with {h,f,g}
Expand All @@ -235,9 +232,8 @@ std::vector<ExprPtr> CC::λ_pt(size_t rank, size_t order,

std::vector<ExprPtr> result(N + 1);
for (auto p = N; p >= 1; --p) {
const auto freq_term = ex<Variable>(L"ω") *
Λ_pt_(p, {.order = order, .nbatch = nbatch}) *
P(nₚ(-p));
const auto freq_term =
L"ω" * op::λʼ(p, {.order = order, .nbatch = nbatch}) * P(nₚ(-p));
result.at(p) =
this->ref_av(expr * P(nₚ(-p)), op_connect) + this->ref_av(freq_term);
}
Expand Down
4 changes: 2 additions & 2 deletions SeQuant/domain/mbpt/models/cc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CC {
/// @pre `rank==1 && order==1`, only first order perturbation and one-body perturbation operator is supported now
/// @return std::vector of perturbed t amplitude equations
// clang-format on
[[nodiscard]] std::vector<ExprPtr> t_pt(
[[nodiscard]] std::vector<ExprPtr> (
size_t rank = 1, size_t order = 1,
std::optional<size_t> nbatch = std::nullopt);

Expand All @@ -100,7 +100,7 @@ class CC {
/// @pre `rank==1 && order==1`, only first order perturbation and one-body perturbation operator is supported now
/// @return std::vector of perturbed λ amplitude equations
// clang-format on
[[nodiscard]] std::vector<ExprPtr> λ_pt(
[[nodiscard]] std::vector<ExprPtr> λʼ(
size_t rank = 1, size_t order = 1,
std::optional<size_t> nbatch = std::nullopt);

Expand Down
Loading