CheMPS2
SyBookkeeper.h
1 /*
2  CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry
3  Copyright (C) 2013-2016 Sebastian Wouters
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 #ifndef SYBOOKKEEPER_CHEMPS2_H
21 #define SYBOOKKEEPER_CHEMPS2_H
22 
23 #include "Problem.h"
24 
25 namespace CheMPS2{
34  class SyBookkeeper{
35 
36  public:
37 
39 
41  SyBookkeeper( const Problem * Prob, const int D );
42 
44 
45  SyBookkeeper( const SyBookkeeper & tocopy );
46 
48  virtual ~SyBookkeeper();
49 
51 
52  const Problem * gProb() const;
53 
55 
56  int gL() const;
57 
59 
61  int gIrrep( const int orbital ) const;
62 
64 
65  int gTwoS() const;
66 
68 
69  int gN() const;
70 
72 
73  int gIrrep() const;
74 
76 
77  int getNumberOfIrreps() const;
78 
80 
82  int gNmin( const int boundary ) const;
83 
85 
87  int gNmax( const int boundary ) const;
88 
90 
93  int gTwoSmin( const int boundary, const int N ) const;
94 
96 
99  int gTwoSmax( const int boundary, const int N ) const;
100 
102 
107  int gFCIdim( const int boundary, const int N, const int TwoS, const int irrep ) const;
108 
110 
115  int gCurrentDim( const int boundary, const int N, const int TwoS, const int irrep ) const;
116 
118 
119  bool IsPossible() const;
120 
122 
127  void SetDim( const int boundary, const int N, const int TwoS, const int irrep, const int value );
128 
130 
132  int gMaxDimAtBound( const int boundary ) const;
133 
135 
137  int gTotDimAtBound( const int boundary ) const;
138 
140 
143  void restart( const int start, const int stop, const int virtual_dim );
144 
145  private:
146 
147  // Pointer to the Problem --> constructed and destructed outside of this class
148  const Problem * Prob;
149 
150  // The number of irreps
151  int num_irreps;
152 
153  // Contains the minimum particle number possible at a boundary ( array length = L + 1 )
154  int * Nmin;
155 
156  // Contains the maximum particle number possible at a boundary ( array length = L + 1 )
157  int * Nmax;
158 
159  // Contains twice the minimum spin projection possible at a boundary & particle number ( array dimensions = ( L + 1 ) x ( Nmax[ boundary ] - Nmin[ boundary ] + 1 )
160  int ** TwoSmin;
161 
162  // Contains twice the maximum spin projection possible at a boundary & particle number ( array dimensions = ( L + 1 ) x ( Nmax[ boundary ] - Nmin[ boundary ] + 1 )
163  int ** TwoSmax;
164 
165  // FCI dimensions ( array access: FCIdim[ boundary ][ N - gNmin( boundary ) ][ ( TwoS - gTwoSmin( boundary, N ) ) / 2 ][ irrep ] )
166  int **** FCIdim;
167 
168  // CUR dimensions ( array access: CURdim[ boundary ][ N - gNmin( boundary ) ][ ( TwoS - gTwoSmin( boundary, N ) ) / 2 ][ irrep ] )
169  int **** CURdim;
170 
171  // Allocate the arrays
172  void allocate_arrays();
173 
174  // Construct the FCI dimensions
175  void fillFCIdim();
176  void fill_fci_dim_right( int **** storage, const int start, const int stop );
177  void fill_fci_dim_left( int **** storage, const int start, const int stop );
178 
179  // Get a dimension of FCIdim / CURdim
180  int gDimPrivate( int **** storage, const int boundary, const int N, const int TwoS, const int irrep ) const;
181 
182  // Scale CURdim with virtual_dim from boundary start to boundary stop ( both included )
183  void ScaleCURdim( const int virtual_dim, const int start, const int stop );
184 
185  // Copy dimension arrays
186  void CopyDim( int **** origin, int **** target );
187 
188  };
189 }
190 
191 #endif
int gNmin(const int boundary) const
Get the min. possible particle number for a certain boundary.
int gTotDimAtBound(const int boundary) const
Get the total reduced virtual dimension at a certain boundary.
SyBookkeeper(const Problem *Prob, const int D)
Constructor.
int gFCIdim(const int boundary, const int N, const int TwoS, const int irrep) const
Get the FCI virtual dimensions ( bound by SYBK_dimensionCutoff )
Definition: CASPT2.h:42
int gCurrentDim(const int boundary, const int N, const int TwoS, const int irrep) const
Get the current virtual dimensions.
void restart(const int start, const int stop, const int virtual_dim)
Restart by setting the virtual dimensions from boundary start to boundary stop to FCI virtual dimensi...
int gTwoS() const
Get twice the targeted spin.
virtual ~SyBookkeeper()
Destructor.
const Problem * gProb() const
Get the problem.
int gTwoSmin(const int boundary, const int N) const
Get the minimum possible spin value for a certain boundary and particle number.
int gTwoSmax(const int boundary, const int N) const
Get the maximum possible spin value for a certain boundary and particle number.
int gIrrep() const
Get the targeted irrep.
bool IsPossible() const
Get whether the desired symmetry sector is possible.
int getNumberOfIrreps() const
Get the total number of irreps.
int gL() const
Get the number of orbitals.
int gMaxDimAtBound(const int boundary) const
Get the maximum virtual dimension at a certain boundary.
int gNmax(const int boundary) const
Get the max. possible particle number for a certain boundary.
void SetDim(const int boundary, const int N, const int TwoS, const int irrep, const int value)
Get the current virtual dimensions.
int gN() const
Get the targeted particle number.