From 89ee10e1fd8efe3228395817637bc7e4bcf5fae1 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Thu, 30 Nov 2023 18:57:46 -0500 Subject: [PATCH] =?UTF-8?q?for=20windows'=20toolchain=20sake=20give=20up?= =?UTF-8?q?=20and=20use=20ascii=20label=20for=20=CF=83pV=CF=83p=20operator?= =?UTF-8?q?=20descriptor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/libint2/engine.h | 6 +- include/libint2/engine.impl.h | 18 +- src/bin/libint/build_libint.cc | 6 +- src/bin/libint/oper.h | 914 ++++++++++++++++++--------------- 4 files changed, 506 insertions(+), 438 deletions(-) diff --git a/include/libint2/engine.h b/include/libint2/engine.h index 5211ad8fb..1ef884f0e 100644 --- a/include/libint2/engine.h +++ b/include/libint2/engine.h @@ -129,7 +129,7 @@ enum class Operator { //! Previous to cdbb9f3 released in v2.8.0, Standard -or- Gaussian ordering could be be specified at generator/compiler configure time. sphemultipole, /// The four components of σp . V . σp, where V is the nuclear potential. - σpVσp, + opVop, /// \f$ \delta(\vec{r}_1 - \vec{r}_2) \f$ delta, /// (2-body) Coulomb operator = \f$ r_{12}^{-1} \f$ @@ -162,7 +162,7 @@ enum class Operator { invalid = -1, // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!keep this updated!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! first_1body_oper = overlap, - last_1body_oper = σpVσp, + last_1body_oper = opVop, first_2body_oper = delta, last_2body_oper = stg_x_coulomb, first_oper = first_1body_oper, @@ -222,7 +222,7 @@ struct operator_traits #endif }; template <> -struct operator_traits +struct operator_traits : public operator_traits { static constexpr auto nopers = 4; static constexpr auto intrinsic_deriv_order = 2; diff --git a/include/libint2/engine.impl.h b/include/libint2/engine.impl.h index 5c8461e1c..02785880e 100644 --- a/include/libint2/engine.impl.h +++ b/include/libint2/engine.impl.h @@ -80,7 +80,7 @@ typename std::remove_all_extents::type* to_ptr1(T (&a)[N]) { (2emultipole, \ (3emultipole, \ (sphemultipole, \ - (σpVσp, \ + (opVop, \ (eri, (eri, (eri, (eri, (eri, (eri, (eri, (eri, (eri, (eri, BOOST_PP_NIL)))))))))))))))))))) #define BOOST_PP_NBODY_OPERATOR_INDEX_TUPLE \ @@ -88,7 +88,7 @@ typename std::remove_all_extents::type* to_ptr1(T (&a)[N]) { #define BOOST_PP_NBODY_OPERATOR_INDEX_LIST \ BOOST_PP_TUPLE_TO_LIST(BOOST_PP_NBODY_OPERATOR_INDEX_TUPLE) #define BOOST_PP_NBODY_OPERATOR_LAST_ONEBODY_INDEX \ - 9 // σpVσp, the 10th member of BOOST_PP_NBODY_OPERATOR_LIST, is the last + 9 // opVop, the 10th member of BOOST_PP_NBODY_OPERATOR_LIST, is the last // 1-body operator // make list of braket indices for n-body ints @@ -180,7 +180,7 @@ __libint2_engine_inline const Engine::target_ptr_vec& Engine::compute1( const auto oper_is_nuclear = (oper_ == Operator::nuclear || oper_ == Operator::erf_nuclear || - oper_ == Operator::erfc_nuclear || oper_ == Operator::σpVσp); + oper_ == Operator::erfc_nuclear || oper_ == Operator::opVop); const auto l1 = s1.contr[0].l; const auto l2 = s2.contr[0].l; @@ -249,7 +249,7 @@ __libint2_engine_inline const Engine::target_ptr_vec& Engine::compute1( const auto compute_directly = lmax == 0 && deriv_order_ == 0 && (oper_ == Operator::overlap || oper_is_nuclear) && - oper_ != Operator::σpVσp; + oper_ != Operator::opVop; if (compute_directly) { primdata_[0].stack[0] = 0; targets_[0] = primdata_[0].stack; @@ -750,7 +750,7 @@ Engine::compute2_ptrs() const { __libint2_engine_inline unsigned int Engine::nparams() const { switch (oper_) { case Operator::nuclear: - case Operator::σpVσp: + case Operator::opVop: return any_cast::oper_params_type&>(params_) .size(); case Operator::erf_nuclear: @@ -929,7 +929,7 @@ __libint2_engine_inline void Engine::compute_primdata(Libint_t& primdata, const const auto oper_is_nuclear = (oper_ == Operator::nuclear || oper_ == Operator::erf_nuclear || - oper_ == Operator::erfc_nuclear || oper_ == Operator::σpVσp); + oper_ == Operator::erfc_nuclear || oper_ == Operator::opVop); // need to use HRR? see strategy.cc const auto l1 = s1.contr[0].l; @@ -1032,7 +1032,7 @@ __libint2_engine_inline void Engine::compute_primdata(Libint_t& primdata, const primdata._0_Overlap_0_y[0] = ovlp_ss_y; primdata._0_Overlap_0_z[0] = ovlp_ss_z; - if (oper_ == Operator::kinetic || (deriv_order_ > 0) || oper_ == Operator::σpVσp) { + if (oper_ == Operator::kinetic || (deriv_order_ > 0) || oper_ == Operator::opVop) { #if LIBINT2_DEFINED(eri, two_alpha0_bra) primdata.two_alpha0_bra[0] = 2.0 * alpha1; #endif @@ -1043,7 +1043,7 @@ __libint2_engine_inline void Engine::compute_primdata(Libint_t& primdata, const if (oper_is_nuclear) { - const auto& params = (oper_ == Operator::nuclear || oper_ == Operator::σpVσp) ? + const auto& params = (oper_ == Operator::nuclear || oper_ == Operator::opVop) ? any_cast::oper_params_type&>(params_) : std::get<1>(any_cast::oper_params_type&>(params_)); @@ -1078,7 +1078,7 @@ __libint2_engine_inline void Engine::compute_primdata(Libint_t& primdata, const const scalar_type U = gammap * PC2; const auto mmax = s1.contr[0].l + s2.contr[0].l + deriv_order_ + intrinsic_deriv_order(); auto* fm_ptr = &(primdata.LIBINT_T_S_ELECPOT_S(0)[0]); - if (oper_ == Operator::nuclear || oper_ == Operator::σpVσp) { + if (oper_ == Operator::nuclear || oper_ == Operator::opVop) { const auto& fm_engine_ptr = any_cast&>(core_eval_pack_) .first(); diff --git a/src/bin/libint/build_libint.cc b/src/bin/libint/build_libint.cc index 176686b33..01fe3f5c4 100644 --- a/src/bin/libint/build_libint.cc +++ b/src/bin/libint/build_libint.cc @@ -395,7 +395,7 @@ build_onebody_1b_1k(std::ostream& os, std::string label, const SafePtr::value ? 3 : 1; for(unsigned int xyz=0; xyz target = Onebody_sh_1_1::Instance(a,b,nullaux,oper); targets.push_back(target); } // loop over operator components - + last_deriv = diter.last(); if (!last_deriv) diter.next(); } while (!last_deriv); // loop over derivatives @@ -518,7 +518,7 @@ void try_main (int argc, char* argv[]) 2emultipole, \ 3emultipole, \ sphemultipole, \ - σpVσp \ + opVop \ ) #define BOOST_PP_ONEBODY_TASK_OPER_TUPLE (OverlapOper, \ KineticOper, \ diff --git a/src/bin/libint/oper.h b/src/bin/libint/oper.h index dfa7a6db8..ee1738417 100644 --- a/src/bin/libint/oper.h +++ b/src/bin/libint/oper.h @@ -21,255 +21,283 @@ #ifndef _libint2_src_bin_libint_oper_h_ #define _libint2_src_bin_libint_oper_h_ -#include - -#include - -#include +#include #include -#include +#include #include -#include -#include #include +#include +#include + +#include +#include namespace libint2 { - /** Permutational symmetries: antisymmetric(anti), symmetric(symm), nonsymmetric (nonsymm), - some more complicated symmetry (nonstd) */ - struct PermutationalSymmetry { - typedef enum {anti=-1, symm=1, nonsymm=0, nonstd=-2} type; - }; - - /** OperatorProperties describes various properties of an operator or operator set - @tparam NP number of particles - @tparam multi true if multiplicative - @tparam psymmetry symmetry with respect to permutation of bra and ket - @tparam origin_dependent true if operator is origin-dependent - */ - template - class OperatorProperties { - public: - static constexpr auto np = NP; - static constexpr auto multiplicative = multi; - static constexpr auto psymm = psymmetry; - static constexpr auto odep = origin_dependent; - }; - - /** OperSet is the base class for all (sets of) operators. - OperSet's must be constructable using - SafePtr or SafePtr. - */ - class OperSet : public ConstructablePolymorphically { - public: - typedef DummyIterator iter_type; - virtual ~OperSet() {}; - - /// Returns full human-readable description of the operator - virtual std::string description() const =0; - /// Returns short label for the operator - virtual std::string label() const =0; - /** Returns 1, 0, or -1, if each operator in the set is symmetric, nonsymmetric, - or antisymmetric with respect to permutation of particles i and j */ - virtual int psymm(int i, int j) const =0; - /** Returns 1, 0, or -1, if each operator in the set is Hermitian, non-Hermitian, - or anti-Hermitian w.r.t. particle p */ - virtual int hermitian(int p) const =0; - - /// is operator origin-dependent? - virtual bool origin_dependent() const =0; - - /// Number of operators in the set - virtual unsigned int num_oper() const =0; - }; - - /** Oper is OperSet characterized by properties Props +/** Permutational symmetries: antisymmetric(anti), symmetric(symm), nonsymmetric + (nonsymm), some more complicated symmetry (nonstd) */ +struct PermutationalSymmetry { + typedef enum { anti = -1, symm = 1, nonsymm = 0, nonstd = -2 } type; +}; + +/** OperatorProperties describes various properties of an operator or operator + set + @tparam NP number of particles + @tparam multi true if multiplicative + @tparam psymmetry symmetry with respect to permutation of bra and ket + @tparam origin_dependent true if operator is origin-dependent */ - template - class Oper : public OperSet { - public: - typedef Props Properties; - virtual ~Oper() {} - - /// Implementation of OperSet::psymm() - int psymm(int i, int j) const override; - /// Implementation of OperSet::hermitian() - int hermitian(int p) const override; - /// Implementation of OperSet::origin_dependent() - bool origin_dependent() const override { return Props::odep; } - - bool operator==(const Oper&) const; - - protected: - /// The only declared constructor is only useable by derived classes - Oper() {} - - private: - /// Must be overloaded by derived classes if Props::psymm == PermutationalSymmetry::nonstd - virtual int nonstd_psymm(int i, int j) const { throw ProgrammingError("nonstd_psymm is not overloaded"); } - /// Must be overloaded by derived classes if Props::multi != true - virtual int nonstd_hermitian(int p) const { throw ProgrammingError("nonstd_hermitian is not overloaded"); } - }; - - template - int - Oper::psymm(int i, int j) const - { - if (i<0 || i>=static_cast(Props::np)) - throw std::runtime_error("Oper::psymm(i,j) -- index i out of bounds"); - if (j<0 || j>=static_cast(Props::np)) - throw std::runtime_error("Oper::psymm(i,j) -- index j out of bounds"); - if (i == j) - return 1; - - switch(Props::psymm) { - case PermutationalSymmetry::anti: - return -1; - case PermutationalSymmetry::symm: - return 1; - case PermutationalSymmetry::nonsymm: - return 0; - case PermutationalSymmetry::nonstd: - return nonstd_psymm(i,j); - default: - abort(); - } - } +template +class OperatorProperties { + public: + static constexpr auto np = NP; + static constexpr auto multiplicative = multi; + static constexpr auto psymm = psymmetry; + static constexpr auto odep = origin_dependent; +}; - template - int - Oper::hermitian(int p) const - { - if (Props::multiplicative) - return +1; - else - return nonstd_hermitian(p); - } +/** OperSet is the base class for all (sets of) operators. + OperSet's must be constructable using + SafePtr or SafePtr. +*/ +class OperSet : public ConstructablePolymorphically { + public: + typedef DummyIterator iter_type; + virtual ~OperSet(){}; + + /// Returns full human-readable description of the operator + virtual std::string description() const = 0; + /// Returns short label for the operator + virtual std::string label() const = 0; + /** Returns 1, 0, or -1, if each operator in the set is symmetric, + nonsymmetric, or antisymmetric with respect to permutation of particles i + and j */ + virtual int psymm(int i, int j) const = 0; + /** Returns 1, 0, or -1, if each operator in the set is Hermitian, + non-Hermitian, or anti-Hermitian w.r.t. particle p */ + virtual int hermitian(int p) const = 0; + + /// is operator origin-dependent? + virtual bool origin_dependent() const = 0; + + /// Number of operators in the set + virtual unsigned int num_oper() const = 0; +}; - template - bool - Oper::operator==(const Oper& a) const - { - return true; - } +/** Oper is OperSet characterized by properties Props + */ +template +class Oper : public OperSet { + public: + typedef Props Properties; + virtual ~Oper() {} + + /// Implementation of OperSet::psymm() + int psymm(int i, int j) const override; + /// Implementation of OperSet::hermitian() + int hermitian(int p) const override; + /// Implementation of OperSet::origin_dependent() + bool origin_dependent() const override { return Props::odep; } + + bool operator==(const Oper&) const; + + protected: + /// The only declared constructor is only useable by derived classes + Oper() {} + + private: + /// Must be overloaded by derived classes if Props::psymm == + /// PermutationalSymmetry::nonstd + virtual int nonstd_psymm(int i, int j) const { + throw ProgrammingError("nonstd_psymm is not overloaded"); + } + /// Must be overloaded by derived classes if Props::multi != true + virtual int nonstd_hermitian(int p) const { + throw ProgrammingError("nonstd_hermitian is not overloaded"); + } +}; -////////////////////////////// +template +int Oper::psymm(int i, int j) const { + if (i < 0 || i >= static_cast(Props::np)) + throw std::runtime_error( + "Oper::psymm(i,j) -- index i out of bounds"); + if (j < 0 || j >= static_cast(Props::np)) + throw std::runtime_error( + "Oper::psymm(i,j) -- index j out of bounds"); + if (i == j) return 1; + + switch (Props::psymm) { + case PermutationalSymmetry::anti: + return -1; + case PermutationalSymmetry::symm: + return 1; + case PermutationalSymmetry::nonsymm: + return 0; + case PermutationalSymmetry::nonstd: + return nonstd_psymm(i, j); + default: + abort(); + } +} - /** GenOper is a single operator described by descriptor Descr - */ - template - class GenOper : public Oper, public Hashable { - public: - typedef Descr Descriptor; - typedef typename Descr::Properties Properties; - typedef Oper parent_type; - /// GenOper is not a set - typedef GenOper iter_type; - - unsigned int num_oper() const override { return 1; } - /// Implementation of Hashable::key() - unsigned int key() const override { return descr_.key(); } - /// Range of key is [0,Descr::max_key) - static const unsigned int max_key = Descr::max_key; - /// Implementation of OperSet::description() - std::string description() const override { return descr_.description(); } - /// Implementation of OperSet::label() - std::string label() const override { return descr_.label(); } - /// Return the descriptor object - Descr& descr() { return descr_; } - /// Return the descriptor object - const Descr& descr() const { return descr_; } - - GenOper(Descr descr = Descr()) : descr_(descr) {} - GenOper(const SafePtr& o) : descr_(o->descr_) {} - GenOper(const SafePtr& o) : descr_(require_dynamic_cast(o)->descr_) {} - GenOper(const SafePtr& o) : descr_(require_dynamic_cast(o)->descr_) {} - explicit GenOper(const ConstructablePolymorphically& o) : descr_(require_dynamic_cast(&o)->descr_) {} - virtual ~GenOper() {} - - private: - Descr descr_; - - /// Implementation of Oper::nonstd_psymm() - int nonstd_psymm(int i, int j) const override { - // TODO: figure out how to call this only if Desc::Properties::psymm == PermutationalSymmetry::nonstd - if (Descr::Properties::psymm == PermutationalSymmetry::nonstd) - return descr_.psymm(i,j); - else throw ProgrammingError("GenOper::nonstd_psymm -- descriptor is not nonstd"); - } - - /// Implementation of Oper::nonstd_hermitian() - int nonstd_hermitian(int i) const override { - // TODO: figure out how to call this only if Desc::Properties::psymm == PermutationalSymmetry::nonstd - if (!Descr::Properties::multiplicative) - return descr_.hermitian(i); - else throw ProgrammingError("GenOper::nonstd_hermitian -- this operator is multiplicative"); - } - - }; +template +int Oper::hermitian(int p) const { + if (Props::multiplicative) + return +1; + else + return nonstd_hermitian(p); +} + +template +bool Oper::operator==(const Oper& a) const { + return true; +} ////////////////////////////// - typedef OperatorProperties<1,false,PermutationalSymmetry::nonsymm> Nonmultiplicative1Body_Props; - typedef OperatorProperties<1,true, PermutationalSymmetry::nonsymm> Multiplicative1Body_Props; - typedef OperatorProperties<1,true, PermutationalSymmetry::nonsymm, true> MultiplicativeODep1Body_Props; - typedef OperatorProperties<2,true, PermutationalSymmetry::symm> MultiplicativeSymm2Body_Props; - typedef OperatorProperties<2,true, PermutationalSymmetry::nonsymm> MultiplicativeNonsymm2Body_Props; - typedef OperatorProperties<2,false,PermutationalSymmetry::symm> NonmultiplicativeSymm2Body_Props; - typedef OperatorProperties<2,false,PermutationalSymmetry::nonsymm> NonmultiplicativeNonsymm2Body_Props; +/** GenOper is a single operator described by descriptor Descr + */ +template +class GenOper : public Oper, + public Hashable { + public: + typedef Descr Descriptor; + typedef typename Descr::Properties Properties; + typedef Oper parent_type; + /// GenOper is not a set + typedef GenOper iter_type; + + unsigned int num_oper() const override { return 1; } + /// Implementation of Hashable::key() + unsigned int key() const override { return descr_.key(); } + /// Range of key is [0,Descr::max_key) + static const unsigned int max_key = Descr::max_key; + /// Implementation of OperSet::description() + std::string description() const override { return descr_.description(); } + /// Implementation of OperSet::label() + std::string label() const override { return descr_.label(); } + /// Return the descriptor object + Descr& descr() { return descr_; } + /// Return the descriptor object + const Descr& descr() const { return descr_; } + + GenOper(Descr descr = Descr()) : descr_(descr) {} + GenOper(const SafePtr& o) : descr_(o->descr_) {} + GenOper(const SafePtr& o) + : descr_(require_dynamic_cast(o)->descr_) {} + GenOper(const SafePtr& o) + : descr_(require_dynamic_cast(o) + ->descr_) {} + explicit GenOper(const ConstructablePolymorphically& o) + : descr_(require_dynamic_cast(&o) + ->descr_) {} + virtual ~GenOper() {} + + private: + Descr descr_; + + /// Implementation of Oper::nonstd_psymm() + int nonstd_psymm(int i, int j) const override { + // TODO: figure out how to call this only if Desc::Properties::psymm == + // PermutationalSymmetry::nonstd + if (Descr::Properties::psymm == PermutationalSymmetry::nonstd) + return descr_.psymm(i, j); + else + throw ProgrammingError( + "GenOper::nonstd_psymm -- descriptor is not nonstd"); + } - /** GenMultSymmOper is a generic multiplicative symmetric N-body operator - */ - template - struct GenMultSymmOper_Descr : public Contractable > { - typedef OperatorProperties Properties; - static const unsigned int max_key = 1; - unsigned int key() const { return 0; } - std::string description() const { return "generic multiplicative symmetric operator"; } - std::string label() const { return "GenMultSymmOper"; } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { abort(); } - }; - typedef GenOper< GenMultSymmOper_Descr<2> > GenMultSymm2BodyOper; - -#define BOOST_PP_DECLARE_HERMITIAN_ONEBODY_DESCRIPTOR(r,propprefix,opname) \ - struct opname ## _Descr : public Contractable { \ - typedef propprefix ## 1Body_Props Properties; \ - static const unsigned int max_key = 1; \ - unsigned int key() const { return 0; } \ - std::string description() const { return #opname; } \ - std::string label() const { return #opname; } \ - int psymm(int i, int j) const { abort(); } \ - int hermitian(int i) const { return +1; } \ - }; \ - typedef GenOper opname ## Oper; \ + /// Implementation of Oper::nonstd_hermitian() + int nonstd_hermitian(int i) const override { + // TODO: figure out how to call this only if Desc::Properties::psymm == + // PermutationalSymmetry::nonstd + if (!Descr::Properties::multiplicative) + return descr_.hermitian(i); + else + throw ProgrammingError( + "GenOper::nonstd_hermitian -- this operator is multiplicative"); + } +}; + +////////////////////////////// + +typedef OperatorProperties<1, false, PermutationalSymmetry::nonsymm> + Nonmultiplicative1Body_Props; +typedef OperatorProperties<1, true, PermutationalSymmetry::nonsymm> + Multiplicative1Body_Props; +typedef OperatorProperties<1, true, PermutationalSymmetry::nonsymm, true> + MultiplicativeODep1Body_Props; +typedef OperatorProperties<2, true, PermutationalSymmetry::symm> + MultiplicativeSymm2Body_Props; +typedef OperatorProperties<2, true, PermutationalSymmetry::nonsymm> + MultiplicativeNonsymm2Body_Props; +typedef OperatorProperties<2, false, PermutationalSymmetry::symm> + NonmultiplicativeSymm2Body_Props; +typedef OperatorProperties<2, false, PermutationalSymmetry::nonsymm> + NonmultiplicativeNonsymm2Body_Props; + +/** GenMultSymmOper is a generic multiplicative symmetric N-body operator + */ +template +struct GenMultSymmOper_Descr : public Contractable> { + typedef OperatorProperties Properties; + static const unsigned int max_key = 1; + unsigned int key() const { return 0; } + std::string description() const { + return "generic multiplicative symmetric operator"; + } + std::string label() const { return "GenMultSymmOper"; } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { abort(); } +}; +typedef GenOper> GenMultSymm2BodyOper; + +#define BOOST_PP_DECLARE_HERMITIAN_ONEBODY_DESCRIPTOR(r, propprefix, opname) \ + struct opname##_Descr : public Contractable { \ + typedef propprefix##1Body_Props Properties; \ + static const unsigned int max_key = 1; \ + unsigned int key() const { return 0; } \ + std::string description() const { return #opname; } \ + std::string label() const { return #opname; } \ + int psymm(int i, int j) const { abort(); } \ + int hermitian(int i) const { return +1; } \ + }; \ + typedef GenOper opname##Oper; #define BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST (Kinetic, BOOST_PP_NIL) -BOOST_PP_LIST_FOR_EACH ( BOOST_PP_DECLARE_HERMITIAN_ONEBODY_DESCRIPTOR, Nonmultiplicative, BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST) +BOOST_PP_LIST_FOR_EACH(BOOST_PP_DECLARE_HERMITIAN_ONEBODY_DESCRIPTOR, + Nonmultiplicative, BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST) #undef BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST #define BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST (Overlap, BOOST_PP_NIL) -BOOST_PP_LIST_FOR_EACH ( BOOST_PP_DECLARE_HERMITIAN_ONEBODY_DESCRIPTOR, Multiplicative, BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST) +BOOST_PP_LIST_FOR_EACH(BOOST_PP_DECLARE_HERMITIAN_ONEBODY_DESCRIPTOR, + Multiplicative, BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST) #undef BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST #define BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST (ElecPot, BOOST_PP_NIL) -BOOST_PP_LIST_FOR_EACH ( BOOST_PP_DECLARE_HERMITIAN_ONEBODY_DESCRIPTOR, MultiplicativeODep, BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST) +BOOST_PP_LIST_FOR_EACH(BOOST_PP_DECLARE_HERMITIAN_ONEBODY_DESCRIPTOR, + MultiplicativeODep, BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST) #undef BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST -// N.B. σpVσp has 4 (Pauli) components, so need to customize its descriptor ... may need to generalize this if need similar operators elsewhere -//#define BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST (σpVσp, BOOST_PP_NIL) -//BOOST_PP_LIST_FOR_EACH ( BOOST_PP_DECLARE_HERMITIAN_ONEBODY_DESCRIPTOR, MultiplicativeODep, BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST) -//#undef BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST +// N.B. σpVσp has 4 (Pauli) components, so need to customize its descriptor ... +// may need to generalize this if need similar operators elsewhere +// #define BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST (σpVσp, BOOST_PP_NIL) +// BOOST_PP_LIST_FOR_EACH ( BOOST_PP_DECLARE_HERMITIAN_ONEBODY_DESCRIPTOR, +// MultiplicativeODep, BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST) #undef +// BOOST_PP_HERMITIAN_ONEBODY_OPER_LIST struct σpVσp_Descr : public Contractable<σpVσp_Descr> { typedef MultiplicativeODep1Body_Props Properties; - σpVσp_Descr() : pauli_index_(0) { } - σpVσp_Descr(int pauli_index) : pauli_index_(pauli_index) { assert(pauli_index <= 3); } + σpVσp_Descr() : pauli_index_(0) {} + σpVσp_Descr(int pauli_index) : pauli_index_(pauli_index) { + assert(pauli_index <= 3); + } static const unsigned int max_key = 4; unsigned int key() const { return pauli_index(); } std::string description() const { - std::string descr("σpVσp["); + std::string descr("opVop["); if (pauli_index() == 0) descr += "0"; else if (pauli_index() == 1) @@ -278,7 +306,8 @@ struct σpVσp_Descr : public Contractable<σpVσp_Descr> { descr += "X"; else if (pauli_index() == 3) descr += "Y"; - else abort(); + else + abort(); return descr + "]"; } std::string label() const { return description(); } @@ -286,28 +315,34 @@ struct σpVσp_Descr : public Contractable<σpVσp_Descr> { int hermitian(int i) const { return +1; } int pauli_index() const { return pauli_index_; } -private: + + private: const int pauli_index_ = -1; }; typedef GenOper<σpVσp_Descr> σpVσpOper; /// cartesian multipole operator in \c NDIM dimensions -/// \f$ \hat{O}(\vec{k}) \equiv \vec{r}^{\cdot \vec{k}} = r_1^{k_1} r_2^{k_2} \cdots \f$ -/// \internal OriginDerivative is used to store cartesian multipole quanta, not the derivative quanta +/// \f$ \hat{O}(\vec{k}) \equiv \vec{r}^{\cdot \vec{k}} = r_1^{k_1} r_2^{k_2} +/// \cdots \f$ \internal OriginDerivative is used to store cartesian +/// multipole quanta, not the derivative quanta template -struct CartesianMultipole_Descr : public Contractable>, - public CartesianMultipoleQuanta { +struct CartesianMultipole_Descr + : public Contractable>, + public CartesianMultipoleQuanta { typedef MultiplicativeODep1Body_Props Properties; using CartesianMultipoleQuanta::max_key; - CartesianMultipole_Descr() { } - CartesianMultipole_Descr(unsigned int k) { assert(NDIM==1u); this->inc(0,k); } + CartesianMultipole_Descr() {} + CartesianMultipole_Descr(unsigned int k) { + assert(NDIM == 1u); + this->inc(0, k); + } std::string description() const { std::string descr("CartesianMultipole["); std::ostringstream oss; - for(unsigned i=0; i!=NDIM; ++i) { + for (unsigned i = 0; i != NDIM; ++i) { oss << (*this)[i]; - if (i+1 != NDIM) oss << ","; + if (i + 1 != NDIM) oss << ","; } return descr + oss.str() + "]"; } @@ -315,26 +350,34 @@ struct CartesianMultipole_Descr : public Contractable using CartesianMultipoleOper = GenOper>; +template +using CartesianMultipoleOper = GenOper>; /** Represents quantum numbers of \em real spherical multipole operator - * defined in Eqs. 5 and 6 of J.M. Pérez-Jordá and W. Yang, J Chem Phys 104, 8003 (1996). - * ( \f$ m \geq 0 \f$ corresponds to moments \f$ \mathcal{N}^+ \f$ , \f$ m < 0 \f$ corresponds to \f$ \mathcal{N}^- \f$ ) + * defined in Eqs. 5 and 6 of J.M. Pérez-Jordá and W. Yang, J Chem Phys 104, + * 8003 (1996). ( \f$ m \geq 0 \f$ corresponds to moments \f$ \mathcal{N}^+ \f$ + * , \f$ m < 0 \f$ corresponds to \f$ \mathcal{N}^- \f$ ) */ -struct SphericalMultipole_Descr : public Contractable, public SphericalMultipoleQuanta { +struct SphericalMultipole_Descr : public Contractable, + public SphericalMultipoleQuanta { typedef MultiplicativeODep1Body_Props Properties; using SphericalMultipoleQuanta::max_key; using SphericalMultipoleQuanta::Sign; /// Default ctor makes a 0th-order multipole - SphericalMultipole_Descr() : SphericalMultipole_Descr(0,0) { } - /// constructs \f$ \mathcal{N}^{+}_{l,m} \f$ if \f$ m \geq 0 \f$, otherwise constructs \f$ \mathcal{N}^{-}_{l,m} \f$ - SphericalMultipole_Descr(int l, int m) : SphericalMultipoleQuanta(l,m) {} - SphericalMultipole_Descr(int l, int m, Sign sign) : SphericalMultipoleQuanta(l,m,sign) {} - SphericalMultipole_Descr(const SphericalMultipoleQuanta& quanta) : SphericalMultipoleQuanta(quanta) {} + SphericalMultipole_Descr() : SphericalMultipole_Descr(0, 0) {} + /// constructs \f$ \mathcal{N}^{+}_{l,m} \f$ if \f$ m \geq 0 \f$, otherwise + /// constructs \f$ \mathcal{N}^{-}_{l,m} \f$ + SphericalMultipole_Descr(int l, int m) : SphericalMultipoleQuanta(l, m) {} + SphericalMultipole_Descr(int l, int m, Sign sign) + : SphericalMultipoleQuanta(l, m, sign) {} + SphericalMultipole_Descr(const SphericalMultipoleQuanta& quanta) + : SphericalMultipoleQuanta(quanta) {} std::string description() const { - std::string descr = std::string("SphericalMultipole[") + std::to_string(this->l()) + "," + std::to_string((this->sign() == Sign::plus ? 1 : -1) * this->m()) + "]"; + std::string descr = + std::string("SphericalMultipole[") + std::to_string(this->l()) + "," + + std::to_string((this->sign() == Sign::plus ? 1 : -1) * this->m()) + "]"; return descr; } std::string label() const { return description(); } @@ -343,193 +386,218 @@ struct SphericalMultipole_Descr : public Contractable, }; using SphericalMultipoleOper = GenOper; - /** TwoPRep is the two-body repulsion operator. - */ - struct TwoPRep_Descr : public Contractable { - typedef MultiplicativeSymm2Body_Props Properties; - static const unsigned int max_key = 1; - unsigned int key() const { return 0; } - std::string description() const { return "1/r_{12}"; } - std::string label() const { return "TwoPRep"; } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { return +1; } - }; - typedef GenOper TwoPRep; - - /** GTG_1d is the two-body 1-dimensional Gaussian geminal - */ - struct GTG_1d_Descr : public Contractable { - typedef MultiplicativeSymm2Body_Props Properties; - static const unsigned int max_key = 1; - unsigned int key() const { return 0; } - std::string description() const { return "GTG_1d"; } - std::string label() const { return "GTG_1d"; } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { return +1; } - }; - typedef GenOper GTG_1d; - - /** R12_k_G12 is a two-body operator of form r_{12}^k * exp(-\gamma * r_{12}), - where k is an integer and \gamma is a positive real number. - */ - class R12_k_G12_Descr : public Contractable { - public: - typedef MultiplicativeSymm2Body_Props Properties; - /// K can range from -1 to 4 - R12_k_G12_Descr(int K) : K_(K) { assert(K >= -1 && K <= 4); } - R12_k_G12_Descr(const R12_k_G12_Descr& a) : Contractable(a), K_(a.K_) {} - static const unsigned int max_key = 5; - unsigned int key() const { return K_ + 1; } - std::string description() const { return label_(K_, this->contracted()); } - std::string label() const { return symbol_(K_, this->contracted()); } - int K() const { return K_; } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { abort(); } - private: - R12_k_G12_Descr(); - static std::string label_(int K, bool contracted); - static std::string symbol_(int K, bool contracted); - int K_; - }; - typedef GenOper R12kG12; - - /** R12k_R12l_G12 is a two-body operator of form ( r_{12x}^kx * r_{12y}^ky * r_{12z}^kz ) * (r_{12x}^lx * r_{12y}^ly * r_{12z}^lz ) * G12 - The following restrictions are imposed: 0 <= kx+ky+kz <= 4, 0 <= lx+ly+lz <= 4 - */ - class R12k_R12l_G12_Descr : public Contractable { - public: - typedef MultiplicativeSymm2Body_Props Properties; - static const int kmax = 4; - R12k_R12l_G12_Descr(const IntVec3& K, const IntVec3& L) : K_(K), L_(L) { } - R12k_R12l_G12_Descr(const R12k_R12l_G12_Descr& a) : Contractable(a), K_(a.K_), L_(a.L_) {} - const IntVec3& K() const { return K_; } - const IntVec3& L() const { return L_; } - static const unsigned int max_key = kmax * kmax * kmax * kmax * kmax * kmax; - unsigned int key() const; - std::string description() const { return label_(K_,L_, this->contracted()); } - std::string label() const { return symbol_(K_,L_, this->contracted()); } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { abort(); } - private: - R12k_R12l_G12_Descr(); - static std::string label_(const IntVec3& K, const IntVec3& L, bool contracted); - static std::string symbol_(const IntVec3& K, const IntVec3& L, bool contracted); - IntVec3 K_; - IntVec3 L_; - }; - typedef GenOper R12kR12lG12; - - /** Ti_G12 is a two-body operator of form [T_i, G12], - where i is particle index (0 or 1) and G12 is a Gaussian Geminal. - */ - class Ti_G12_Descr : public Contractable { - public: - typedef NonmultiplicativeNonsymm2Body_Props Properties; - /// K can range from 0 to 1 - static const unsigned int max_key = 2; - Ti_G12_Descr(int K) : K_(K) { assert(K >= 0 && K <= 1); } - Ti_G12_Descr(const Ti_G12_Descr& a) : Contractable(a), K_(a.K_) {} - unsigned int key() const { return K_; } - std::string description() const { return label_(K_, this->contracted()); } - std::string label() const { return symbol_(K_, this->contracted()); } - int K() const { return K_; } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { if (i != K_) return +1; else return -1; } - private: - Ti_G12_Descr(); - static std::string label_(int K, bool contracted); - static std::string symbol_(int K, bool contracted); - int K_; - }; - typedef GenOper TiG12; - - /** G12_Ti_G12 is a two-body operator of form [G12, [T_i, G12]] = (Nabla_i G12) \dot (Nabla_i G12) - where i is particle index (0 or 1) and G12 is a Gaussian Geminal. - It is a *multiplicative* operator! - */ - class G12_Ti_G12_Descr : public Contractable { - public: - typedef MultiplicativeSymm2Body_Props Properties; - /// K can range from 0 to 1 - static const unsigned int max_key = 2; - G12_Ti_G12_Descr(int K) : K_(K) { assert(K >= 0 && K <= 1); } - G12_Ti_G12_Descr(const G12_Ti_G12_Descr& a) : Contractable(a), K_(a.K_) {} - unsigned int key() const { return K_; } - std::string description() const { return label_(K_, this->contracted()); } - std::string label() const { return symbol_(K_, this->contracted()); } - int K() const { return K_; } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { return +1; } - private: - G12_Ti_G12_Descr(); - static std::string label_(int K, bool contracted); - static std::string symbol_(int K, bool contracted); - int K_; - }; - typedef GenOper G12TiG12; - - /** r_1.r_1 x g12 is a result of differentiation of exp( - a r_1^2 - a r_2^2 - c r_{12}^2) geminal . - */ - struct R1dotR1_G12_Descr : public Contractable { - typedef MultiplicativeNonsymm2Body_Props Properties; - static const unsigned int max_key = 1; - unsigned int key() const { return 0; } - std::string description() const { return "r_1.r_1 x G12"; } - std::string label() const { return "R1dotR1_G12"; } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { abort(); } - }; - typedef GenOper< R1dotR1_G12_Descr > R1dotR1_G12; - - /** r_2.r_2 x g12 is a result of differentiation of exp( - a r_1^2 - a r_2^2 - c r_{12}^2) geminal . - */ - struct R2dotR2_G12_Descr : public Contractable { - typedef MultiplicativeNonsymm2Body_Props Properties; - static const unsigned int max_key = 1; - unsigned int key() const { return 0; } - std::string description() const { return "r_2.r_2 x G12"; } - std::string label() const { return "R2dotR2_G12"; } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { abort(); } - }; - typedef GenOper< R2dotR2_G12_Descr > R2dotR2_G12; - - /** r_1.r_2 x g12 is a result of differentiation of exp( - a r_1^2 - a r_2^2 - c r_{12}^2) geminal . - */ - struct R1dotR2_G12_Descr : public Contractable { - typedef MultiplicativeSymm2Body_Props Properties; - static const unsigned int max_key = 1; - unsigned int key() const { return 0; } - std::string description() const { return "r_1.r_2 x G12"; } - std::string label() const { return "R1dotR2_G12"; } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { abort(); } - }; - typedef GenOper< R1dotR2_G12_Descr > R1dotR2_G12; - - /** \f$ (\nabla_I \cdot g_{12}') (g_{12}' \cdot \nabla_K) \f$ is a component of \f$ [g_{12}, [\nabla_I^4, g_{12}]] \f$ integral - where I = 1 or 2. +/** TwoPRep is the two-body repulsion operator. + */ +struct TwoPRep_Descr : public Contractable { + typedef MultiplicativeSymm2Body_Props Properties; + static const unsigned int max_key = 1; + unsigned int key() const { return 0; } + std::string description() const { return "1/r_{12}"; } + std::string label() const { return "TwoPRep"; } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { return +1; } +}; +typedef GenOper TwoPRep; + +/** GTG_1d is the two-body 1-dimensional Gaussian geminal + */ +struct GTG_1d_Descr : public Contractable { + typedef MultiplicativeSymm2Body_Props Properties; + static const unsigned int max_key = 1; + unsigned int key() const { return 0; } + std::string description() const { return "GTG_1d"; } + std::string label() const { return "GTG_1d"; } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { return +1; } +}; +typedef GenOper GTG_1d; + +/** R12_k_G12 is a two-body operator of form r_{12}^k * exp(-\gamma * r_{12}), + where k is an integer and \gamma is a positive real number. +*/ +class R12_k_G12_Descr : public Contractable { + public: + typedef MultiplicativeSymm2Body_Props Properties; + /// K can range from -1 to 4 + R12_k_G12_Descr(int K) : K_(K) { assert(K >= -1 && K <= 4); } + R12_k_G12_Descr(const R12_k_G12_Descr& a) + : Contractable(a), K_(a.K_) {} + static const unsigned int max_key = 5; + unsigned int key() const { return K_ + 1; } + std::string description() const { return label_(K_, this->contracted()); } + std::string label() const { return symbol_(K_, this->contracted()); } + int K() const { return K_; } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { abort(); } + + private: + R12_k_G12_Descr(); + static std::string label_(int K, bool contracted); + static std::string symbol_(int K, bool contracted); + int K_; +}; +typedef GenOper R12kG12; + +/** R12k_R12l_G12 is a two-body operator of form ( r_{12x}^kx * r_{12y}^ky * + r_{12z}^kz ) * (r_{12x}^lx * r_{12y}^ly * r_{12z}^lz ) * G12 The following + restrictions are imposed: 0 <= kx+ky+kz <= 4, 0 <= lx+ly+lz <= 4 */ - struct DivG12prime_xTx_Descr : public Contractable { - typedef NonmultiplicativeNonsymm2Body_Props Properties; - static const unsigned int max_key = 2; - DivG12prime_xTx_Descr(int I) : I_(I) { assert(I >= 0 && I <= 1); } - DivG12prime_xTx_Descr(const DivG12prime_xTx_Descr& a) : Contractable(a), I_(a.I_) {} - unsigned int key() const { return I_; } - std::string description() const { return label_(I_); } - std::string label() const { return symbol_(I_); } - int I() const { return I_; } - int psymm(int i, int j) const { abort(); } - int hermitian(int i) const { if (i != I_) return +1; else return -1; } - private: - DivG12prime_xTx_Descr(); - static std::string label_(int I); - static std::string symbol_(int I); - int I_; - }; - typedef GenOper< DivG12prime_xTx_Descr > DivG12prime_xTx; +class R12k_R12l_G12_Descr : public Contractable { + public: + typedef MultiplicativeSymm2Body_Props Properties; + static const int kmax = 4; + R12k_R12l_G12_Descr(const IntVec3& K, const IntVec3& L) : K_(K), L_(L) {} + R12k_R12l_G12_Descr(const R12k_R12l_G12_Descr& a) + : Contractable(a), K_(a.K_), L_(a.L_) {} + const IntVec3& K() const { return K_; } + const IntVec3& L() const { return L_; } + static const unsigned int max_key = kmax * kmax * kmax * kmax * kmax * kmax; + unsigned int key() const; + std::string description() const { return label_(K_, L_, this->contracted()); } + std::string label() const { return symbol_(K_, L_, this->contracted()); } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { abort(); } + + private: + R12k_R12l_G12_Descr(); + static std::string label_(const IntVec3& K, const IntVec3& L, + bool contracted); + static std::string symbol_(const IntVec3& K, const IntVec3& L, + bool contracted); + IntVec3 K_; + IntVec3 L_; +}; +typedef GenOper R12kR12lG12; + +/** Ti_G12 is a two-body operator of form [T_i, G12], + where i is particle index (0 or 1) and G12 is a Gaussian Geminal. +*/ +class Ti_G12_Descr : public Contractable { + public: + typedef NonmultiplicativeNonsymm2Body_Props Properties; + /// K can range from 0 to 1 + static const unsigned int max_key = 2; + Ti_G12_Descr(int K) : K_(K) { assert(K >= 0 && K <= 1); } + Ti_G12_Descr(const Ti_G12_Descr& a) + : Contractable(a), K_(a.K_) {} + unsigned int key() const { return K_; } + std::string description() const { return label_(K_, this->contracted()); } + std::string label() const { return symbol_(K_, this->contracted()); } + int K() const { return K_; } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { + if (i != K_) + return +1; + else + return -1; + } + + private: + Ti_G12_Descr(); + static std::string label_(int K, bool contracted); + static std::string symbol_(int K, bool contracted); + int K_; +}; +typedef GenOper TiG12; + +/** G12_Ti_G12 is a two-body operator of form [G12, [T_i, G12]] = (Nabla_i G12) + \dot (Nabla_i G12) where i is particle index (0 or 1) and G12 is a Gaussian + Geminal. It is a *multiplicative* operator! +*/ +class G12_Ti_G12_Descr : public Contractable { + public: + typedef MultiplicativeSymm2Body_Props Properties; + /// K can range from 0 to 1 + static const unsigned int max_key = 2; + G12_Ti_G12_Descr(int K) : K_(K) { assert(K >= 0 && K <= 1); } + G12_Ti_G12_Descr(const G12_Ti_G12_Descr& a) + : Contractable(a), K_(a.K_) {} + unsigned int key() const { return K_; } + std::string description() const { return label_(K_, this->contracted()); } + std::string label() const { return symbol_(K_, this->contracted()); } + int K() const { return K_; } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { return +1; } + private: + G12_Ti_G12_Descr(); + static std::string label_(int K, bool contracted); + static std::string symbol_(int K, bool contracted); + int K_; }; +typedef GenOper G12TiG12; -#endif +/** r_1.r_1 x g12 is a result of differentiation of exp( - a r_1^2 - a r_2^2 - c + * r_{12}^2) geminal . + */ +struct R1dotR1_G12_Descr : public Contractable { + typedef MultiplicativeNonsymm2Body_Props Properties; + static const unsigned int max_key = 1; + unsigned int key() const { return 0; } + std::string description() const { return "r_1.r_1 x G12"; } + std::string label() const { return "R1dotR1_G12"; } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { abort(); } +}; +typedef GenOper R1dotR1_G12; +/** r_2.r_2 x g12 is a result of differentiation of exp( - a r_1^2 - a r_2^2 - c + * r_{12}^2) geminal . + */ +struct R2dotR2_G12_Descr : public Contractable { + typedef MultiplicativeNonsymm2Body_Props Properties; + static const unsigned int max_key = 1; + unsigned int key() const { return 0; } + std::string description() const { return "r_2.r_2 x G12"; } + std::string label() const { return "R2dotR2_G12"; } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { abort(); } +}; +typedef GenOper R2dotR2_G12; + +/** r_1.r_2 x g12 is a result of differentiation of exp( - a r_1^2 - a r_2^2 - c + * r_{12}^2) geminal . + */ +struct R1dotR2_G12_Descr : public Contractable { + typedef MultiplicativeSymm2Body_Props Properties; + static const unsigned int max_key = 1; + unsigned int key() const { return 0; } + std::string description() const { return "r_1.r_2 x G12"; } + std::string label() const { return "R1dotR2_G12"; } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { abort(); } +}; +typedef GenOper R1dotR2_G12; + +/** \f$ (\nabla_I \cdot g_{12}') (g_{12}' \cdot \nabla_K) \f$ is a component of + \f$ [g_{12}, [\nabla_I^4, g_{12}]] \f$ integral where I = 1 or 2. +*/ +struct DivG12prime_xTx_Descr : public Contractable { + typedef NonmultiplicativeNonsymm2Body_Props Properties; + static const unsigned int max_key = 2; + DivG12prime_xTx_Descr(int I) : I_(I) { assert(I >= 0 && I <= 1); } + DivG12prime_xTx_Descr(const DivG12prime_xTx_Descr& a) + : Contractable(a), I_(a.I_) {} + unsigned int key() const { return I_; } + std::string description() const { return label_(I_); } + std::string label() const { return symbol_(I_); } + int I() const { return I_; } + int psymm(int i, int j) const { abort(); } + int hermitian(int i) const { + if (i != I_) + return +1; + else + return -1; + } + + private: + DivG12prime_xTx_Descr(); + static std::string label_(int I); + static std::string symbol_(int I); + int I_; +}; +typedef GenOper DivG12prime_xTx; + +}; // namespace libint2 + +#endif