1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-12-22 12:23:37 +01:00

Merge branch 'master' of gitlab.com:scemama/qp_plugins_scemama

This commit is contained in:
Anthony Scemama 2022-05-25 14:59:33 +02:00
commit 50d842bfa7
6 changed files with 377 additions and 105 deletions

View File

@ -16,15 +16,27 @@ doc: If True, export two-body reduced density matrix
interface: ezfio, ocaml, provider interface: ezfio, ocaml, provider
default: False default: False
[export_ao_ints] [export_ao_one_e_ints]
type: logical
doc: If True, export one-electron integrals in AO basis
interface: ezfio, ocaml, provider
default: False
[export_mo_one_e_ints]
type: logical
doc: If True, export one-electron integrals in MO basis
interface: ezfio, ocaml, provider
default: False
[export_ao_two_e_ints]
type: logical type: logical
doc: If True, export two-electron integrals in AO basis doc: If True, export two-electron integrals in AO basis
interface: ezfio, ocaml, provider interface: ezfio, ocaml, provider
default: False default: False
[export_mo_ints] [export_mo_two_e_ints]
type: logical type: logical
doc: If True, export two-electron integrals in MO basis doc: If True, export two-electron integrals in MO basis
interface: ezfio, ocaml, provider interface: ezfio, ocaml, provider
default: True default: False

View File

