Skip to content

Commit 3581f50

Browse files
authored
Remove stubs and comments for Ehrenfest method (#87)
This was never implemented so removing for now.
1 parent d012313 commit 3581f50

12 files changed

+36
-1636
lines changed

sample_inputs/input.in.cmd.nab

-69
This file was deleted.

sample_inputs/input.pdb

-512
This file was deleted.

sample_inputs/input.top

-869
This file was deleted.

src/README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Short descriptions of key source files.
77
| Path | Description |
88
|----------|-------------|
99
| abin.F90 | Main routine. |
10-
| modules.F90 | Modules containing all basic variables. |
10+
| modules.F90 | Modules containing all basic global settings. |
1111
| init.F90 | Big ugly init routine. Reads input parameters, restart files and checks for errors in input. |
1212
| mdstep.f90 | Routines for propagation of equations of motion (velocity Verlet and RESPA). |
13-
| forces.f90 | Main routine for getting forces (force_clas) and quantum forces in PIMD (force_quant). |
13+
| forces.f90 | Main wrapper routine for getting forces (force_clas) and quantum forces in PIMD (force_quant). |
1414
| force_abin.f90 | Routine that calls ab initio BASH interfaces. |
1515
| nosehoover.f90 | Nosé-Hoover thermostat. |
1616
| surfacehop.f90 | Surface Hopping dynamics |
@@ -20,9 +20,8 @@ Short descriptions of key source files.
2020
| shake.f90 | Constraints using SHAKE algorithm. |
2121
| analysis.f90 | Driver routine for printing output. |
2222
| arrays.f90 | Module containing all dynamically allocated arrays.|
23-
| random.f90 | Random number generator. |
23+
| random.f90 | Pseudo-random number generator. |
2424
| vinit.f90 | Initial velocities. |
25-
| potentials.f90 | Analytical potentials and hessians for harmonic and Morse oscillators and others. |
26-
| density.f90 | Evaluates distance, angle and dihedrals distributions during dynamics. |
25+
| potentials.f90 | Analytical potentials and hessians (harmonic, Morse etc.)
2726
| estimators.f90 | Energy and heat capacity estimators for PIMD. |
2827
| transform.F90 | Coordinate transformations for PIMD. |

src/abin.F90

+9-5
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ program abin
6262
end if
6363

6464
! Surface hopping initialization
65-
if (ipimd == 2 .or. ipimd == 4) then
65+
if (ipimd == 2) then
6666
call sh_init(x, y, z, vx, vy, vz)
6767
else if (ipimd == 5 .and. pot == '_tera_') then
6868
call sh_init(x, y, z, vx, vy, vz)
@@ -117,12 +117,16 @@ program abin
117117
call force_clas(fxc_diff, fyc_diff, fzc_diff, x, y, z, eclas, pot)
118118
end if
119119

120-
! setting initial values for SURFACE HOPPING
121-
if (ipimd == 2 .or. ipimd == 4) then
120+
! setting initial values for surface hopping
121+
if (ipimd == 2) then
122122
do itrj = 1, ntraj
123-
if (irest /= 1) call get_nacm(itrj)
123+
if (irest /= 1) then
124+
call get_nacm(itrj)
125+
end if
124126
call move_vars(vx, vy, vz, vx_old, vy_old, vz_old, itrj)
125-
if (pot == '_tera_' .or. restrain_pot == '_tera_') call move_new2old_terash()
127+
if (pot == '_tera_' .or. restrain_pot == '_tera_') then
128+
call move_new2old_terash()
129+
end if
126130
end do
127131
else if (ipimd == 5 .and. pot == '_tera_') then
128132
call move_new2old_terash()

src/arrays.F90

-45
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ module mod_arrays
2929
! for multiple time-stepping and ring contraction ala O. Marsalek
3030
real(DP), allocatable :: fxc_diff(:, :), fyc_diff(:, :), fzc_diff(:, :)
3131
real(DP) :: epot_diff = 0.0D0 ! not really array, but for now let's keep it here
32-
!ehrenfest forces
33-
real(DP), allocatable :: fxeh(:, :), fyeh(:, :), fzeh(:, :) ! interpolation forces
34-
real(DP), allocatable :: fxeh_old(:, :), fyeh_old(:, :), fzeh_old(:, :) ! interpolation forces
35-
real(DP), allocatable :: fxmid(:, :), fymid(:, :), fzmid(:, :) ! mid step approximative forces
3632
save
3733
contains
3834

@@ -83,9 +79,6 @@ subroutine allocate_arrays(natomalloc, nwalkalloc)
8379
vx_old = vx; vy_old = vx_old; vz_old = vx_old
8480
transxv = vx; transyv = transxv; transzv = transxv
8581

86-
! TODO-EH: we need to allocate fxc according to the number of states
87-
! but this subroutine is called before we now the number of states
88-
! so leave this as is and reallocate elsewhere
8982
allocate (fxc(natomalloc, nwalkalloc))
9083
allocate (fyc(natomalloc, nwalkalloc))
9184
allocate (fzc(natomalloc, nwalkalloc))
@@ -114,30 +107,6 @@ subroutine allocate_arrays(natomalloc, nwalkalloc)
114107

115108
end subroutine allocate_arrays
116109

117-
!EHRENFEST gradients and midstep approximative forces for all states
118-
subroutine allocate_ehrenfest(natom, nstate)
119-
integer, intent(in) :: nstate
120-
integer, intent(in) :: natom
121-
allocate (fxeh(natom, nstate))
122-
allocate (fyeh(natom, nstate))
123-
allocate (fzeh(natom, nstate))
124-
allocate (fxeh_old(natom, nstate))
125-
allocate (fyeh_old(natom, nstate))
126-
allocate (fzeh_old(natom, nstate))
127-
allocate (fxmid(natom, nstate))
128-
allocate (fymid(natom, nstate))
129-
allocate (fzmid(natom, nstate))
130-
fxeh = 0.0D0
131-
fyeh = 0.0D0
132-
fzeh = 0.0D0
133-
fxeh_old = 0.0D0
134-
fyeh_old = 0.0D0
135-
fzeh_old = 0.0D0
136-
fxmid = 0.0D0
137-
fymid = 0.0D0
138-
fzmid = 0.0D0
139-
end subroutine allocate_ehrenfest
140-
141110
subroutine deallocate_arrays
142111
! If x is allocated, all of them should be.
143112
! If not, something is horribly wrong anyway
@@ -159,20 +128,6 @@ subroutine deallocate_arrays
159128
if (allocated(fxc_diff)) then
160129
deallocate (fxc_diff); deallocate (fyc_diff); deallocate (fzc_diff);
161130
end if
162-
163-
! Ehrenfest variables (hmm, are these really needed??
164-
! Would be better to just use the existing ones...
165-
if (allocated(fxeh)) then
166-
deallocate (fxeh)
167-
deallocate (fyeh)
168-
deallocate (fzeh)
169-
deallocate (fxeh_old)
170-
deallocate (fyeh_old)
171-
deallocate (fzeh_old)
172-
deallocate (fxmid)
173-
deallocate (fymid)
174-
deallocate (fzmid)
175-
end if
176131
end subroutine deallocate_arrays
177132

178133
end module mod_arrays

src/force_abin.F90

+8-17
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,14 @@ subroutine force_abin(x, y, z, fx, fy, fz, eclas, chpot, walkmax)
6161
end do
6262
close (unit=MAXUNITS + iw)
6363

64-
! Surface hopping or Ehrenfest
65-
if (ipimd == 2 .or. ipimd == 4) then
64+
if (ipimd == 2) then
6665

6766
open (unit=MAXUNITS + iw + 2 * walkmax, file='state.dat')
6867
write (MAXUNITS + iw + 2 * walkmax, '(I2)') nstate
6968

70-
! Diagonal of tocalc holds info about needed forces
71-
! tocalc(x,x)= 1 -> compute forces for electronic state X
72-
! totalc for Ehrenfest muset be set just for required states according to c coef. TO-DO in ehrenfest enrehfest_forces
69+
! Diagonal of tocalc holds info about needed forces
70+
! tocalc(x,x) = 1 -> compute forces for electronic state X
71+
! off-diagonal elements correspond to non-adiabatic couplings
7372
do ist1 = 1, nstate
7473
write (MAXUNITS + iw + 2 * walkmax, '(I1,A1)', advance='no') tocalc(ist1, ist1), ' '
7574
end do
@@ -82,10 +81,7 @@ subroutine force_abin(x, y, z, fx, fy, fz, eclas, chpot, walkmax)
8281
open (unit=MAXUNITS + iw + 2 * walkmax, file='state.dat')
8382
write (MAXUNITS + iw + 2 * walkmax, '(I2)') nstate_lz !How many el. states
8483

85-
!do ist1=1,nstate_lz
86-
! write(MAXUNITS+iw+2*walkmax,'(I1,A1)',advance='no')tocalc_lz(ist1),' '
87-
!end do
88-
!First we have singlets, then triplets
84+
! First we have singlets, then triplets
8985
do ist1 = 1, nstate_lz
9086
if (tocalc_lz(ist1) == 1) write (MAXUNITS + iw + 2 * walkmax, '(I2,A1)') ist1, ' ' !Number of gradient state
9187
end do
@@ -114,7 +110,7 @@ subroutine force_abin(x, y, z, fx, fy, fz, eclas, chpot, walkmax)
114110

115111
! for SH, pass the 4th parameter: precision of forces as 10^(-force_accu1)
116112
! TODO: This should not be hard-coded
117-
if (ipimd == 2 .or. ipimd == 4 .or. ipimd == 5) then
113+
if (ipimd == 2 .or. ipimd == 5) then
118114
write (chsystem, '(A60,I3,A12)') chsystem, 7, ' < state.dat'
119115
end if
120116

@@ -163,12 +159,11 @@ subroutine force_abin(x, y, z, fx, fy, fz, eclas, chpot, walkmax)
163159
eclas = eclas + temp1
164160
! SH
165161
! TODO: Have each state in different file?
166-
if (ipimd == 2 .or. ipimd == 4) then
162+
if (ipimd == 2) then
167163
en_array(1, iw) = temp1
168164
do ist1 = 2, nstate
169165
read (MAXUNITS + iw, *) en_array(ist1, iw)
170166
end do
171-
! TODO-EH: eclas must be correctly overwritten later
172167
eclas = en_array(istate(iw), iw)
173168
end if
174169
! LZ
@@ -189,11 +184,7 @@ subroutine force_abin(x, y, z, fx, fy, fz, eclas, chpot, walkmax)
189184
eclas = en_array_lz(istate_lz, 1)
190185
end if
191186

192-
! TODO-EH: Read additional forces probably somewhere here, use second index (iw) for different states
193-
! Actually, we should make a routine read_engrad() and make it general for both EH and SH
194-
! always read energies, read forces based on tocalc
195-
196-
if (ipimd == 2 .or. ipimd == 4) then
187+
if (ipimd == 2) then
197188
iost = read_forces(fx, fy, fz, natqm, tocalc(istate(iw), istate(iw)), MAXUNITS + iw)
198189
else if (ipimd == 5) then
199190
iost = read_forces(fx, fy, fz, natqm, tocalc_lz(istate_lz), MAXUNITS + iw) !Save only the computed state

src/forces.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ subroutine force_wrapper(x, y, z, fx, fy, fz, e_pot, chpot, walkmax)
198198
case ("_cp2k_")
199199
call force_cp2k(x, y, z, fx, fy, fz, eclas, walkmax)
200200
case ("_tera_")
201-
if (ipimd == 2 .or. ipimd == 4 .or. ipimd == 5) then
201+
if (ipimd == 2 .or. ipimd == 5) then
202202
call force_terash(x, y, z, fx, fy, fz, eclas)
203203
else
204204
call force_tera(x, y, z, fx, fy, fz, eclas, walkmax)

src/init.F90

+12-15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ subroutine init(dt)
1616
use mod_const
1717
use mod_interfaces, only: print_compile_info, omp_set_num_threads, print_runtime_info
1818
use mod_cmdline, only: get_cmdline
19+
use mod_error, only: fatal_error
1920
use mod_files
2021
use mod_arrays
2122
use mod_array_size
@@ -222,10 +223,10 @@ subroutine init(dt)
222223
ipimd = 2
223224
case ('minimization')
224225
ipimd = 3
225-
case ('ehrenfest')
226-
ipimd = 4
227226
case ('landau_zener')
228227
ipimd = 5
228+
case default
229+
call fatal_error(__FILE__, __LINE__, 'invalid mdtype in '//trim(chinput))
229230
end select
230231
end if
231232

@@ -265,8 +266,6 @@ subroutine init(dt)
265266
print '(a)', ' Surface Hopping MD '
266267
case (3)
267268
print '(a)', ' Minimization '
268-
case (4)
269-
print '(a)', ' Ehrenfest MD '
270269
case (5)
271270
print '(a)', ' Landau Zener MD '
272271
end select
@@ -348,9 +347,6 @@ subroutine init(dt)
348347

349348
! allocate all basic arrays and set them to 0.0d0
350349
call allocate_arrays(natom, nwalk + 1)
351-
! Ehrenfest require larger array since gradients for all of the states are need
352-
! TODO: We should really make this differently..
353-
if (ipimd == 4) call allocate_ehrenfest(natom, nstate)
354350

355351
if (iplumed == 1) then
356352
call plumed_init()
@@ -417,7 +413,7 @@ subroutine init(dt)
417413
read (150, nhcopt)
418414
rewind (150)
419415

420-
if (ipimd == 2 .or. ipimd == 4) then
416+
if (ipimd == 2) then
421417
read (150, sh)
422418
rewind (150)
423419
integ = tolower(integ)
@@ -445,15 +441,15 @@ subroutine init(dt)
445441

446442
if (pot == '_tera_' .or. restrain_pot == '_tera_') then
447443
call initialize_tc_servers()
448-
if (ipimd == 2 .or. ipimd == 4 .or. ipimd == 5) then
444+
if (ipimd == 2 .or. ipimd == 5) then
449445
call init_terash(x, y, z)
450446
end if
451447
end if
452448

453-
!-----HERE WE CHECK FOR ERRORS IN INPUT-----------
449+
! Check whether input parameters make sense
454450
call check_inputsanity()
455451

456-
! resetting number of walkers to 1 in case of classical simulation
452+
! resetting number of walkers to 1 in case of classical simulation
457453
if (ipimd == 0) then
458454
if (my_rank == 0) then
459455
write (*, *) 'Using velocity Verlet integrator'
@@ -465,8 +461,9 @@ subroutine init(dt)
465461
! algorithm as well
466462
end if
467463

468-
!for surface hopping and ehrenfest
469-
if (ipimd == 2 .or. ipimd == 4 .or. ipimd == 5) then
464+
! Selecting proper integrator for a given MD type
465+
! (controlled by variable 'md')
466+
if (ipimd == 2 .or. ipimd == 5) then
470467
nwalk = ntraj !currently 1
471468
md = 2 ! velocity verlet
472469
nabin = 1
@@ -648,7 +645,7 @@ subroutine init(dt)
648645
write (*, nml=nhcopt, delim='APOSTROPHE')
649646
write (*, *)
650647
end if
651-
if (ipimd == 2 .or. ipimd == 4) then
648+
if (ipimd == 2) then
652649
write (*, nml=sh, delim='APOSTROPHE')
653650
write (*, *)
654651
end if
@@ -911,7 +908,7 @@ subroutine check_inputsanity()
911908
write (*, *) chknow
912909
if (iknow /= 1) error = 1
913910
end if
914-
if (inose == 1 .and. (ipimd == 2 .or. ipimd == 4) .and. en_restraint == 0) then
911+
if (inose == 1 .and. (ipimd == 2) .and. en_restraint == 0) then
915912
write (*, *) 'Thermostating is not meaningful for surface hopping simulation.'
916913
write (*, *) chknow
917914
if (iknow /= 1) error = 1

src/mdstep.F90

+1-10
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ end subroutine thermostat
8080
! Contains propagation of normal modes according to:
8181
! eq 23 from J. Chem. Phys. 133, 124104 2010
8282
subroutine verletstep(x, y, z, px, py, pz, amt, dt, eclas, fxc, fyc, fzc)
83-
use mod_general, only: pot, ipimd, inormalmodes, en_restraint
83+
use mod_general, only: pot, inormalmodes, en_restraint
8484
use mod_nhc, only: inose
8585
use mod_interfaces, only: force_clas, propagate_nm
86-
! Not yet implemented
87-
!use mod_sh, only: ehrenfest_forces
8886
use mod_en_restraint
8987
real(DP), intent(inout) :: x(:, :), y(:, :), z(:, :)
9088
real(DP), intent(inout) :: fxc(:, :), fyc(:, :), fzc(:, :)
@@ -107,13 +105,6 @@ subroutine verletstep(x, y, z, px, py, pz, amt, dt, eclas, fxc, fyc, fzc)
107105

108106
call force_clas(fxc, fyc, fzc, x, y, z, eclas, pot)
109107

110-
if (ipimd == 4) then
111-
! This is only a stub for now
112-
write (*, *) 'ERROR: Ehrenfest MD not implemented yet!!'
113-
call abinerror('verletstep')
114-
!call ehrenfest_forces(x, y, z, fxc, fyc, fzc, px, py, pz, dt, eclas)
115-
end if
116-
117108
call shiftP(px, py, pz, fxc, fyc, fzc, dt / 2)
118109

119110
if (inose > 0) call thermostat(px, py, pz, amt, dt / 2)

0 commit comments

Comments
 (0)