LIBINT 2.7.2
comp_11_g12tig12_11.h
1/*
2 * Copyright (C) 2004-2021 Edward F. Valeev
3 *
4 * This file is part of Libint.
5 *
6 * Libint is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Libint is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Libint. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#ifndef _libint2_src_bin_libint_cr11g12tig1211_h_
22#define _libint2_src_bin_libint_cr11g12tig1211_h_
23
24#include <generic_rr.h>
25#include <gaussoper.h>
26
27namespace libint2 {
28
31 template <class BFSet>
32 class CR_11_G12TiG12_11 : public GenericRecurrenceRelation< CR_11_G12TiG12_11<BFSet>,
33 BFSet,
34 GenIntegralSet_11_11<BFSet,G12TiG12,mType> >
35 {
36 public:
42 static const unsigned int max_nchildren = 1;
43
45
47 static bool directional() { return false; }
48
49 private:
50 using ParentType::RecurrenceRelation::expr_;
51 using ParentType::RecurrenceRelation::nflops_;
52 using ParentType::target_;
54
56 CR_11_G12TiG12_11(const SafePtr<TargetType>&, unsigned int dir);
57 static std::string descr() { return "CR"; }
58
59#if LIBINT_ENABLE_GENERIC_CODE
61 bool has_generic(const SafePtr<CompilationParameters>& cparams) const override;
63 std::string generic_header() const override { return "GenericScale.h"; }
65 std::string generic_instance(const SafePtr<CodeContext>& context, const SafePtr<CodeSymbols>& args) const override;
66#endif
67 };
68
69 template <class F>
70 CR_11_G12TiG12_11<F>::CR_11_G12TiG12_11(const SafePtr<TargetType>& Tint,
71 unsigned int dir) :
72 ParentType(Tint,dir)
73 {
74 if (dir != 0)
75 return;
76 using namespace libint2::algebra;
77 using namespace libint2::prefactor;
78 using namespace libint2::braket;
79 // kinetic energy of which electron?
80 //const int i = target_->oper()->descr().K();
81 const R12kG12 G2(2);
82
83 F a(Tint->bra(0,0));
84 F b(Tint->ket(0,0));
85 F c(Tint->bra(1,0));
86 F d(Tint->ket(1,0));
87
88 if (target_->oper()->descr().contracted())
89 return;
90
91 // [G12,[T1,G12]] = [G12,[T2,G12]]
92 {
93 typedef GenIntegralSet_11_11<BasisFunctionType,R12kG12,mType> ChildType;
94 ChildFactory<ThisType,ChildType> factory(this);
95 auto ab_G2_cd = factory.make_child(a,b,c,d,0u,G2);
96 if (is_simple()) {
97 expr_ = Scalar("R12_2_G12_scale_to_G12T1G12") * ab_G2_cd;
98 nflops_ += 1;
99 }
100 }
101
102 }
103
104#if LIBINT_ENABLE_GENERIC_CODE
105 template <class F>
106 bool
107 CR_11_G12TiG12_11<F>::has_generic(const SafePtr<CompilationParameters>& cparams) const
108 {
109 F sh_a(target_->bra(0,0));
110 F sh_b(target_->ket(0,0));
111 F sh_c(target_->bra(1,0));
112 F sh_d(target_->ket(1,0));
113 const unsigned int max_opt_am = cparams->max_am_opt();
114 // to generate optimized code for xxxx integral need to generate specialized code for up to (x+x)0(x+x)0 integrals
115 if (!TrivialBFSet<F>::result &&
116 (sh_a.norm() > max_opt_am ||
117 sh_b.norm() > max_opt_am ||
118 sh_c.norm() > max_opt_am ||
119 sh_d.norm() > max_opt_am
120 )
121 )
122 return true;
123 return false;
124 }
125
126 template <class F>
127 std::string
128 CR_11_G12TiG12_11<F>::generic_instance(const SafePtr<CodeContext>& context, const SafePtr<CodeSymbols>& args) const {
129 std::ostringstream oss;
130
131 const bool vec = (context->cparams()->max_vector_length() != 1);
132 if (vec)
133 oss << "_libint2_static_api_scale_vec_short_(";
134 else
135 oss << "_libint2_static_api_scale_short_(";
136
137 const unsigned int nargs = args->n();
138 for(unsigned int a=0; a<nargs; a++) {
139 oss << args->symbol(a) << ",";
140 }
141
142 oss << target_->size() << "*" << (vec ? "inteval->veclen" : "1")
143 << ",inteval->R12_2_G12_scale_to_G12T1G12" << (vec ? ",inteval->veclen" : "[0]") << ");";
144
145 // HACK alert ... unfortunately it's not completely possible to figure out all "precomputed" symbols from the DAG alone
146 // force R12_2_G12_scale_to_G12T1G12 on the list of symbols
147 {
148 LibraryTaskManager& taskmgr = LibraryTaskManager::Instance();
149 std::list<std::string> forced_symbol;
150 forced_symbol.push_back(std::string("R12_2_G12_scale_to_G12T1G12"));
151 taskmgr.current().symbols()->add(forced_symbol);
152 }
153
154 return oss.str();
155 }
156#endif
157
158};
159
160#endif
Set of basis functions.
Definition: bfset.h:42
Compute relation for 2-e integrals of the G12_Ti_G12 operators.
Definition: comp_11_g12tig12_11.h:35
static bool directional()
This relation is not directional.
Definition: comp_11_g12tig12_11.h:47
Generic integral over a two-body operator with one bfs for each particle in bra and ket.
Definition: integral_11_11.h:33
RRImpl must inherit GenericRecurrenceRelation<RRImpl>
Definition: generic_rr.h:47
bool is_simple() const override
Implementation of RecurrenceRelation::is_simple()
Definition: generic_rr.h:79
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 LibraryTaskManager & Instance()
LibraryTaskManager is a Singleton.
Definition: task.cc:34
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