/* 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" //NOTE: ncore is the number of "frozen" orbitals already in the TDDFT program, for which no excitations have been generated and no coefficients in tddft_coefs exist //in contrast, inactive_occ and inactive_virt are numbers core and virtuals to be dropped at this stage, for which there are //elements in the tddft_coefs to be ignored. void do_cis_casida(bool uhf, bool spinflip, int ncore, int (&nocc)[2], int (&nvirt)[2], bool orthonormalize, bool do_casida, bool inverse_casida, bool do_normalize, int inactive_occ, int inactive_virt) { cout <<"core, occ, virt, freeze, discard "< energies; const NRVec orbener[2]; cin >> *(const_cast * > (orbener+0)); if(uhf) cin >> *(const_cast * > (orbener+1)); else *(const_cast * > (orbener+1)) = orbener[0]; cin >> energies; int nstate=energies.size(); cout << "Number of states (incl ground) = " < > tddft_coefs(nstate,2); for(int i=0; i> *(const_cast * > (&tddft_coefs(i,0)) ); if(uhf) cin >> *(const_cast * > (&tddft_coefs(i,1)) ); else {*(const_cast * > (&tddft_coefs(i,1)) ) = tddft_coefs(i,0);} } int nocc_eff[2]; nocc_eff[0]= nocc[0]-inactive_occ; nocc_eff[1]= nocc[1]-inactive_occ; int nvirt_eff[2]; nvirt_eff[0] = nvirt[0] - inactive_virt; nvirt_eff[1] = nvirt[1] - inactive_virt; cout <<"nocc_eff = "< transformation = sqrtinv(casidaoverlaps); cout << "Orthonormalization matrix\n"< cis_coefs_new = transformation * cis_coefs; cout << "overlap check after orthonormalization\n" << cis_coefs_new * cis_coefs_new.transpose(); // #if 0 NRSMat casidaoverlaps_diagonal(0.,casidaoverlaps.ncols()); for(int i=0; i normalization_only = sqrtinv(casidaoverlaps_diagonal); cout << "test normalization only trafo matrix\n"< invcasidaoverlaps_diagonalof(casidaoverlaps.ncols()); normalization_only.diagonalof(invcasidaoverlaps_diagonalof); NRMat overlaps_n(casidaoverlaps); overlaps_n.diagmultr(invcasidaoverlaps_diagonalof); overlaps_n.diagmultl(invcasidaoverlaps_diagonalof); cout << "overlaps of normalized\n"< overlaps_ns(overlaps_n); NRMat transformation_n = sqrtinv(overlaps_ns); cout << "Orthonormalization matrix of already normalized vectors\n"< cis_coefs_new2 = transformation_n * cis_coefs; cout << "NORM of difference of the two approaches \n"<<(cis_coefs_new-cis_coefs_new2).norm()<1 && !strcmp(argv[1],"-U")) {uhf=1; --argc; ++argv;} if(argc>1 && !strcmp(argv[1],"-S")) {spinflip=1; --argc; ++argv;} if(argc>1 && !strcmp(argv[1],"-o")) {orthonormalize=true; --argc; ++argv;} if(argc>1 && !strcmp(argv[1],"-c")) {do_casida=true; inverse_casida=false; --argc; ++argv;} if(argc>1 && !strcmp(argv[1],"-C")) {inverse_casida=true; do_casida=false; --argc; ++argv;} if(argc>1 && !strcmp(argv[1],"-n")) {do_normalize=true; --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],"-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_casida(uhf,spinflip,ncore,nocc,nvirt,orthonormalize,do_casida,inverse_casida,do_normalize,inactive_occ,inactive_virt); }