-
Notifications
You must be signed in to change notification settings - Fork 4
/
lattice_1dchain.cpp
153 lines (110 loc) · 3.33 KB
/
lattice_1dchain.cpp
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
/*
* Copyright (c) 2013, Robert Rueger <[email protected]>
*
* This file is part of hVMC.
*
* hVMC is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* hVMC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with hVMC. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lattice_1dchain.hpp"
#if VERBOSE >= 1
# include <iostream>
#endif
#include <cmath>
using namespace std;
Lattice1DChain::Lattice1DChain( unsigned int L_init )
: Lattice( L_init ) { }
void Lattice1DChain::get_Xnn(
Lattice::spindex l, unsigned int X, std::vector<Lattice::spindex>* outbuf ) const
{
assert( l < 2 * L );
assert( X == 1 || X == 2 || X == 3 );
outbuf->resize( 2 );
// add left neighbor to the list
if ( l < X || ( l >= L && l < L + X ) ) {
( *outbuf )[0] = l + L - X;
} else {
( *outbuf )[0] = l - X;
}
// add right neighbor to the list
if ( ( l < L && l >= L - X ) || l >= 2 * L - X ) {
( *outbuf )[1] = l + X - L;
} else {
( *outbuf )[1] = l + X;
}
}
Lattice::irridxrel Lattice1DChain::reduce_idxrel(
Lattice::spindex i, Lattice::spindex j ) const
{
assert( i < 2 * L );
assert( j < 2 * L );
assert( get_spindex_type( i ) == get_spindex_type( j ) );
const unsigned int d = j > i ? j - i : i - j;
const Lattice::irridxrel result = min( d, L - d );
#if VERBOSE >= 2
cout << "Lattice1DChain::reduce_idxrel() : reduction "
<< "(" << i << "," << j << ") -> " << result << endl;
#endif
assert( get_all_irridxrels().count( result ) == 1 );
return result;
}
set<Lattice::irridxrel> Lattice1DChain::get_all_irridxrels() const
{
set<Lattice::irridxrel> allrels;
for ( unsigned int d = 0; d <= L - d; ++d ) {
assert( d < L );
allrels.insert( d );
}
#if VERBOSE >= 2
cout << "Lattice1DChain::irreducible_idxrel_list() : "
<< "list of irreducible index relations =" << endl;
for ( auto it = allrels.begin(); it != allrels.end(); ++it ) {
cout << *it << endl;
}
#endif
return allrels;
}
Lattice::irridxrel Lattice1DChain::get_maxdist_irridxrel() const
{
return L / 2;
}
Eigen::VectorXd Lattice1DChain::r( Lattice::index i, Lattice::index j ) const
{
assert( i < L );
assert( j < L );
Eigen::VectorXd result = Eigen::VectorXd::Zero( 1 );
result( 0 ) = static_cast<double>( j ) - static_cast<double>( i );
return result;
}
vector<Eigen::VectorXd> Lattice1DChain::get_qvectors() const
{
vector<Eigen::VectorXd> allq;
allq.reserve( L / 2 );
for ( unsigned int i = 1; i <= L / 2; ++i ) {
Eigen::VectorXd q( 1 );
q[0] = i * 2.0 * M_PI / static_cast<double>( L );
allq.push_back( q );
}
return allq;
}
double Lattice1DChain::pairsym_modifier(
optpairsym_t, Lattice::spindex, Lattice::spindex ) const
{
// s- or d-wave symmetry doesn't make a difference in 1D ...
return 1.0;
}
unsigned int Lattice1DChain::get_index_sublattice( Lattice::index i ) const
{
assert( i < L );
return i % 2;
}