File: test5.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 (103 lines) | stat: -rw-r--r-- 3,204 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
95
96
97
98
99
100
101
102
103
/*
   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 "DMRG.h"
#include "MPIchemps2.h"

using namespace std;

int main(void){

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

   CheMPS2::Initialize::Init();

   //The path to the matrix elements
   string matrixelements = "${CMAKE_SOURCE_DIR}/tests/matrixelements/N2.STO3G.FCIDUMP";
   
   //The Hamiltonian
   const int psi4groupnumber = 7; // d2h -- see Irreps.h and N2.sto3g.out
   CheMPS2::Hamiltonian * Ham = new CheMPS2::Hamiltonian( matrixelements, psi4groupnumber );
   
   //The targeted state
   int TwoS = 0;
   int N = 14;
   int Irrep = 0;
   CheMPS2::Problem * Prob = new CheMPS2::Problem(Ham, TwoS, N, Irrep);
   Prob->SetupReorderD2h();
   
   //The optimization scheme
   int D = 1000;
   double Econv = 1e-12;
   int maxSweeps = 100;
   double noisePrefactor = 0.0;
   CheMPS2::ConvergenceScheme * OptScheme = new CheMPS2::ConvergenceScheme(1);
   OptScheme->setInstruction(0,D,Econv,maxSweeps,noisePrefactor);
   
   //Run ground state calculation
   CheMPS2::DMRG * theDMRG = new CheMPS2::DMRG(Prob,OptScheme);
   double Energy0 = theDMRG->Solve();
   theDMRG->calc2DMandCorrelations();
   
   //Calculate the first two excited states
   theDMRG->activateExcitations(10);
   theDMRG->newExcitation(20.0);
   double Energy1 = theDMRG->Solve();
   theDMRG->calc2DMandCorrelations();
   theDMRG->newExcitation(20.0);
   double Energy2 = theDMRG->Solve();
   theDMRG->calc2DMandCorrelations();
   
   //Clean up
   if (CheMPS2::DMRG_storeMpsOnDisk){ theDMRG->deleteStoredMPS(); }
   if (CheMPS2::DMRG_storeRenormOptrOnDisk){ theDMRG->deleteStoredOperators(); }
   delete theDMRG;
   delete OptScheme;
   delete Prob;
   delete Ham;
   
   //Check succes
   const bool OK1 = ( fabs( Energy0 + 107.648250974014 ) < 1e-8 )? true : false;
   const bool OK2 = ( fabs( Energy1 + 106.944757308768 ) < 1e-8 )? true : false;
   const bool OK3 = ( fabs( Energy2 + 106.92314213886  ) < 1e-8 )? true : false;
   
   const bool success = (OK1 && OK2 && OK3);
   
   #ifdef CHEMPS2_MPI_COMPILATION
   CheMPS2::MPIchemps2::mpi_finalize();
   #endif
   
   cout << "================> Did test 5 succeed : ";
   if (success){
      cout << "yes" << endl;
      return 0; //Success
   }
   cout << "no" << endl;
   return 7; //Fail

}