diff --git a/src/dftbp/common/assert.F90 b/src/dftbp/common/assert.F90 index d9684ab861..4907157b35 100644 --- a/src/dftbp/common/assert.F90 +++ b/src/dftbp/common/assert.F90 @@ -23,7 +23,7 @@ module dftbp_common_assert !> Prints assertion error and abort program execution. - subroutine assertError(fileName, lineNr) + subroutine assertError(fileName, lineNr, message) !> Name of the file in which the error occurred. character(*), intent(in) :: fileName @@ -31,9 +31,15 @@ subroutine assertError(fileName, lineNr) !> Nr. of the line at which the error occurred. integer, intent(in) :: lineNr + !> Additional message for error + character(*), intent(in), optional :: message + write(stdout, '(A)') "!!! UNFULLFILLED ASSERTION" write(stdout, '(A,A)') "!!! FILE: ", fileName write(stdout, '(A,I0)') "!!! LINE NR.: ", lineNr + if (present(message)) then + write(stdout, '(A,A,A)') '!!! MESSAGE: "', trim(message), '"' + end if call abortProgram() end subroutine assertError diff --git a/src/dftbp/dftb/hybridxc.F90 b/src/dftbp/dftb/hybridxc.F90 index b7edc7ff7a..f396f446e6 100644 --- a/src/dftbp/dftb/hybridxc.F90 +++ b/src/dftbp/dftb/hybridxc.F90 @@ -1068,14 +1068,14 @@ subroutine updateCoords_kpts(this, env, symNeighbourList, nNeighbourCamSym, skOv contains - !> Returns the number of non-zero elements in a descending array of reals. + !> Returns the number of non-zero elements in a descending array of non-negative reals. function getNumberOfNonZeroElements(array) result(nNonZeroEntries) !> Descending, one-dimensional, real-valued array to search real(dp), intent(in) :: array(:) !> Number of non-zero entries - real(dp) :: nNonZeroEntries + integer :: nNonZeroEntries !! iterates over all array elements integer :: ii @@ -1083,7 +1083,10 @@ function getNumberOfNonZeroElements(array) result(nNonZeroEntries) nNonZeroEntries = 0 do ii = 1, size(array) - if (array(ii) < 1e-16_dp) return + if (array(ii) < epsilon(1.0_dp)) then + @:ASSERT(all(array(ii:) >= 0.0_dp)) + return + end if nNonZeroEntries = ii end do diff --git a/src/dftbp/dftbplus/initprogram.F90 b/src/dftbp/dftbplus/initprogram.F90 index 9751613038..71a357a9d2 100644 --- a/src/dftbp/dftbplus/initprogram.F90 +++ b/src/dftbp/dftbplus/initprogram.F90 @@ -2092,7 +2092,8 @@ subroutine initProgramVariables(this, input, env) ! requires stress to already be possible and it being a periodic calculation ! with forces - this%tStress = (this%tPeriodic .and. this%tForces .and. .not.this%tNegf .and. this%tStress) + this%tStress = (this%tPeriodic .and. this%tForces .and. .not.this%tNegf .and. this%tStress& + & .and. .not. this%isHybridXc) this%nMovedAtom = input%ctrl%nrMoved this%nMovedCoord = 3 * this%nMovedAtom diff --git a/src/dftbp/dftbplus/main.F90 b/src/dftbp/dftbplus/main.F90 index c1eac3155b..a2c7fe3bb3 100644 --- a/src/dftbp/dftbplus/main.F90 +++ b/src/dftbp/dftbplus/main.F90 @@ -1161,7 +1161,7 @@ subroutine processGeometry(this, env, iGeoStep, iLatGeoStep, tWriteRestart, tSto call buildS(env, this%ints%overlap, this%skOverCont, this%coord, this%nNeighbourSk,& & this%neighbourList%iNeighbour, this%species, this%iSparseStart, this%orb) case(hamiltonianTypes%xtb) - @:ASSERT(allocated(this%tblite)) + @:ASSERT(allocated(this%tblite), "Compiled without TBLITE included") call this%tblite%buildSH0(env, this%species, this%coord, this%nNeighbourSk, & & this%neighbourList%iNeighbour, this%img2CentCell, this%iSparseStart, & & this%orb, this%H0, this%ints%overlap, this%ints%dipoleBra, this%ints%dipoleKet, & diff --git a/src/dftbp/dftbplus/parser.F90 b/src/dftbp/dftbplus/parser.F90 index 382f8a560e..94f1b4a828 100644 --- a/src/dftbp/dftbplus/parser.F90 +++ b/src/dftbp/dftbplus/parser.F90 @@ -775,6 +775,9 @@ subroutine readDriver(node, parent, geom, ctrl) ctrl%BarostatStrength = 0.0_dp call getChild(node, "Barostat", child, requested=.false.) if (associated(child)) then + if (allocated(ctrl%hybridXcInp)) then + call detailedError(node, "Barostating not currently implemented for hybrid functionals") + end if if (ctrl%nrMoved /= geom%nAtom) then call error("Dynamics for a subset of atoms is not currently& & possible when using a barostat") @@ -953,6 +956,10 @@ subroutine commonGeoOptions(node, ctrl, geom, atomsRange, isMaxStepNeeded) call getChildValue(node, "LatticeOpt", ctrl%tLatOpt, .false.) if (ctrl%tLatOpt) then + if (allocated(ctrl%hybridXcInp)) then + call detailedError(node, "Lattice optimisation not currently implemented for hybrid& + & functionals") + end if call getChildValue(node, "Pressure", ctrl%pressure, 0.0_dp, modifier=modifier, child=child) call convertUnitHsd(char(modifier), pressureUnits, child, ctrl%pressure) call getChildValue(node, "FixAngles", ctrl%tLatOptFixAng, .false.) diff --git a/src/dftbp/include/common.fypp b/src/dftbp/include/common.fypp index 4a0f497880..1e4f5cfb00 100644 --- a/src/dftbp/include/common.fypp +++ b/src/dftbp/include/common.fypp @@ -42,12 +42,17 @@ #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #! Check a condition if WITH_ASSERT is True and call assertError if condition is False. -#:def ASSERT(cond) +#! If an optional text string is included, print this in addition as an error +#:def ASSERT(cond, msg=None) #:if WITH_ASSERT if (.not. (${cond}$)) then block use dftbp_common_assert, only : assertError + #:if msg + call assertError("${_FILE_}$", ${_LINE_}$, ${msg}$) + #:else call assertError("${_FILE_}$", ${_LINE_}$) + #:endif end block end if #:endif diff --git a/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-force-cam/_autotest.tag b/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-force-cam/_autotest.tag index 60662733c8..71e7b72d15 100644 --- a/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-force-cam/_autotest.tag +++ b/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-force-cam/_autotest.tag @@ -16,10 +16,6 @@ forces :real:2:3,6 0.841660967120195E-002 0.697051031432246E-001 0.513195666348540E-001 -0.620943202995113E-002 0.634863771762222E-001 0.275900765775735E-001 0.497820956029776E-001 -0.891614303165121E-001 -0.445325050423699E-001 -stress :real:2:3,3 - -0.281999257658939E-005 -0.158116756538915E-005 0.102667636911802E-005 - -0.156358396136917E-005 -0.252276970467409E-004 -0.522593971446003E-005 - 0.114245562571053E-005 -0.471287324240145E-005 -0.129752725811918E-003 mermin_energy :real:0: -0.948497872629297E+001 end_coords :real:2:3,6 diff --git a/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-restart-ascii/_autotest.tag b/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-restart-ascii/_autotest.tag index 97934de30d..661d64e0ad 100644 --- a/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-restart-ascii/_autotest.tag +++ b/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-restart-ascii/_autotest.tag @@ -58,10 +58,6 @@ forces :real:2:3,24 0.493238878787503E-015 -0.959662094714747E-002 0.923325535891134E-003 -0.269250933995395E-015 0.720775339666282E-002 0.518856670313658E-005 -0.450523667348162E-015 -0.719861523598164E-002 -0.936432014589893E-003 -stress :real:2:3,3 - 0.755590898324902E-015 -0.189935845010847E-028 0.000000000000000E+000 - -0.505614948936562E-024 -0.117762105292865E-008 -0.145094833627475E-009 - -0.103626319007240E-022 -0.144659133375066E-009 0.559114273422329E-008 mermin_energy :real:0: -0.369576859354938E+002 end_coords :real:2:3,24 diff --git a/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-restart/_autotest.tag b/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-restart/_autotest.tag index 97934de30d..661d64e0ad 100644 --- a/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-restart/_autotest.tag +++ b/test/app/dftb+/hybrid/periodic/Acene-gamma-matrix-restart/_autotest.tag @@ -58,10 +58,6 @@ forces :real:2:3,24 0.493238878787503E-015 -0.959662094714747E-002 0.923325535891134E-003 -0.269250933995395E-015 0.720775339666282E-002 0.518856670313658E-005 -0.450523667348162E-015 -0.719861523598164E-002 -0.936432014589893E-003 -stress :real:2:3,3 - 0.755590898324902E-015 -0.189935845010847E-028 0.000000000000000E+000 - -0.505614948936562E-024 -0.117762105292865E-008 -0.145094833627475E-009 - -0.103626319007240E-022 -0.144659133375066E-009 0.559114273422329E-008 mermin_energy :real:0: -0.369576859354938E+002 end_coords :real:2:3,24 diff --git a/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-cam/_autotest.tag b/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-cam/_autotest.tag index 60662733c8..71e7b72d15 100644 --- a/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-cam/_autotest.tag +++ b/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-cam/_autotest.tag @@ -16,10 +16,6 @@ forces :real:2:3,6 0.841660967120195E-002 0.697051031432246E-001 0.513195666348540E-001 -0.620943202995113E-002 0.634863771762222E-001 0.275900765775735E-001 0.497820956029776E-001 -0.891614303165121E-001 -0.445325050423699E-001 -stress :real:2:3,3 - -0.281999257658939E-005 -0.158116756538915E-005 0.102667636911802E-005 - -0.156358396136917E-005 -0.252276970467409E-004 -0.522593971446003E-005 - 0.114245562571053E-005 -0.471287324240145E-005 -0.129752725811918E-003 mermin_energy :real:0: -0.948497872629297E+001 end_coords :real:2:3,6 diff --git a/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-hyb/_autotest.tag b/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-hyb/_autotest.tag index ad61ffbad7..af2da91760 100644 --- a/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-hyb/_autotest.tag +++ b/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-hyb/_autotest.tag @@ -16,10 +16,6 @@ forces :real:2:3,6 0.490814414093120E-001 0.689735135036105E-001 0.959798797873647E-001 -0.924262124944980E-002 0.232218750518948E+000 0.857296606840727E-001 0.938494492111061E-001 -0.177009363276372E+000 -0.877839911175921E-001 -stress :real:2:3,3 - -0.674095774857295E-005 -0.360531043796975E-005 0.343569648098372E-005 - -0.359597537879627E-005 -0.828906667405799E-004 -0.821376769563750E-005 - 0.350845297205745E-005 -0.791977911498074E-005 -0.227688487849422E-003 mermin_energy :real:0: -0.128558094165303E+002 end_coords :real:2:3,6 diff --git a/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-lc/_autotest.tag b/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-lc/_autotest.tag index 7383a40f66..776da60055 100644 --- a/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-lc/_autotest.tag +++ b/test/app/dftb+/hybrid/periodic/Acene-gamma-neigh-force-lc/_autotest.tag @@ -16,10 +16,6 @@ forces :real:2:3,6 -0.154838545150892E-002 0.833123500998445E-001 0.102729355302494E-001 0.408344670576044E-002 0.394272079707581E+000 0.126300821241770E+000 -0.329638582134210E-001 0.147473193591006E+000 -0.549694766448895E-002 -stress :real:2:3,3 - 0.122230902158787E-005 -0.687135951653311E-005 0.409370727878236E-005 - -0.685421381117794E-005 0.169600681378801E-004 0.123588330362186E-004 - 0.423611578595749E-005 0.130163090530549E-004 -0.516524942088586E-004 mermin_energy :real:0: -0.926212417308193E+001 end_coords :real:2:3,6 diff --git a/test/app/dftb+/hybrid/periodic/Acene-kpts-matrix-force-lc/_autotest.tag b/test/app/dftb+/hybrid/periodic/Acene-kpts-matrix-force-lc/_autotest.tag index eef83365d1..1f7723d279 100644 --- a/test/app/dftb+/hybrid/periodic/Acene-kpts-matrix-force-lc/_autotest.tag +++ b/test/app/dftb+/hybrid/periodic/Acene-kpts-matrix-force-lc/_autotest.tag @@ -16,10 +16,6 @@ forces :real:2:3,6 -0.307830339046029E-002 0.723949733495977E-001 0.270782304449810E-001 -0.269126109792879E-002 0.793805739166834E-001 0.504923173775043E-001 -0.240518378954985E-001 0.105740086928808E+000 -0.130951813750250E-001 -stress :real:2:3,3 - 0.738061845006802E-006 -0.481962470220905E-005 0.190589688228491E-005 - -0.479019782201099E-005 0.202081325354995E-006 0.229470360298319E-005 - 0.201193025664104E-005 0.224556383825435E-005 0.203526301219277E-004 mermin_energy :real:0: -0.909710016832326E+001 end_coords :real:2:3,6 diff --git a/test/app/dftb+/hybrid/periodic/Acene-kpts-neigh-force-lc/_autotest.tag b/test/app/dftb+/hybrid/periodic/Acene-kpts-neigh-force-lc/_autotest.tag index eef83365d1..1f7723d279 100644 --- a/test/app/dftb+/hybrid/periodic/Acene-kpts-neigh-force-lc/_autotest.tag +++ b/test/app/dftb+/hybrid/periodic/Acene-kpts-neigh-force-lc/_autotest.tag @@ -16,10 +16,6 @@ forces :real:2:3,6 -0.307830339046029E-002 0.723949733495977E-001 0.270782304449810E-001 -0.269126109792879E-002 0.793805739166834E-001 0.504923173775043E-001 -0.240518378954985E-001 0.105740086928808E+000 -0.130951813750250E-001 -stress :real:2:3,3 - 0.738061845006802E-006 -0.481962470220905E-005 0.190589688228491E-005 - -0.479019782201099E-005 0.202081325354995E-006 0.229470360298319E-005 - 0.201193025664104E-005 0.224556383825435E-005 0.203526301219277E-004 mermin_energy :real:0: -0.909710016832326E+001 end_coords :real:2:3,6 diff --git a/test/app/dftb+/hybrid/periodic/Benzene-gamma-matrix-spin-force-grp1/_autotest.tag b/test/app/dftb+/hybrid/periodic/Benzene-gamma-matrix-spin-force-grp1/_autotest.tag index 71468d7396..5e069ec028 100644 --- a/test/app/dftb+/hybrid/periodic/Benzene-gamma-matrix-spin-force-grp1/_autotest.tag +++ b/test/app/dftb+/hybrid/periodic/Benzene-gamma-matrix-spin-force-grp1/_autotest.tag @@ -114,10 +114,6 @@ forces :real:2:3,48 0.173915854201560E-002 0.578944820816400E-002 0.419946079869956E-003 0.458366266793410E-002 0.412820938522018E-003 -0.446265655259587E-002 -0.253065808366456E-002 0.289574034634869E-002 0.350199532970742E-002 -stress :real:2:3,3 - 0.263269711953852E-003 0.193483529876307E-014 -0.183212067691962E-014 - 0.162827533779606E-014 0.408303206956582E-003 -0.880483910343211E-015 - 0.397758224151406E-015 0.714146595131474E-016 0.266694692658430E-003 mermin_energy :real:0: -0.589841478128182E+002 end_coords :real:2:3,48 diff --git a/test/app/dftb+/hybrid/periodic/Benzene-gamma-neigh-spin-force/_autotest.tag b/test/app/dftb+/hybrid/periodic/Benzene-gamma-neigh-spin-force/_autotest.tag index 19bad2810e..39da894924 100644 --- a/test/app/dftb+/hybrid/periodic/Benzene-gamma-neigh-spin-force/_autotest.tag +++ b/test/app/dftb+/hybrid/periodic/Benzene-gamma-neigh-spin-force/_autotest.tag @@ -114,10 +114,6 @@ forces :real:2:3,48 0.173915854220047E-002 0.578944820859538E-002 0.419946079940238E-003 0.458366266809072E-002 0.412820938622417E-003 -0.446265655278975E-002 -0.253065808383862E-002 0.289574034663917E-002 0.350199533001377E-002 -stress :real:2:3,3 - 0.263269711953544E-003 0.160733664759151E-014 -0.209355959048147E-014 - 0.149725566887498E-014 0.408303206956204E-003 -0.921743650861119E-015 - 0.471214975994564E-015 -0.213959479251713E-015 0.266694692660646E-003 mermin_energy :real:0: -0.589841478128179E+002 end_coords :real:2:3,48