mirror of
https://github.com/TREX-CoE/fparser.git
synced 2025-01-03 10:06:11 +01:00
coordinates block read properly
This commit is contained in:
parent
bcb87047b8
commit
8e4a092b2e
118
src/iochamp.f90
118
src/iochamp.f90
@ -1,6 +1,3 @@
|
|||||||
!============================================================
|
|
||||||
!= Sample program using the f90 FDF module : September 2007 =
|
|
||||||
!============================================================
|
|
||||||
!
|
!
|
||||||
! Shows FDF capabilities..
|
! Shows FDF capabilities..
|
||||||
!
|
!
|
||||||
@ -10,8 +7,8 @@ PROGRAM iochamp
|
|||||||
implicit none
|
implicit none
|
||||||
!--------------------------------------------------------------- Local Variables
|
!--------------------------------------------------------------- Local Variables
|
||||||
integer, parameter :: maxa = 100
|
integer, parameter :: maxa = 100
|
||||||
logical :: doit, debug, check
|
logical :: doit, debug, check, val
|
||||||
character(len=72) :: fname, axis, status, filename, title, molecule_name
|
character(len=72) :: fname, axis, status, filename, title, molecule_name, key
|
||||||
character(2) :: symbol(maxa)
|
character(2) :: symbol(maxa)
|
||||||
integer(sp) :: i, j, ia, na, external_entry
|
integer(sp) :: i, j, ia, na, external_entry
|
||||||
integer(sp) :: isa(maxa)
|
integer(sp) :: isa(maxa)
|
||||||
@ -21,11 +18,12 @@ PROGRAM iochamp
|
|||||||
real(dp) :: listr(maxa)
|
real(dp) :: listr(maxa)
|
||||||
type(block_fdf) :: bfdf
|
type(block_fdf) :: bfdf
|
||||||
type(parsed_line), pointer :: pline
|
type(parsed_line), pointer :: pline
|
||||||
|
!type(fdf_file) :: fdffile
|
||||||
integer :: nextorb, nblk_max, nopt_iter, max_iteration, max_iter
|
integer :: nextorb, nblk_max, nopt_iter, max_iteration, max_iter
|
||||||
real(dp) :: energy_tol
|
real(dp) :: energy_tol
|
||||||
real(dp) :: sr_tau, sr_eps, sr_adiag
|
real(dp) :: sr_tau, sr_eps, sr_adiag
|
||||||
character(len=15) :: real_format = '(A, T20, F8.5)'
|
character(len=15) :: real_format = '(A, T20, F8.5)'
|
||||||
character(len=15) :: int_format = '(A, T20, I6)'
|
character(len=15) :: int_format = '(A, T20, I8)'
|
||||||
|
|
||||||
!------------------------------------------------------------------------- BEGIN
|
!------------------------------------------------------------------------- BEGIN
|
||||||
|
|
||||||
@ -72,44 +70,45 @@ PROGRAM iochamp
|
|||||||
write(6,'(A, L2)') 'Debug:', debug
|
write(6,'(A, L2)') 'Debug:', debug
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
! mixed types in one line (for example, reading a number with units)
|
! mixed types in one line (for example, reading a number with units)
|
||||||
cutoff = fdf_physical('Energy_Cutoff', 8.d0, 'Ry')
|
cutoff = fdf_physical('Energy_Cutoff', 8.d0, 'Ry')
|
||||||
write(6,fmt=real_format) 'Energy CutOff:', cutoff, " eV"
|
write(6,fmt=real_format) 'Energy CutOff:', cutoff, " eV"
|
||||||
|
|
||||||
phonon_energy = fdf_physical('phonon-energy', 0.01d0, 'eV')
|
phonon_energy = fdf_physical('phonon-energy', 0.01d0, 'eV')
|
||||||
write(6,*) 'Phonon Energy:', phonon_energy
|
write(6,fmt=real_format) 'Phonon Energy:', phonon_energy
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
! ! to check if a certain flag is defined or not
|
|
||||||
! check = fdf_defined('optimization_flags')
|
|
||||||
! write(6,*) 'optimization flags block defined', check
|
|
||||||
|
|
||||||
|
! block containing other key-value pairs (currently not working)
|
||||||
! if (fdf_block('optimization_flags', bfdf)) then
|
! if (fdf_block('optimization_flags', bfdf)) then
|
||||||
! ! Forward reading
|
! ia = 1
|
||||||
! do while(fdf_bline(bfdf, pline))
|
! do while((fdf_bline(bfdf, pline)) .and. (ia .le. na))
|
||||||
! doit = fdf_bboolean(pline, 1)
|
! ! doit = fdf_bboolean(pline, 1)
|
||||||
! write(*,*) "inside opt block", doit
|
! doit = fdf_boolean("optimize_wavefunction", .true.)
|
||||||
! enddo
|
! write(6,*) 'optimize_wavefunction', doit
|
||||||
|
|
||||||
|
! doit = fdf_boolean('optimize_ci', .true.)
|
||||||
|
! write(6,*) 'optimize_ci', doit
|
||||||
|
|
||||||
|
! doit = fdf_boolean('optimize_jastrow', .true.)
|
||||||
|
! write(6,*) 'optimize_jastrow:', doit
|
||||||
|
|
||||||
|
! doit = fdf_boolean('optimize_orbitals', .true.)
|
||||||
|
! write(6,*) 'optimize_orbitals:', doit
|
||||||
|
! enddo
|
||||||
! endif
|
! endif
|
||||||
|
|
||||||
|
|
||||||
! if (fdf_block('optimization_flags', bfdf)) then
|
doit = fdf_boolean("opt.optimize_wavefunction", .true.)
|
||||||
! doit = fdf_bboolean(pline, 1)
|
write(6,*) 'optimize_wavefunction', doit
|
||||||
! write(6,*) 'optimize_wavefunction', doit
|
|
||||||
|
|
||||||
! doit = fdf_boolean('optimize_ci', .true.)
|
doit = fdf_boolean('opt.optimize_ci', .true.)
|
||||||
! write(6,*) 'optimize_ci', doit
|
write(6,*) 'optimize_ci', doit
|
||||||
|
|
||||||
! doit = fdf_boolean('optimize_jastrow', .true.)
|
doit = fdf_boolean('opt.optimize_jastrow', .true.)
|
||||||
! write(6,*) 'optimize_jastrow:', doit
|
write(6,*) 'optimize_jastrow:', doit
|
||||||
|
|
||||||
! doit = fdf_boolean('optimize_orbitals', .true.)
|
|
||||||
! write(6,*) 'optimize_orbitals:', doit
|
|
||||||
! endif
|
|
||||||
|
|
||||||
|
doit = fdf_boolean('opt.optimize_orbitals', .true.)
|
||||||
|
write(6,*) 'optimize_orbitals:', doit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -118,36 +117,51 @@ PROGRAM iochamp
|
|||||||
write(6,*) 'Examples: maximum_iter =', max_iter
|
write(6,*) 'Examples: maximum_iter =', max_iter
|
||||||
|
|
||||||
|
|
||||||
|
if (fdf_defined('molecule')) then
|
||||||
check = fdf_defined('molecule')
|
write(6,*) "molecule block has been defined :: molecule's geometry in angstrom units"
|
||||||
write(6,*) 'molecule block has been defined', check
|
molecule_name = fdf_string('molecule', 'h2o.xyz')
|
||||||
|
write(6,*) 'Name of xyz file:', molecule_name
|
||||||
if (fdf_block('Other-Block', bfdf)) then
|
|
||||||
write(6,*) "inside molecule block"
|
|
||||||
fname = fdf_string('molecule.xyz', 'h2o.xyz')
|
|
||||||
write(6,*) 'Name of xyz file:', fname
|
|
||||||
|
|
||||||
write(6,*) 'Coordinates:'
|
|
||||||
|
|
||||||
na = fdf_bintegers(pline, 1)
|
|
||||||
write(6,*) 'Number of atoms =', na
|
|
||||||
molecule_name = fdf_bnames(pline, 1)
|
|
||||||
write(6,*) 'Name of the molecule =', molecule_name
|
|
||||||
ia = 1
|
ia = 1
|
||||||
do while((fdf_bline(bfdf, pline)) .and. (ia .le. na))
|
do while(fdf_bline(bfdf, pline))
|
||||||
symbol(ia) = fdf_bnames(pline, 1)
|
symbol(ia) = fdf_bnames(pline, 1)
|
||||||
do i= 1, 3
|
do i= 1, 3
|
||||||
xa(i,ia) = fdf_breals(pline, i)
|
xa(i,ia) = fdf_breals(pline, i)
|
||||||
enddo
|
|
||||||
ia = ia + 1
|
|
||||||
enddo
|
enddo
|
||||||
|
ia = ia + 1
|
||||||
|
enddo
|
||||||
|
na = ia - 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
write(6,*) 'Coordinates from an external file:'
|
||||||
|
do ia = 1, na
|
||||||
|
write(6,'(A, 4x, 3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
! Molecule coordinate block begins here
|
||||||
|
|
||||||
|
if (fdf_block('Coordinates', bfdf)) then
|
||||||
|
ia = 1
|
||||||
|
do while(fdf_bline(bfdf, pline))
|
||||||
|
symbol(ia) = fdf_bnames(pline, 1)
|
||||||
|
do i= 1, 3
|
||||||
|
xa(i,ia) = fdf_breals(pline, i)
|
||||||
|
enddo
|
||||||
|
ia = ia + 1
|
||||||
|
enddo
|
||||||
|
na = ia - 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
write(6,*) 'Coordinates:'
|
write(6,*) 'Coordinates:'
|
||||||
do ia= 1, na
|
do ia = 1, na
|
||||||
write(6,'(3F10.6,I5)') (xa(i,ia),i=1,3), symbol(ia)
|
write(6,'(A, 4x, 3F10.6)') symbol(ia), (xa(i,ia),i=1,3)
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
|
! Molecule coordinate block ends here
|
||||||
|
|
||||||
|
|
||||||
if (fdf_block('Other-Block', bfdf)) then
|
if (fdf_block('Other-Block', bfdf)) then
|
||||||
|
|
||||||
|
@ -1,39 +1,5 @@
|
|||||||
title "A Sample QMC input file parsed by libfdf interfaced to CHAMP"
|
title "A Sample QMC input file parsed by libfdf interfaced to CHAMP"
|
||||||
|
|
||||||
%block general
|
|
||||||
pool_directory pool
|
|
||||||
pseudopotential BFD
|
|
||||||
basis BFD-T-normf0
|
|
||||||
%endblock
|
|
||||||
|
|
||||||
|
|
||||||
%block sample
|
|
||||||
max_iteration 3
|
|
||||||
Energy_Cutoff 500.0 eV
|
|
||||||
float_value 3.14e10
|
|
||||||
filename 'sample read input.txt'
|
|
||||||
phonon-energy 344 cm**-1
|
|
||||||
%endblock
|
|
||||||
|
|
||||||
molecule caffeine.xyz
|
|
||||||
|
|
||||||
|
|
||||||
%include pool/BFD-T.bfinfo
|
|
||||||
|
|
||||||
|
|
||||||
# Comments start with a '#' Can be included anywhere
|
|
||||||
|
|
||||||
#%include TZ_1M_500.det
|
|
||||||
#%include jastrow_good_b3lyp.0
|
|
||||||
|
|
||||||
%block optimization_flags
|
|
||||||
optimize_wavefunction true
|
|
||||||
optimize_ci T
|
|
||||||
optimize_jastrow yes
|
|
||||||
optimize_orbitals 0
|
|
||||||
%endblock
|
|
||||||
|
|
||||||
|
|
||||||
nextorb 280
|
nextorb 280
|
||||||
nblk_max 200
|
nblk_max 200
|
||||||
nopt_iter 2
|
nopt_iter 2
|
||||||
@ -44,4 +10,61 @@ sr_adiag 0.05
|
|||||||
energy_tol 0.0
|
energy_tol 0.0
|
||||||
|
|
||||||
|
|
||||||
|
opt.optimize_wavefunction no
|
||||||
|
opt.optimize_ci No
|
||||||
|
opt.optimize_jastrow yes
|
||||||
|
opt.optimize_orbitals False
|
||||||
|
|
||||||
|
|
||||||
|
# The sub blocks currently does not parse.
|
||||||
|
|
||||||
|
%block general
|
||||||
|
pool_directory pool
|
||||||
|
pseudopotential BFD
|
||||||
|
basis BFD-T-normf0
|
||||||
|
%endblock
|
||||||
|
|
||||||
|
%block mixed
|
||||||
|
max_iteration 3
|
||||||
|
Energy_Cutoff 500.0 eV
|
||||||
|
float_value 3.14e10
|
||||||
|
filename 'sample read input.txt'
|
||||||
|
phonon-energy 344 cm**-1
|
||||||
|
%endblock
|
||||||
|
|
||||||
|
|
||||||
|
# Read molecule's geometry directly from the xyz file
|
||||||
|
|
||||||
|
# molecule caffeine.xyz
|
||||||
|
|
||||||
|
|
||||||
|
# An alternative way to provide coordinates
|
||||||
|
|
||||||
|
%block Coordinates
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# %include pool/BFD-T.bfinfo
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### To be implemented (large file reading support, possibly hdf5 files)
|
||||||
|
|
||||||
|
#%include TZ_1M_500.det
|
||||||
|
#%include jastrow_good_b3lyp.0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user