-
Notifications
You must be signed in to change notification settings - Fork 4
/
pconf.hpp
111 lines (80 loc) · 2.92 KB
/
pconf.hpp
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
/*
* 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/>.
*/
#ifndef PARTICLE_CONFIGURATION_H_INCLUDED
#define PARTICLE_CONFIGURATION_H_INCLUDED
#include <vector>
#include <random>
#include <memory>
#include <boost/optional.hpp>
#define EIGEN_NO_AUTOMATIC_RESIZING
#include <eigen3/Eigen/Core>
#include "macros.h"
#include "lattice.hpp"
enum ParticleOccupation_t {
PARTICLE_OCCUPATION_EMPTY = 0,
PARTICLE_OCCUPATION_FULL = 1
};
struct ParticleHop final {
// id of the hopping particle
const unsigned int beta;
// position of particle beta before the hop
const Lattice::spindex k;
// site that it hops to
const Lattice::spindex l;
// hop possible = site l unoccupied?
const bool possible;
ParticleHop( unsigned int beta_init, Lattice::spindex l_init,
Lattice::spindex k_init, bool possible_init )
: beta( beta_init ), k( k_init ), l( l_init ), possible( possible_init ) { }
};
class ParticleConfiguration final
{
private:
const std::shared_ptr<Lattice> lat;
public:
// BEWARE: particle-hole-transformation!!
// -> spin up particles are spin up electrons
// -> spin down particles are spin down electron holes
// total number of ...
const unsigned int Ne; // ... electrons
const unsigned int Npu; // ... spin up particles
const unsigned int Npd; /// ... spin down particles
const unsigned int Np; // ... particles
Eigen::VectorXi spindex_occ;
std::vector<Lattice::spindex> particlenum_pos;
private:
std::mt19937& rng;
// buffer vectors for nearest-neighbors
// (in order to avoid allocating new ones all the time)
mutable std::vector<Lattice::spindex> k_1nb, k_2nb, k_3nb;
void reconstr_particlenum_pos();
public:
ParticleConfiguration(
const std::shared_ptr<Lattice>& lat_init, unsigned int Ne_init,
std::mt19937& rng_init,
boost::optional<const Eigen::VectorXi&> spindex_occ_init
= boost::optional<const Eigen::VectorXi&>()
);
void distribute_random();
ParticleHop propose_random_hop( unsigned int update_hop_maxdist ) const;
void do_hop( const ParticleHop& hop );
const Eigen::VectorXi& get_spindex_occ() const;
const std::vector<Lattice::spindex>& get_particlenum_pos() const;
};
#endif // PARTICLE_CONFIGURATION_H_INCLUDED