Skip to content

Commit

Permalink
density is being successfully read
Browse files Browse the repository at this point in the history
  • Loading branch information
vtripath65 committed Nov 15, 2024
1 parent 018cc32 commit 4ed71c7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
27 changes: 15 additions & 12 deletions src/modules/quick_method_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ module quick_method_module
logical :: debug = .false. ! debug mode
logical :: nodirect = .false. ! conventional scf
logical :: readDMX = .false. ! flag to read density matrix
logical :: readPMat = .false. ! flag to read density matrix
logical :: writePMat = .false. ! flag to write density matrix
logical :: readden = .false. ! flag to read density matrix
logical :: writeden = .false. ! flag to write density matrix
logical :: readSAD = .true. ! flag to read SAD guess
logical :: writeSAD = .false. ! flag to write SAD guess
logical :: diisSCF = .false. ! DIIS SCF
Expand Down Expand Up @@ -235,8 +235,8 @@ subroutine broadcast_quick_method(self, ierr)
call MPI_BCAST(self%calcDensLap,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%gridspacing,1,mpi_double_precision,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%lapGridSpacing,1,mpi_double_precision,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%readPMat,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%writePMat,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%readden,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%writeden,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%extCharges,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%PDB,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%SAD,1,mpi_logical,0,MPI_COMM_WORLD,mpierror)
Expand Down Expand Up @@ -410,8 +410,8 @@ subroutine print_quick_method(self,io,ierr)
if (self%printEnergy) write(io,'(" PRINT ENERGY EVERY CYCLE")')

if (self%readDMX) write(io,'(" READ DENSITY MATRIX FROM FILE")')
if (self%readPMat) write(io,'(" READ DENSITY MATRIX From DATAFILE")')
if (self%writePMat) write(io,'(" WRITE DENSITY MATRIX TO FILE")')
if (self%readden) write(io,'(" READ DENSITY MATRIX From DATAFILE")')
if (self%writeden) write(io,'(" WRITE DENSITY MATRIX TO FILE")')
if (self%readSAD) write(io,'(" READ SAD GUESS FROM FILE")')
if (self%writeSAD) write(io,'(" WRITE SAD GUESS TO FILE")')

Expand Down Expand Up @@ -504,13 +504,13 @@ subroutine read_quick_method(self,keywd,ierr)
use quick_mpi_module
use quick_files_module, only : write_molden
implicit none
character(len=200) :: keyWD
character(len=200) :: tempstring
character(len=300) :: keyWD
character(len=300) :: tempstring
integer :: itemp,i,j
type (quick_method_type) self
integer, intent(inout) :: ierr

call upcase(keyWD,200)
call upcase(keyWD,300)
if (index(keyWD,'PDB').ne. 0) self%PDB=.true.
if (index(keyWD,'MFCC').ne.0) self%MFCC=.true.
if (index(keyWD,'FMM').ne.0) self%FMM=.true.
Expand Down Expand Up @@ -633,7 +633,7 @@ subroutine read_quick_method(self,keywd,ierr)
end if
if (index(keyWD,'ZMAKE').ne.0) self%zmat=.true.
if (index(keyWD,'DIPOLE').ne.0) self%dipole=.true.
if (index(keyWD,'WRITE').ne.0) self%writePMat=.true.
if (index(keyWD,'WRITE').ne.0) self%writeden=.true.
if (index(keyWD,'EXTCHARGES').ne.0) self%EXTCHARGES=.true.
if (index(keyWD,'FORCE').ne.0) self%grad=.true.

Expand All @@ -652,6 +652,9 @@ subroutine read_quick_method(self,keywd,ierr)
endif
endif

!Read density matrix
if (index(keyWD,'READDEN').ne.0) self%readden=.true.

if (self%DFT) then
if (index(keyWD,'SG0').ne.0) then
self%iSG=0
Expand Down Expand Up @@ -840,8 +843,8 @@ subroutine init_quick_method(self,ierr)
self%hasF = .false. ! If f orbitial is contained
self%calcDens = .false. ! calculate density
self%calcDensLap = .false. ! calculate density lap
self%readPMat = .false. ! Input density matrix
self%writePMat = .false. ! Output density matrix
self%readden = .false. ! Input density matrix
self%writeden = .false. ! Output density matrix
self%extCharges = .false. ! external charge
self%PDB = .false. ! PDB input
self%SAD = .true. ! SAD initial guess
Expand Down
28 changes: 24 additions & 4 deletions src/modules/quick_scf_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ subroutine electdiis(jscf,ierr)
#endif

implicit none


logical :: fail

! variable inputed to return
integer :: jscf ! scf interation
integer :: jscf ! scf iteration
integer, intent(inout) :: ierr

logical :: diisdone = .false. ! flag to indicate if diis is done
Expand Down Expand Up @@ -267,7 +269,17 @@ subroutine electdiis(jscf,ierr)
if (bMPI) call MPI_setup_hfoperator
!-------------- END MPI / ALL NODE -----------
#endif


if(quick_method%readden)then
nbasis = quick_molspec%nbasis
if(master)then
open(unit=iDataFile,file=dataFileName,status='OLD',form='UNFORMATTED')
call rchk_int(iDataFile, "nbasis", nbasis, fail)
call rchk_darray(iDataFile, "dense", nbasis, nbasis, 1, quick_qm_struct%dense, fail)
close(iDataFile)
endif
endif

#ifdef MPIV
if (bMPI) then
! call MPI_BCAST(quick_qm_struct%o,nbasis*nbasis,mpi_double_precision,0,MPI_COMM_WORLD,mpierror)
Expand Down Expand Up @@ -714,7 +726,15 @@ subroutine electdiis(jscf,ierr)
!--------------- END MPI/ALL NODES -------------------------------------

if (master) then


if(quick_method%writeden)then
! open data file then write calculated info to dat file
call quick_open(iDataFile, dataFileName, 'R', 'U', 'A',.true.,ierr)
call wchk_int(iDataFile, "nbasis", nbasis, fail)
call wchk_darray(iDataFile, "dense", nbasis, nbasis, 1, quick_qm_struct%dense, fail)
close(iDataFile)
endif

#ifdef USEDAT
! open data file then write calculated info to dat file
SAFE_CALL(quick_open(iDataFile, dataFileName, 'R', 'U', 'R',.true.,ierr)
Expand Down
16 changes: 9 additions & 7 deletions src/subs/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ subroutine wchk_int(chk,key,nvalu,fail)
write(chk) 'I '
write(chk) nvalu
fail=1
return
200 return

end
Expand Down Expand Up @@ -376,18 +377,19 @@ subroutine wchk_darray(chk,key,x,y,z,dim,fail)
enddo
endif

fail=0
do
read(chk,end=100,err=200)
enddo
! fail=0
! do
! read(chk,end=100,err=200)
! enddo

100 rewind(chk)
! 100 rewind(chk)
write(chk) '#'//kline(1:40)
write(chk) 'RR'
write(chk) x*y*z
write(chk) (((dim(i,j,k),i=1,x),j=1,y),k=1,z)
fail=1
200 return
! fail=1
! 200 return
return

end

Expand Down

0 comments on commit 4ed71c7

Please sign in to comment.