IM-SRG++  0
Operator.hh
1 
2 #ifndef Operator_h
3 #define Operator_h 1
4 
5 #include "ModelSpace.hh"
6 #include "TwoBodyME.hh"
7 #include "ThreeBodyME.hh"
8 #include "IMSRGProfiler.hh"
9 #include <armadillo>
10 #include <string>
11 #include <vector>
12 #include <deque>
13 #include <map>
14 
15 using namespace std;
16 
21 class Operator
22 {
23  public:
24  //Fields
26  double ZeroBody;
27  arma::mat OneBody;
30 
31  int rank_J;
32  int rank_T;
33  int parity;
35 
36  int E2max;
37  int E3max;
38 
39  bool hermitian;
40  bool antihermitian;
41  int nChannels;
42 
43 
44  map<array<int,3>,vector<index_t> > OneBodyChannels;
45  IMSRGProfiler profiler;
46 
47  static double bch_transform_threshold;
48  static double bch_product_threshold;
49  static bool scalar_transform_first_pass;
50  static bool tensor_transform_first_pass;
51  static bool use_brueckner_bch;
52 
53 
54 
55  //Constructors
56  ~Operator();
57  Operator();
59  Operator(ModelSpace&, int Jrank, int Trank, int Parity, int part_rank);
60  Operator( const Operator& rhs);
61  Operator( Operator&&);
62 
63  //Overloaded operators
64  Operator& operator=( const Operator& rhs);
65  Operator& operator+=( const Operator& rhs);
66  Operator operator+( const Operator& rhs) const;
67  Operator& operator+=( const double& rhs);
68  Operator operator+( const double& rhs) const;
69  Operator& operator-=( const Operator& rhs);
70  Operator operator-( const Operator& rhs) const;
71  Operator operator-( ) const;
72  Operator& operator-=( const double& rhs);
73  Operator operator-( const double& rhs) const;
74  Operator& operator*=( const double rhs);
75  Operator operator*( const double rhs) const;
76  Operator& operator/=( const double rhs);
77  Operator operator/( const double rhs) const;
78 
79  Operator& operator=(Operator&& rhs);
80 
81  //Methods
82  Operator& TempOp(size_t n);
83 
84  // One body setter/getters
85  double GetOneBody(int i,int j) {return OneBody(i,j);};
86 // void SetOneBody(int i, int j, double val) { OneBody(i,j) = val;};
87  void SetOneBody(int i, int j, double val) ;
88  int GetTwoBodyDimension(int ch_bra, int ch_ket){ return TwoBody.GetMatrix(ch_bra, ch_ket).n_cols;};
89 // double GetTwoBody(int ch_bra, int ch_ket, int i, int j){ return TwoBody.GetMatrix(ch_bra, ch_ket)(i,j);};
90  double GetTwoBody(int ch_bra, int ch_ket, int i, int j);
91  void SetTwoBody(int J1, int p1, int T1, int J2, int p2, int T2, int i, int j, int k, int l, double v);
92 
93  void SetE3max(int e){E3max = e;};
94  int GetE3max(){return E3max;};
95 
96  // Other setter-getters
97  ModelSpace * GetModelSpace();
98  void SetModelSpace(ModelSpace &ms){modelspace = &ms;};
99 
100  void Erase();
101  void EraseZeroBody(){ZeroBody = 0;};
102  void EraseOneBody();
103  void EraseTwoBody();
104  void EraseThreeBody();
105 
106  void SetHermitian() ;
107  void SetAntiHermitian() ;
108  void SetNonHermitian() ;
109  bool IsHermitian()const {return hermitian;};
110  bool IsAntiHermitian()const {return antihermitian;};
111  bool IsNonHermitian()const {return not (hermitian or antihermitian);};
112  int GetParticleRank()const {return particle_rank;};
113  int GetJRank()const {return rank_J;};
114  int GetTRank()const {return rank_T;};
115  int GetParity()const {return parity;};
116  void SetParticleRank(int pr) {particle_rank = pr;};
117  void ResetTensorTransformFirstPass(){tensor_transform_first_pass=true;};
118 
119  void MakeReduced();
120  void MakeNotReduced();
121 
122  void ScaleZeroBody(double x);
123  void ScaleOneBody(double x);
124  void ScaleTwoBody(double x);
125  void Symmetrize();
126  void AntiSymmetrize();
127  void SetUpOneBodyChannels();
128  size_t Size();
129 
130  void WriteBinary(ofstream& ofs);
131  void ReadBinary(ifstream& ifs);
132 
133 
134  // The actually interesting methods
135  Operator DoNormalOrdering();
136  Operator DoNormalOrdering2();
137  Operator DoNormalOrdering3();
138  Operator UndoNormalOrdering();
139  Operator Truncate(ModelSpace& ms_new);
140 
141  void SetToCommutator(const Operator& X, const Operator& Y);
142  void CommutatorScalarScalar( const Operator& X, const Operator& Y) ;
143  void CommutatorScalarTensor( const Operator& X, const Operator& Y) ;
144  friend Operator Commutator(const Operator& X, const Operator& Y) ;
145 // friend Operator CommutatorScalarScalar( const Operator& X, const Operator& Y) ;
146 // friend Operator CommutatorScalarTensor( const Operator& X, const Operator& Y) ;
147 
148  Operator BCH_Product( Operator& ) ;
149  Operator BCH_Transform( const Operator& ) ;
150  Operator Standard_BCH_Transform( const Operator& ) ;
151  Operator Brueckner_BCH_Transform( const Operator& ) ;
152 
153  void CalculateKineticEnergy();
154  void Eye();
155 
156  double GetMP2_Energy();
157  double GetMP3_Energy();
158  double MP1_Eval(Operator& );
159 
160  void PrintTimes(){profiler.PrintAll();};
161 
162 
163  double Norm() const;
164  double OneBodyNorm() const;
165  double TwoBodyNorm() const;
166 
167 
168  void PrintOneBody() const {OneBody.print();};
169  void PrintTwoBody(int ch) const {TwoBody.PrintMatrix(ch,ch);};
170 
171 
172  static void Set_BCH_Transform_Threshold(double x){bch_transform_threshold=x;};
173  static void Set_BCH_Product_Threshold(double x){bch_product_threshold=x;};
174  static void SetUseBruecknerBCH(bool tf){use_brueckner_bch = tf;};
175 
176  deque<arma::mat> InitializePandya(size_t nch, string orientation);
177 // void DoPandyaTransformation(deque<arma::mat>&, deque<arma::mat>&, string orientation) const ;
178  void DoPandyaTransformation(deque<arma::mat>&, string orientation) const ;
179  void DoPandyaTransformation_SingleChannel(arma::mat& X, int ch_cc, string orientation) const ;
180  void AddInversePandyaTransformation(deque<arma::mat>&);
181  void AddInversePandyaTransformation_SingleChannel(arma::mat& Z, int ch_cc);
182 
183 
184  void comm110ss( const Operator& X, const Operator& Y) ;
185  void comm220ss( const Operator& X, const Operator& Y) ;
186  void comm111ss( const Operator& X, const Operator& Y) ;
187  void comm121ss( const Operator& X, const Operator& Y) ;
188  void comm221ss( const Operator& X, const Operator& Y) ;
189  void comm122ss( const Operator& X, const Operator& Y) ;
190  void comm222_pp_hhss( const Operator& X, const Operator& Y) ;
191  void comm222_phss( const Operator& X, const Operator& Y) ;
192  void comm222_pp_hh_221ss( const Operator& X, const Operator& Y) ;
193 
194 // scalar-tensor commutators
195 
196 // void DoTensorPandyaTransformation(map<array<int,2>,arma::mat>&, map<array<int,2>,arma::mat>&) const;
197  void DoTensorPandyaTransformation(map<array<int,2>,arma::mat>&) const;
198  void DoTensorPandyaTransformation_SingleChannel(arma::mat& X, int ch_bra_cc, int ch_ket_cc) const;
199  void AddInverseTensorPandyaTransformation(map<array<int,2>,arma::mat>&);
200  void AddInverseTensorPandyaTransformation_SingleChannel(arma::mat& Zbar, int ch_bra_cc, int ch_ket_cc);
201 
202  void comm111st( const Operator& X, const Operator& Y) ;
203  void comm121st( const Operator& X, const Operator& Y) ;
204  void comm122st( const Operator& X, const Operator& Y) ;
205  void comm222_pp_hh_221st( const Operator& X, const Operator& Y) ;
206  void comm222_phst( const Operator& X, const Operator& Y) ;
207 
208 };
209 
211 Operator operator*(const double lhs, const Operator& rhs);
212 Operator operator*(const double lhs, const Operator&& rhs);
213 
214 
215 
216 #endif
217 
double ZeroBody
The zero body piece of the operator.
Definition: Operator.hh:26
int nChannels
Number of two-body channels associated with the model space.
Definition: Operator.hh:41
Definition: Operator.hh:21
ThreeBodyME ThreeBody
The three body piece of the operator.
Definition: Operator.hh:29
int E3max
For three-body matrix elements, E3max.
Definition: Operator.hh:37
int parity
Parity of the operator, 0=even 1=odd.
Definition: Operator.hh:33
Definition: ReadWrite.cc:3012
Definition: IMSRGProfiler.hh:17
int rank_J
Spherical tensor rank of the operator.
Definition: Operator.hh:31
int E2max
For two-body matrix elements, E2max.
Definition: Operator.hh:36
arma::mat OneBody
The one body piece of the operator, stored in a single NxN armadillo matrix, where N is the number of...
Definition: Operator.hh:27
int particle_rank
Maximum particle rank. Should be 2 or 3.
Definition: Operator.hh:34
int rank_T
Isotensor rank of the operator.
Definition: Operator.hh:32
Definition: ModelSpace.hh:157
ModelSpace * modelspace
Pointer to the associated modelspace.
Definition: Operator.hh:25
Definition: ThreeBodyME.hh:18
Definition: TwoBodyME.hh:31
TwoBodyME TwoBody
The two body piece of the operator.
Definition: Operator.hh:28