File: test8.cpp.in

package info (click to toggle)
chemps2 1.8.12-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,432 kB
  • sloc: cpp: 38,521; python: 1,116; f90: 215; makefile: 45; sh: 23
file content (94 lines) | stat: -rw-r--r-- 3,296 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
   CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry
   Copyright (C) 2013-2018 Sebastian Wouters

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along
   with this program; if not, write to the Free Software Foundation, Inc.,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <iostream>
#include <math.h>
#include <string.h>

#include "Initialize.h"
#include "CASSCF.h"
#include "DMRGSCFoptions.h"
#include "MPIchemps2.h"

using namespace std;

int main(void){

   #ifdef CHEMPS2_MPI_COMPILATION
   CheMPS2::MPIchemps2::mpi_init();
   #endif

   CheMPS2::Initialize::Init();

   // Setup the Hamiltonian
   string matrixelements = "${CMAKE_SOURCE_DIR}/tests/matrixelements/N2.CCPVDZ.FCIDUMP";
   const int psi4groupnumber = 7; // d2h -- see Irreps.h and N2.ccpvdz.out
   CheMPS2::Hamiltonian * Ham = new CheMPS2::Hamiltonian( matrixelements, psi4groupnumber );

   // Setup CASSCF --> number of irreps = 8
   int DOCC[]  = { 3, 0, 0, 0, 0, 2, 1, 1 }; // see N2.ccpvdz.out
   int SOCC[]  = { 0, 0, 0, 0, 0, 0, 0, 0 };
   int NOCC[]  = { 1, 0, 0, 0, 0, 1, 0, 0 };
   int NDMRG[] = { 2, 0, 1, 1, 0, 2, 1, 1 };
   int NVIRT[] = { 4, 1, 2, 2, 1, 4, 2, 2 };
   CheMPS2::CASSCF koekoek( Ham, DOCC, SOCC, NOCC, NDMRG, NVIRT );

   // Setup symmetry sector
   int N     = 14;
   int TwoS  = 0;
   int Irrep = 0;

   // Setup convergence scheme
   CheMPS2::ConvergenceScheme * OptScheme = new CheMPS2::ConvergenceScheme( 1 );
   // ConvergenceScheme::set_instruction( counter, virtual_dimension, energy_convergence, max_sweeps, noise_prefactor, dvdson_rtol );
   OptScheme->set_instruction( 0, 1000, 1e-8, 20, 0.0, 1e-8 );

   // Run CASSCF
   const int root_num = 1; // Ground state only
   CheMPS2::DMRGSCFoptions * theDMRGSCFoptions = new CheMPS2::DMRGSCFoptions();
   theDMRGSCFoptions->setDoDIIS( true );
   theDMRGSCFoptions->setWhichActiveSpace( 1 ); // 1 means natural orbitals
   theDMRGSCFoptions->setDumpCorrelations( true );
   const double Energy = koekoek.solve( N, TwoS, Irrep, OptScheme, root_num, theDMRGSCFoptions );

   // Clean up
   if (theDMRGSCFoptions->getStoreUnitary()){ koekoek.deleteStoredUnitary( theDMRGSCFoptions->getUnitaryStorageName() ); }
   if (theDMRGSCFoptions->getStoreDIIS()){ koekoek.deleteStoredDIIS( theDMRGSCFoptions->getDIISStorageName() ); }
   delete OptScheme;
   delete theDMRGSCFoptions;
   delete Ham;

   // Check succes
   const bool success = ( fabs( Energy + 109.103502335253 ) < 1e-8 ) ? true : false;

   #ifdef CHEMPS2_MPI_COMPILATION
   CheMPS2::MPIchemps2::mpi_finalize();
   #endif

   cout << "================> Did test 8 succeed : ";
   if (success){
      cout << "yes" << endl;
      return 0; //Success
   }
   cout << "no" << endl;
   return 7; //Fail

}