@ -12,8 +12,8 @@ subroutine run
! Exports the wave function in TREXIO format ! Exports the wave function in TREXIO format
END_DOC END_DOC
integer(8) :: f ! TREXIO file handle integer(trexio_t) :: f ! TREXIO file handle
integer :: rc integer(trexio_exit_code) :: rc
double precision, allocatable :: factor(:) double precision, allocatable :: factor(:)
print *, 'TREXIO file : '//trim(trexio_filename) print *, 'TREXIO file : '//trim(trexio_filename)
@ -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
@ -41,10 +40,10 @@ subroutine run
print *, 'Electrons' print *, 'Electrons'
rc = trexio_write_electron_up_num(f, elec_alpha_num) rc = trexio_write_electron_up_num(f, elec_alpha_num)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_electron_dn_num(f, elec_beta_num) rc = trexio_write_electron_dn_num(f, elec_beta_num)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
! Nuclei ! Nuclei
@ -53,19 +52,19 @@ subroutine run
print *, 'Nuclei' print *, 'Nuclei'
rc = trexio_write_nucleus_num(f, nucl_num) rc = trexio_write_nucleus_num(f, nucl_num)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_nucleus_charge(f, nucl_charge) rc = trexio_write_nucleus_charge(f, nucl_charge)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_nucleus_coord(f, nucl_coord_transp) rc = trexio_write_nucleus_coord(f, nucl_coord_transp)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_nucleus_label(f, nucl_label, 32) rc = trexio_write_nucleus_label(f, nucl_label, 32)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_nucleus_repulsion(f, nuclear_repulsion) rc = trexio_write_nucleus_repulsion(f, nuclear_repulsion)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
! Pseudo-potentials ! Pseudo-potentials
@ -142,28 +141,28 @@ subroutine run
lmax(:) = lmax(:)+1 lmax(:) = lmax(:)+1
rc = trexio_write_ecp_max_ang_mom_plus_1(f, lmax) rc = trexio_write_ecp_max_ang_mom_plus_1(f, lmax)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ecp_z_core(f, int(nucl_charge_remove)) rc = trexio_write_ecp_z_core(f, int(nucl_charge_remove))
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ecp_num(f, num) rc = trexio_write_ecp_num(f, num)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ecp_ang_mom(f, ang_mom) rc = trexio_write_ecp_ang_mom(f, ang_mom)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ecp_nucleus_index(f, nucleus_index) rc = trexio_write_ecp_nucleus_index(f, nucleus_index)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ecp_exponent(f, exponent) rc = trexio_write_ecp_exponent(f, exponent)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ecp_coefficient(f, coefficient) rc = trexio_write_ecp_coefficient(f, coefficient)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ecp_power(f, power) rc = trexio_write_ecp_power(f, power)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
endif endif
@ -175,19 +174,19 @@ subroutine run
rc = trexio_write_basis_type(f, 'Gaussian', len('Gaussian')) rc = trexio_write_basis_type(f, 'Gaussian', len('Gaussian'))
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_basis_prim_num(f, prim_num) rc = trexio_write_basis_prim_num(f, prim_num)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_basis_shell_num(f, shell_num) rc = trexio_write_basis_shell_num(f, shell_num)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_basis_nucleus_index(f, basis_nucleus_index) rc = trexio_write_basis_nucleus_index(f, basis_nucleus_index)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_basis_shell_ang_mom(f, shell_ang_mom) rc = trexio_write_basis_shell_ang_mom(f, shell_ang_mom)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
allocate(factor(shell_num)) allocate(factor(shell_num))
if (ao_normalized) then if (ao_normalized) then
@ -196,18 +195,18 @@ subroutine run
factor(1:shell_num) = 1.d0 factor(1:shell_num) = 1.d0
endif endif
rc = trexio_write_basis_shell_factor(f, factor) rc = trexio_write_basis_shell_factor(f, factor)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
deallocate(factor) deallocate(factor)
rc = trexio_write_basis_shell_index(f, shell_index) rc = trexio_write_basis_shell_index(f, shell_index)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_basis_exponent(f, prim_expo) rc = trexio_write_basis_exponent(f, prim_expo)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_basis_coefficient(f, prim_coef) rc = trexio_write_basis_coefficient(f, prim_coef)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
allocate(factor(prim_num)) allocate(factor(prim_num))
if (primitives_normalized) then if (primitives_normalized) then
@ -216,7 +215,7 @@ subroutine run
factor(1:prim_num) = 1.d0 factor(1:prim_num) = 1.d0
endif endif
rc = trexio_write_basis_prim_factor(f, factor) rc = trexio_write_basis_prim_factor(f, factor)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
deallocate(factor) deallocate(factor)
@ -226,13 +225,13 @@ subroutine run
print *, 'AOs' print *, 'AOs'
rc = trexio_write_ao_num(f, ao_num) rc = trexio_write_ao_num(f, ao_num)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ao_cartesian(f, 1) rc = trexio_write_ao_cartesian(f, 1)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ao_shell(f, ao_shell) rc = trexio_write_ao_shell(f, ao_shell)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
integer :: i, pow0(3), powA(3), j, k, l, nz integer :: i, pow0(3), powA(3), j, k, l, nz
double precision :: normA, norm0, C_A(3), overlap_x, overlap_z, overlap_y, c double precision :: normA, norm0, C_A(3), overlap_x, overlap_z, overlap_y, c
@ -252,38 +251,38 @@ subroutine run
factor(:) = 1.d0 factor(:) = 1.d0
endif endif
rc = trexio_write_ao_normalization(f, factor) rc = trexio_write_ao_normalization(f, factor)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
deallocate(factor) deallocate(factor)
! One-e AO integrals ! One-e AO integrals
! ------------------ ! ------------------
print *, 'AO integrals' if (export_ao_one_e_ints) then
print *, 'AO one-e integrals'
rc = trexio_write_ao_1e_int_overlap(f,ao_overlap) rc = trexio_write_ao_1e_int_overlap(f,ao_overlap)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ao_1e_int_kinetic(f,ao_kinetic_integrals) rc = trexio_write_ao_1e_int_kinetic(f,ao_kinetic_integrals)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_ao_1e_int_potential_n_e(f,ao_integrals_n_e) rc = trexio_write_ao_1e_int_potential_n_e(f,ao_integrals_n_e)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
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) call trexio_assert(rc, TREXIO_SUCCESS)
endif
rc = trexio_write_ao_1e_int_ecp_non_local(f,ao_pseudo_integrals_non_local) rc = trexio_write_ao_1e_int_core_hamiltonian(f,ao_one_e_integrals)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
endif end if
rc = trexio_write_ao_1e_int_core_hamiltonian(f,ao_one_e_integrals)
call check_success(rc)
! Two-e AO integrals ! Two-e AO integrals
! ------------------ ! ------------------
if (export_ao_ints) then if (export_ao_two_e_ints) then
print *, 'AO two-e integrals'
PROVIDE ao_two_e_integrals_in_map PROVIDE ao_two_e_integrals_in_map
integer(8), parameter :: BUFSIZE=10000_8 integer(8), parameter :: BUFSIZE=10000_8
@ -312,7 +311,7 @@ subroutine run
eri_index(4,icount) = l eri_index(4,icount) = l
if (icount == BUFSIZE) then if (icount == BUFSIZE) then
rc = trexio_write_ao_2e_int_eri(f, offset, icount, eri_index, eri_buffer) rc = trexio_write_ao_2e_int_eri(f, offset, icount, eri_index, eri_buffer)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
offset += icount offset += icount
icount = 0_8 icount = 0_8
end if end if
@ -323,7 +322,7 @@ subroutine run
if (icount >= 0_8) then if (icount >= 0_8) then
rc = trexio_write_ao_2e_int_eri(f, offset, icount, eri_index, eri_buffer) rc = trexio_write_ao_2e_int_eri(f, offset, icount, eri_index, eri_buffer)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
end if end if
end if end if
@ -334,41 +333,41 @@ subroutine run
print *, 'MOs' print *, 'MOs'
rc = trexio_write_mo_type(f, mo_label, len(trim(mo_label))) rc = trexio_write_mo_type(f, mo_label, len(trim(mo_label)))
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_mo_num(f, mo_num) rc = trexio_write_mo_num(f, mo_num)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_mo_coefficient(f, mo_coef) rc = trexio_write_mo_coefficient(f, mo_coef)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
! One-e MO integrals ! One-e MO integrals
! ------------------ ! ------------------
print *, 'MO integrals' if (export_mo_two_e_ints) then
print *, 'MO one-e integrals'
rc = trexio_write_mo_1e_int_kinetic(f,mo_kinetic_integrals) rc = trexio_write_mo_1e_int_kinetic(f,mo_kinetic_integrals)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_mo_1e_int_potential_n_e(f,mo_integrals_n_e) rc = trexio_write_mo_1e_int_potential_n_e(f,mo_integrals_n_e)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
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) call trexio_assert(rc, TREXIO_SUCCESS)
endif
rc = trexio_write_mo_1e_int_ecp_non_local(f,mo_pseudo_integrals_non_local) rc = trexio_write_mo_1e_int_core_hamiltonian(f,mo_one_e_integrals)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
endif end if
rc = trexio_write_mo_1e_int_core_hamiltonian(f,mo_one_e_integrals)
call check_success(rc)
! Two-e MO integrals ! Two-e MO integrals
! ------------------ ! ------------------
if (export_mo_ints) then if (export_mo_two_e_ints) then
print *, 'MO two-e integrals'
PROVIDE mo_two_e_integrals_in_map PROVIDE mo_two_e_integrals_in_map
double precision, external :: mo_two_e_integral double precision, external :: mo_two_e_integral
@ -392,7 +391,7 @@ subroutine run
eri_index(4,icount) = l eri_index(4,icount) = l
if (icount == BUFSIZE) then if (icount == BUFSIZE) then
rc = trexio_write_mo_2e_int_eri(f, offset, icount, eri_index, eri_buffer) rc = trexio_write_mo_2e_int_eri(f, offset, icount, eri_index, eri_buffer)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
offset += icount offset += icount
icount = 0_8 icount = 0_8
end if end if
@ -403,7 +402,7 @@ subroutine run
if (icount >= 0_8) then if (icount >= 0_8) then
rc = trexio_write_mo_2e_int_eri(f, offset, icount, eri_index, eri_buffer) rc = trexio_write_mo_2e_int_eri(f, offset, icount, eri_index, eri_buffer)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
end if end if
end if end if
@ -413,13 +412,13 @@ subroutine run
! --------- ! ---------
rc = trexio_write_rdm_1e(f,one_e_dm_mo) rc = trexio_write_rdm_1e(f,one_e_dm_mo)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_rdm_1e_up(f,one_e_dm_mo_alpha_average) rc = trexio_write_rdm_1e_up(f,one_e_dm_mo_alpha_average)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_rdm_1e_dn(f,one_e_dm_mo_beta_average) rc = trexio_write_rdm_1e_dn(f,one_e_dm_mo_beta_average)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
! Two-e RDM ! Two-e RDM
@ -427,6 +426,7 @@ subroutine run
if (export_rdm) then if (export_rdm) then
PROVIDE two_e_dm_mo PROVIDE two_e_dm_mo
print *, 'Two-e RDM'
icount = 0_8 icount = 0_8
offset = 0_8 offset = 0_8
@ -444,7 +444,7 @@ subroutine run
eri_index(4,icount) = l eri_index(4,icount) = l
if (icount == BUFSIZE) then if (icount == BUFSIZE) then
rc = trexio_write_rdm_2e(f, offset, icount, eri_index, eri_buffer) rc = trexio_write_rdm_2e(f, offset, icount, eri_index, eri_buffer)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
offset += icount offset += icount
icount = 0_8 icount = 0_8
end if end if
@ -455,29 +455,72 @@ subroutine run
if (icount >= 0_8) then if (icount >= 0_8) then
rc = trexio_write_rdm_2e(f, offset, icount, eri_index, eri_buffer) rc = trexio_write_rdm_2e(f, offset, icount, eri_index, eri_buffer)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
end if end if
end if end if
! ------------------------------------------------------------------------------ ! ------------------------------------------------------------------------------
! Determinants
! ------------
integer*8, allocatable :: det_buffer(:,:,:)
double precision, allocatable :: coef_buffer(:,:)
integer :: nint
! rc = trexio_read_determinant_int64_num(f, nint)
! call trexio_assert(rc, TREXIO_SUCCESS)
nint = N_int
if (nint /= N_int) then
stop 'Problem with N_int'
endif
allocate ( det_buffer(nint, 2, BUFSIZE), coef_buffer(BUFSIZE, n_states) )
icount = 0_8
offset = 0_8
rc = trexio_write_state_num(f, n_states)
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_set_state (f, 0)
call trexio_assert(rc, TREXIO_SUCCESS)
do k=1,n_det
icount += 1_8
det_buffer(1:nint, 1:2, icount) = psi_det(1:N_int, 1:2, k)
coef_buffer(icount,1:N_states) = psi_coef(k,1:N_states)
if (icount == BUFSIZE) then
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_determinant_list(f, offset, icount, det_buffer)
call trexio_assert(rc, TREXIO_SUCCESS)
do i=1,N_states
rc = trexio_set_state (f, i-1)
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_determinant_coefficient(f, offset, icount, coef_buffer(1,i))
end do
rc = trexio_set_state (f, 0)
offset += icount
icount = 0_8
end if
end do
if (icount >= 0_8) then
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_determinant_list(f, offset, icount, det_buffer)
call trexio_assert(rc, TREXIO_SUCCESS)
do i=1,N_states
rc = trexio_set_state (f, i-1)
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_write_determinant_coefficient(f, offset, icount, coef_buffer(1,i))
end do
rc = trexio_set_state (f, 0)
end if
deallocate ( det_buffer, coef_buffer )
rc = trexio_close(f) rc = trexio_close(f)
call check_success(rc) call trexio_assert(rc, TREXIO_SUCCESS)
end end
subroutine check_success(rc)
use trexio
implicit none
integer, intent(in) :: rc
character*(128) :: str
if (rc /= TREXIO_SUCCESS) then
call trexio_string_of_error(rc,str)
print *, 'TREXIO Error: ' //trim(str)
stop -1
endif
end
! -*- mode: f90 -*- ! -*- mode: f90 -*-

