diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index 03ed91cd..45b84a6a 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -773,22 +773,35 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d endif + integer :: degree + logical :: do_cycle if (excitation_max >= 0) then - integer :: degree - call get_excitation_degree(ref_bitmask(1,1),det(1,1),degree,N_int) - if (degree > excitation_max) cycle + do_cycle = .True. + do k=1,N_states + call get_excitation_degree(psi_det(1,1,dominant_det(k)),det(1,1),degree,N_int) + do_cycle = do_cycle .and. (degree > excitation_max) + enddo + if (do_cycle) cycle endif if (excitation_alpha_max >= 0) then - call get_excitation_degree_spin(ref_bitmask(1,1),det(1,1),degree,N_int) - if (degree > excitation_alpha_max) cycle + do_cycle = .True. + do k=1,N_states + call get_excitation_degree_spin(psi_det(1,1,dominant_det(k)),det(1,1),degree,N_int) + do_cycle = do_cycle .and. (degree > excitation_alpha_max) + enddo + if (do_cycle) cycle endif if (excitation_beta_max >= 0) then - call get_excitation_degree_spin(ref_bitmask(1,2),det(1,2),degree,N_int) - if (degree > excitation_beta_max) cycle + do_cycle = .True. + do k=1,N_states + call get_excitation_degree_spin(psi_det(1,2,dominant_det(k)),det(1,2),degree,N_int) + do_cycle = do_cycle .and. (degree > excitation_beta_max) + enddo + if (do_cycle) cycle endif diff --git a/src/determinants/determinants.irp.f b/src/determinants/determinants.irp.f index 5806634f..2a6057de 100644 --- a/src/determinants/determinants.irp.f +++ b/src/determinants/determinants.irp.f @@ -256,6 +256,26 @@ BEGIN_PROVIDER [ double precision, psi_average_norm_contrib, (psi_det_size) ] enddo END_PROVIDER +BEGIN_PROVIDER [ integer, dominant_det, (N_states) ] + implicit none + BEGIN_DOC + ! Determinant with the largest weight, for each state + END_DOC + integer :: i, k + double precision :: wmax, c + do k=1,N_states + wmax = 0.d0 + do i=1,N_det + c = psi_coef(i,k)*psi_coef(i,k) + if (c > wmax) then + dominant_det(k) = i + wmax = c + endif + enddo + enddo + +END_PROVIDER + !==============================================================================!