Bisection.h 2.73 KB
Newer Older
Francois Gygi's avatar
Francois Gygi committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2011 The Regents of the University of California
//
// This file is part of Qbox
//
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
// Bisection.h
//
////////////////////////////////////////////////////////////////////////////////

19
20
#ifndef BISECTION_H
#define BISECTION_H
Francois Gygi's avatar
Francois Gygi committed
21
22
23
24
#include <iostream>
#include <fstream>
#include <iomanip>
#include <complex>
25
#include <vector>
Francois Gygi's avatar
Francois Gygi committed
26
27
28
29
30

#include "Context.h"
#include "SlaterDet.h"
#include "Matrix.h"

31
class FourierTransform;
Francois Gygi's avatar
Francois Gygi committed
32
33
34
35
class Bisection
{
  private:

36
    Context ctxt_;
Francois Gygi's avatar
Francois Gygi committed
37
38
39
40
41

    // bisection levels in each directions
    int nlevels_[3]; // bisection level
    int ndiv_[3];    // number of subdivisions
    int nlevelsmax_; // max level of bisection
42
43
    int nst_;        // number of states in SlaterDet
    int nstloc_;
Francois Gygi's avatar
Francois Gygi committed
44
45
46
47
48
49
50
51

    // real space grid
    int np_[3];            // grid size
    int np01_;             // size of one xy plane
    int np2loc_;           // local z size
    int np012loc_;         // local size
    FourierTransform *ft_;

52
    std::vector<long int> localization_; // localization indices
Francois Gygi's avatar
Francois Gygi committed
53
54

    // xy_proj[ir]: projector in xy plane associated with grid point ir
55
    std::vector<int> xy_proj_;
Francois Gygi's avatar
Francois Gygi committed
56
57

    // matrices of real space wave functions in subdomains
58
    std::vector<DoubleMatrix*> rmat_;
Francois Gygi's avatar
Francois Gygi committed
59
60
61

    // a matrices
    int nmat_;
62
63
    std::vector<DoubleMatrix*> amat_;
    std::vector<std::vector<double> > adiag_;
Francois Gygi's avatar
Francois Gygi committed
64
65
66
    DoubleMatrix *u_;

    // test function
67
68
    bool check_amat(const ComplexMatrix &c);
    void trim_amat(const std::vector<double>& occ);
Francois Gygi's avatar
Francois Gygi committed
69
70
71

  public:

72
73
74
75
76
77
78
79
    Bisection(const SlaterDet& sd, int nlevels[3]);
    void compute_transform(const SlaterDet& sd, int maxsweep, double tol);
    void compute_localization(double epsilon);
    void forward(SlaterDet& sd);
    void forward(DoubleMatrix& u, SlaterDet& sd);
    void backward(SlaterDet& sd);
    void backward(DoubleMatrix& u, SlaterDet& sd);

Francois Gygi's avatar
Francois Gygi committed
80
    int nmat(void) const { return nmat_; }
81
    long int localization(int i) const { return localization_[i]; }
Francois Gygi's avatar
Francois Gygi committed
82
83
84
85
    const std::vector<long int>& localization(void) const
    { return localization_; }
    bool overlap(int i, int j) const;
    bool overlap(const std::vector<long int>& loc, int i, int j) const;
86
    const DoubleMatrix& u(void) const { return *u_; }
Francois Gygi's avatar
Francois Gygi committed
87
88
89
    double pair_fraction(void) const;
    double size(int i) const;
    double total_size(void) const;
Francois Gygi's avatar
Francois Gygi committed
90
91
    ~Bisection();
};
92
#endif