v2DM-DOCI  1.0
TPM.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Copyright (C) 2014-2015 Ward Poelmans
5  *
6  * This file is part of v2DM-DOCI.
7  *
8  * v2DM-DOCI is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Foobar is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * @END LICENSE
22  */
23 
24 #ifndef TPM_H
25 #define TPM_H
26 
27 #include <iostream>
28 #include <memory>
29 #include <string>
30 #include <functional>
31 #include <hdf5.h>
32 
33 #include "Container.h"
34 #include "helpers.h"
35 
36 namespace doci2DM
37 {
38 
39 class SUP;
40 class Lineq;
41 class PHM;
42 
43 class TPM: public Container
44 {
45  friend std::ostream &operator<<(std::ostream &output,doci2DM::TPM &tpm);
46 
47  public:
48 
49  TPM(int L, int N);
50 
51  TPM(const TPM &) = default;
52 
53  TPM(TPM &&) = default;
54 
55  virtual ~TPM() = default;
56 
57  TPM& operator=(const TPM &) = default;
58 
59  TPM& operator=(TPM &&) = default;
60 
61  using Container::operator=;
62 
63  using Container::operator();
64 
65  double operator()(int a, int b, int c, int d) const;
66 
67  int gN() const;
68 
69  int gL() const;
70 
71  int gn() const;
72 
73  void HF_molecule(std::string filename);
74 
75  void ham(std::function<double(int,int)> &T, std::function<double(int,int,int,int)> &V);
76 
77  void WriteToFile(hid_t &group_id) const;
78 
79  void WriteToFile(std::string filename) const;
80 
81  void ReadFromFile(std::string filename);
82 
83  void ReadFromFile(hid_t &group_id);
84 
85  double S_2() const;
86 
87  void unit();
88 
89  void init(const Lineq &);
90 
91  void Proj_Tr();
92 
93  void collaps(const SUP &, const Lineq &);
94 
95  void constr_grad(double t,const SUP &, const TPM &, const Lineq &);
96 
97  void Q(const TPM &);
98 
99  void Q(double a, double b, double c, const TPM &, bool=false);
100 
101  int solve(double t, const SUP &, TPM &, const Lineq &);
102 
103  void H(double t,const TPM &, const SUP &, const Lineq &);
104 
105  double line_search(double t, SUP &, const TPM &) const;
106 
107  double line_search(double t, const TPM &, const TPM &) const;
108 
109  void ReadFromFileFull(std::string filename);
110 
111  void Proj_E(const Lineq &, int option=0);
112 
113  std::vector<TPM> DOCI_constrains() const;
114 
115  std::vector<TPM> singlet_constrains() const;
116 
117  void S(const TPM &);
118 
119  int InverseS(TPM &, const Lineq &);
120 
121  double getDiag(int, int) const;
122 
123  void G(const PHM &);
124 
125  void pairing(double);
126 
127  void rotate_doci(int, int, double);
128 
129  double calc_rotate_doci(const TPM &, int, int, double) const;
130 
131  double calc_rotate_slow_doci(const TPM &, int, int, double) const;
132 
133  std::pair<double,bool> find_min_angle_doci(const TPM &, int, int, double=0) const;
134 
135  double calc_rotate(int k, int l, double theta, std::function<double(int,int)> &T, std::function<double(int,int,int,int)> &V) const;
136 
137  double calc_rotate_slow(int k, int l, double theta, std::function<double(int,int)> &T, std::function<double(int,int,int,int)> &V) const;
138 
139  std::pair<double,bool> find_min_angle(int k, int l, double start_angle, std::function<double(int,int)> &T, std::function<double(int,int,int,int)> &V) const;
140 
141  void rotate(int, int, double, std::function<double(int,int)> &, std::function<double(int,int,int,int)> &);
142 
143  void WriteFullToFile(std::string filename) const;
144 
145  void WriteFullToFile(hid_t& group) const;
146 
147  static TPM CreateFromFile(std::string filename);
148 
149  private:
150 
151  void constr_lists(int L);
152 
154  int N;
155 
157  int L;
158 
160  int n;
161 
163  static std::unique_ptr<helpers::tmatrix<unsigned int>> s2t;
164 
166  static std::unique_ptr<helpers::tmatrix<unsigned int>> t2s;
167 };
168 
169 }
170 
171 #endif
172 
173 /* vim: set ts=3 sw=3 expandtab :*/
void ReadFromFile(std::string filename)
Definition: TPM.cpp:442
int gN() const
Definition: TPM.cpp:110
TPM(int L, int N)
Definition: TPM.cpp:46
double calc_rotate_slow_doci(const TPM &, int, int, double) const
Definition: TPM.cpp:1265
static TPM CreateFromFile(std::string filename)
Definition: TPM.cpp:1825
void G(const PHM &)
Definition: TPM.cpp:1030
void ReadFromFileFull(std::string filename)
Definition: TPM.cpp:817
double line_search(double t, SUP &, const TPM &) const
Definition: TPM.cpp:767
int n
dimension of the full TPM
Definition: TPM.h:160
std::pair< double, bool > find_min_angle_doci(const TPM &, int, int, double=0) const
Definition: TPM.cpp:1317
void ham(std::function< double(int, int)> &T, std::function< double(int, int, int, int)> &V)
Definition: TPM.cpp:183
void HF_molecule(std::string filename)
Definition: TPM.cpp:243
void WriteFullToFile(std::string filename) const
Definition: TPM.cpp:1741
double calc_rotate_doci(const TPM &, int, int, double) const
Definition: TPM.cpp:1223
double calc_rotate_slow(int k, int l, double theta, std::function< double(int, int)> &T, std::function< double(int, int, int, int)> &V) const
Definition: TPM.cpp:1383
double S_2() const
Definition: TPM.cpp:497
void Proj_Tr()
Definition: TPM.cpp:546
int InverseS(TPM &, const Lineq &)
Definition: TPM.cpp:981
double operator()(int a, int b, int c, int d) const
Definition: TPM.cpp:134
void rotate(int, int, double, std::function< double(int, int)> &, std::function< double(int, int, int, int)> &)
Definition: TPM.cpp:1684
void constr_grad(double t, const SUP &, const TPM &, const Lineq &)
Definition: TPM.cpp:595
void H(double t, const TPM &, const SUP &, const Lineq &)
Definition: TPM.cpp:725
void pairing(double)
Definition: TPM.cpp:1087
void Q(const TPM &)
Definition: TPM.cpp:610
friend std::ostream & operator<<(std::ostream &output, doci2DM::TPM &tpm)
Definition: TPM.cpp:159
double calc_rotate(int k, int l, double theta, std::function< double(int, int)> &T, std::function< double(int, int, int, int)> &V) const
Definition: TPM.cpp:1431
std::pair< double, bool > find_min_angle(int k, int l, double start_angle, std::function< double(int, int)> &T, std::function< double(int, int, int, int)> &V) const
Definition: TPM.cpp:1577
TPM & operator=(const TPM &)=default
void rotate_doci(int, int, double)
Definition: TPM.cpp:1163
void init(const Lineq &)
Definition: TPM.cpp:538
virtual ~TPM()=default
void constr_lists(int L)
Definition: TPM.cpp:61
void Proj_E(const Lineq &, int option=0)
Definition: TPM.cpp:852
double getDiag(int, int) const
Definition: TPM.cpp:905
void unit()
Definition: TPM.cpp:523
int L
the size of the sp DOCI space (there are 2*L sp states)
Definition: TPM.h:157
int N
number of particles
Definition: TPM.h:154
void WriteToFile(hid_t &group_id) const
Definition: TPM.cpp:304
static std::unique_ptr< helpers::tmatrix< unsigned int > > t2s
table translating two particles indices to single particle indices
Definition: TPM.h:166
void S(const TPM &)
Definition: TPM.cpp:922
static std::unique_ptr< helpers::tmatrix< unsigned int > > s2t
table translating single particles indices to two particle indices
Definition: TPM.h:163
int gL() const
Definition: TPM.cpp:115
std::vector< TPM > DOCI_constrains() const
Definition: TPM.cpp:872
std::vector< TPM > singlet_constrains() const
void collaps(const SUP &, const Lineq &)
Definition: TPM.cpp:568
int solve(double t, const SUP &, TPM &, const Lineq &)
Definition: TPM.cpp:666
int gn() const
Definition: TPM.cpp:120