1 /* Copyright (c) 2015 Gerald Knizia 2 * 3 * This file is part of the IboView program (see: http://www.iboview.org) 4 * 5 * IboView 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, version 3. 8 * 9 * IboView is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with bfint (LICENSE). If not, see http://www.gnu.org/licenses/ 16 * 17 * Please see IboView documentation in README.txt for: 18 * -- A list of included external software and their licenses. The included 19 * external software's copyright is not touched by this agreement. 20 * -- Notes on re-distribution and contributions to/further development of 21 * the IboView software 22 */ 23 24 #ifndef CT_RHF_H 25 #define CT_RHF_H 26 27 #include <string> 28 #include "CtBasisSet.h" 29 #include "CtAtomSet.h" 30 #include "CtMatrix.h" 31 // #include "CtDma.h" 32 #include "CtDftGrid.h" // for grid params. 33 #include "CtFockBuild.h" 34 #include "CtRhfOptions.h" 35 #include "CtIo.h" 36 #include "CxPodArray.h" 37 38 namespace ct { 39 40 41 42 // Stores stuff which came out of a calculation. Can also be used for initial 43 // guesses of later calculations. 44 struct FHfResult : public FIntrusivePtrDest 45 { 46 FHeapMatrix 47 Orb, 48 Occ, 49 Ew; 50 FBasisSetPtr 51 pOrbBasis; 52 double 53 Energy; 54 FAtomSet const 55 *pAtoms; 56 57 ~FHfResult(); 58 }; 59 typedef boost::intrusive_ptr<FHfResult> 60 FHfResultPtr; 61 62 63 struct FHfMethod 64 { 65 FHfOptions 66 Options; 67 FWfDecl 68 WfDecl; 69 70 FHfMethod(FHfResult *pResult_, FHfResult *pStartingGuess_, FLog &Log_, FWfDecl const &WfDecl_, FAtomSet const &Atoms_, FHfOptions const &Options_, FMemoryStack &Mem, bool FreeObjects=true); 71 protected: 72 FHfResult 73 *m_pResult; 74 FLog 75 &Log; 76 77 FAtomSet const 78 // Geometry & environment we are calculating: 79 // required to instantiate basis sets and 1e integrals 80 *pAtoms; 81 FBasisSetPtr 82 pOrbBasis, pFitBasis, pMinBasis; 83 size_t 84 nAo, nFit; 85 FMatrixView 86 Ew, // fock matrix eigenvalues. 87 Overlap, // S := <mu|nu> of orbital basis 88 Smh, // S^-{1/2}. FIXME: Do I still need this? 89 Scd, // Cholesky decomposition of S 90 // Jcd, // Choleksy decomposition of fitting metric matx (A|B). // FIXME: is this still valid? seems to be moved to Fock builder. 91 CoreH, // 1e Hamiltonian 92 Fock, // Fock matrix 93 ExchO; // open-shell exchange. 94 FMatrixView 95 Orb; // Orbital matrix 96 FTimerSet 97 m_Timers; 98 FTimer 99 m_tTotal; 100 double 101 m_Energy; // total energy of result. 102 bool 103 // set once we have a set of orbitals which is reasonably consistent with 104 // the current Fock matrix, as computed with a RHF coupling pattern. This is 105 // not the case if (a) we are in the 1st iteration, and (b) we used anything 106 // except for a previous orbital set as initial guess. 107 m_HaveOrbitals; 108 109 FFockComponentBuilderList 110 m_FockComponentBuilders; 111 112 void Init(FHfResult *pStartingGuess, FMemoryStack &Mem); 113 void Run(FMemoryStack &Mem); 114 void UpdateOrbitals(FMatrixView &Orb, FMatrixView &COccC, FMatrixView &COccO, FMatrixView &DenC, FMatrixView &DenO, 115 FMatrixView const Fock, FMatrixView const &ExchO, FMatrixView &T1, FMemoryStack &Mem); 116 void MakeInitialGuess(FMemoryStack &Mem); 117 // output: 3 x pAtoms->size() array. 118 void MakeGradient(double *pOut, FMemoryStack &Mem); 119 void PrintGradient(double *pGrad); 120 // void EvalDma(FDmaDescPtr &pDmaResult, FMemoryStack &Mem); 121 }; 122 123 } // namespace ct 124 125 #endif // CT_RHF_H 126