2
/* Revision 1.28.4.3 2005/01/29 20:10:11 crawdad
3
/* (1) Fixed a bug in the UHF computation of the density in cints.
4
/* (2) Corrected calculation of <S^2> for UHF in cscf.
2
* Revision 1.32 2007/04/05 15:45:25 crawdad
3
* Fixed a few memory leaks identified by valgrind. -TDC
5
/* Revision 1.31 2005/11/10 16:37:50 evaleev
6
/* Added CHECK_MO_ORTHONORMALITY input keyword. Useful for debugging.
8
/* Revision 1.30 2004/08/12 19:13:32 crawdad
9
/* Corrected computation of <S^2> for UHF references. The equations were
10
/* coded correctly, but variable types screwed up results for doublets,
11
/* quartets, etc. -TDC
13
/* Revision 1.29 2004/05/03 04:32:40 crawdad
14
/* Major mods based on merge with stable psi-3-2-1 release. Note that this
15
/* version has not been fully tested and some scf-optn test cases do not run
16
/* correctly beccause of changes in mid-March 2004 to optking.
7
/* Revision 1.28.4.2 2004/09/07 21:40:37 evaleev
8
/* Incorrect value for iopen was written out to chkpt file in UHF calculations.
10
19
/* Revision 1.28.4.1 2004/04/01 22:04:49 evaleev
11
20
/* A critical bug: lagrangian was not written out to chkpt file correctly
12
21
/* thanks to missing symblk offsets in computing MO indices. ROHF HF gradients
378
384
for(k=0,row=0,col=0; k < num_ir; k++) {
380
for(i=0; i < s->num_so; i++) {
381
for(j=0; j < s->num_mo; j++) {
382
scr1[i+row][j+col] = s->cmat[i][j];
390
/* Test normalization of MOs */
391
if (check_mo_orthonormality) {
392
fprintf(outfile," -Testing orthonormality of MOs in symmetry block %d\n",k);
393
fprintf(outfile," -overlap matrix:\n");
394
print_array(s->smat,s->num_so,outfile);
395
fprintf(outfile," -MOs:\n");
396
print_mat(s->cmat,s->num_so,s->num_mo,outfile);
397
s_sq = block_matrix(s->num_so,s->num_so);
398
tri_to_sq(s->smat,s_sq,s->num_so);
399
tmp = block_matrix(s->num_so,s->num_so);
400
mmult(s_sq,0,s->cmat,0,tmp,0,s->num_so,s->num_so,s->num_so,0);
401
mmult(s->cmat,1,tmp,0,s_sq,0,s->num_mo,s->num_so,s->num_mo,0);
402
fprintf(outfile," -Ct.S.C:\n");
403
print_mat(s_sq,s->num_mo,s->num_mo,outfile);
408
for(i=0; i < s->num_so; i++) {
409
for(j=0; j < s->num_mo; j++) {
410
scr1[i+row][j+col] = s->cmat[i][j];
388
418
chkpt_wt_scf(scr1);
675
709
double ssquare(void){
684
double **scr1,**scr2,**S;
687
scr1 = (double **)init_matrix(nsfmax,nsfmax);
688
scr2 = (double **)init_matrix(nsfmax,nsfmax);
690
/* Calculate the overlap matrix elements */
692
for(i = 0;i < num_ir;i++){
694
na += spin_info[0].scf_spin[i].noccup;
695
nb += spin_info[1].scf_spin[i].noccup;
700
tri_to_sq(s->smat,scr1,nn);
702
/* Transform the Overlap matrix to the MO basis */
704
mmult(spin_info[0].scf_spin[i].cmat,1
705
,scr1,0,scr2,0,num_mo,nn,nn,0);
706
mmult(scr2,0,spin_info[1].scf_spin[i].cmat,0
707
,scr1,0,num_mo,nn,num_mo,0);
709
for(j = 0; j < spin_info[0].scf_spin[i].noccup; j++){
710
for(k = 0;k < spin_info[1].scf_spin[i].noccup; k++){
711
ss -= scr1[j][k]*scr1[j][k];
718
double **scr1,**scr2,**S;
721
scr1 = (double **)init_matrix(nsfmax,nsfmax);
722
scr2 = (double **)init_matrix(nsfmax,nsfmax);
724
/* Calculate the overlap matrix elements */
726
for(i = 0;i < num_ir;i++){
728
na += spin_info[0].scf_spin[i].noccup;
729
nb += spin_info[1].scf_spin[i].noccup;
734
tri_to_sq(s->smat,scr1,nn);
736
/* Transform the Overlap matrix to the MO basis */
738
mmult(spin_info[0].scf_spin[i].cmat,1,scr1,0,scr2,0,num_mo,nn,nn,0);
739
mmult(scr2,0,spin_info[1].scf_spin[i].cmat,0,scr1,0,num_mo,nn,num_mo,0);
741
for(j = 0; j < spin_info[0].scf_spin[i].noccup; j++){
742
for(k = 0;k < spin_info[1].scf_spin[i].noccup; k++){
743
ss -= scr1[j][k]*scr1[j][k];
718
/* Calculate the occupation part of the equation */
750
/* Calculate the occupation part of the equation */
723
ss += (nm*(nm+1))+nb;
725
free_matrix(scr1,nsfmax);
726
free_matrix(scr2,nsfmax);
755
ss += (nm*(nm+1))+nb;
757
free_matrix(scr1,nsfmax);
758
free_matrix(scr2,nsfmax);