From 24faf493f3ebe247ff532cdc69d3165acf26ce21 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 30 Jul 2015 16:05:28 +0200 Subject: [PATCH] Changed psi_svd into psi_bilinear --- plugins/MRCC_Utils_new/README.rst | 2 +- plugins/Psiref_Utils/README.rst | 35 +++++---- src/Determinants/README.rst | 59 +++++++-------- src/Determinants/det_svd.irp.f | 61 ---------------- src/Determinants/spindeterminants.irp.f | 96 +++++++------------------ 5 files changed, 74 insertions(+), 179 deletions(-) delete mode 100644 src/Determinants/det_svd.irp.f diff --git a/plugins/MRCC_Utils_new/README.rst b/plugins/MRCC_Utils_new/README.rst index 5d2f243e..6f070867 100644 --- a/plugins/MRCC_Utils_new/README.rst +++ b/plugins/MRCC_Utils_new/README.rst @@ -23,7 +23,7 @@ Documentation .. Do not edit this section. It was auto-generated from the .. by the `update_README.py` script. -`apply_excitation_operator `_ +`apply_excitation_operator `_ Undocumented diff --git a/plugins/Psiref_Utils/README.rst b/plugins/Psiref_Utils/README.rst index d00ee877..2dd9b745 100644 --- a/plugins/Psiref_Utils/README.rst +++ b/plugins/Psiref_Utils/README.rst @@ -13,11 +13,11 @@ Documentation .. Do not edit this section. It was auto-generated from the .. by the `update_README.py` script. -`get_index_in_psi_ref_sorted_bit `_ +`get_index_in_psi_ref_sorted_bit `_ Returns the index of the determinant in the ``psi_ref_sorted_bit`` array -`h_matrix_ref `_ +`h_matrix_ref `_ Undocumented @@ -32,16 +32,25 @@ Documentation Set of determinants which are not part of the reference, defined from the application of the reference bitmask on the determinants. idx_non_ref gives the indice of the determinant in psi_det. + idx_non_ref_rev gives the reverse. -`is_in_psi_ref `_ - True if the determinant ``det`` is in the wave function - - -`n_det_non_ref `_ +`idx_non_ref_rev `_ Set of determinants which are not part of the reference, defined from the application of the reference bitmask on the determinants. idx_non_ref gives the indice of the determinant in psi_det. + idx_non_ref_rev gives the reverse. + + +`is_in_psi_ref `_ + True if the determinant ``det`` is in the wave function + + +`n_det_non_ref `_ + Set of determinants which are not part of the reference, defined from the application + of the reference bitmask on the determinants. + idx_non_ref gives the indice of the determinant in psi_det. + idx_non_ref_rev gives the reverse. `particles_operators `_ @@ -51,7 +60,7 @@ Documentation been done going from psi_ref to psi_non_ref -`psi_coef_ref_diagonalized `_ +`psi_coef_ref_diagonalized `_ Undocumented @@ -59,20 +68,22 @@ Documentation Set of determinants which are not part of the reference, defined from the application of the reference bitmask on the determinants. idx_non_ref gives the indice of the determinant in psi_det. + idx_non_ref_rev gives the reverse. `psi_non_ref_coef `_ Set of determinants which are not part of the reference, defined from the application of the reference bitmask on the determinants. idx_non_ref gives the indice of the determinant in psi_det. + idx_non_ref_rev gives the reverse. -`psi_non_ref_coef_sorted_bit `_ +`psi_non_ref_coef_sorted_bit `_ Reference determinants sorted to accelerate the search of a random determinant in the wave function. -`psi_non_ref_sorted_bit `_ +`psi_non_ref_sorted_bit `_ Reference determinants sorted to accelerate the search of a random determinant in the wave function. @@ -82,11 +93,11 @@ Documentation function. -`psi_ref_energy `_ +`psi_ref_energy `_ Undocumented -`psi_ref_energy_diagonalized `_ +`psi_ref_energy_diagonalized `_ Undocumented diff --git a/src/Determinants/README.rst b/src/Determinants/README.rst index c7e455bf..0cdf8673 100644 --- a/src/Determinants/README.rst +++ b/src/Determinants/README.rst @@ -141,8 +141,9 @@ Documentation After calling this subroutine, N_det, psi_det and psi_coef need to be touched -`create_wf_of_psi_svd_matrix `_ - Matrix of wf coefficients. Outer product of alpha and beta determinants +`create_wf_of_psi_bilinear_matrix `_ + Generate a wave function containing all possible products + of alpha and beta determinants `davidson_converged `_ @@ -233,10 +234,6 @@ Documentation Return an integer*8 corresponding to a determinant index for searching -`det_svd `_ - Computes the SVD of the Alpha x Beta determinant coefficient matrix - - `det_to_occ_pattern `_ Transform a determinant to an occupation pattern @@ -347,7 +344,7 @@ Documentation Determinants are taken from the psi_det_sorted_ab array -`generate_all_alpha_beta_det_products `_ +`generate_all_alpha_beta_det_products `_ Create a wave function from all possible alpha x beta determinants @@ -633,6 +630,26 @@ Documentation Wave function sorted by determinants contribution to the norm (state-averaged) +`psi_bilinear_matrix `_ + Coefficient matrix if the wave function is expressed in a bilinear form : + D_a^t C D_b + + +`psi_bilinear_matrix_columns `_ + Sparse coefficient matrix if the wave function is expressed in a bilinear form : + D_a^t C D_b + + +`psi_bilinear_matrix_rows `_ + Sparse coefficient matrix if the wave function is expressed in a bilinear form : + D_a^t C D_b + + +`psi_bilinear_matrix_values `_ + Sparse coefficient matrix if the wave function is expressed in a bilinear form : + D_a^t C D_b + + `psi_cas `_ CAS wave function, defined from the application of the CAS bitmask on the determinants. idx_cas gives the indice of the CAS determinant in psi_det. @@ -774,34 +791,6 @@ Documentation psi_occ_pattern(:,2,j) = jth occ_pattern of the wave function : represent all the double occupation -`psi_svd_alpha `_ - SVD wave function - - -`psi_svd_beta `_ - SVD wave function - - -`psi_svd_coefs `_ - SVD wave function - - -`psi_svd_matrix `_ - Matrix of wf coefficients. Outer product of alpha and beta determinants - - -`psi_svd_matrix_columns `_ - Matrix of wf coefficients. Outer product of alpha and beta determinants - - -`psi_svd_matrix_rows `_ - Matrix of wf coefficients. Outer product of alpha and beta determinants - - -`psi_svd_matrix_values `_ - Matrix of wf coefficients. Outer product of alpha and beta determinants - - `put_gess `_ Undocumented diff --git a/src/Determinants/det_svd.irp.f b/src/Determinants/det_svd.irp.f deleted file mode 100644 index 0a57acf3..00000000 --- a/src/Determinants/det_svd.irp.f +++ /dev/null @@ -1,61 +0,0 @@ -program det_svd - implicit none - BEGIN_DOC -! Computes the SVD of the Alpha x Beta determinant coefficient matrix - END_DOC - integer :: i,j,k - - read_wf = .True. - TOUCH read_wf - - print *, 'SVD matrix before filling' - print *, '=========================' - print *, '' - print *, 'N_det = ', N_det - print *, 'N_det_alpha = ', N_det_alpha_unique - print *, 'N_det_beta = ', N_det_beta_unique - print *, '' - -! do i=1,N_det_alpha_unique -! do j=1,N_det_beta_unique -! print *, i,j,psi_svd_matrix(i,j,:) -! enddo -! enddo - - print *, '' - print *, 'Energy = ', ci_energy - print *, '' - - print *, psi_svd_coefs(1:20,1) - - call generate_all_alpha_beta_det_products - print *, '' - print *, 'Energy = ', ci_energy - print *, '' - - print *, 'SVD matrix after filling' - print *, '========================' - print *, '' - print *, 'N_det = ', N_det - print *, 'N_det_alpha = ', N_det_alpha_unique - print *, 'N_det_beta = ', N_det_beta_unique - print *, '' - print *, '' - call diagonalize_ci - print *, 'Energy = ', ci_energy - - do i=1,N_det_alpha_unique - do j=1,N_det_beta_unique - do k=1,N_states - if (dabs(psi_svd_matrix(i,j,k)) < 1.d-15) then - psi_svd_matrix(i,j,k) = 0.d0 - endif - enddo - enddo - enddo - - print *, '' - print *, psi_svd_coefs(1:20,1) - call save_wavefunction - -end diff --git a/src/Determinants/spindeterminants.irp.f b/src/Determinants/spindeterminants.irp.f index 5279dc2c..5994798d 100644 --- a/src/Determinants/spindeterminants.irp.f +++ b/src/Determinants/spindeterminants.irp.f @@ -344,9 +344,9 @@ subroutine write_spindeterminants call ezfio_set_spindeterminants_psi_det_beta(psi_det_beta_unique) deallocate(tmpdet) - call ezfio_set_spindeterminants_psi_coef_matrix_values(psi_svd_matrix_values) - call ezfio_set_spindeterminants_psi_coef_matrix_rows(psi_svd_matrix_rows) - call ezfio_set_spindeterminants_psi_coef_matrix_columns(psi_svd_matrix_columns) + call ezfio_set_spindeterminants_psi_coef_matrix_values(psi_bilinear_matrix_values) + call ezfio_set_spindeterminants_psi_coef_matrix_rows(psi_bilinear_matrix_rows) + call ezfio_set_spindeterminants_psi_coef_matrix_columns(psi_bilinear_matrix_columns) end @@ -357,13 +357,14 @@ end ! ! !==============================================================================! -BEGIN_PROVIDER [ double precision, psi_svd_matrix_values, (N_det,N_states) ] -&BEGIN_PROVIDER [ integer, psi_svd_matrix_rows, (N_det) ] -&BEGIN_PROVIDER [ integer, psi_svd_matrix_columns, (N_det) ] +BEGIN_PROVIDER [ double precision, psi_bilinear_matrix_values, (N_det,N_states) ] +&BEGIN_PROVIDER [ integer, psi_bilinear_matrix_rows, (N_det) ] +&BEGIN_PROVIDER [ integer, psi_bilinear_matrix_columns, (N_det) ] use bitmasks implicit none BEGIN_DOC -! Matrix of wf coefficients. Outer product of alpha and beta determinants +! Sparse coefficient matrix if the wave function is expressed in a bilinear form : +! D_a^t C D_b END_DOC integer :: i,j,k, l integer(bit_kind) :: tmp_det(N_int,2) @@ -382,41 +383,43 @@ BEGIN_PROVIDER [ double precision, psi_svd_matrix_values, (N_det,N_states) ] j = get_index_in_psi_det_beta_unique (psi_det(1,2,k),N_int) do l=1,N_states - psi_svd_matrix_values(k,l) = psi_coef(k,l) + psi_bilinear_matrix_values(k,l) = psi_coef(k,l) enddo - psi_svd_matrix_rows(k) = i - psi_svd_matrix_columns(k) = j + psi_bilinear_matrix_rows(k) = i + psi_bilinear_matrix_columns(k) = j to_sort(k) = N_det_alpha_unique * (j-1) + i iorder(k) = k enddo call isort(to_sort, iorder, N_det) - call iset_order(psi_svd_matrix_rows,iorder,N_det) - call iset_order(psi_svd_matrix_columns,iorder,N_det) - call dset_order(psi_svd_matrix_values,iorder,N_det) + call iset_order(psi_bilinear_matrix_rows,iorder,N_det) + call iset_order(psi_bilinear_matrix_columns,iorder,N_det) + call dset_order(psi_bilinear_matrix_values,iorder,N_det) deallocate(iorder,to_sort) END_PROVIDER -BEGIN_PROVIDER [ double precision, psi_svd_matrix, (N_det_alpha_unique,N_det_beta_unique,N_states) ] +BEGIN_PROVIDER [ double precision, psi_bilinear_matrix, (N_det_alpha_unique,N_det_beta_unique,N_states) ] implicit none BEGIN_DOC -! Matrix of wf coefficients. Outer product of alpha and beta determinants +! Coefficient matrix if the wave function is expressed in a bilinear form : +! D_a^t C D_b END_DOC integer :: i,j,k,istate - psi_svd_matrix = 0.d0 + psi_bilinear_matrix = 0.d0 do k=1,N_det - i = psi_svd_matrix_rows(k) - j = psi_svd_matrix_columns(k) + i = psi_bilinear_matrix_rows(k) + j = psi_bilinear_matrix_columns(k) do istate=1,N_states - psi_svd_matrix(i,j,istate) = psi_svd_matrix_values(k,istate) + psi_bilinear_matrix(i,j,istate) = psi_bilinear_matrix_values(k,istate) enddo enddo END_PROVIDER -subroutine create_wf_of_psi_svd_matrix +subroutine create_wf_of_psi_bilinear_matrix use bitmasks implicit none BEGIN_DOC -! Matrix of wf coefficients. Outer product of alpha and beta determinants +! Generate a wave function containing all possible products +! of alpha and beta determinants END_DOC integer :: i,j,k integer(bit_kind) :: tmp_det(N_int,2) @@ -437,8 +440,8 @@ subroutine create_wf_of_psi_svd_matrix idx = get_index_in_psi_det_sorted_bit(tmp_det,N_int) if (idx > 0) then do k=1,N_states - psi_coef_sorted_bit(idx,k) = psi_svd_matrix(i,j,k) - norm(k) += psi_svd_matrix(i,j,k) + psi_coef_sorted_bit(idx,k) = psi_bilinear_matrix(i,j,k) + norm(k) += psi_bilinear_matrix(i,j,k) enddo endif enddo @@ -506,51 +509,4 @@ subroutine generate_all_alpha_beta_det_products SOFT_TOUCH psi_det psi_coef N_det end - BEGIN_PROVIDER [ double precision, psi_svd_alpha, (N_det_alpha_unique,N_det_alpha_unique,N_states) ] -&BEGIN_PROVIDER [ double precision, psi_svd_beta , (N_det_beta_unique,N_det_beta_unique,N_states) ] -&BEGIN_PROVIDER [ double precision, psi_svd_coefs, (N_det_beta_unique,N_states) ] - implicit none - BEGIN_DOC - ! SVD wave function - END_DOC - - integer :: lwork, info, istate - double precision, allocatable :: work(:), tmp(:,:), copy(:,:) - allocate (work(1),tmp(N_det_beta_unique,N_det_beta_unique), & - copy(size(psi_svd_matrix,1),size(psi_svd_matrix,2))) - - do istate = 1,N_states - copy(:,:) = psi_svd_matrix(:,:,istate) - lwork=-1 - call dgesvd('A','A', N_det_alpha_unique, N_det_beta_unique, & - copy, size(copy,1), & - psi_svd_coefs(1,istate), psi_svd_alpha(1,1,istate), & - size(psi_svd_alpha,1), & - tmp, size(psi_svd_beta,2), & - work, lwork, info) - lwork = work(1) - deallocate(work) - allocate(work(lwork)) - call dgesvd('A','A', N_det_alpha_unique, N_det_beta_unique, & - copy, size(copy,1), & - psi_svd_coefs(1,istate), psi_svd_alpha(1,1,istate), & - size(psi_svd_alpha,1), & - tmp, size(psi_svd_beta,2), & - work, lwork, info) - deallocate(work) - if (info /= 0) then - print *, irp_here//': error in det SVD' - stop 1 - endif - integer :: i,j - do j=1,N_det_beta_unique - do i=1,N_det_beta_unique - psi_svd_beta(i,j,istate) = tmp(j,i) - enddo - enddo - deallocate(tmp,copy) - enddo - -END_PROVIDER -