1/* 2 CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry 3 Copyright (C) 2013-2018 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 <iostream> 21#include <math.h> 22#include <string.h> 23 24#include "Initialize.h" 25#include "CASSCF.h" 26#include "DMRGSCFoptions.h" 27#include "MPIchemps2.h" 28 29using namespace std; 30 31int main(void){ 32 33 #ifdef CHEMPS2_MPI_COMPILATION 34 CheMPS2::MPIchemps2::mpi_init(); 35 #endif 36 37 CheMPS2::Initialize::Init(); 38 39 // Setup the Hamiltonian 40 string matrixelements = "${CMAKE_SOURCE_DIR}/tests/matrixelements/O2.CCPVDZ.FCIDUMP"; 41 const int psi4groupnumber = 7; // d2h -- see Irreps.h and O2.ccpvdz.out 42 CheMPS2::Hamiltonian * Ham = new CheMPS2::Hamiltonian( matrixelements, psi4groupnumber ); 43 44 // Setup CASSCF --> number of irreps = 8 45 int DOCC[] = { 2, 0, 1, 1, 0, 2, 1, 1 }; // see O2.ccpvdz.out 46 int SOCC[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 47 int NOCC[] = { 1, 0, 0, 0, 0, 1, 0, 0 }; 48 int NDMRG[] = { 2, 0, 2, 2, 0, 2, 2, 2 }; 49 int NVIRT[] = { 4, 1, 1, 1, 1, 4, 1, 1 }; 50 CheMPS2::CASSCF koekoek( Ham, DOCC, SOCC, NOCC, NDMRG, NVIRT ); 51 52 // Setup symmetry sector 53 int N = 16; 54 int TwoS = 0; 55 int Irrep = 0; 56 57 // Setup convergence scheme 58 CheMPS2::ConvergenceScheme * OptScheme = new CheMPS2::ConvergenceScheme( 1 ); 59 // ConvergenceScheme::set_instruction( counter, virtual_dimension, energy_convergence, max_sweeps, noise_prefactor, dvdson_rtol ); 60 OptScheme->set_instruction( 0, 1000, 1e-8, 20, 0.0, 1e-8 ); 61 62 // Run CASSCF 63 const int root_num = 2; // Do the first excited state 64 CheMPS2::DMRGSCFoptions * theDMRGSCFoptions = new CheMPS2::DMRGSCFoptions(); 65 theDMRGSCFoptions->setDoDIIS( true ); 66 theDMRGSCFoptions->setWhichActiveSpace( 1 ); // 1 means natural orbitals 67 theDMRGSCFoptions->setStateAveraging( true ); 68 const double Energy = koekoek.solve( N, TwoS, Irrep, OptScheme, root_num, theDMRGSCFoptions ); 69 70 // Clean up 71 if (theDMRGSCFoptions->getStoreUnitary()){ koekoek.deleteStoredUnitary( theDMRGSCFoptions->getUnitaryStorageName() ); } 72 if (theDMRGSCFoptions->getStoreDIIS()){ koekoek.deleteStoredDIIS( theDMRGSCFoptions->getDIISStorageName() ); } 73 delete OptScheme; 74 delete theDMRGSCFoptions; 75 delete Ham; 76 77 // Check succes 78 const bool success = ( fabs( Energy + 149.6802657522 ) < 1e-8 ) ? true : false; 79 80 #ifdef CHEMPS2_MPI_COMPILATION 81 CheMPS2::MPIchemps2::mpi_finalize(); 82 #endif 83 84 cout << "================> Did test 6 succeed : "; 85 if (success){ 86 cout << "yes" << endl; 87 return 0; //Success 88 } 89 cout << "no" << endl; 90 return 7; //Fail 91 92} 93 94 95