1
0
mirror of https://github.com/TREX-CoE/fparser.git synced 2024-11-03 20:54:11 +01:00

reading the det file block

This commit is contained in:
Ravindra Shinde 2021-02-23 22:44:22 +01:00
parent 86c224105b
commit 3d304d79a2
4 changed files with 149 additions and 4 deletions

1
.gitignore vendored
View File

@ -5,7 +5,6 @@
*.lof *.lof
*.log *.log
*.lot *.lot
*.out
*.toc *.toc
auto/ auto/
.DS_Store .DS_Store

View File

@ -5,6 +5,7 @@ PROGRAM iochamp
USE fdf USE fdf
USE prec USE prec
USE parse USE parse
use io_fdf
implicit none implicit none
!--------------------------------------------------------------- Local Variables !--------------------------------------------------------------- Local Variables
integer, parameter :: maxa = 100 integer, parameter :: maxa = 100
@ -31,6 +32,11 @@ PROGRAM iochamp
character(len=20) :: real_format = '(A, T20, F14.5)' character(len=20) :: real_format = '(A, T20, F14.5)'
character(len=20) :: int_format = '(A, T20, I8)' character(len=20) :: int_format = '(A, T20, I8)'
! for determinants sections
integer :: nelectrons, nalpha, nbeta, ndeterminants, nexcitation, iostat
integer, allocatable :: det_alpha(:), det_beta(:)
real(dp), allocatable :: det_coeff(:)
character(len=20) :: temp1, temp2, temp3, temp4, temp5
!------------------------------------------------------------------------- BEGIN !------------------------------------------------------------------------- BEGIN
! Initialize ! Initialize
@ -268,6 +274,43 @@ PROGRAM iochamp
write(6,*) '------------------------------------------------------' write(6,*) '------------------------------------------------------'
if (fdf_block('molecule2', bfdf)) then
! External file reading
write(6,*) 'beginning of external file coordinates block '
ia = 1
! write(*,*) "linecount", fdf_block_linecount("molecule")
do while((fdf_bline(bfdf, pline)))
if (pline%ntokens == 1) then
number_of_atoms = fdf_bintegers(pline, 1)
write(*,*) "number of atoms", number_of_atoms
endif
na = number_of_atoms
if (pline%ntokens == 4) then
symbol(ia) = fdf_bnames(pline, 1)
do i= 1, 3
xa(i,ia) = fdf_bvalues(pline, i)
enddo
ia = ia + 1
endif
enddo
endif
write(6,*) 'Coordinates from Molecule2 block: External file'
do ia= 1, na
write(6,'(A4,3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
enddo
write(6,'(A)')
write(6,*) '------------------------------------------------------'
@ -303,6 +346,84 @@ PROGRAM iochamp
stop 1 stop 1
end if end if
write(6,'(A)')
write(6,*) '------------------------------------------------------'
write(6,'(A)') " Determinants Block"
write(6,*) '------------------------------------------------------'
if (fdf_block('determinants', bfdf)) then
! External file reading
write(6,*) 'beginning of external file determinant block '
ia = 1
! call io_status()
! call fdf_printfdf()
print*, "printing label ", bfdf%label
print*, "pline obtained", (fdf_bline(bfdf, pline))
open (unit=11,file='TZ_1M_500.det', iostat=iostat, action='read' )
read(11,*) temp1, temp2, nelectrons, temp3, nalpha
! write(*,'(a,1x,i3,1x,i3)') "write after read1", nelectrons, nalpha
read(11,*) temp1, ndeterminants, nexcitation
! write(*,'(a,1x,i3, 1x, i3)') "write after read2", ndeterminants, nexcitation
read(11,*) (det_coeff(i), i=1,ndeterminants)
write(*,'(<ndeterminants>(f11.8,1x))') (det_coeff(i), i=1,ndeterminants)
! write(*,'(<ndeterminants>(f10.8, 1x))') (det_coeff(i), i=1,ndeterminants)
close(11)
if(fdf_bsearch(pline, "&electrons")) then
nelectrons = integers(pline, 1)
nalpha = integers(pline, 2)
nbeta = nelectrons - nalpha
write(*,*) "total number of electrons ", nelectrons
write(*,*) " number of alpha electrons ", nalpha
write(*,*) " number of beta electrons ", nalpha
if (.not. allocated(det_alpha)) allocate(det_alpha(nalpha))
if (.not. allocated(det_beta)) allocate(det_beta(nbeta))
endif
if(fdf_bsearch(pline, "determinants")) then
ndeterminants = fdf_bintegers(pline, 1)
nexcitation = fdf_bintegers(pline, 2)
write(*,*) "total number of determinants ", ndeterminants
write(*,*) " number of excitations ", nexcitation
if (.not. allocated(det_coeff)) allocate(det_coeff(ndeterminants))
endif
na = nintegers(pline)
write(*,'(2(a,i0),a)') 'number of integers: ', na, ' integers'
write(*,'(tr5,a,<nalpha>(tr1,i0))') 'list: ', det_alpha(1:nalpha)
! endif
! enddo
endif
! write(6,*) 'Coordinates from Molecule block: External file'
! do ia= 1, na
! write(6,'(A4,3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
! enddo
write(6,'(A)')
write(6,*) '------------------------------------------------------'
call fdf_shutdown() call fdf_shutdown()

View File

@ -68,7 +68,7 @@ H 3.750 -0.068 -9.293
### Read molecule's geometry directly from the xyz file ### Read molecule's geometry directly from the xyz file (filename should be given as is.)
%block molecule < caffeine.xyz %block molecule < caffeine.xyz
@ -76,7 +76,7 @@ H 3.750 -0.068 -9.293
### Two blocks with the same name not supported. Ignored without warning ### Two blocks with the same name not supported. Ignored without warning
%block molecule < "benzene.xyz" %block molecule2 < benzene.xyz %dump
@ -94,3 +94,10 @@ H 3.750 -0.068 -9.293
list_floats [ 0.94725807 -0.09274559 -0.05238276 -0.05238264 -0.04867531 -0.04162750 -0.04054186 -0.04017050 -0.04017045 -0.02963522 -0.02749165 -0.02351945 0.02056895 0.02056894 -0.01996166 0.01987062 0.01987060] list_floats [ 0.94725807 -0.09274559 -0.05238276 -0.05238264 -0.04867531 -0.04162750 -0.04054186 -0.04017050 -0.04017045 -0.02963522 -0.02749165 -0.02351945 0.02056895 0.02056894 -0.01996166 0.01987062 0.01987060]
### Read determinants directly from the .det file
#%block determinants < TZ_1M_500.det # sample.det
%block determinants < sample.det

View File

@ -84,6 +84,22 @@ optimize_orbitals F
H 5.262 -0.118 -8.904 H 5.262 -0.118 -8.904
H 5.167 1.714 -8.641 H 5.167 1.714 -8.641
%endblock inline_xyz2 %endblock inline_xyz2
%block molecule2
12
benzene example
C 0.00000 1.40272 0.00000
H 0.00000 2.49029 0.00000
C -1.21479 0.70136 0.00000
H -2.15666 1.24515 0.00000
C -1.21479 -0.70136 0.00000
H -2.15666 -1.24515 0.00000
C 0.00000 -1.40272 0.00000
H 0.00000 -2.49029 0.00000
C 1.21479 -0.70136 0.00000
H 2.15666 -1.24515 0.00000
C 1.21479 0.70136 0.00000
H 2.15666 1.24515 0.00000
%endblock molecule2
%block ListBlock %block ListBlock
list_integers [1 to 6 7 9 10 ] [ 1 to 7 8 9 11 12 ] list_integers [1 to 6 7 9 10 ] [ 1 to 7 8 9 11 12 ]
%endblock ListBlock %endblock ListBlock
@ -92,3 +108,5 @@ optimize_orbitals F
#:linteger? list_floats F #:linteger? list_floats F
list_floats 17 list_floats 17
list_floats 17 list_floats 17
%block determinants
&electrons nelec 22 nup 11