From 3d304d79a21c91cce5c26780b7ccec1c1ba8e5fb Mon Sep 17 00:00:00 2001 From: Ravindra Shinde Date: Tue, 23 Feb 2021 22:44:22 +0100 Subject: [PATCH] reading the det file block --- .gitignore | 1 - src/iochamp.f90 | 121 +++++++++++++++++++++++++++++++++++++++++++++ src/test-champ.inp | 13 +++-- src/test-champ.out | 18 +++++++ 4 files changed, 149 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4d33bb1..9fedeb2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ *.lof *.log *.lot -*.out *.toc auto/ .DS_Store diff --git a/src/iochamp.f90 b/src/iochamp.f90 index 478fbbe..e8281fd 100644 --- a/src/iochamp.f90 +++ b/src/iochamp.f90 @@ -5,6 +5,7 @@ PROGRAM iochamp USE fdf USE prec USE parse + use io_fdf implicit none !--------------------------------------------------------------- Local Variables integer, parameter :: maxa = 100 @@ -31,6 +32,11 @@ PROGRAM iochamp character(len=20) :: real_format = '(A, T20, F14.5)' 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 ! Initialize @@ -268,6 +274,43 @@ PROGRAM iochamp 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 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(*,'((f11.8,1x))') (det_coeff(i), i=1,ndeterminants) +! write(*,'((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,(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() diff --git a/src/test-champ.inp b/src/test-champ.inp index f8282f2..8158d4e 100644 --- a/src/test-champ.inp +++ b/src/test-champ.inp @@ -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 @@ -76,7 +76,7 @@ H 3.750 -0.068 -9.293 ### Two blocks with the same name not supported. Ignored without warning -%block molecule < "benzene.xyz" +%block molecule2 < benzene.xyz %dump @@ -93,4 +93,11 @@ H 3.750 -0.068 -9.293 %endblock ListBlock -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] \ No newline at end of file +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 diff --git a/src/test-champ.out b/src/test-champ.out index 6c649ed..04e601e 100644 --- a/src/test-champ.out +++ b/src/test-champ.out @@ -84,6 +84,22 @@ optimize_orbitals F H 5.262 -0.118 -8.904 H 5.167 1.714 -8.641 %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 list_integers [1 to 6 7 9 10 ] [ 1 to 7 8 9 11 12 ] %endblock ListBlock @@ -92,3 +108,5 @@ optimize_orbitals F #:linteger? list_floats F list_floats 17 list_floats 17 +%block determinants + &electrons nelec 22 nup 11