1
0
mirror of https://github.com/TREX-CoE/fparser.git synced 2024-12-23 04:44:04 +01:00

inline reading of molecule coordinates works

This commit is contained in:
Ravindra Shinde 2021-02-18 11:01:41 +01:00
parent 07e5166d14
commit dafa315545
2 changed files with 136 additions and 117 deletions

View File

@ -81,6 +81,9 @@ PROGRAM iochamp
phonon_energy = fdf_physical('phonon-energy', 0.01d0, 'eV') phonon_energy = fdf_physical('phonon-energy', 0.01d0, 'eV')
write(6,fmt=real_format) 'Phonon Energy:', phonon_energy write(6,fmt=real_format) 'Phonon Energy:', phonon_energy
write(6,'(A)')
write(6,*) '------------------------------------------------------'
! block containing other key-value pairs (currently not working) ! block containing other key-value pairs (currently not working)
@ -115,6 +118,9 @@ PROGRAM iochamp
enddo enddo
endif endif
write(6,'(A)')
write(6,*) '------------------------------------------------------'
@ -131,38 +137,46 @@ PROGRAM iochamp
write(6,*) 'outside optimize_orbitals:', doit write(6,*) 'outside optimize_orbitals:', doit
max_iter = fdf_integer('max_iteration', 100) max_iter = fdf_integer('max_iteration', 100)
write(6,*) 'Examples: maximum_iter =', max_iter write(6,*) 'Examples: maximum_iter =', max_iter
if (fdf_defined('molecule')) then
write(6,*) "molecule block has been defined :: molecule's geometry in angstrom units" write(6,'(A)')
! molecule_name = fdf_string('molecule', 'h2o.xyz')
! write(6,*) 'Name of xyz file:', molecule_name write(6,*) '------------------------------------------------------'
na = 24 ! debug
if (fdf_block('molecule', bfdf)) then
ia = 1
do while(fdf_bline(bfdf, pline)) ! if (fdf_defined('molecule')) then
! na = fdf_bintegers(pline, 1) ! write(6,*) "molecule block has been defined :: molecule's geometry in angstrom units"
! write(*,*) na ! ! molecule_name = fdf_string('molecule', 'h2o.xyz')
symbol(ia) = fdf_bnames(pline, 1) ! ! write(6,*) 'Name of xyz file:', molecule_name
do i= 1, 3 ! na = 24 ! debug
xa(i,ia) = fdf_breals(pline, i) ! if (fdf_block('molecule', bfdf)) then
enddo ! ia = 1
ia = ia + 1 ! do while(fdf_bline(bfdf, pline))
enddo ! ! na = fdf_bintegers(pline, 1)
na = ia - 1 ! ! write(*,*) na
endif ! symbol(ia) = fdf_bnames(pline, 1)
endif ! do i= 1, 3
! xa(i,ia) = fdf_breals(pline, i)
! enddo
! ia = ia + 1
! enddo
! na = ia - 1
! endif
! endif
write(6,*) 'Coordinates from an external file:' ! write(6,*) 'Coordinates from an external file:'
do ia = 1, 24 ! do ia = 1, 24
write(6,'(A, 4x, 3F10.6)') symbol(ia), (xa(i,ia),i=1,3) ! write(6,'(A, 4x, 3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
enddo ! enddo
write(6,'(A)')
write(6,*) '------------------------------------------------------'
! Molecule coordinate block begins here ! Molecule coordinate block begins here
@ -185,10 +199,14 @@ PROGRAM iochamp
enddo enddo
! Molecule coordinate block ends here ! Molecule coordinate block ends here
write(6,*) '------------------------------------------------------'
write(6,'(A)')
write(6,*) '------------------------------------------------------'
if (fdf_block('Other-Block', bfdf)) then if (fdf_block('inline_xyz', bfdf)) then
! Forward reading ! Forward reading
write(6,*) 'beginning of other block ' write(6,*) 'beginning of other block '
ia = 1 ia = 1
@ -200,7 +218,13 @@ PROGRAM iochamp
number_of_atoms = fdf_bintegers(pline, 1) number_of_atoms = fdf_bintegers(pline, 1)
write(*,*) "number of atoms", number_of_atoms write(*,*) "number of atoms", number_of_atoms
endif endif
na = 3 na = number_of_atoms
if (pline%ntokens == 1) then
molecule_name = fdf_string('', 'Unknown molecule')
write(*,*) "Comment from the XYZ coordinate file", molecule_name
endif
if (pline%ntokens == 4) then if (pline%ntokens == 4) then
symbol(ia) = fdf_bnames(pline, 1) symbol(ia) = fdf_bnames(pline, 1)
do i= 1, na do i= 1, na
@ -210,73 +234,78 @@ PROGRAM iochamp
endif endif
enddo enddo
write(6,*) 'Other-Block (Forward):' write(6,*) 'Inline XYZ Coordinates block:'
do ia= 1, na
write(6,'(A4,3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
enddo
! Backward reading
ia = 1
do while((fdf_bbackspace(bfdf, pline)) .and. (ia .le. na))
symbol(ia) = fdf_bnames(pline, 1)
do i= 1, na
xa(i,ia) = fdf_breals(pline, i)
enddo
ia = ia + 1
enddo
write(6,*) 'Other-Block (Backward):'
do ia= 1, na
write(6,'(A4,3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
enddo
! Forward reading
ia = 1
do while((fdf_bline(bfdf, pline)) .and. (ia .le. na))
symbol(ia) = fdf_bnames(pline, 1)
do i= 1, na
xa(i,ia) = fdf_breals(pline, i)
enddo
ia = ia + 1
enddo
write(6,*) 'Other-Block (Forward):'
do ia= 1, na
write(6,'(A4,3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
enddo
! Forward reading with rewind
call fdf_brewind(bfdf)
ia = 1
do while((fdf_bline(bfdf, pline)) .and. (ia .le. na))
symbol(ia) = fdf_bnames(pline, 1)
do i= 1, na
xa(i,ia) = fdf_breals(pline, i)
enddo
ia = ia + 1
enddo
write(6,*) 'Other-Block (Forward-with-rewind):'
do ia= 1, na do ia= 1, na
write(6,'(A4,3F10.6)') symbol(ia), (xa(i,ia),i=1,3) write(6,'(A4,3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
enddo enddo
endif endif
if ( fdf_block('ListBlock',bfdf) ) then
i = 0
do while ( fdf_bline(bfdf,pline) )
i = i + 1
na = fdf_bnlists(pline) ! ! Backward reading
write(*,'(2(a,i0),a)') 'Listblock line: ',i,' has ',na,' lists' ! ia = 1
do ia = 1 , na ! do while((fdf_bbackspace(bfdf, pline)) .and. (ia .le. na))
j = -1 ! symbol(ia) = fdf_bnames(pline, 1)
call fdf_bilists(pline,ia,j,isa) ! do i= 1, na
write(*,'(tr5,2(a,i0),a)') 'list ',ia,' has ',j,' entries' ! xa(i,ia) = fdf_breals(pline, i)
call fdf_bilists(pline,ia,j,isa) ! enddo
write(*,'(tr5,a,1000(tr1,i0))') 'list: ',isa(1:j) ! ia = ia + 1
end do ! enddo
end do
end if ! write(6,*) 'Other-Block (Backward):'
! do ia= 1, na
! write(6,'(A4,3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
! enddo
! ! Forward reading
! ia = 1
! do while((fdf_bline(bfdf, pline)) .and. (ia .le. na))
! symbol(ia) = fdf_bnames(pline, 1)
! do i= 1, na
! xa(i,ia) = fdf_breals(pline, i)
! enddo
! ia = ia + 1
! enddo
! write(6,*) 'Other-Block (Forward):'
! do ia= 1, na
! write(6,'(A4,3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
! enddo
! ! Forward reading with rewind
! call fdf_brewind(bfdf)
! ia = 1
! do while((fdf_bline(bfdf, pline)) .and. (ia .le. na))
! symbol(ia) = fdf_bnames(pline, 1)
! do i= 1, na
! xa(i,ia) = fdf_breals(pline, i)
! enddo
! ia = ia + 1
! enddo
! write(6,*) 'Other-Block (Forward-with-rewind):'
! do ia= 1, na
! write(6,'(A4,3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
! enddo
! if ( fdf_block('ListBlock',bfdf) ) then
! i = 0
! do while ( fdf_bline(bfdf,pline) )
! i = i + 1
! na = fdf_bnlists(pline)
! write(*,'(2(a,i0),a)') 'Listblock line: ',i,' has ',na,' lists'
! do ia = 1 , na
! j = -1
! call fdf_bilists(pline,ia,j,isa)
! write(*,'(tr5,2(a,i0),a)') 'list ',ia,' has ',j,' entries'
! call fdf_bilists(pline,ia,j,isa)
! write(*,'(tr5,a,1000(tr1,i0))') 'list: ',isa(1:j)
! end do
! end do
! end if
! Check lists ! Check lists
if ( fdf_islinteger('MyList') .and. fdf_islist('MyList') & if ( fdf_islinteger('MyList') .and. fdf_islist('MyList') &

View File

@ -1,12 +1,12 @@
title "A Sample QMC input file parsed by libfdf interfaced to CHAMP" title "A Sample QMC input file parsed by libfdf interfaced to CHAMP"
nextorb 280 nextorb 280
nblk_max 200 nblk_max 200
nopt_iter 2 nopt_iter 2
sr_tau 1.023 sr_tau 1.023
sr_eps 0.001 sr_eps 0.001
sr_adiag 0.05 sr_adiag 0.05
energy_tol 0.004 energy_tol 0.004
%block optimization_flags %block optimization_flags
@ -27,26 +27,12 @@ energy_tol 0.004
%block mixed %block mixed
max_iteration 3 max_iteration 3
Energy_Cutoff 500.0 eV Energy_Cutoff 500.0 eV
float_value 3.14e10 float_value 3.14e10
filename 'sample read input.txt' filename 'sample read input.txt'
phonon-energy 344 cm**-1 phonon-energy 344 cm**-1
%endblock %endblock
# Read molecule's geometry directly from the xyz file
%block molecule < "caffeine.xyz"
%block Other-Block
99
Nh 1.500000 1.108000 -3.000000
Ox 0.333000 0.000000 45.000000
Pd -1.431000 -1.108000 20.000000
%endblock Other-Block
# An alternative way to provide coordinates # An alternative way to provide coordinates
%block Coordinates %block Coordinates
@ -66,14 +52,18 @@ energy_tol 0.004
%block inline_xyz
3
# %include pool/BFD-T.bfinfo molecule name unknown
Nh 1.50 1.108000 -3.
Ox 0.333000 0. 45.
Pd -1.431000 -1.108000 20.
%endblock inline_xyz
### To be implemented (large file reading support, possibly hdf5 files)
#%include TZ_1M_500.det ### Read molecule's geometry directly from the xyz file
#%include jastrow_good_b3lyp.0
### %block molecule < "caffeine.xyz"