Skip to content

Commit 8450f14

Browse files
committed
Add mDFTB
1 parent a6bddfe commit 8450f14

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5412
-68
lines changed

src/dftbp/dftb/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ set(sources-fpp
3434
${curdir}/halogenx.F90
3535
${curdir}/hamiltonian.F90
3636
${curdir}/hybridxc.F90
37+
${curdir}/multiexpan.F90
3738
${curdir}/nonscc.F90
3839
${curdir}/onscorrection.F90
3940
${curdir}/orbitalequiv.F90

src/dftbp/dftb/energytypes.F90

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ module dftbp_dftb_energytypes
3535
!> range-separation energy
3636
real(dp) :: Efock = 0.0_dp
3737

38+
!> MultiPole energy
39+
real(dp) :: EDftbMultiExpan = 0.0_dp
40+
real(dp) :: EDftbMultiExpanMD = 0.0_dp
41+
real(dp) :: EDftbMultiExpanDD = 0.0_dp
42+
real(dp) :: EDftbMultiExpanMQ = 0.0_dp
43+
real(dp) :: EDftbMultiExpanDQ = 0.0_dp
44+
real(dp) :: EDftbMultiExpanQQ = 0.0_dp
45+
3846
!> spin orbit energy
3947
real(dp) :: ELS = 0.0_dp
4048

@@ -121,6 +129,9 @@ module dftbp_dftb_energytypes
121129
!> atom resolved spin
122130
real(dp), allocatable :: atomSpin(:)
123131

132+
!> atom resolved Multipole
133+
real(dp), allocatable :: atomDftbMultiExpan(:)
134+
124135
!> atom resolved spin orbit
125136
real(dp), allocatable :: atomLS(:)
126137

@@ -192,6 +203,7 @@ subroutine TEnergies_init(this, nAtom, nSpin)
192203
allocate(this%atomOnSite(nAtom))
193204
allocate(this%atomHalogenX(nAtom))
194205
allocate(this%atom3rd(nAtom))
206+
allocate(this%atomDftbMultiExpan(nAtom))
195207
allocate(this%atomSolv(nAtom))
196208
allocate(this%atomTotal(nAtom))
197209
this%atomRep(:) = 0.0_dp
@@ -214,6 +226,12 @@ subroutine TEnergies_init(this, nAtom, nSpin)
214226
this%ESCC = 0.0_dp
215227
this%Espin = 0.0_dp
216228
this%Efock = 0.0_dp
229+
this%EDftbMultiExpan = 0.0_dp
230+
this%EDftbMultiExpanMD = 0.0_dp
231+
this%EDftbMultiExpanDD = 0.0_dp
232+
this%EDftbMultiExpanMQ = 0.0_dp
233+
this%EDftbMultiExpanDQ = 0.0_dp
234+
this%EDftbMultiExpanQQ = 0.0_dp
217235
this%ELS = 0.0_dp
218236
this%Edftbu = 0.0_dp
219237
this%Eext = 0.0_dp

src/dftbp/dftb/getenergies.F90

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module dftbp_dftb_getenergies
1818
use dftbp_dftb_dftbplusu, only : TDftbU
1919
use dftbp_dftb_dispiface, only : TDispersionIface
2020
use dftbp_dftb_energytypes, only : TEnergies
21+
use dftbp_dftb_multiexpan, only : TDftbMultiExpan
2122
use dftbp_dftb_onsitecorrection, only : getEons
2223
use dftbp_dftb_periodic, only : TNeighbourList
2324
use dftbp_dftb_populations, only : mulliken
@@ -46,8 +47,8 @@ module dftbp_dftb_getenergies
4647

4748

4849
!> Calculates various energy contribution that can potentially update for the same geometry
49-
subroutine calcEnergies(env, sccCalc, tblite, qOrb, q0, chargePerShell, multipole, species,&
50-
& isExtField, isXlbomd, dftbU, tDualSpinOrbit, rhoPrim, H0, orb, neighbourList,&
50+
subroutine calcEnergies(env, sccCalc, tblite, qOrb, q0, chargePerShell, multipole, dftbMultiExpan,&
51+
& species, isExtField, isXlbomd, dftbU, tDualSpinOrbit, rhoPrim, H0, orb, neighbourList,&
5152
& nNeighbourSK, img2CentCell, iSparseStart, cellVol, extPressure, TS, potential,&
5253
& energy, thirdOrd, solvation, hybridXc, reks, qDepExtPot, qBlock, qiBlock, xi,&
5354
& iAtInCentralRegion, tFixEf, Ef, tRealHS, onSiteElements, errStatus, qNetAtom,&
@@ -74,6 +75,9 @@ subroutine calcEnergies(env, sccCalc, tblite, qOrb, q0, chargePerShell, multipol
7475
!> Multipole moments
7576
type(TMultipole), intent(in) :: multipole
7677

78+
!> DFTB multipole moments
79+
type(TDftbMultiExpan), intent(inout), allocatable :: dftbMultiExpan
80+
7781
!> chemical species
7882
integer, intent(in) :: species(:)
7983

@@ -279,6 +283,13 @@ subroutine calcEnergies(env, sccCalc, tblite, qOrb, q0, chargePerShell, multipol
279283
energy%ELS = sum(energy%atomLS(iAtInCentralRegion))
280284
end if
281285

286+
! Add contribution for DFTB multipole calculations
287+
if (allocated(dftbMultiExpan)) then
288+
call dftbMultiExpan%addMultiExpanEnergy(energy%atomDftbMultiExpan, energy%EDftbMultiExpanMD,&
289+
& energy%EDftbMultiExpanDD, energy%EDftbMultiExpanMQ, energy%EDftbMultiExpanDQ,&
290+
& energy%EDftbMultiExpanQQ, energy%EDftbMultiExpan)
291+
end if
292+
282293
! Add exchange contribution for range separated calculations
283294
if (allocated(hybridXc) .and. .not. allocated(reks)) then
284295
if (tRealHS) then
@@ -351,11 +362,12 @@ subroutine sumEnergies(energy)
351362
type(TEnergies), intent(inout) :: energy
352363

353364
energy%Eelec = energy%EnonSCC + energy%ESCC + energy%Espin + energy%ELS + energy%Edftbu&
354-
& + energy%Eext + energy%e3rd + energy%eOnSite + energy%ESolv + energy%Efock
365+
& + energy%Eext + energy%e3rd + energy%eOnSite + energy%ESolv + energy%Efock&
366+
& + energy%EDftbMultiExpan
355367

356368
energy%atomElec(:) = energy%atomNonSCC + energy%atomSCC + energy%atomSpin + energy%atomDftbu&
357-
& + energy%atomLS + energy%atomExt + energy%atom3rd + energy%atomOnSite &
358-
& + energy%atomSolv
369+
& + energy%atomLS + energy%atomExt + energy%atom3rd + energy%atomOnSite&
370+
& + energy%atomSolv + energy%atomDftbMultiExpan
359371
energy%atomTotal(:) = energy%atomElec + energy%atomRep + energy%atomDisp + energy%atomHalogenX
360372
energy%Etotal = energy%Eelec + energy%Erep + energy%eDisp + energy%eHalogenX
361373
energy%EMermin = energy%Etotal - sum(energy%TS)

src/dftbp/dftb/hamiltonian.F90

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module dftbp_dftb_hamiltonian
1717
use dftbp_dftb_dftbplusu, only : TDftbU
1818
use dftbp_dftb_dispersions, only : TDispersionIface
1919
use dftbp_dftb_extfields, only : TEField
20+
use dftbp_dftb_multiexpan, only : TDftbMultiExpan
2021
use dftbp_dftb_periodic, only : TNeighbourList
2122
use dftbp_dftb_potentials, only : TPotentials
2223
use dftbp_dftb_scc, only : TScc
@@ -148,7 +149,7 @@ end subroutine resetInternalPotentials
148149
!> spin, and where relevant dispersion
149150
subroutine addChargePotentials(env, sccCalc, tblite, updateScc, qInput, q0, chargePerShell,&
150151
& orb, multipole, species, neighbourList, img2CentCell, spinW, solvation, thirdOrd,&
151-
& dispersion, potential, errStatus)
152+
& dftbMultiExpan, dispersion, potential, errStatus)
152153

153154
!> Environment settings
154155
type(TEnvironment), intent(inout) :: env
@@ -195,6 +196,9 @@ subroutine addChargePotentials(env, sccCalc, tblite, updateScc, qInput, q0, char
195196
!> third order SCC interactions
196197
type(TThirdOrder), allocatable, intent(inout) :: thirdOrd
197198

199+
!> Multipole expansion
200+
type(TDftbMultiExpan), allocatable, intent(inout) :: dftbMultiExpan
201+
198202
!> Potentials acting
199203
type(TPotentials), intent(inout) :: potential
200204

@@ -207,6 +211,7 @@ subroutine addChargePotentials(env, sccCalc, tblite, updateScc, qInput, q0, char
207211
! local variables
208212
real(dp), allocatable :: atomPot(:,:)
209213
real(dp), allocatable :: shellPot(:,:,:)
214+
real(dp), allocatable :: deltaMAtom(:)
210215
real(dp), allocatable :: dipPot(:,:), quadPot(:,:)
211216
integer, pointer :: pSpecies0(:)
212217
integer :: nAtom, nSpin
@@ -264,6 +269,13 @@ subroutine addChargePotentials(env, sccCalc, tblite, updateScc, qInput, q0, char
264269
end if
265270
end if
266271

272+
if (allocated(dftbMultiExpan)) then
273+
allocate(deltaMAtom(nAtom))
274+
call sccCalc%getDeltaQAtom(deltaMAtom)
275+
call dftbMultiExpan%updateDQPotentials(deltaMAtom)
276+
deallocate(deltaMAtom)
277+
end if
278+
267279
if (allocated(thirdOrd)) then
268280
call thirdOrd%updateCharges(pSpecies0, neighbourList, qInput, q0, img2CentCell, orb)
269281
call thirdOrd%getShifts(atomPot(:,1), shellPot(:,:,1))
@@ -331,7 +343,7 @@ end subroutine addBlockChargePotentials
331343

332344
!> Returns the Hamiltonian for the given scc iteration
333345
subroutine getSccHamiltonian(env, H0, ints, nNeighbourSK, neighbourList, species, orb,&
334-
& iSparseStart, img2CentCell, potential, isREKS, ham, iHam)
346+
& iSparseStart, img2CentCell, potential, dftbMultiExpan, isREKS, ham, iHam)
335347

336348
!> Environment settings
337349
type(TEnvironment), intent(in) :: env
@@ -363,6 +375,9 @@ subroutine getSccHamiltonian(env, H0, ints, nNeighbourSK, neighbourList, species
363375
!> Potential acting on system
364376
type(TPotentials), intent(in) :: potential
365377

378+
!> DFTB multipole expansion
379+
type(TDftbMultiExpan), allocatable, intent(inout) :: dftbMultiExpan
380+
366381
!> Is this DFTB/SSR formalism
367382
logical, intent(in) :: isREKS
368383

@@ -413,6 +428,11 @@ subroutine getSccHamiltonian(env, H0, ints, nNeighbourSK, neighbourList, species
413428
& potential%quadrupoleAtom)
414429
end if
415430

431+
if (allocated(dftbMultiExpan)) then
432+
call dftbMultiExpan%addMultiExpanHamiltonian(ham, ints%overlap, nNeighbourSK,&
433+
& neighbourList%iNeighbour, species, orb, iSparseStart, nAtom, img2CentCell)
434+
end if
435+
416436
if (allocated(iHam)) then
417437
iHam(:,:) = 0.0_dp
418438
call addShift(env, iHam, ints%overlap, nNeighbourSK, neighbourList%iNeighbour, species, orb,&

0 commit comments

Comments
 (0)