View File

@ -0,0 +1,79 @@
program import_determinants_ao
call run
end
subroutine run
use trexio
use map_module
implicit none
BEGIN_DOC
! Program to import determinants from TREXIO
END_DOC
integer(trexio_t) :: f ! TREXIO file handle
integer(trexio_exit_code) :: rc
integer :: m
double precision, allocatable :: coef_buffer(:,:)
integer*8 , allocatable :: det_buffer(:,:,:)
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
! Determinants
! ------------
integer :: nint, nstates
integer :: bufsize
rc = trexio_read_state_num(f, nstates)
call trexio_assert(rc, TREXIO_SUCCESS)
! rc = trexio_read_determinant_int64_num(f, nint)
! call trexio_assert(rc, TREXIO_SUCCESS)
nint = N_int
if (nint /= N_int) then
stop 'Problem with N_int'
endif
integer*8 :: offset, icount
rc = trexio_read_determinant_num(f, bufsize)
call trexio_assert(rc, TREXIO_SUCCESS)
print *, 'N_det = ', bufsize
allocate ( det_buffer(nint, 2, bufsize), coef_buffer(bufsize, n_states) )
offset = 0_8
icount = bufsize
rc = trexio_read_determinant_list(f, offset, icount, det_buffer)
call trexio_assert(rc, TREXIO_SUCCESS)
if (icount /= bufsize) then
print *, 'error: bufsize /= N_det: ', bufsize, icount
stop -1
endif
do m=1,nstates
rc = trexio_set_state(f, m-1)
call trexio_assert(rc, TREXIO_SUCCESS)
rc = trexio_read_determinant_coefficient(f, offset, icount, coef_buffer(1,m))
call trexio_assert(rc, TREXIO_SUCCESS)
if (icount /= bufsize) then
print *, 'error: bufsize /= N_det for state', m, ':', icount, bufsize
stop -1
endif
enddo
call save_wavefunction_general(bufsize,nstates,det_buffer,size(coef_buffer,1),coef_buffer)
end

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(trexio_t) :: f ! TREXIO file handle
integer(trexio_exit_code) :: 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,13 +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: try:
label = labels[trexio.read_mo_type(trexio_file)] label = labels[trexio.read_mo_type(trexio_file)]
except KeyError: except:
label = "Canonical" label = "None"
ezfio.set_mo_basis_mo_label(label) ezfio.set_mo_basis_mo_label(label)
try: try:
@ -372,8 +373,8 @@ def get_full_path(file_path):
if __name__ == '__main__': if __name__ == '__main__':
ARGUMENTS = docopt(__doc__) ARGUMENTS = docopt(__doc__)
FILE = ARGUMENTS['FILE'] FILE = get_full_path(ARGUMENTS['FILE'])
trexio_filename = get_full_path(FILE) trexio_filename = FILE
if ARGUMENTS["--output"]: if ARGUMENTS["--output"]:
EZFIO_FILE = get_full_path(ARGUMENTS["--output"]) EZFIO_FILE = get_full_path(ARGUMENTS["--output"])

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'