diff --git a/devel/casscf/EZFIO.cfg b/devel/casscf/EZFIO.cfg index ff1f7b3..95b032d 100644 --- a/devel/casscf/EZFIO.cfg +++ b/devel/casscf/EZFIO.cfg @@ -10,12 +10,6 @@ doc: Calculated |FCI| energy + |PT2| interface: ezfio size: (determinants.n_states) -[cisd_guess] -type: logical -doc: If true, the CASSCF starts with a CISD wave function -interface: ezfio,provider,ocaml -default: True - [state_following_casscf] type: logical doc: If |true|, the CASSCF will try to follow the guess CI vector and orbitals @@ -48,3 +42,10 @@ type: logical doc: If true, the two-rdm are computed with a fast algo interface: ezfio,provider,ocaml default: True + +[criterion_casscf] +type: character*(32) +doc: choice of the criterion for the convergence of the casscf: can be energy or gradients +interface: ezfio, provider, ocaml +default: energy + diff --git a/devel/casscf/casscf.irp.f b/devel/casscf/casscf.irp.f index 27ffe74..f5e37da 100644 --- a/devel/casscf/casscf.irp.f +++ b/devel/casscf/casscf.irp.f @@ -41,22 +41,30 @@ subroutine run call write_double(6,norm_grad_vec2_tab(3), ' Active-virtual gradients = ') call write_double(6,energy_improvement, 'Predicted energy improvement = ') - converged = dabs(energy_improvement) < thresh_scf + if(criterion_casscf == "energy")then + converged = dabs(energy_improvement) < thresh_scf + else if (criterion_casscf == "gradients")then + converged = norm_grad_vec2 < thresh_scf + else + converged = dabs(energy_improvement) < thresh_scf + endif pt2_max = dabs(energy_improvement / pt2_relative_error) mo_coef = NewOrbs mo_occ = occnum call save_mos - iteration += 1 - N_det = max(N_det/2 ,N_states) - psi_det = psi_det_sorted - psi_coef = psi_coef_sorted - read_wf = .True. - call clear_mo_map - SOFT_TOUCH mo_coef N_det pt2_max psi_det psi_coef - if(iteration .gt. 3)then - state_following_casscf = state_following_casscf_save - touch state_following_casscf + if(.not.converged)then + iteration += 1 + N_det = max(N_det/2 ,N_states) + psi_det = psi_det_sorted + psi_coef = psi_coef_sorted + read_wf = .True. + call clear_mo_map + SOFT_TOUCH mo_coef N_det pt2_max psi_det psi_coef + if(iteration .gt. 3)then + state_following_casscf = state_following_casscf_save + touch state_following_casscf + endif endif enddo diff --git a/devel/casscf/neworbs.irp.f b/devel/casscf/neworbs.irp.f index d19e556..a7cebbb 100644 --- a/devel/casscf/neworbs.irp.f +++ b/devel/casscf/neworbs.irp.f @@ -54,9 +54,9 @@ END_PROVIDER ! Eigenvectors/eigenvalues of the single-excitation matrix END_DOC if(nMonoEx+1.gt.n_det_max_full)then -! if(bavard)then + if(bavard)then print*,'Using the Davidson algorithm to diagonalize the SXmatrix' -! endif + endif double precision, allocatable :: u_in(:,:),energies(:) allocate(u_in(nMonoEx+1,n_states_diag),energies(n_guess_sx_mat)) call davidson_diag_sx_mat(n_guess_sx_mat, u_in, energies) @@ -70,9 +70,9 @@ END_PROVIDER enddo enddo else -! if(bavard)then + if(bavard)then print*,'Diagonalize the SXmatrix with Jacobi' -! endif + endif call lapack_diag(SXeigenval,SXeigenvec,SXmatrix,nMonoEx+1,nMonoEx+1) endif if (bavard) then @@ -84,9 +84,9 @@ END_PROVIDER write(6,*) ' 4 - ',SXeigenval(4),SXeigenvec(1,4) write(6,*) ' 5 - ',SXeigenval(5),SXeigenvec(1,5) endif - endif write(6,*) write(6,*) ' SXdiag : lowest eigenvalue = ',SXeigenval(1) + endif END_PROVIDER BEGIN_PROVIDER [real*8, energy_improvement]