CheMPS2
DMRGSCFunitary.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 DMRGSCFUNITARY_CHEMPS2_H
21 #define DMRGSCFUNITARY_CHEMPS2_H
22 
23 #include "Options.h"
24 #include "DMRGSCFindices.h"
25 #include "DMRGSCFmatrix.h"
26 #include "DIIS.h"
27 
28 namespace CheMPS2{
70  class DMRGSCFunitary : public DMRGSCFmatrix{
71 
72  public:
73 
75 
77 
79  virtual ~DMRGSCFunitary();
80 
82 
83  int getNumVariablesX() const;
84 
86 
91  void updateUnitary( double * workmem1, double * workmem2, double * vector, const bool multiply, const bool compact );
92 
94 
96  void rotateActiveSpaceVectors( double * eigenvecs, double * work );
97 
99 
100  void CheckDeviationFromUnitary( double * work ) const;
101 
103 
106  void getLog( double * vector, double * temp1, double * temp2 ) const;
107 
109 
111  void makeSureAllBlocksDetOne( double * temp1, double * temp2 );
112 
114 
115  void saveU( const string filename=DMRGSCF_unitary_storage_name ) const;
116 
118 
119  void loadU( const string filename=DMRGSCF_unitary_storage_name );
120 
121  private:
122 
123  //Number of variables in the x-matrix
124  int x_linearlength;
125 
126  //Helper arrays to jump from linear x-matrix index to orbital indices and back
127  int ** jumper;
128 
129  // Build in result the skew symmetric matrix X for irrep block irrep based on the elements in Xelem. If compact==true, they are stored in gradient form.
130  void buildSkewSymmX( const int irrep, double * result, double * Xelem, const bool compact ) const;
131 
132  // Get the determinant, and in the process fill work1 with eigvec( U[ irrep ] + U^T[ irrep ] ) and work2 with work1^T U work1 (TRIDIAGONAL matrix).
133  double get_determinant( const int irrep, double * work1, double * work2, double * work_eig, int lwork_eig ) const;
134 
135  };
136 }
137 
138 #endif
void rotateActiveSpaceVectors(double *eigenvecs, double *work)
Rotate the unitary matrix.
const DMRGSCFindices * iHandler
The information on the occupied, active, and virtual spaces.
Definition: DMRGSCFmatrix.h:94
DMRGSCFunitary(const DMRGSCFindices *iHandler)
Constructor.
Definition: CASPT2.h:42
void loadU(const string filename=DMRGSCF_unitary_storage_name)
Load the unitary from disk.
void getLog(double *vector, double *temp1, double *temp2) const
Obtain the logarithm of the unitary matrix.
void saveU(const string filename=DMRGSCF_unitary_storage_name) const
Save the unitary to disk.
virtual ~DMRGSCFunitary()
Destructor.
void CheckDeviationFromUnitary(double *work) const
Calculate the two-norm of U^T*U - I.
void makeSureAllBlocksDetOne(double *temp1, double *temp2)
Orbitals are defined up to a phase factor. Make sure that the logarithm of each block of the unitary ...
int getNumVariablesX() const
Get the number of variables in the x-parametrization of the unitary update.
void updateUnitary(double *workmem1, double *workmem2, double *vector, const bool multiply, const bool compact)
Update the unitary transformation.