/* Copyright (C) 2008 Jiri Pittner or 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 3 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, see . */ #include #include #include #include #include #include #include #include #include #include "gelfand.h" #include "drt.h" #include "readintegrals.h" #include "options.h" //LA #include "vec.h" #include "mat.h" #include "smat.h" #include "sparsemat.h" #include "nonclass.h" #include "qsort.h" void do_cis_slater(bool uhf, bool spinflip, int ncore0, int (&nocc0)[2], int (&nvirt0)[2], int inactive_occ, int inactive_virt, bool include_occ = 1, bool number_occ = 1) { cout << "Is this UHF run? "< positions[2]; if(uhf) { positions[0].resize(nocc[0]); positions[1].resize(nocc[1]); } int noccmin=nocc[0]; if(nocc[1]noccmax) noccmax=nocc[1]; //generate part with alternating alpha and beta for(int iocc=1; iocc<=noccmin; ++iocc) { int pos=2*shiftcore + 2*iocc-2; tmp[2*shiftcore + 2*iocc-2] = iocc + numcore; tmp[pos+1] = -iocc -numcore; if(uhf) {positions[0][iocc-1] = pos; positions[1][iocc-1] = pos+1;} } //and add extra alpha or beta orbitals if(nocc[0]!=nocc[1]) { int spin= nocc[0]>nocc[1] ? 1 : -1; for(int iocc=noccmin+1; iocc<=noccmax; ++iocc) { int pos=2*shiftcore + 2*noccmin + iocc-noccmin-1; tmp[pos] = spin * (iocc+numcore); if(uhf) positions[spin==1?0:1][iocc-1] = pos; } } //store the vacuum if(!spinflip) tmp.put(slaterfile,false); //now generate all possible excitations //order of indices will be occ,virt //notice that we make replacement in place - parity of permutation to bring a given spinorb in front and after excitation to bring it back compensates if(uhf) { for(int spin=0; spin<=1; ++spin) //first all alpha, then all beta excitations { for(int iocc=1; iocc<=nocc[spin]; ++iocc) for(int ivirt=nocc[spin]+1; ivirt<=nocc[spin]+nvirt[spin]; ++ivirt) { //use stored positions to make replacements int pos = positions[spin][iocc-1]; int original = tmp[pos]; tmp[pos] = (spin?-1:1)*(ivirt + numcore); tmp.put(slaterfile,false); tmp[pos] = original; } } } else if(spinflip) { for(int iocc=1; iocc<=nocc[1]; ++iocc) for(int ivirt=nocc[0]+1; ivirt<=nocc[0]+nvirt[0]; ++ivirt) { int orig=tmp[2*shiftcore + 2*iocc-1]; tmp[2*shiftcore + 2*iocc-1] = ivirt + numcore; tmp.put(slaterfile,false); //beta to alpha excitation tmp[2*shiftcore + 2*iocc-1] = orig; if(orig != -iocc - numcore) laerror("assertion failed in spinflip excitations"); } } else //rhf ... keep original order of determinants for full backward compatibility { for(int iocc=1; iocc<=nocc[0]; ++iocc) for(int ivirt=nocc[0]+1; ivirt<=nocc[0]+nvirt[0]; ++ivirt) { tmp[2*shiftcore + 2*iocc-2] = ivirt + numcore; tmp.put(slaterfile,false); //alpha excitation tmp[2*shiftcore + 2*iocc-2] = iocc + numcore; tmp[2*shiftcore + 2*iocc-1] = -ivirt -numcore; tmp.put(slaterfile,false); //beta excitation tmp[2*shiftcore + 2*iocc-1] = -iocc - numcore; } } cout <<"Number of determinants generated = "<< (spinflip?nocc[1]*nvirt[0] : 1+nocc[0]*nvirt[0]+nocc[1]*nvirt[1])<1 && !strcmp(argv[1],"-U")) { uhf=1; argc -=1; argv+=1; } if(argc>1 && !strcmp(argv[1],"-S")) {spinflip=1; --argc; ++argv;} if(argc>2 && !strcmp(argv[1],"-i")) { sscanf(argv[2],"%d",&inactive_occ); argc -=2; argv+=2; } if(argc>2 && !strcmp(argv[1],"-j")) { sscanf(argv[2],"%d",&inactive_occ); argc -=2; argv+=2; include_occ=0; } if(argc>2 && !strcmp(argv[1],"-k")) { sscanf(argv[2],"%d",&inactive_occ); argc -=2; argv+=2; include_occ=0; number_occ=0; } if(argc>2 && !strcmp(argv[1],"-I")) { sscanf(argv[2],"%d",&inactive_virt); argc -=2; argv+=2; } } if(uhf&&spinflip) laerror("UHF and SPINFLIP options are incompatible"); cout.setf(ios::fixed); //cout.setf(ios::scientific); cout.precision(12); int ncore,nocc[2],nvirt[2]; cin >>ncore >>nocc[0] >>nvirt[0]; if(uhf) cin >> nocc[1] >> nvirt[1]; else {nocc[1]=nocc[0]; nvirt[1]=nvirt[0];} do_cis_slater(uhf,spinflip,ncore,nocc,nvirt,inactive_occ,inactive_virt,include_occ,number_occ); }