forked from sanshar/Block
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slater.h
165 lines (134 loc) · 3.59 KB
/
slater.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
Developed by Sandeep Sharma and Garnet K.-L. Chan, 2012
Copyright (c) 2012, Garnet K.-L. Chan
This program is integrated in Molpro with the permission of
Sandeep Sharma and Garnet K.-L. Chan
*/
#ifndef SPIN_SLATER_HEADER
#define SPIN_SLATER_HEADER
#include "orbstring.h"
#include <iostream>
#include "global.h"
#include <map>
#include "Symmetry.h"
#include <boost/functional/hash.hpp>
namespace SpinAdapted{
//this is the slater orbital index
inline int SymmetryOfSpinOrb (const int i)
{
return dmrginp.spin_orbs_symmetry()[i];
}
//this is the irrep orbital index
inline IrrepSpace SymmetryOfSpatialOrb(const int i)
{
int symm = dmrginp.spin_orbs_symmetry()[dmrginp.spatial_to_spin()[i]];
if (sym == "dinfh")
symm = abs(symm);
return IrrepSpace(symm);
}
inline IrrepSpace SymmetryOfOrb(const int i)
{
if(dmrginp.spinAdapted()) return SymmetryOfSpatialOrb(i);
int symm = dmrginp.spin_orbs_symmetry()[i];
if (sym == "dinfh")
symm = abs(symm);
return IrrepSpace(symm);
}
inline int SpinOf (const int i)
{
return i%2==0?1:-1;
}
inline int SzOf(const int i)
{
return i%2==0? 1 : -1;
}
inline SpinQuantum getSpinQuantum(const int i)
{
if(dmrginp.spinAdapted())
return SpinQuantum(1, SpinSpace(1), SymmetryOfSpatialOrb(i));
else
return SpinQuantum(1, SpinSpace(SpinOf(i)), IrrepSpace(abs(dmrginp.spin_orbs_symmetry()[i])));
}
void ConvertList (std::vector<int>& a, const std::vector<int>& b);
struct Slater
{
Orbstring alpha;
int n;
int Sz;
public:
Slater (): n(0), Sz(0) {}
Slater (const Orbstring& a);
Slater (const vector<bool>& occ_rep, int sign);
Slater (const Slater& s) : alpha (s.alpha), n (s.n), Sz (s.Sz) {}
void operator= (const Slater& s) { if (this != &s) {alpha = s.alpha; n = s.n; Sz = s.Sz;} }
// accessors
inline int size () const { return alpha.size (); }
inline int n_is () const { return n; }
inline int Sz_is () const { return Sz; }
inline Slater& c (int i)
{
this->alpha.c (i);
++n;
Sz += SzOf (i);
return (*this);
}
boost::shared_ptr<Slater> getLeftSlater(int index);
boost::shared_ptr<Slater> getRightSlater(int index);
inline Slater& d (int i)
{
this->alpha.d (i);
--n;
Sz -= SzOf (i);
return (*this);
}
bool isempty()
{
return alpha.isempty();
}
inline int parity(int i)
{
return alpha.parity(i);
}
inline void setSign(int i)
{
alpha.setSign(i);
}
inline int getSign()
{
return alpha.getSign();
}
inline int trace (const Slater& s)
{
return this->alpha.trace (s.alpha);
}
void connect (const Slater& s, std::vector<int>& cv, std::vector<int>& dv) const;
bool operator< (const Slater& s) const;
bool operator== (const Slater& s) const ;
double hash_value() const;
void outerProd(const Slater& s, Slater& output) const;
friend ostream& operator<< (ostream& os, const Slater& s)
{
os << s.alpha << endl;
return os;
}
};
inline IrrepSpace AbelianSymmetryOf (const Slater& s)
{
if(sym == "dinfh") {perr <<"dinfh is not abelian"<<endl;exit(0);}
IrrepSpace symmetry = IrrepSpace(0), tempsym;
for (int i=0; i<s.alpha.size(); ++i) {
if (s.alpha[i]) {
tempsym = (symmetry + IrrepSpace(SymmetryOfSpinOrb(i)))[0];
symmetry = tempsym;
}
}
return symmetry;
}
extern void Convert (Slater& s);
inline int flipindex(int i)
{
return 0;
}
double det_energy (const Slater& s, int integralIndex);
}
#endif