CheMPS2
DMRGSCFwtilde.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 "DMRGSCFwtilde.h"
21 
23 
24  iHandler = iHandler_in;
25 
26  Nocc_dmrg = new int[ iHandler->getNirreps() ];
27  for (int irrep = 0; irrep < iHandler->getNirreps(); irrep++){
28  Nocc_dmrg[ irrep ] = iHandler->getNOCC( irrep ) + iHandler->getNDMRG( irrep );
29  }
30 
31  wmattilde = new double***[ iHandler->getNirreps() ];
32  for (int irrep_pq = 0; irrep_pq < iHandler->getNirreps(); irrep_pq++){
33  wmattilde[ irrep_pq ] = new double**[ iHandler->getNirreps() ];
34  for (int irrep_rs = 0; irrep_rs < iHandler->getNirreps(); irrep_rs++){
35  const unsigned int sizeblock_pr = Nocc_dmrg[ irrep_pq ] * Nocc_dmrg[ irrep_rs ];
36  const unsigned int sizeblock_qs = iHandler->getNORB( irrep_pq ) * iHandler->getNORB( irrep_rs );
37  wmattilde[ irrep_pq ][ irrep_rs ] = new double*[ sizeblock_pr ];
38  for (unsigned int combined_pr = 0; combined_pr < sizeblock_pr; combined_pr++){
39  wmattilde[ irrep_pq ][ irrep_rs ][ combined_pr ] = new double[ sizeblock_qs ];
40  }
41  }
42  }
43 
44 }
45 
47 
48  for (int irrep_pq = 0; irrep_pq < iHandler->getNirreps(); irrep_pq++){
49  for (int irrep_rs = 0; irrep_rs < iHandler->getNirreps(); irrep_rs++){
50  const unsigned int sizeblock_pr = Nocc_dmrg[ irrep_pq ] * Nocc_dmrg[ irrep_rs ];
51  for (unsigned int combined_pr = 0; combined_pr < sizeblock_pr; combined_pr++){
52  delete [] wmattilde[ irrep_pq ][ irrep_rs ][ combined_pr ];
53  }
54  delete [] wmattilde[ irrep_pq ][ irrep_rs ];
55  }
56  delete [] wmattilde[ irrep_pq ];
57  }
58  delete [] wmattilde;
59 
60  delete [] Nocc_dmrg;
61 
62 }
63 
65 
66  for (int irrep_pq = 0; irrep_pq < iHandler->getNirreps(); irrep_pq++){
67  for (int irrep_rs = 0; irrep_rs < iHandler->getNirreps(); irrep_rs++){
68  const unsigned int sizeblock_pr = Nocc_dmrg[ irrep_pq ] * Nocc_dmrg[ irrep_rs ];
69  const unsigned int sizeblock_qs = iHandler->getNORB( irrep_pq ) * iHandler->getNORB( irrep_rs );
70  for (unsigned int combined_pr = 0; combined_pr < sizeblock_pr; combined_pr++){
71  for (unsigned int combined_qs = 0; combined_qs < sizeblock_qs; combined_qs++){
72  wmattilde[ irrep_pq ][ irrep_rs ][ combined_pr ][ combined_qs ] = 0.0;
73  }
74  }
75  }
76  }
77 
78 }
79 
80 void CheMPS2::DMRGSCFwtilde::set(const int irrep_pq, const int irrep_rs, const int p, const int q, const int r, const int s, const double val){
81 
82  wmattilde[ irrep_pq ][ irrep_rs ][ p + Nocc_dmrg[ irrep_pq ] * r ][ q + iHandler->getNORB(irrep_pq) * s ] = val;
83 
84 }
85 
86 double CheMPS2::DMRGSCFwtilde::get(const int irrep_pq, const int irrep_rs, const int p, const int q, const int r, const int s) const{
87 
88  return wmattilde[ irrep_pq ][ irrep_rs ][ p + Nocc_dmrg[ irrep_pq ] * r ][ q + iHandler->getNORB(irrep_pq) * s ];
89 
90 }
91 
92 double * CheMPS2::DMRGSCFwtilde::getBlock(const int irrep_pq, const int irrep_rs, const int p, const int r){
93 
94  return wmattilde[ irrep_pq ][ irrep_rs ][ p + Nocc_dmrg[ irrep_pq ] * r ];
95 
96 }
97 
int getNORB(const int irrep) const
Get the number of orbitals for an irrep.
virtual ~DMRGSCFwtilde()
Destructor.
double get(const int irrep_pq, const int irrep_rs, const int p, const int q, const int r, const int s) const
Get an element of w_tilde_pqrs.
DMRGSCFwtilde(DMRGSCFindices *iHandler_in)
Constructor.
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.
void set(const int irrep_pq, const int irrep_rs, const int p, const int q, const int r, const int s, const double val)
Set an element of w_tilde_pqrs.
double * getBlock(const int irrep_pq, const int irrep_rs, const int p, const int r)
Get the (pr) subblock of w_tilde_pqrs, which is stored as w_tilde[ I_pq ][ I_rs ][ p + ( Nocc[I_pq] +...
int getNirreps() const
Get the number of irreps.