1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-07-26 12:47:30 +02:00
qp_plugins_scemama/devel/import_integrals/import_integrals_mo.irp.f

212 lines
5.1 KiB
FortranFixed
Raw Normal View History

2020-03-04 14:43:22 +01:00
program import_integrals_mo
2020-03-04 16:17:22 +01:00
PROVIDE mo_num
2020-03-04 14:43:22 +01:00
call run
end
subroutine run
use map_module
implicit none
BEGIN_DOC
! Program to import integrals in the MO basis.
!
2020-03-10 09:44:59 +01:00
! one-electron integrals : format is : i j value
! two-electron integrals : format is : i j k l value
2020-03-04 14:43:22 +01:00
! Dirac's notation is used : <ij|kl> is <r1 r2|r1 r2>
!
! These files are read:
!
! E.qp : Contains the nuclear repulsion energy
!
2021-03-17 14:08:24 +01:00
! T_mo.qp : kinetic energy integrals
2020-03-04 14:43:22 +01:00
!
2021-03-17 14:08:24 +01:00
! P_mo.qp : pseudopotential integrals
2020-03-04 14:43:22 +01:00
!
2021-03-17 14:08:24 +01:00
! V_mo.qp : electron-nucleus potential
2020-03-04 14:43:22 +01:00
!
2021-03-17 14:08:24 +01:00
! H_mo.qp : core hamiltonian. If hmo exists, the other 1-e files are not read
2020-03-04 14:43:22 +01:00
!
2021-03-17 14:08:24 +01:00
! W_mo.qp : electron repulsion integrals
2020-03-04 14:43:22 +01:00
!
END_DOC
2020-03-10 09:44:59 +01:00
2021-03-12 13:13:49 +01:00
integer :: iunit
integer :: getunitandopen
2020-03-04 14:43:22 +01:00
2021-03-12 13:13:49 +01:00
integer :: i,j,k,l
double precision :: integral
double precision, allocatable :: A(:,:)
2020-03-04 14:43:22 +01:00
2021-03-12 13:13:49 +01:00
integer :: n_integrals
logical :: exists
integer(key_kind), allocatable :: buffer_i(:)
2020-03-04 14:43:22 +01:00
real(integral_kind), allocatable :: buffer_values(:)
2020-03-04 16:17:22 +01:00
allocate(buffer_i(mo_num**3), buffer_values(mo_num**3))
2020-03-04 14:43:22 +01:00
allocate (A(mo_num,mo_num))
2021-03-17 14:08:24 +01:00
PROVIDE mo_integrals_map
PROVIDE mo_integrals_threshold
2021-03-12 13:13:49 +01:00
! Nuclear repulsion
2020-03-10 09:44:59 +01:00
2020-03-04 14:43:22 +01:00
A(1,1) = huge(1.d0)
iunit = getunitandopen('E.qp','r')
read (iunit,*,end=9) A(1,1)
9 continue
close(iunit)
if (A(1,1) /= huge(1.d0)) then
call ezfio_set_nuclei_nuclear_repulsion(A(1,1))
2020-03-04 16:17:22 +01:00
call ezfio_set_nuclei_io_nuclear_repulsion('Read')
2020-03-04 14:43:22 +01:00
endif
2021-03-12 13:13:49 +01:00
! One-electron integrals
2020-03-04 14:43:22 +01:00
2021-03-12 13:13:49 +01:00
exists = .False.
2021-03-17 14:08:24 +01:00
inquire(file='H_mo.qp',exist=exists)
2021-03-12 13:13:49 +01:00
if (exists) then
A = 0.d0
i = 1
j = 1
2021-03-17 14:08:24 +01:00
iunit = getunitandopen('H_mo.qp','r')
2021-03-12 13:13:49 +01:00
do
read (iunit,*,end=8) i,j, integral
if (i<0 .or. i>mo_num) then
print *, i
2021-03-17 14:08:24 +01:00
stop 'i out of bounds in H_mo.qp'
2021-03-12 13:13:49 +01:00
endif
if (j<0 .or. j>mo_num) then
print *, j
2021-03-17 14:08:24 +01:00
stop 'j out of bounds in H_mo.qp'
2021-03-12 13:13:49 +01:00
endif
A(i,j) = integral
enddo
8 continue
close(iunit)
call ezfio_set_mo_one_e_ints_mo_one_e_integrals(A)
call ezfio_set_mo_one_e_ints_io_mo_one_e_integrals('Read')
2021-03-17 14:08:24 +01:00
call ezfio_set_mo_one_e_ints_io_mo_integrals_kinetic('None')
call ezfio_set_mo_one_e_ints_io_mo_integrals_pseudo('None')
call ezfio_set_mo_one_e_ints_io_mo_integrals_n_e('None')
2021-03-12 13:13:49 +01:00
else
2021-03-17 14:08:24 +01:00
call ezfio_set_mo_one_e_ints_io_mo_one_e_integrals('None')
2021-03-12 13:13:49 +01:00
A = 0.d0
i = 1
j = 1
2021-03-17 14:08:24 +01:00
iunit = getunitandopen('T_mo.qp','r')
2021-03-12 13:13:49 +01:00
do
read (iunit,*,end=10) i,j, integral
if (i<0 .or. i>mo_num) then
print *, i
2021-03-17 14:08:24 +01:00
stop 'i out of bounds in T_mo.qp'
2021-03-12 13:13:49 +01:00
endif
if (j<0 .or. j>mo_num) then
print *, j
2021-03-17 14:08:24 +01:00
stop 'j out of bounds in T_mo.qp'
2021-03-12 13:13:49 +01:00
endif
A(i,j) = integral
enddo
10 continue
close(iunit)
call ezfio_set_mo_one_e_ints_mo_integrals_kinetic(A)
call ezfio_set_mo_one_e_ints_io_mo_integrals_kinetic('Read')
A = 0.d0
i = 1
j = 1
2021-03-17 14:08:24 +01:00
iunit = getunitandopen('P_mo.qp','r')
2021-03-12 13:13:49 +01:00
do
read (iunit,*,end=14) i,j, integral
if (i<0 .or. i>mo_num) then
print *, i
2021-03-17 14:08:24 +01:00
stop 'i out of bounds in P_mo.qp'
2021-03-12 13:13:49 +01:00
endif
if (j<0 .or. j>mo_num) then
print *, j
2021-03-17 14:08:24 +01:00
stop 'j out of bounds in P_mo.qp'
2021-03-12 13:13:49 +01:00
endif
A(i,j) = integral
enddo
14 continue
close(iunit)
call ezfio_set_mo_one_e_ints_mo_integrals_pseudo(A)
call ezfio_set_mo_one_e_ints_io_mo_integrals_pseudo('Read')
A = 0.d0
i = 1
j = 1
2021-03-17 14:08:24 +01:00
iunit = getunitandopen('V_mo.qp','r')
2021-03-12 13:13:49 +01:00
do
read (iunit,*,end=12) i,j, integral
if (i<0 .or. i>mo_num) then
print *, i
2021-03-17 14:08:24 +01:00
stop 'i out of bounds in V_mo.qp'
2021-03-12 13:13:49 +01:00
endif
if (j<0 .or. j>mo_num) then
print *, j
2021-03-17 14:08:24 +01:00
stop 'j out of bounds in V_mo.qp'
2021-03-12 13:13:49 +01:00
endif
A(i,j) = integral
enddo
12 continue
close(iunit)
call ezfio_set_mo_one_e_ints_mo_integrals_n_e(A)
call ezfio_set_mo_one_e_ints_io_mo_integrals_n_e('Read')
end if
2021-03-12 13:15:32 +01:00
2021-03-12 13:13:49 +01:00
! Two-electron integrals
2020-03-04 14:43:22 +01:00
2021-03-17 14:08:24 +01:00
iunit = getunitandopen('W_mo.qp','r')
2020-03-04 14:43:22 +01:00
n_integrals=0
2020-03-10 09:44:59 +01:00
i = 1
j = 1
k = 1
l = 1
2020-03-04 14:43:22 +01:00
buffer_values = 0.d0
2020-03-10 09:44:59 +01:00
do
2020-03-04 14:43:22 +01:00
read (iunit,*,end=13) i,j,k,l, integral
2020-03-04 16:17:22 +01:00
if (i<0 .or. i>mo_num) then
print *, i
2021-03-17 14:08:24 +01:00
stop 'i out of bounds in W_mo.qp'
2020-03-04 16:17:22 +01:00
endif
if (j<0 .or. j>mo_num) then
print *, j
2021-03-17 14:08:24 +01:00
stop 'j out of bounds in W_mo.qp'
2020-03-04 16:17:22 +01:00
endif
if (k<0 .or. k>mo_num) then
print *, k
2021-03-17 14:08:24 +01:00
stop 'k out of bounds in W_mo.qp'
2020-03-04 16:17:22 +01:00
endif
if (l<0 .or. l>mo_num) then
print *, l
2021-03-17 14:08:24 +01:00
stop 'l out of bounds in W_mo.qp'
2020-03-04 16:17:22 +01:00
endif
2020-03-04 14:43:22 +01:00
n_integrals += 1
2020-03-04 16:17:22 +01:00
call mo_two_e_integrals_index(i, j, k, l, buffer_i(n_integrals) )
2020-03-04 14:43:22 +01:00
buffer_values(n_integrals) = integral
if (n_integrals == size(buffer_i)) then
2021-03-17 14:08:24 +01:00
call map_append(mo_integrals_map, buffer_i, buffer_values, n_integrals)
2020-03-04 14:43:22 +01:00
n_integrals = 0
endif
enddo
13 continue
close(iunit)
2020-03-10 09:44:59 +01:00
2020-03-04 14:43:22 +01:00
if (n_integrals > 0) then
2021-03-17 14:08:24 +01:00
call map_append(mo_integrals_map, buffer_i, buffer_values, n_integrals)
2020-03-04 14:43:22 +01:00
endif
2021-03-17 14:08:24 +01:00
call map_sort(mo_integrals_map)
2020-03-10 09:46:49 +01:00
call map_unique(mo_integrals_map)
2020-03-04 14:43:22 +01:00
call map_save_to_disk(trim(ezfio_filename)//'/work/mo_ints',mo_integrals_map)
call ezfio_set_mo_two_e_ints_io_mo_two_e_integrals('Read')
2020-03-10 09:44:59 +01:00
2020-03-04 14:43:22 +01:00
end
2021-03-17 14:08:24 +01:00