10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-26 15:12:14 +02:00

Changed psi_svd into psi_bilinear

This commit is contained in:
Anthony Scemama 2015-07-30 16:05:28 +02:00
parent e23dba89ba
commit 24faf493f3
5 changed files with 74 additions and 179 deletions

View File

@ -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 <http://github.com/LCPQ/quantum_package/tree/master/src/MRCC_Utils_new/mrcc_dress.irp.f#L138>`_
`apply_excitation_operator <http://github.com/LCPQ/quantum_package/tree/master/src/MRCC_Utils_new/mrcc_dress.irp.f#L132>`_
Undocumented

View File

@ -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 <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L136>`_
`get_index_in_psi_ref_sorted_bit <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L140>`_
Returns the index of the determinant in the ``psi_ref_sorted_bit`` array
`h_matrix_ref <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L70>`_
`h_matrix_ref <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L74>`_
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 <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L122>`_
True if the determinant ``det`` is in the wave function
`n_det_non_ref <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L21>`_
`idx_non_ref_rev <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L21>`_
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 <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L126>`_
True if the determinant ``det`` is in the wave function
`n_det_non_ref <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L22>`_
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 <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_excitations_operators.irp.f#L4>`_
@ -51,7 +60,7 @@ Documentation
been done going from psi_ref to psi_non_ref
`psi_coef_ref_diagonalized <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L82>`_
`psi_coef_ref_diagonalized <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L86>`_
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 <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L19>`_
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 <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L58>`_
`psi_non_ref_coef_sorted_bit <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L62>`_
Reference determinants sorted to accelerate the search of a random determinant in the wave
function.
`psi_non_ref_sorted_bit <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L57>`_
`psi_non_ref_sorted_bit <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L61>`_
Reference determinants sorted to accelerate the search of a random determinant in the wave
function.
@ -82,11 +93,11 @@ Documentation
function.
`psi_ref_energy <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L101>`_
`psi_ref_energy <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L105>`_
Undocumented
`psi_ref_energy_diagonalized <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L83>`_
`psi_ref_energy_diagonalized <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_Utils/psi_ref_utils.irp.f#L87>`_
Undocumented

View File

@ -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 <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L415>`_
Matrix of wf coefficients. Outer product of alpha and beta determinants
`create_wf_of_psi_bilinear_matrix <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L417>`_
Generate a wave function containing all possible products
of alpha and beta determinants
`davidson_converged <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/davidson.irp.f#L382>`_
@ -233,10 +234,6 @@ Documentation
Return an integer*8 corresponding to a determinant index for searching
`det_svd <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/det_svd.irp.f#L1>`_
Computes the SVD of the Alpha x Beta determinant coefficient matrix
`det_to_occ_pattern <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/occ_pattern.irp.f#L2>`_
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 <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L469>`_
`generate_all_alpha_beta_det_products <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L472>`_
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 <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L400>`_
Coefficient matrix if the wave function is expressed in a bilinear form :
D_a^t C D_b
`psi_bilinear_matrix_columns <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L362>`_
Sparse coefficient matrix if the wave function is expressed in a bilinear form :
D_a^t C D_b
`psi_bilinear_matrix_rows <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L361>`_
Sparse coefficient matrix if the wave function is expressed in a bilinear form :
D_a^t C D_b
`psi_bilinear_matrix_values <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L360>`_
Sparse coefficient matrix if the wave function is expressed in a bilinear form :
D_a^t C D_b
`psi_cas <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/psi_cas.irp.f#L3>`_
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 <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L509>`_
SVD wave function
`psi_svd_beta <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L510>`_
SVD wave function
`psi_svd_coefs <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L511>`_
SVD wave function
`psi_svd_matrix <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L399>`_
Matrix of wf coefficients. Outer product of alpha and beta determinants
`psi_svd_matrix_columns <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L362>`_
Matrix of wf coefficients. Outer product of alpha and beta determinants
`psi_svd_matrix_rows <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L361>`_
Matrix of wf coefficients. Outer product of alpha and beta determinants
`psi_svd_matrix_values <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/spindeterminants.irp.f#L360>`_
Matrix of wf coefficients. Outer product of alpha and beta determinants
`put_gess <http://github.com/LCPQ/quantum_package/tree/master/src/Determinants/guess_triplet.irp.f#L1>`_
Undocumented

View File

@ -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

View File

@ -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