21#ifndef _libint2_src_bin_libint_vrr1onep1_h_
22#define _libint2_src_bin_libint_vrr1onep1_h_
25#include <generic_rr.h>
33 template <
class BFSet, FunctionPosition where>
36 GenIntegralSet_1_1<BFSet,OverlapOper,EmptySet> >
44 static const unsigned int max_nchildren = 9;
52 using ParentType::RecurrenceRelation::expr_;
53 using ParentType::RecurrenceRelation::nflops_;
54 using ParentType::target_;
60 static std::string descr() {
return "OSVRROverlap"; }
63 template <
class F, FunctionPosition where>
64 VRR_1_Overlap_1<F,where>::VRR_1_Overlap_1(
const SafePtr< TargetType >& Tint,
68 using namespace libint2::algebra;
69 using namespace libint2::prefactor;
71 const F& _1 = unit<F>(dir);
82 const OriginDerivative<3u> dA = Tint->bra(0,0).deriv();
83 const OriginDerivative<3u> dB = Tint->ket(0,0).deriv();
84 const bool deriv = !dA.zero() ||
87 typedef TargetType ChildType;
88 ChildFactory<ThisType,ChildType> factory(
this);
93 auto a = ( where == InBra ? Tint->bra(0,0) - _1 : Tint->bra(0,0) );
95 auto b = ( where == InKet ? Tint->ket(0,0) - _1 : Tint->ket(0,0) );
98 auto AB = factory.make_child(a,b);
99 if (is_simple()) { expr_ = Vector(where == InBra ?
"PA" :
"PB")[dir] * AB; nflops_+=1; }
101 auto am1 = a - _1;
auto am1_exists =
exists(am1);
102 auto bm1 = b - _1;
auto bm1_exists =
exists(bm1);
105 auto Am1B = factory.make_child(am1,b);
106 if (is_simple()) { expr_ += (Scalar(a[dir]) * Scalar(
"oo2z")) * Am1B; nflops_+=3; }
109 auto ABm1 = factory.make_child(a,bm1);
110 if (is_simple()) { expr_ += (Scalar(b[dir]) * Scalar(
"oo2z")) * ABm1; nflops_+=3; }
118 F a( where == InBra ? Tint->bra(0,0) - _1 : Tint->bra(0,0) );
119 F b( where == InKet ? Tint->ket(0,0) - _1 : Tint->ket(0,0) );
124 for(
unsigned int dxyz=0; dxyz<3; ++dxyz) {
126 if (is_simple() && dxyz != dir)
129 OriginDerivative<3u> _d1; _d1.inc(dxyz);
131 SafePtr<DGVertex> _nullptr;
135 const OriginDerivative<3u> dAm1(dA - _d1);
138 auto AB = factory.make_child(a,b);
140 if (where == InBra) {
141 expr_ -= Vector(dA)[dxyz] * Scalar(
"rho12_over_alpha1") * AB; nflops_ += 3; }
142 if (where == InKet) {
143 expr_ += Vector(dA)[dxyz] * Scalar(
"rho12_over_alpha2") * AB; nflops_ += 3; }
151 const OriginDerivative<3u> dBm1(dB - _d1);
154 auto AB = factory.make_child(a,b);
156 if (where == InBra) {
157 expr_ += Vector(dB)[dxyz] * Scalar(
"rho12_over_alpha1") * AB; nflops_ += 3; }
158 if (where == InKet) {
159 expr_ -= Vector(dB)[dxyz] * Scalar(
"rho12_over_alpha2") * AB; nflops_ += 3; }
174 template <CartesianAxis Axis, FunctionPosition where>
177 GenIntegralSet_1_1<CGF1d<Axis>,OverlapOper,EmptySet> >
185 static const unsigned int max_nchildren = 9;
186 static constexpr auto axis = Axis;
194 using ParentType::RecurrenceRelation::expr_;
195 using ParentType::RecurrenceRelation::nflops_;
196 using ParentType::target_;
202 static std::string descr() {
return std::string(
"OSVRROverlap") +
to_string(axis); }
205 template <CartesianAxis Axis, FunctionPosition where>
206 VRR_1_Overlap_1_1d<Axis,where>::VRR_1_Overlap_1_1d(
const SafePtr< TargetType >& Tint,
212 using namespace libint2::algebra;
213 using namespace libint2::prefactor;
215 typedef CGF1d<Axis> F;
216 const F& _1 = unit<F>(dir);
221 if (a.contracted() ||
227 const OriginDerivative<1u> dA = Tint->bra(0,0).deriv();
228 const OriginDerivative<1u> dB = Tint->ket(0,0).deriv();
229 const bool deriv = !dA.zero() ||
232 typedef TargetType ChildType;
233 ChildFactory<ThisType,ChildType> factory(
this);
238 auto zero = Tint->bra(0,0).zero() and Tint->ket(0,0).zero() and not deriv;
240 SafePtr<DGVertex> int00 = Vector(
"_0_Overlap_0")[Axis];
241 expr_ = Scalar(0u) + int00;
249 auto a = ( where == InBra ? Tint->bra(0,0) - _1 : Tint->bra(0,0) );
251 auto b = ( where == InKet ? Tint->ket(0,0) - _1 : Tint->ket(0,0) );
254 auto AB = factory.make_child(a,b);
255 if (is_simple()) { expr_ = Vector(where == InBra ?
"PA" :
"PB")[Axis] * AB; nflops_+=1; }
257 auto am1 = a - _1;
auto am1_exists =
exists(am1);
258 auto bm1 = b - _1;
auto bm1_exists =
exists(bm1);
261 auto Am1B = factory.make_child(am1,b);
262 if (is_simple()) { expr_ += (Scalar(a.qn()) * Scalar(
"oo2z")) * Am1B; nflops_+=3; }
265 auto ABm1 = factory.make_child(a,bm1);
266 if (is_simple()) { expr_ += (Scalar(b.qn()) * Scalar(
"oo2z")) * ABm1; nflops_+=3; }
274 F a( where == InBra ? Tint->bra(0,0) - _1 : Tint->bra(0,0) );
275 F b( where == InKet ? Tint->ket(0,0) - _1 : Tint->ket(0,0) );
278 OriginDerivative<1u> _d1; _d1.inc(0);
280 SafePtr<DGVertex> _nullptr;
284 const OriginDerivative<1u> dAm1(dA - _d1);
287 auto AB = factory.make_child(a,b);
289 if (where == InBra) {
290 expr_ -= Scalar(dA[0]) * Scalar(
"rho12_over_alpha1") * AB; nflops_ += 3; }
291 if (where == InKet) {
292 expr_ += Scalar(dA[0]) * Scalar(
"rho12_over_alpha2") * AB; nflops_ += 3; }
300 const OriginDerivative<1u> dBm1(dB - _d1);
303 auto AB = factory.make_child(a,b);
305 if (where == InBra) {
306 expr_ += Scalar(dB[0]) * Scalar(
"rho12_over_alpha1") * AB; nflops_ += 3; }
307 if (where == InKet) {
308 expr_ -= Scalar(dB[0]) * Scalar(
"rho12_over_alpha2") * AB; nflops_ += 3; }
324 template <
class BFSet, FunctionPosition where>
327 GenIntegralSet_1_1<BFSet,KineticOper,EmptySet> >
335 static const unsigned int max_nchildren = 9;
343 using ParentType::RecurrenceRelation::expr_;
344 using ParentType::RecurrenceRelation::nflops_;
345 using ParentType::target_;
351 static std::string descr() {
return "OSVRRKinetic"; }
354 template <
class F, FunctionPosition where>
355 VRR_1_Kinetic_1<F,where>::VRR_1_Kinetic_1(
const SafePtr< TargetType >& Tint,
359 using namespace libint2::algebra;
360 using namespace libint2::prefactor;
362 const F& _1 = unit<F>(dir);
367 if (a.contracted() ||
373 const OriginDerivative<3u> dA = Tint->bra(0,0).deriv();
374 const OriginDerivative<3u> dB = Tint->ket(0,0).deriv();
375 const bool deriv = !dA.zero() ||
378 typedef TargetType Child1Type;
379 ChildFactory<ThisType,Child1Type> factory(
this);
380 typedef GenIntegralSet_1_1<F,OverlapOper,EmptySet> Child2Type;
381 ChildFactory<ThisType,Child2Type> overlap_factory(
this);
386 auto a = ( where == InBra ? Tint->bra(0,0) - _1 : Tint->bra(0,0) );
388 auto b = ( where == InKet ? Tint->ket(0,0) - _1 : Tint->ket(0,0) );
391 auto AB = factory.make_child(a,b);
392 if (is_simple()) { expr_ = Vector(where == InBra ?
"PA" :
"PB")[dir] * AB; nflops_+=1; }
396 auto Am1B = factory.make_child(am1,b);
397 auto S_Am1B = (where == InBra) ? overlap_factory.make_child(am1,b) : SafePtr<DGVertex>();
399 if (where == InBra) {
400 expr_ += Scalar(a[dir]) * ( Scalar(
"oo2z") * Am1B -
401 Scalar(
"rho12_over_alpha1") * S_Am1B );
405 expr_ += Scalar(a[dir]) * Scalar(
"oo2z") * Am1B;
412 auto ABm1 = factory.make_child(a,bm1);
413 auto S_ABm1 = (where == InKet) ? overlap_factory.make_child(a,bm1) : SafePtr<DGVertex>();
415 if (where == InKet) {
416 expr_ += Scalar(b[dir]) * ( Scalar(
"oo2z") * ABm1 -
417 Scalar(
"rho12_over_alpha2") * S_ABm1 );
421 expr_ += Scalar(b[dir]) * Scalar(
"oo2z") * ABm1;
428 auto S_AB_target = where == InBra ? overlap_factory.make_child(a + _1,b) : overlap_factory.make_child(a,b + _1);
430 expr_ += Scalar(
"two_rho12") * S_AB_target;
443 F a( where == InBra ? Tint->bra(0,0) - _1 : Tint->bra(0,0) );
444 F b( where == InKet ? Tint->ket(0,0) - _1 : Tint->ket(0,0) );
449 for(
unsigned int dxyz=0; dxyz<3; ++dxyz) {
451 if (is_simple() && dxyz != dir)
454 OriginDerivative<3u> _d1; _d1.inc(dxyz);
456 SafePtr<DGVertex> _nullptr;
460 const OriginDerivative<3u> dAm1(dA - _d1);
463 auto AB = factory.make_child(a,b);
465 if (where == InBra) {
466 expr_ -= Vector(dA)[dxyz] * Scalar(
"rho12_over_alpha1") * AB; nflops_ += 3; }
467 if (where == InKet) {
468 expr_ += Vector(dA)[dxyz] * Scalar(
"rho12_over_alpha2") * AB; nflops_ += 3; }
476 const OriginDerivative<3u> dBm1(dB - _d1);
479 auto AB = factory.make_child(a,b);
481 if (where == InBra) {
482 expr_ += Vector(dB)[dxyz] * Scalar(
"rho12_over_alpha1") * AB; nflops_ += 3; }
483 if (where == InKet) {
484 expr_ -= Vector(dB)[dxyz] * Scalar(
"rho12_over_alpha2") * AB; nflops_ += 3; }
499 template <
class BFSet, FunctionPosition where>
502 GenIntegralSet_1_1<BFSet,ElecPotOper,mType> >
510 static const unsigned int max_nchildren = 9;
518 using ParentType::RecurrenceRelation::expr_;
519 using ParentType::RecurrenceRelation::nflops_;
520 using ParentType::target_;
526 static std::string descr() {
return "OSVRRElecPot"; }
530 std::string generate_label()
const override
532 typedef typename TargetType::AuxIndexType
mType;
533 static SafePtr<mType> aux0(
new mType(0u));
534 std::ostringstream os;
536 << genintegralset_label(target_->bra(),target_->ket(),aux0,target_->oper());
541 template <
class F, FunctionPosition where>
542 VRR_1_ElecPot_1<F,where>::VRR_1_ElecPot_1(
const SafePtr< TargetType >& Tint,
546 using namespace libint2::algebra;
547 using namespace libint2::prefactor;
549 const unsigned int m = Tint->aux()->elem(0);
550 const F& _1 = unit<F>(dir);
555 if (a.contracted() ||
561 const OriginDerivative<3u> dA = Tint->bra(0,0).deriv();
562 const OriginDerivative<3u> dB = Tint->ket(0,0).deriv();
563 const bool deriv = !dA.zero() ||
566 typedef TargetType ChildType;
567 ChildFactory<ThisType,ChildType> factory(
this);
572 auto a = ( where == InBra ? Tint->bra(0,0) - _1 : Tint->bra(0,0) );
574 auto b = ( where == InKet ? Tint->ket(0,0) - _1 : Tint->ket(0,0) );
577 auto AB_m = factory.make_child(a,b,m);
578 auto AB_mp1 = factory.make_child(a,b,m+1);
580 expr_ = Vector(where == InBra ?
"PA" :
"PB")[dir] * AB_m -
581 Vector(
"PC")[dir] * AB_mp1;
587 auto Am1B_m = factory.make_child(am1,b,m);
588 auto Am1B_mp1 = factory.make_child(am1,b,m+1);
589 if (is_simple()) { expr_ += Scalar(a[dir]) * Scalar(
"oo2z") * (Am1B_m - Am1B_mp1); nflops_+=4; }
593 auto ABm1_m = factory.make_child(a,bm1,m);
594 auto ABm1_mp1 = factory.make_child(a,bm1,m+1);
595 if (is_simple()) { expr_ += Scalar(b[dir]) * Scalar(
"oo2z") * (ABm1_m - ABm1_mp1); nflops_+=4; }
603 F a( where == InBra ? Tint->bra(0,0) - _1 : Tint->bra(0,0) );
604 F b( where == InKet ? Tint->ket(0,0) - _1 : Tint->ket(0,0) );
609 for(
unsigned int dxyz=0; dxyz<3; ++dxyz) {
611 if (is_simple() && dxyz != dir)
614 OriginDerivative<3u> _d1; _d1.inc(dxyz);
616 SafePtr<DGVertex> _nullptr;
620 const OriginDerivative<3u> dAm1(dA - _d1);
623 auto AB_m = factory.make_child(a,b,m);
624 auto AB_mp1 = factory.make_child(a,b,m+1);
626 if (where == InBra) {
627 expr_ -= Vector(dA)[dxyz] * (Scalar(
"rho12_over_alpha1") * AB_m + Scalar(
"rho12_over_alpha2") * AB_mp1); nflops_ += 5; }
628 if (where == InKet) {
629 expr_ += Vector(dA)[dxyz] * Scalar(
"rho12_over_alpha2") * (AB_m - AB_mp1); nflops_ += 4; }
637 const OriginDerivative<3u> dBm1(dB - _d1);
640 auto AB_m = factory.make_child(a,b,m);
641 auto AB_mp1 = factory.make_child(a,b,m+1);
643 if (where == InBra) {
644 expr_ += Vector(dB)[dxyz] * Scalar(
"rho12_over_alpha1") * (AB_m - AB_mp1); nflops_ += 4; }
645 if (where == InKet) {
646 expr_ -= Vector(dB)[dxyz] * (Scalar(
"rho12_over_alpha2") * AB_m + Scalar(
"rho12_over_alpha1") * AB_mp1); nflops_ += 5; }
661 template <
class BFSet, FunctionPosition where>
664 GenIntegralSet_1_1<BFSet,SphericalMultipoleOper,EmptySet> >
673 static const unsigned int max_nchildren = 8;
681 using ParentType::RecurrenceRelation::expr_;
682 using ParentType::RecurrenceRelation::nflops_;
683 using ParentType::target_;
685 using typename ParentType::RecurrenceRelation::ExprType;
687 static std::string descr() {
return "OSVRRSMultipole"; }
690 VRR_1_SMultipole_1(
const SafePtr<TargetType>& Tint,
unsigned int dir) :
693 using namespace libint2::algebra;
694 using namespace libint2::prefactor;
696 using Sign = SphericalMultipoleQuanta::Sign;
698 const F& _1 = unit<F>(dir);
703 if (a.contracted() ||
711 const OriginDerivative<3u> dA = Tint->bra(0,0).deriv();
712 const OriginDerivative<3u> dB = Tint->ket(0,0).deriv();
713 const bool deriv = !dA.zero() ||
718 auto O_l_m = Tint->oper()->descr();
719 const auto l = O_l_m.l();
720 const auto m = O_l_m.m();
721 const auto sign = O_l_m.sign();
723 typedef TargetType ChildType;
724 ChildFactory<ThisType,ChildType> factory(
this);
726 auto make_child = [&](
const F& bra,
const F& ket,
const OperType::Descriptor& descr) -> SafePtr<DGVertex> {
727 return factory.make_child(bra, ket,
EmptySet(), descr);
731 if (Tint->bra(0,0).norm() != 0 || Tint->ket(0,0).norm() != 0) {
735 auto a = ( where == InBra ? Tint->bra(0,0) - _1 : Tint->bra(0,0) );
737 auto b = ( where == InKet ? Tint->ket(0,0) - _1 : Tint->ket(0,0) );
744 if (is_simple()) { expr_ = Vector(where == InBra ?
"PA" :
"PB")[dir] * AB; nflops_+=1; }
746 auto am1 = a - _1;
auto am1_exists =
exists(am1);
747 auto bm1 = b - _1;
auto bm1_exists =
exists(bm1);
749 SafePtr<ExprType> subexpr;
753 if (is_simple()) { subexpr += Scalar(a[dir]) * Am1B; nflops_+=1; }
757 if (is_simple()) { subexpr += Scalar(b[dir]) * ABm1; nflops_+=1; }
762 auto O_lm1_mp1 = SphericalMultipole_Descr(l-1, m+1, sign);
764 auto AB_O_lm1_mp1 =
make_child(a, b, O_lm1_mp1);
765 if (is_simple() && dir == 0) {
766 subexpr += Scalar(O_lm1_mp1.phase() > 0 ? 0.5 : -0.5) * AB_O_lm1_mp1;
771 auto O_lm1_mm1 = SphericalMultipole_Descr(l-1, m-1, sign);
773 auto AB_O_lm1_mm1 =
make_child(a, b, O_lm1_mm1);
774 if (is_simple() && dir == 0) {
775 subexpr -= Scalar(O_lm1_mm1.phase() > 0 ? 0.5 : -0.5) * AB_O_lm1_mm1;
782 const auto m_pfac = sign == Sign::plus ? 1 : -1;
783 auto Om_lm1_mp1 = SphericalMultipole_Descr(l-1, m+1,
flip(sign));
785 auto AB_Om_lm1_mp1 =
make_child(a, b, Om_lm1_mp1);
786 if (is_simple() && dir == 1) {
787 subexpr += Scalar(m_pfac * (Om_lm1_mp1.phase() > 0 ? 0.5 : -0.5)) * AB_Om_lm1_mp1;
792 auto Om_lm1_mm1 = SphericalMultipole_Descr(l-1, m-1,
flip(sign));
794 auto AB_Om_lm1_mm1 =
make_child(a, b, Om_lm1_mm1);
795 if (is_simple() && dir == 1) {
796 subexpr += Scalar(m_pfac * (Om_lm1_mm1.phase() > 0 ? 0.5 : -0.5)) * AB_Om_lm1_mm1;
802 auto O_lm1_m = SphericalMultipole_Descr(l-1, m, sign);
805 if (is_simple() && dir == 2) {
806 subexpr += AB_O_lm1_m;
813 expr_ += Scalar(
"oo2z") * subexpr;
818 if (dir != 0)
return;
819 auto a = Tint->bra(0,0);
820 auto b = Tint->ket(0,0);
824 assert(sign == Sign::plus);
827 typedef GenIntegralSet_1_1<BFSet, CartesianMultipoleOper<3u>,
EmptySet>
829 ChildFactory<ThisType, OverlapType> overlap_factory(
this);
830 auto S00 = overlap_factory.make_child(a, b);
832 expr_ = Scalar(1) * S00;
835 SafePtr<ExprType> subexpr;
841 SphericalMultipole_Descr(l - 1, m - 1, Sign::plus);
842 auto AB_Op_lm1_mm1 =
make_child(a, b, Op_lm1_mm1);
844 subexpr = Scalar(sign == Sign::plus ?
"PO_x" :
"PO_y") *
848 SphericalMultipole_Descr(l - 1, m - 1, Sign::minus);
850 auto AB_Om_lm1_mm1 =
make_child(a, b, Om_lm1_mm1);
852 if (sign == Sign::plus)
853 subexpr -= Scalar(
"PO_y") * AB_Om_lm1_mm1;
855 subexpr += Scalar(
"PO_x") * AB_Om_lm1_mm1;
860 expr_ = Scalar(-0.5 / m) * subexpr;
864 SafePtr<ExprType> subexpr;
866 auto O_lm1_m = SphericalMultipole_Descr(l - 1, m, sign);
870 subexpr = Scalar((2 * l - 1)) * Scalar(
"PO_z") * AB_O_lm1_m;
873 auto O_lm2_m = SphericalMultipole_Descr(l - 2, m, sign);
877 subexpr -= Scalar(
"PO2") * AB_O_lm2_m;
882 expr_ = Scalar(1.0 / ((l + m) * (l - m))) * subexpr;
Set of basis functions.
Definition: bfset.h:42
Cartesian components of 3D CGF = 1D CGF.
Definition: bfset.h:440
Generic integral over a one-body operator with one bfs for each particle in bra and ket.
Definition: integral_1_1.h:33
GenOper is a single operator described by descriptor Descr.
Definition: oper.h:162
RRImpl must inherit GenericRecurrenceRelation<RRImpl>
Definition: generic_rr.h:47
const SafePtr< DGVertex > & make_child(const typename RealChildType::BasisFunctionType &A, const typename RealChildType::BasisFunctionType &B, const typename RealChildType::BasisFunctionType &C, const typename RealChildType::BasisFunctionType &D, const typename RealChildType::AuxIndexType &aux=typename RealChildType::AuxIndexType(), const typename RealChildType::OperType &oper=typename RealChildType::OperType())
make_child should really looks something like this, but gcc 4.3.0 craps out TODO test is this works
Definition: generic_rr.h:126
bool is_simple() const override
Implementation of RecurrenceRelation::is_simple()
Definition: generic_rr.h:79
const SafePtr< DGVertex > & add_child(const SafePtr< DGVertex > &child)
add child
Definition: generic_rr.h:108
static SafePtr< RRImpl > Instance(const SafePtr< TargetType > &Tint, unsigned int dir)
Return an instance if applicable, or a null pointer otherwise.
Definition: generic_rr.h:55
static bool default_directional()
is this recurrence relation parameterized by a direction (x, y, or z).
Definition: generic_rr.h:99
VRR Recurrence Relation for 1-e electrostatic potential integrals.
Definition: vrr_1_onep_1.h:503
static bool directional()
Default directionality.
Definition: vrr_1_onep_1.h:515
VRR Recurrence Relation for 1-e kinetic energy integrals.
Definition: vrr_1_onep_1.h:328
static bool directional()
Default directionality.
Definition: vrr_1_onep_1.h:340
VRR Recurrence Relation for 1-d overlap integrals.
Definition: vrr_1_onep_1.h:178
static bool directional()
Default directionality.
Definition: vrr_1_onep_1.h:191
VRR Recurrence Relation for 1-e overlap integrals.
Definition: vrr_1_onep_1.h:37
static bool directional()
Default directionality.
Definition: vrr_1_onep_1.h:49
VRR Recurrence Relation for 1-e spherical multipole moment aka regular solid harmonics integrals.
Definition: vrr_1_onep_1.h:665
static bool directional()
Default directionality.
Definition: vrr_1_onep_1.h:678
these objects help to construct BraketPairs
Definition: src/bin/libint/braket.h:270
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24
bool exists(const IncableBFSet &A)
Return true if A is valid.
Definition: bfset.h:92
DefaultQuantumNumbers< unsignedint, 1 >::Result mType
mType is the type that describes the auxiliary index of standard 2-body repulsion integrals
Definition: quanta.h:408
std::string to_string(const T &x)
Converts x to its string representation.
Definition: entity.h:74
DefaultQuantumNumbers< int, 0 >::Result EmptySet
EmptySet is the type that describes null set of auxiliary indices.
Definition: quanta.h:404
SphericalMultipoleQuanta::Sign flip(const SphericalMultipoleQuanta::Sign &s)
plus <-> minus
Definition: multipole.h:240