1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-11-07 14:43:41 +01:00
This commit is contained in:
Anthony Scemama 2022-04-11 23:03:50 +02:00
parent 44ef244fc0
commit d8a7caf967
3 changed files with 2384 additions and 1306 deletions

View File

@ -0,0 +1,141 @@
program import_integrals_ao
call run
end
subroutine run
use trexio
use map_module
implicit none
BEGIN_DOC
! Program to import integrals from TREXIO
END_DOC
integer(8) :: f ! TREXIO file handle
integer :: rc
integer ::i,j,k,l
double precision :: integral
double precision, allocatable :: A(:,:)
integer :: n_integrals
integer(key_kind), allocatable :: buffer_i(:)
real(integral_kind), allocatable :: buffer_values(:)
f = trexio_open(trexio_filename, 'r', TREXIO_AUTO, rc)
if (f == 0_8) then
print *, 'Unable to open TREXIO file for reading'
print *, 'rc = ', rc
stop -1
endif
double precision, allocatable :: A(:,:)
double precision, allocatable :: V(:)
double precision, allocatable :: s
allocate(A(ao_num, ao_num))
if (trexio_has_nucleus_repulsion(f)) then
rc = trexio_read_nucleus_repulsion(f, s)
if (rc /= TREXIO_SUCCESS) then
print *, irp_here
print *, 'Error reading nuclear repulsion'
stop -1
endif
call ezfio_set_nuclei_nuclear_repulsion(s)
call ezfio_set_nuclei_io_nuclear_repulsion('Read')
endif
if (trexio_has_ao_1e_int_overlap(f) == TREXIO_SUCCESS) then
rc = trexio_read_ao_1e_int_overlap(f, A)
if (rc /= TREXIO_SUCCESS) then
print *, irp_here
print *, 'Error reading AO overlap'
stop -1
endif
call ezfio_set_ao_one_e_ints_ao_integrals_overlap(A)
call ezfio_set_ao_one_e_ints_io_ao_integrals_overlap('Read')
endif
if (trexio_has_ao_1e_int_kinetic(f) == TREXIO_SUCCESS) then
rc = trexio_read_ao_1e_int_kinetic(f, A)
if (rc /= TREXIO_SUCCESS) then
print *, irp_here
print *, 'Error reading AO kinetic integrals'
stop -1
endif
call ezfio_set_ao_one_e_ints_ao_integrals_kinetic(A)
call ezfio_set_ao_one_e_ints_io_ao_integrals_kinetic('Read')
endif
if (trexio_has_ao_1e_int_ecp(f) == TREXIO_SUCCESS) then
rc = trexio_read_ao_1e_int_ecp(f, A)
if (rc /= TREXIO_SUCCESS) then
print *, irp_here
print *, 'Error reading AO ECP local integrals'
stop -1
endif
call ezfio_set_ao_one_e_ints_ao_integrals_pseudo(A)
call ezfio_set_ao_one_e_ints_io_ao_integrals_pseudo('Read')
endif
if (trexio_has_ao_1e_int_potential_n_e(f) == TREXIO_SUCCESS) then
rc = trexio_read_ao_1e_int_potential_n_e(f, A)
if (rc /= TREXIO_SUCCESS) then
print *, irp_here
print *, 'Error reading AO potential N-e integrals'
stop -1
endif
call ezfio_set_ao_one_e_ints_ao_integrals_n_e(A)
call ezfio_set_ao_one_e_ints_io_ao_integrals_n_e('Read')
endif
allocate(buffer_i(ao_num**3), buffer_values(ao_num**3))
iunit = getunitandopen('W.qp','r')
n_integrals=0
i = 1
j = 1
k = 1
l = 1
buffer_values = 0.d0
do
read (iunit,*,end=13) i,j,k,l, integral
if (i<0 .or. i>ao_num) then
print *, i
stop 'i out of bounds in W.qp'
endif
if (j<0 .or. j>ao_num) then
print *, j
stop 'j out of bounds in W.qp'
endif
if (k<0 .or. k>ao_num) then
print *, k
stop 'k out of bounds in W.qp'
endif
if (l<0 .or. l>ao_num) then
print *, l
stop 'l out of bounds in W.qp'
endif
n_integrals += 1
call two_e_integrals_index(i, j, k, l, buffer_i(n_integrals) )
buffer_values(n_integrals) = integral
if (n_integrals == size(buffer_i)) then
call insert_into_ao_integrals_map(n_integrals,buffer_i,buffer_values)
n_integrals = 0
endif
enddo
13 continue
close(iunit)
if (n_integrals > 0) then
call insert_into_ao_integrals_map(n_integrals,buffer_i,buffer_values)
endif
call map_sort(ao_integrals_map)
call map_unique(ao_integrals_map)
call map_save_to_disk(trim(ezfio_filename)//'/work/ao_ints',ao_integrals_map)
call ezfio_set_ao_two_e_ints_io_ao_two_e_integrals('Read')
end

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ subroutine write_champ_csf
implicit none implicit none
integer, parameter :: istate=1 integer, parameter :: istate=1
character*(2048) :: format character*(2048) :: fmt
integer :: i, n_elements, j, k integer :: i, n_elements, j, k
integer, allocatable :: list(:,:) integer, allocatable :: list(:,:)
@ -19,24 +19,24 @@ subroutine write_champ_csf
! Determinants ! Determinants
write(iunit, '(A, I10)') 'determinants', N_det write(iunit, '(A, I10)') 'determinants', N_det
write(format,*) '(', N_det, '(F12.8, X))' write(fmt,*) '(', N_det, '(F12.8, X))'
write(iunit, format) psi_coef(1:N_det,istate) write(iunit, fmt) psi_coef(1:N_det,istate)
write(format,*) '( ', elec_alpha_num, '(I4,X), 2X, ', elec_beta_num, '(I4,X))' write(fmt,*) '( ', elec_alpha_num, '(I4,X), 2X, ', elec_beta_num, '(I4,X))'
allocate ( list(bit_kind_size,2) ) allocate ( list(bit_kind_size,2) )
do i=1, N_det do i=1, N_det
call bitstring_to_list( psi_det(1,1,i), list(1,1), n_elements, N_int) call bitstring_to_list( psi_det(1,1,i), list(1,1), n_elements, N_int)
call bitstring_to_list( psi_det(1,2,i), list(1,2), n_elements, N_int) call bitstring_to_list( psi_det(1,2,i), list(1,2), n_elements, N_int)
write(iunit,format) list(1:elec_alpha_num,1), list(1:elec_beta_num,2) write(iunit,fmt) list(1:elec_alpha_num,1), list(1:elec_beta_num,2)
end do end do
write(iunit, '(A)') 'end' write(iunit, '(A)') 'end'
! CSF ! CSF
write(iunit, '(A, I10, X, I3)') 'csf', N_csf, N_states write(iunit, '(A, I10, X, I3)') 'csf', N_csf, N_states
write(format,*) '(', N_csf, '(F12.8, X))' write(fmt,*) '(', N_csf, '(F12.8, X))'
do i=1,N_states do i=1,N_states
write(iunit, format) psi_csf_coef(1:N_csf,i) write(iunit, fmt) psi_csf_coef(1:N_csf,i)
end do end do
write(iunit, '(A)') 'end' write(iunit, '(A)') 'end'