CheMPS2
Hamiltonian.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 HAMILTONIAN_CHEMPS2_H
21 #define HAMILTONIAN_CHEMPS2_H
22 
23 #include <string>
24 
25 #include "Irreps.h"
26 #include "TwoIndex.h"
27 #include "FourIndex.h"
28 #include "Options.h"
29 
30 using std::string;
31 
32 namespace CheMPS2{
53  class Hamiltonian{
54 
55  public:
56 
58 
61  Hamiltonian(const int Norbitals, const int nGroup, const int * OrbIrreps);
62 
64 
66  Hamiltonian(const string filename, const int psi4groupnumber);
67 
69 
73  Hamiltonian(const bool fileh5, const string main_file=HAMILTONIAN_ParentStorageName, const string file_tmat=HAMILTONIAN_TmatStorageName, const string file_vmat=HAMILTONIAN_VmatStorageName);
74 
76  virtual ~Hamiltonian();
77 
79 
80  int getL() const;
81 
83 
84  int getNGroup() const;
85 
87 
89  int getOrbitalIrrep(const int nOrb) const;
90 
92 
93  void setEconst(const double val);
94 
96 
99  void setTmat(const int index1, const int index2, const double val);
100 
102 
107  void setVmat(const int index1, const int index2, const int index3, const int index4, const double val);
108 
110 
115  void addToVmat(const int index1, const int index2, const int index3, const int index4, const double val);
116 
118 
119  double getEconst() const;
120 
122 
125  double getTmat(const int index1, const int index2) const;
126 
128 
133  double getVmat(const int index1, const int index2, const int index3, const int index4) const;
134 
136 
137  const TwoIndex * getTmat();
138 
140 
141  FourIndex * getVmat();
142 
144 
147  void save(const string file_parent=HAMILTONIAN_ParentStorageName, const string file_tmat=HAMILTONIAN_TmatStorageName, const string file_vmat=HAMILTONIAN_VmatStorageName) const;
148 
150 
153  void read(const string file_parent=HAMILTONIAN_ParentStorageName, const string file_tmat=HAMILTONIAN_TmatStorageName, const string file_vmat=HAMILTONIAN_VmatStorageName);
154 
156 
160  void writeFCIDUMP( const string fcidumpfile, const int Nelec, const int TwoS, const int TargetIrrep ) const;
161 
163  void debugcheck() const;
164 
166 
169  void readfock( const string fockfile, double * fockmx, const bool printinfo ) const;
170 
171  private:
172 
173  //number of orbitals
174  int L;
175 
176  //symmetry info
177  Irreps SymmInfo;
178 
179  //irrep of each orbital
180  int * orb2irrep;
181 
182  //number of orbitals per irrep
183  int * irrep2num_orb;
184 
185  //index of an orbital within irrep block
186  int * orb2indexSy;
187 
188  //1-particle matrix elements
189  TwoIndex * Tmat;
190 
191  //2-particle matrix elements
192  FourIndex * Vmat;
193 
194  //Constant part of the Hamiltonian
195  double Econst;
196 
197  //If filename=="LOADH5" in Hamiltonian::Hamiltonian then the HDF5 Hamiltonian is loaded
198  void CreateAndFillFromH5(const string file_parent, const string file_tmat, const string file_vmat);
199 
200  //Load the FCIDUMP Hamiltonian (with molpro irreps!)
201  void CreateAndFillFromFCIDUMP( const string fcidumpfile );
202 
203  };
204 }
205 
206 #endif
void readfock(const string fockfile, double *fockmx, const bool printinfo) const
Read in a FOCK file.
void setTmat(const int index1, const int index2, const double val)
Set a Tmat element.
Definition: CASPT2.h:42
int getOrbitalIrrep(const int nOrb) const
Get an orbital irrep number.
Definition: Hamiltonian.cpp:97
void debugcheck() const
Debug check certain elements and sums.
void setVmat(const int index1, const int index2, const int index3, const int index4, const double val)
Set a Vmat element.
void save(const string file_parent=HAMILTONIAN_ParentStorageName, const string file_tmat=HAMILTONIAN_TmatStorageName, const string file_vmat=HAMILTONIAN_VmatStorageName) const
Save the Hamiltonian.
void setEconst(const double val)
Set the constant energy.
Definition: Hamiltonian.cpp:99
virtual ~Hamiltonian()
Destructor.
Definition: Hamiltonian.cpp:83
void writeFCIDUMP(const string fcidumpfile, const int Nelec, const int TwoS, const int TargetIrrep) const
Write the Hamiltonian to a FCIDUMP file.
void read(const string file_parent=HAMILTONIAN_ParentStorageName, const string file_tmat=HAMILTONIAN_TmatStorageName, const string file_vmat=HAMILTONIAN_VmatStorageName)
Load the Hamiltonian.
void addToVmat(const int index1, const int index2, const int index3, const int index4, const double val)
Add to Vmat element.
FourIndex * getVmat()
Get the pointer to the two-electron integrals.
int getNGroup() const
Get the group number.
Definition: Hamiltonian.cpp:95
double getEconst() const
Get the constant energy.
Hamiltonian(const int Norbitals, const int nGroup, const int *OrbIrreps)
Constructor.
Definition: Hamiltonian.cpp:39
const TwoIndex * getTmat()
Get the pointer to the one-electron integrals.
int getL() const
Get the number of orbitals.
Definition: Hamiltonian.cpp:93