1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-11-08 23:23:42 +01:00

Compare commits

...

2 Commits

Author SHA1 Message Date
04f6220317 Update trexio module 2022-04-11 23:05:24 +02:00
d8a7caf967 Fixed #1 2022-04-11 23:03:50 +02:00
5 changed files with 2348 additions and 1401 deletions

View File

@ -21,13 +21,12 @@ subroutine run
call system('rm -rf '//trim(trexio_filename)//'.bak') call system('rm -rf '//trim(trexio_filename)//'.bak')
call system('mv '//trim(trexio_filename)//' '//trim(trexio_filename)//'.bak') call system('mv '//trim(trexio_filename)//' '//trim(trexio_filename)//'.bak')
! call system('mv '//trim(trexio_filename)//' '//trim(trexio_filename)''//.bak)
if (backend == 0) then if (backend == 0) then
f = trexio_open(trexio_filename, 'w', TREXIO_HDF5, rc) f = trexio_open(trexio_filename, 'w', TREXIO_HDF5, rc)
else if (backend == 1) then else if (backend == 1) then
f = trexio_open(trexio_filename, 'w', TREXIO_TEXT, rc) f = trexio_open(trexio_filename, 'w', TREXIO_TEXT, rc)
endif endif
if (f == 0) then if (f == 0_8) then
print *, 'Unable to open TREXIO file for writing' print *, 'Unable to open TREXIO file for writing'
print *, 'rc = ', rc print *, 'rc = ', rc
stop -1 stop -1
@ -270,10 +269,7 @@ subroutine run
call check_success(rc) call check_success(rc)
if (do_pseudo) then if (do_pseudo) then
rc = trexio_write_ao_1e_int_ecp_local(f,ao_pseudo_integrals_local) rc = trexio_write_ao_1e_int_ecp(f, ao_pseudo_integrals_local + ao_pseudo_integrals_non_local)
call check_success(rc)
rc = trexio_write_ao_1e_int_ecp_non_local(f,ao_pseudo_integrals_non_local)
call check_success(rc) call check_success(rc)
endif endif
@ -355,10 +351,7 @@ subroutine run
call check_success(rc) call check_success(rc)
if (do_pseudo) then if (do_pseudo) then
rc = trexio_write_mo_1e_int_ecp_local(f,mo_pseudo_integrals_local) rc = trexio_write_mo_1e_int_ecp(f,mo_pseudo_integrals_local)
call check_success(rc)
rc = trexio_write_mo_1e_int_ecp_non_local(f,mo_pseudo_integrals_non_local)
call check_success(rc) call check_success(rc)
endif endif

View File

@ -0,0 +1,137 @@
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,m
double precision :: integral
integer :: n_integrals
integer(key_kind), allocatable :: buffer_i(:)
real(integral_kind), allocatable :: buffer_values(:)
double precision, allocatable :: A(:,:)
double precision, allocatable :: V(:)
integer , allocatable :: Vi(:,:)
double precision, allocatable :: s
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
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
! AO integrals
! ------------
allocate(A(ao_num, ao_num))
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
deallocate(A)
! AO 2e integrals
! ---------------
allocate(buffer_i(ao_num**3), buffer_values(ao_num**3))
allocate(Vi(4,ao_num**3), V(ao_num**3))
integer*8 :: offset, icount
offset = 0_8
icount = 0_8
rc = TREXIO_SUCCESS
do while (icount == size(V))
rc = trexio_read_ao_2e_int_eri(f, offset, icount, Vi, V)
if (rc /= TREXIO_SUCCESS) then
exit
endif
do m=1,icount
i = Vi(1,m)
j = Vi(2,m)
k = Vi(3,m)
l = Vi(4,m)
integral = V(m)
call two_e_integrals_index(i, j, k, l, buffer_i(m) )
buffer_values(m) = integral
enddo
call insert_into_ao_integrals_map(int(icount,4),buffer_i,buffer_values)
offset = offset + icount
end do
n_integrals = offset
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

View File

@ -245,10 +245,14 @@ def write_ezfio(trexio_filename, filename):
labels = { "Canonical" : "Canonical", labels = { "Canonical" : "Canonical",
"RHF" : "Canonical", "RHF" : "Canonical",
"BOYS" : "Localized",
"ROHF" : "Canonical", "ROHF" : "Canonical",
"UHF" : "Canonical", "UHF" : "Canonical",
"Natural": "Natural" } "Natural": "Natural" }
try:
label = labels[trexio.read_mo_type(trexio_file)] label = labels[trexio.read_mo_type(trexio_file)]
except:
label = "None"
ezfio.set_mo_basis_mo_label(label) ezfio.set_mo_basis_mo_label(label)
try: try:

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'