Skip to content

Commit

Permalink
Check old parser sets scc for hybrids (dftbplus#1575)
Browse files Browse the repository at this point in the history
* Check old parser sets scc for hybrids

Trap for Hybrid = None {} case on removal of SCC for v14
Clean up some error messages
Update missed tests from (dftbplus#1571)

* Update src/dftbp/dftbplus/oldcompat.F90

Co-authored-by: Tammo van der Heide <[email protected]>
  • Loading branch information
bhourahine and vanderhe authored Dec 7, 2024
1 parent 901667d commit d58f63f
Show file tree
Hide file tree
Showing 32 changed files with 41 additions and 43 deletions.
41 changes: 35 additions & 6 deletions src/dftbp/dftbplus/oldcompat.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module dftbp_dftbplus_oldcompat
use dftbp_common_accuracy, only : dp
use dftbp_extlibs_xmlf90, only : fnodeList, fnode, removeChild, string, char, getLength,&
& getNodeName, destroyNode, getItem1, destroyNodeList
use dftbp_io_charmanip, only : i2c
use dftbp_io_charmanip, only : i2c, tolower
use dftbp_io_hsdutils, only : getChildValue, setChildValue, getChild, setChild, detailedWarning,&
& detailedError, getChildren
use dftbp_io_hsdutils2, only : getDescendant, setUnprocessed, setNodeName
Expand Down Expand Up @@ -779,7 +779,7 @@ subroutine convert_12_13(root)
!> Root tag of the HSD-tree
type(fnode), pointer :: root

type(fnode), pointer :: ch1, ch2, ch3, par1
type(fnode), pointer :: ch1, ch2, par1
integer :: maxIter
logical :: isPerturb, isConvRequired
real(dp) :: sccTol
Expand Down Expand Up @@ -840,7 +840,9 @@ subroutine convert_13_14(root)
!> Root tag of the HSD-tree
type(fnode), pointer :: root

type(fnode), pointer :: ch1, ch2, par, dummy
type(fnode), pointer :: ch1, ch2, ch3, par, dummy, hybridAlgorithm
type(string) :: buffer
logical :: isScc, isNoneAlgorithm

call getDescendant(root, "Analysis/CalculateForces", ch1)
if (associated(ch1)) then
Expand All @@ -857,10 +859,37 @@ subroutine convert_13_14(root)

call getDescendant(root, "Hamiltonian/DFTB/Hybrid", ch1)
if (associated(ch1)) then
call detailedWarning(ch1, "'Hamiltonian/DFTB/SCC' keyword removed as hybrid calculations are&
& always SCC.")
! test if old input was actually SCC
isScc = .true.
call getDescendant(root, "Hamiltonian/DFTB/SCC", ch2, parent=par)
dummy => removeChild(par, ch2)
if (.not. associated(ch2)) then
isScc = .false.
else
call getChildValue(ch2, "", isScc, child=ch3)
call setUnprocessed(ch3)
end if

call getChildValue(ch1, "", hybridAlgorithm, child=ch3)
call getNodeName(hybridAlgorithm, buffer)

! as this is allowed as an input choice
isNoneAlgorithm = tolower(char(buffer)) == "none"

if (.not.isNoneAlgorithm) then
call detailedWarning(ch1, "'Hamiltonian/DFTB/SCC' keyword removed as hybrid calculations&
& are always SCC.")
dummy => removeChild(par, ch2)
end if

if (.not. isScc .and. .not.isNoneAlgorithm) then
call detailedError(ch1, "Old input versions (<14) require SCC=Yes explicitly for hybrid&
& functional calculations.")
end if

call setUnprocessed(ch3)
call setUnprocessed(ch2)
call setUnprocessed(ch1)

end if

end subroutine convert_13_14
Expand Down
13 changes: 6 additions & 7 deletions src/dftbp/dftbplus/parser.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7964,11 +7964,13 @@ subroutine parseHybridBlock(node, input, geo, skFiles)

if (isHybridInp .and. .not. isHybridSk) then
call error("Hybrid input block present, but SK-file '" // trim(fileName)&
& // "' appears to be (semi-)local.")
& // "'" // newline // " appears to be (semi-)local.")
elseif (isHybridSk .and. .not. isHybridInp) then
call error("Hybrid SK-file '" // trim(fileName) // "' present, but HSD input block missing.")
call error("Hybrid SK-file '" // trim(fileName) // "' provided," // newline //&
& " but the hybrid block is missing from the HSD input file.")
end if

hybridXcInputTag = hybridXcFunc%none
if (isHybridInp) then
! Convert hybrid functional type of user input to enumerator
select case(tolower(char(buffer)))
Expand All @@ -7985,7 +7987,8 @@ subroutine parseHybridBlock(node, input, geo, skFiles)

! Check if hybrid functional type is in line with SK-files
if (.not. hybridXcInputTag == hybridXcSkTag) then
call detailedError(hybridChild, "Hybrid functional type conflict with SK-files.")
call detailedError(hybridChild, "Requested hybrid functional type conflict with provided&
& SK-file(s).")
end if

allocate(input)
Expand Down Expand Up @@ -8072,10 +8075,6 @@ subroutine parseHybridBlock(node, input, geo, skFiles)
call getChildValue(cmValue, "WignerSeitzReduction", input%wignerSeitzReduction, default=0)
end if

else

hybridXcInputTag = hybridXcFunc%none

end if

end subroutine parseHybridBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SCCTolerance = 1.0e-10

Mixer = Broyden {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
ConvergentSCCOnly = No
ReadInitialCharges = Yes
MaxSccIterations = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
ConvergentSCCOnly = No
ReadInitialCharges = Yes
MaxSccIterations = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
ConvergentSCCOnly = No
ReadInitialCharges = Yes
MaxSccIterations = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SccTolerance = 1e-10
MaxSccIterations = 60

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SccTolerance = 1e-10
ReadInitialCharges = Yes
MaxSccIterations = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SccTolerance = 1e-10
MaxSccIterations = 60

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SccTolerance = 1e-10
ReadInitialCharges = Yes
MaxSccIterations = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SccTolerance = 1e-10
MaxSccIterations = 60

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SccTolerance = 1e-10
ReadInitialCharges = Yes
MaxSccIterations = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
ConvergentSCCOnly = No
ReadInitialCharges = Yes
MaxSccIterations = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SccTolerance = 1e-10
MaxSccIterations = 50

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SccTolerance = 1e-10
ReadInitialCharges = Yes
MaxSccIterations = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SCCTolerance = 1e-08

Charge = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SCCTolerance = 1e-08

Charge = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SCCTolerance = 1e-08

Charge = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SCCTolerance = 1e-10

Charge = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
SCCTolerance = 1e-12
MaxSCCIterations = 50

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = GenFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = VaspFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-08

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Geometry = VaspFormat {

Hamiltonian = DFTB {

SCC = Yes
MaxSccIterations = 100
SccTolerance = 1e-08

Expand Down

0 comments on commit d58f63f

Please sign in to comment.