@@ -3511,7 +3511,7 @@ end subroutine writeTDAutotest
35113511
35123512
35133513 ! > Initialize ion dynamics
3514- subroutine initIonDynamics (this , coordNew , coord )
3514+ subroutine initIonDynamics (this , coordNew , coord , movedAccel )
35153515
35163516 ! > ElecDynamics instance
35173517 type (TElecDynamics), intent (inout ) :: this
@@ -3522,6 +3522,9 @@ subroutine initIonDynamics(this, coordNew, coord)
35223522 ! > Atomic coordinates
35233523 real (dp), intent (in ) :: coord(:,:)
35243524
3525+ ! > Accelerations (optional, only needed for restart+kick to apply Euler bootstrap)
3526+ real (dp), intent (in ), optional :: movedAccel(:,:)
3527+
35253528 ! Data for the velocity verlet integrator
35263529 type (TVelocityVerlet), allocatable :: pVelocityVerlet
35273530
@@ -3544,10 +3547,19 @@ subroutine initIonDynamics(this, coordNew, coord)
35443547 end if
35453548
35463549 ! Euler step from 1st VV step
3547- ! Velocities should actually be v(t+0.5*dt), not v(t),
3548- ! like this: this%movedVelo(:,:) = this%movedVelo + 0.5_dp * movedAccel * this%dt
3549- coordNew(:,:) = coord
3550- coordNew(:,this% indMovedAtom) = coordNew(:,this% indMovedAtom) + this% movedVelo * this% dt
3550+ ! For restart+kick case: apply Euler bootstrap to properly initialize velocity history
3551+ ! Transform v(t) to v(t-0.5*dt) and advance coordinates with acceleration term
3552+ if (present (movedAccel)) then
3553+ print * ,' Moved accel' ,movedAccel
3554+ print * ,' Moved velo' ,this% movedVelo
3555+ coordNew(:,:) = coord
3556+ coordNew(:,this% indMovedAtom) = coordNew(:,this% indMovedAtom) + this% movedVelo * this% dt ! &
3557+ ! & + 0.5_dp * movedAccel(:,:) * this%dt * this%dt
3558+ this% movedVelo(:,:) = this% movedVelo + movedAccel * this% dt
3559+ else
3560+ coordNew(:,:) = coord
3561+ coordNew(:,this% indMovedAtom) = coordNew(:,this% indMovedAtom) + this% movedVelo * this% dt
3562+ end if
35513563
35523564 ! This re-initializes the velocity Verlet propagator with coordNew
35533565 if (this% nDynamicsInit == 0 ) then
@@ -4642,7 +4654,13 @@ subroutine initializeDynamics(this, boundaryCond, coord, orb, neighbourList, nNe
46424654 ! needed to initialise the electronic dynamics
46434655 ! coordNew stores the coordinates at t=dt
46444656 if (this% tIons) then
4645- call initIonDynamics(this, this% coordNew, coord)
4657+ ! Pass accelerations only for restart+kick case to apply proper Euler bootstrap
4658+ if (this% tReadRestart .and. this% tKick) then
4659+ print * ," Passing movedAccel to initIonDynamics for restart+kick case"
4660+ call initIonDynamics(this, this% coordNew, coord, this% movedAccel)
4661+ else
4662+ call initIonDynamics(this, this% coordNew, coord)
4663+ end if
46464664 end if
46474665
46484666 ! after calculating the TD function, set initial time to zero for probe simulations
@@ -4666,26 +4684,25 @@ subroutine initializeDynamics(this, boundaryCond, coord, orb, neighbourList, nNe
46664684 & qDepExtPot, this% qBlock, dftbu, xi, iAtInCentralRegion, tFixEf, Ef, onSiteElements,&
46674685 & errStatus)
46684686 @:PROPAGATE_ERROR(errStatus)
4669-
4670- if (.not. this% tReadRestart .or. this% tProbe) then
4671- ! output ground state data
4672- call writeTDOutputs(this, env, this% dipoleDat, this% qDat, this% energyDat, &
4673- & this% forceDat, this% coorDat, this% fdBondPopul, this% fdBondEnergy, this% atomEnergyDat,&
4674- & 0.0_dp , this% energy, this% energyKin, this% dipole, this% deltaQ, coord, this% totalForce,&
4675- & 0 )
4676- end if
4677-
46784687 ! now first step of dynamics is computed (init of leapfrog and first step of nuclei)
46794688
46804689 ! had to add the "or tKick" option to override rhoOld if tReadRestart = yes, otherwise it will
46814690 ! be badly initialised
4682- if (.not. this% tReadRestart .or. ( this% tKick .and. this % startTime < this % dt / 10.0_dp ) ) then
4691+ if (.not. this% tReadRestart .or. this% tKick) then
46834692 ! Initialize electron dynamics
46844693 ! rhoOld is now the GS DM, rho will be the DM at time=dt
46854694 this% trhoOld(:,:,:) = this% trho
46864695 call initializePropagator(this, env, this% dt, this% trhoOld, this% trho, this% H1, this% Sinv,&
46874696 & coordAll, skOverCont, orb, neighbourList, nNeighbourSK, img2CentCell, iSquare)
46884697 end if
4698+
4699+ if (.not. this% tReadRestart .or. this% tProbe) then
4700+ ! output ground state data
4701+ call writeTDOutputs(this, env, this% dipoleDat, this% qDat, this% energyDat, &
4702+ & this% forceDat, this% coorDat, this% fdBondPopul, this% fdBondEnergy, this% atomEnergyDat,&
4703+ & 0.0_dp , this% energy, this% energyKin, this% dipole, this% deltaQ, coord, this% totalForce,&
4704+ & 0 )
4705+ end if
46894706
46904707 this% rho = > this% trho
46914708 this% rhoOld = > this% trhoOld
0 commit comments