CheMPS2
DMRGSCFindices.cpp
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 #include <stdlib.h>
21 #include <assert.h>
22 #include <iostream>
23 #include <algorithm>
24 
25 #include "DMRGSCFindices.h"
26 
27 using std::cout;
28 using std::endl;
29 using std::max;
30 
31 CheMPS2::DMRGSCFindices::DMRGSCFindices(const int L, const int Group, int * NOCCin, int * NDMRGin, int * NVIRTin){
32 
33  this->L = L;
34  SymmInfo.setGroup(Group);
35  this->Nirreps = SymmInfo.getNumberOfIrreps();
36 
37  NORB = new int[Nirreps];
38  NOCC = new int[Nirreps];
39  NDMRG = new int[Nirreps];
40  NVIRT = new int[Nirreps];
41  NORBcumulative = new int[Nirreps+1];
42  NDMRGcumulative = new int[Nirreps+1];
43 
44  int totalNumOrbs = 0;
45  NORBcumulative[0] = 0;
46  NDMRGcumulative[0] = 0;
47  for (int irrep=0; irrep<Nirreps; irrep++){
48 
49  assert( NOCCin [irrep]>=0 );
50  assert( NDMRGin[irrep]>=0 );
51  assert( NVIRTin[irrep]>=0 );
52 
53  NORB[ irrep] = NOCCin[ irrep] + NDMRGin[irrep] + NVIRTin[irrep];
54  NOCC[ irrep] = NOCCin[ irrep];
55  NDMRG[irrep] = NDMRGin[irrep];
56  NVIRT[irrep] = NVIRTin[irrep];
57 
58  totalNumOrbs += NORB[irrep];
59 
60  NORBcumulative[ irrep+1] = NORBcumulative[ irrep] + NORB[irrep];
61  NDMRGcumulative[irrep+1] = NDMRGcumulative[irrep] + NDMRG[irrep];
62 
63  }
64  assert( totalNumOrbs==L );
65 
66  irrepOfEachDMRGorbital = new int[NDMRGcumulative[Nirreps]];
67  irrepOfEachOrbital = new int[L];
68  for (int irrep=0; irrep<Nirreps; irrep++){
69  for (int cnt=0; cnt<NDMRG[irrep]; cnt++){
70  irrepOfEachDMRGorbital[ NDMRGcumulative[irrep] + cnt ] = irrep;
71  }
72  for (int cnt=0; cnt<NORB[irrep]; cnt++){
73  irrepOfEachOrbital[ NORBcumulative[irrep] + cnt ] = irrep;
74  }
75  }
76 
77 }
78 
80 
81  delete [] NORB;
82  delete [] NOCC;
83  delete [] NDMRG;
84  delete [] NVIRT;
85  delete [] NORBcumulative;
86  delete [] NDMRGcumulative;
87  delete [] irrepOfEachDMRGorbital;
88  delete [] irrepOfEachOrbital;
89 
90 }
91 
92 int CheMPS2::DMRGSCFindices::getL() const{ return L; }
93 
95 
96 int CheMPS2::DMRGSCFindices::getNirreps() const{ return Nirreps; }
97 
98 int CheMPS2::DMRGSCFindices::getNORB(const int irrep) const{ return NORB[irrep]; }
99 
100 int CheMPS2::DMRGSCFindices::getNOCC(const int irrep) const{ return NOCC[irrep]; }
101 
102 int CheMPS2::DMRGSCFindices::getNDMRG(const int irrep) const{ return NDMRG[irrep]; }
103 
104 int CheMPS2::DMRGSCFindices::getNVIRT(const int irrep) const{ return NVIRT[irrep]; }
105 
106 int CheMPS2::DMRGSCFindices::getDMRGcumulative(const int irrep) const{ return NDMRGcumulative[irrep]; }
107 
108 int CheMPS2::DMRGSCFindices::getOrigNOCCstart(const int irrep) const{ return NORBcumulative[irrep]; }
109 
110 int CheMPS2::DMRGSCFindices::getOrigNDMRGstart(const int irrep) const{ return NORBcumulative[irrep] + NOCC[irrep]; }
111 
112 int CheMPS2::DMRGSCFindices::getOrigNVIRTstart(const int irrep) const{ return NORBcumulative[irrep+1] - NVIRT[irrep]; }
113 
114 int * CheMPS2::DMRGSCFindices::getIrrepOfEachDMRGorbital(){ return irrepOfEachDMRGorbital; }
115 
116 int CheMPS2::DMRGSCFindices::getOrbitalIrrep(const int index) const{ return irrepOfEachOrbital[index]; }
117 
119 
120  int total = 0;
121  for ( int irrep = 0; irrep < getNirreps(); irrep++ ){ total += getNOCC( irrep ); }
122  return total;
123 
124 }
125 
127 
128  int the_max = 0;
129  for ( int irrep = 0; irrep < getNirreps(); irrep++ ){ the_max = max( the_max, getNORB( irrep ) ); }
130  return the_max;
131 
132 }
133 
135 
136  int paramsize = 0;
137  for ( int irrep = 0; irrep < getNirreps(); irrep++ ){ paramsize += ( getNORB( irrep ) * ( getNORB( irrep ) - 1 ) ) / 2; }
138  return paramsize;
139 
140 }
141 
143 
144  cout << "NORB = [ ";
145  for (int irrep=0; irrep<Nirreps-1; irrep++){ cout << NORB[irrep] << " , "; }
146  cout << NORB[Nirreps-1] << " ]" << endl;
147 
148  cout << "NOCC = [ ";
149  for (int irrep=0; irrep<Nirreps-1; irrep++){ cout << NOCC[irrep] << " , "; }
150  cout << NOCC[Nirreps-1] << " ]" << endl;
151 
152  cout << "NDMRG = [ ";
153  for (int irrep=0; irrep<Nirreps-1; irrep++){ cout << NDMRG[irrep] << " , "; }
154  cout << NDMRG[Nirreps-1] << " ]" << endl;
155 
156  cout << "NVIRT = [ ";
157  for (int irrep=0; irrep<Nirreps-1; irrep++){ cout << NVIRT[irrep] << " , "; }
158  cout << NVIRT[Nirreps-1] << " ]" << endl;
159 
160 }
161 
162 
int getNORB(const int irrep) const
Get the number of orbitals for an irrep.
int getOrigNVIRTstart(const int irrep) const
Get in the original Hamiltonian index the start orbital for the virtual orbitals with a certain irrep...
int getNOCCsum() const
Get the total number of occupied orbitals.
bool setGroup(const int nGroup)
Set the group.
Definition: Irreps.cpp:50
int getROTparamsize() const
Get the orbital rotation parameter space size.
int getOrigNDMRGstart(const int irrep) const
Get in the original Hamiltonian index the start orbital for the active orbitals with a certain irrep...
int getNumberOfIrreps() const
Get the number of irreps for the currently activated group.
Definition: Irreps.cpp:94
DMRGSCFindices(const int L, const int Group, int *NOCCin, int *NDMRGin, int *NVIRTin)
Constructor.
int getGroupNumber() const
Get the group number.
int * getIrrepOfEachDMRGorbital()
Get an array with the irreps of each DMRG orbital.
virtual ~DMRGSCFindices()
Destructor.
int getDMRGcumulative(const int irrep) const
Get the cumulative number of active orbitals for an irrep.
int getGroupNumber() const
Get the group number.
Definition: Irreps.cpp:66
int getNORBmax() const
Get the maximum NORB.
int getL() const
Get the number of orbitals.
void Print() const
Print my contents.
int getNDMRG(const int irrep) const
Get the number of active orbitals for an irrep.
int getNOCC(const int irrep) const
Get the number of occupied orbitals for an irrep.
int getNVIRT(const int irrep) const
Get the number of virtual orbitals for an irrep.
int getOrbitalIrrep(const int index) const
Get the irrep corresponding to a global orbital index.
int getOrigNOCCstart(const int irrep) const
Get in the original Hamiltonian index the start orbital for the occupied orbitals with a certain irre...
int getNirreps() const
Get the number of irreps.