MPQC  3.0.0-alpha
inttraits.h
1 //
2 // inttraits.h
3 //
4 // Copyright (C) 2009 Edward Valeev
5 //
6 // Author: Edward Valeev <evaleev@vt.edu>
7 // Maintainer: EV
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 #ifndef _mpqc_src_lib_chemistry_qc_basis_inttraits_h
29 #define _mpqc_src_lib_chemistry_qc_basis_inttraits_h
30 
31 #include <cassert>
32 #include <chemistry/qc/basis/integral.h>
33 #include <chemistry/qc/basis/intparams.h>
34 
35 namespace sc {
36 
37  // auxiliary type functions
38  namespace detail {
39 
40  template <> struct SEvalCreator<2u> {
42  eval(const Ref<Integral>& factory, const Ref<IntParamsVoid>& params) {
43  return factory->overlap();
44  }
45  };
46  };
47 
49  template <int NumCenters, OneBodyOperSet::type Type> struct OneBodyIntTraits {
58  static const int size = TypeMap::size;
60  static Ref<EvalType> eval(const Ref<Integral>& factory,
61  const Ref<ParamsType>& params) {
62  typedef typename detail::OneBodyEvalCreator<NumCenters,Type>::value OneBodyEvalCreator;
63  return OneBodyEvalCreator::eval(factory,params);
64  }
66  static OneBodyOper::type intset(unsigned int t) {
67  MPQC_ASSERT(t < size);
68  return TypeMap::value[t];
69  }
71  static unsigned int intset(OneBodyOper::type t) {
72  for(unsigned int i=0; i<size; ++i)
73  if (TypeMap::value[i] == t)
74  return i;
75  abort(); // should be unreachable if input is valid
76  }
77 
78  };
79 
80  // auxiliary type functions
81  namespace {
82 
83  template <int NumCenters> struct ERIEvalCreator {
84  static Ref< typename TwoBodyIntEvalType<NumCenters>::value >
85  eval(const Ref<Integral>& factory, const Ref<IntParamsVoid>& params) {
86  return factory->coulomb<NumCenters>();
87  }
88  };
89 
90  template <int NumCenters> struct R12EvalCreator {
91  static Ref< typename TwoBodyIntEvalType<NumCenters>::value >
92  eval(const Ref<Integral>& factory, const Ref<IntParamsVoid>& params) {
93  return factory->grt<NumCenters>();
94  }
95  };
96 
97  template <int NumCenters> struct G12EvalCreator {
98  static Ref< typename TwoBodyIntEvalType<NumCenters>::value >
99  eval(const Ref<Integral>& factory, const Ref<IntParamsG12>& params) {
100  return factory->g12<NumCenters>(params);
101  }
102  };
103 
104  template <int NumCenters> struct G12NCEvalCreator {
105  static Ref< typename TwoBodyIntEvalType<NumCenters>::value >
106  eval(const Ref<Integral>& factory, const Ref<IntParamsG12>& params) {
107  return factory->g12nc<NumCenters>(params);
108  }
109  };
110 
111  template <int NumCenters> struct G12DKHEvalCreator {
112  static Ref< typename TwoBodyIntEvalType<NumCenters>::value >
113  eval(const Ref<Integral>& factory, const Ref<IntParamsG12>& params) {
114  return factory->g12dkh<NumCenters>(params);
115  }
116  };
117 
118  template <int NumCenters, TwoBodyOperSet::type Type> struct TwoBodyEvalCreator;
119  template <int NumCenters> struct TwoBodyEvalCreator<NumCenters,TwoBodyOperSet::ERI> {
120  typedef ERIEvalCreator<NumCenters> value;
121  };
122  template <int NumCenters> struct TwoBodyEvalCreator<NumCenters,TwoBodyOperSet::R12> {
123  typedef R12EvalCreator<NumCenters> value;
124  };
125  template <int NumCenters> struct TwoBodyEvalCreator<NumCenters,TwoBodyOperSet::G12> {
126  typedef G12EvalCreator<NumCenters> value;
127  };
128  template <int NumCenters> struct TwoBodyEvalCreator<NumCenters,TwoBodyOperSet::G12NC> {
129  typedef G12NCEvalCreator<NumCenters> value;
130  };
131  template <int NumCenters> struct TwoBodyEvalCreator<NumCenters,TwoBodyOperSet::G12DKH> {
132  typedef G12DKHEvalCreator<NumCenters> value;
133  };
134  };
135 
137  template <int NumCenters, TwoBodyOperSet::type Type> struct TwoBodyIntTraits {
146  static const int size = TypeMap::size;
148  static Ref<EvalType> eval(const Ref<Integral>& factory,
149  const Ref<ParamsType>& params) {
150  typedef typename detail::TwoBodyEvalCreator<NumCenters,Type>::value TwoBodyEvalCreator;
151  return TwoBodyEvalCreator::eval(factory,params);
152  }
154  static TwoBodyOper::type intset(unsigned int t) {
155  MPQC_ASSERT(t < size);
156  return TypeMap::value[t];
157  }
159  static unsigned int intset(TwoBodyOper::type t) {
160  for(unsigned int i=0; i<size; ++i)
161  if (TypeMap::value[i] == t)
162  return i;
163  abort(); // should be unreachable if input is valid
164  }
165 
166  };
167 
168 } // end of namespace sc
169 
170 #endif // end of header guard
171 
172 
173 // Local Variables:
174 // mode: c++
175 // c-file-style: "CLJ-CONDENSED"
176 // End:
sc::OneBodyIntTraits::intset
static OneBodyOper::type intset(unsigned int t)
maps index of the integral type within this set to TwoBodyOper::type
Definition: inttraits.h:66
sc::OneBodyOper::type
type
Types of one-body operators, includes various context-dependent "projectors", such as 1-RDM,...
Definition: operator.h:103
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::OneBodyOperSetProperties
Describes sets of two-body operators (.
Definition: operator.h:195
sc::OneBodyIntTraits::intset
static unsigned int intset(OneBodyOper::type t)
inverse of the above intset
Definition: inttraits.h:71
sc::detail::OneBodyEvalCreator
Definition: integral.h:79
sc::TwoBodyOperSetProperties
Describes sets of two-body operators (.
Definition: operator.h:368
sc::OneBodyIntTraits::eval
static Ref< EvalType > eval(const Ref< Integral > &factory, const Ref< ParamsType > &params)
creates an Eval object
Definition: inttraits.h:60
sc::detail::SEvalCreator
Definition: integral.h:69
sc::OneBodyIntParamsType
which parameter set needed to specify the operator set?
Definition: operator.h:272
sc::TwoBodyIntTraits
Traits of a set of two-body integrals.
Definition: inttraits.h:137
sc::TwoBodyIntTraits::eval
static Ref< EvalType > eval(const Ref< Integral > &factory, const Ref< ParamsType > &params)
creates an Eval object
Definition: inttraits.h:148
sc::OneBodyIntEvalType
returns the type of the evaluator for evaluating this set of two-body integrals
Definition: integral.h:60
sc::OneBodyIntTraits
Traits of a set of one-body integrals.
Definition: inttraits.h:49
sc::OneBodyIntTraits::size
static const int size
number of integral types
Definition: inttraits.h:58
sc::TwoBodyIntEvalType
returns the type of the evaluator for evaluating this set of two-body integrals
Definition: integral.h:83
sc::TwoBodyIntTraits::TypeMap
TwoBodyOperSetProperties< Type > TypeMap
the type of the NBodyInt object that evaluates this set
Definition: inttraits.h:144
sc::TwoBodyIntTraits::intset
static TwoBodyOper::type intset(unsigned int t)
maps index of the integral type within this set to TwoBodyOper::type
Definition: inttraits.h:154
sc::TwoBodyIntTraits::intset
static unsigned int intset(TwoBodyOper::type t)
inverse of the above intset
Definition: inttraits.h:159
sc::detail::TwoBodyEvalCreator
Definition: integral.h:104
sc::TwoBodyIntTraits::size
static const int size
number of integral types
Definition: inttraits.h:146
sc::OneBodyIntTraits::TypeMap
OneBodyOperSetProperties< Type > TypeMap
the type of the NBodyInt object that evaluates this set
Definition: inttraits.h:56
sc::TwoBodyIntParamsType
which parameter set needed to specify the operator set?
Definition: operator.h:438
sc::OneBodyIntTraits::ParamsType
OneBodyIntParamsType< Type >::value ParamsType
the type of IntParams object needed to initialize the evaluator for computing this set of integrals
Definition: inttraits.h:54
sc::TwoBodyOper::type
type
types of known two-body operators
Definition: operator.h:318
sc::TwoBodyIntTraits::ParamsType
TwoBodyIntParamsType< Type >::value ParamsType
the type of IntParams object needed to initialize the evaluator for computing this set of integrals
Definition: inttraits.h:142
sc::TwoBodyIntTraits::EvalType
TwoBodyIntEvalType< NumCenters >::value EvalType
the type of the NBodyInt object that evaluates this set
Definition: inttraits.h:139
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
sc::OneBodyIntTraits::EvalType
OneBodyIntEvalType< NumCenters >::value EvalType
the type of the NBodyInt object that evaluates this set
Definition: inttraits.h:51

Generated at Sun Jan 26 2020 23:23:57 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.