Skip to content

Commit

Permalink
Manage the Boys number.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathonMisiewicz committed Nov 27, 2023
1 parent 4c5cb33 commit 996585c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
5 changes: 5 additions & 0 deletions include/libint2/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ struct default_operator_traits {
} oper_params_type;
static oper_params_type default_params() { return oper_params_type{}; }
static constexpr auto nopers = 1u;
// N.B.: Below field means we *should* template specialize operator_traits for
// Operator::kinetic, but L2 doesn't use that anywhere.
static constexpr auto intrinsic_nderiv = 0u;
struct _core_eval_type {
template <typename... params>
static std::shared_ptr<const _core_eval_type> instance(params...) {
Expand Down Expand Up @@ -222,6 +225,7 @@ template <>
struct operator_traits<Operator::σpVσp>
: public operator_traits<Operator::nuclear> {
static constexpr auto nopers = 4;
static constexpr auto intrinsic_nderiv = 2;
};

template <>
Expand Down Expand Up @@ -1000,6 +1004,7 @@ class Engine {
//-------
unsigned int nparams() const;
unsigned int nopers() const;
unsigned int intrinsic_nderiv() const;
/// if Params == operator_traits<oper>::oper_params_type, will return
/// \c any(params)
/// else will set return \c any initialized with default value for
Expand Down
27 changes: 23 additions & 4 deletions include/libint2/engine.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,19 @@ __libint2_engine_inline unsigned int Engine::nopers() const {
assert(false && "missing case in switch"); // unreachable
abort();
}
__libint2_engine_inline unsigned int Engine::intrinsic_nderiv() const {
switch (static_cast<int>(oper_)) {
#define BOOST_PP_NBODYENGINE_MCR9(r, data, i, elem) \
case i: \
return operator_traits<static_cast<Operator>(i)>::intrinsic_nderiv;
BOOST_PP_LIST_FOR_EACH_I(BOOST_PP_NBODYENGINE_MCR9, _,
BOOST_PP_NBODY_OPERATOR_LIST)
default:
break;
}
assert(false && "missing case in switch"); // unreachable
abort();
}

template <>
__libint2_engine_inline any Engine::enforce_params_type<any>(
Expand Down Expand Up @@ -828,18 +841,24 @@ __libint2_engine_inline any Engine::enforce_params_type(
return result;
}

/// @param[in] oper the Operator for which to return core-evaluator objects
/// @return a core-integral evaluator and its scratch for @c oper
/// @throw @c oper not registered in BOOST_PP_NBODY_OPERATOR_LIST
/// @throw @c oper has no core_eval_type specialization in operator_traits.
__libint2_engine_inline any Engine::make_core_eval_pack(Operator oper) const {
any result;
switch (static_cast<int>(oper)) {
#define BOOST_PP_NBODYENGINE_MCR6(r, data, i, elem) \
case i: \
result = libint2::detail::make_compressed_pair( \
operator_traits<static_cast<Operator>(i)>::core_eval_type::instance( \
braket_rank() * lmax_ + deriv_order_, \
braket_rank() * lmax_ + deriv_order_ + \
operator_traits<static_cast<Operator>(i)>::intrinsic_nderiv, \
std::numeric_limits<scalar_type>::epsilon()), \
libint2::detail::CoreEvalScratch< \
operator_traits<static_cast<Operator>(i)>::core_eval_type>( \
braket_rank() * lmax_ + deriv_order_)); \
braket_rank() * lmax_ + deriv_order_ + \
operator_traits<static_cast<Operator>(i)>::intrinsic_nderiv)); \
assert(any_cast<detail::core_eval_pack_type<static_cast<Operator>(i)>>( \
&result) != nullptr); \
break;
Expand Down Expand Up @@ -1057,9 +1076,9 @@ __libint2_engine_inline void Engine::compute_primdata(Libint_t& primdata, const
primdata.PC_y[0] * primdata.PC_y[0] +
primdata.PC_z[0] * primdata.PC_z[0];
const scalar_type U = gammap * PC2;
const auto mmax = s1.contr[0].l + s2.contr[0].l + deriv_order_;
const auto mmax = s1.contr[0].l + s2.contr[0].l + deriv_order_ + intrinsic_nderiv();

This comment has been minimized.

Copy link
@evaleev

evaleev Nov 27, 2023

Owner

for consistency rename nderiv -> deriv_order

This comment has been minimized.

Copy link
@JonathonMisiewicz

JonathonMisiewicz Nov 27, 2023

Author Collaborator

Done.

auto* fm_ptr = &(primdata.LIBINT_T_S_ELECPOT_S(0)[0]);
if (oper_ == Operator::nuclear) {
if (oper_ == Operator::nuclear || oper_ == Operator::σpVσp) {
const auto& fm_engine_ptr =
any_cast<const detail::core_eval_pack_type<Operator::nuclear>&>(core_eval_pack_)
.first();
Expand Down

0 comments on commit 996585c

Please sign in to comment.