You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No linked issue. This PR proposes an experimental native DFTB backend and does not close an existing issue.
What's changed?
Adds an experimental, in-process periodic SCC-DFTB solver, selected explicitly with basis_type=dftb and esolver_type=dftbnative. The default Kohn–Sham path is unchanged.
Implements SCC-DFTB2 and the interatomic third-order charge correction corresponding to DFTB+'s ThirdOrderFull, within the supported undamped-gamma model. The implementation includes a legacy SKF s+p basis, generalized Hermitian eigensolving, Mulliken SCC charges, linear/Pulay/modified-Broyden mixing, finite-temperature occupations, SKF spline repulsion, 3D Ewald electrostatics, and an optional frozen-SCC band path.
Writes a detailed OUT.{suffix}/dftb.log with setup, parameter, SCC-iteration, energy, and Mulliken-population data, alongside eigenvalue, occupation, charge, and optional band files. The DFTB log is flushed at each SCC iteration. This solver requires SKF parameter files, but does not require UPF pseudopotentials, ABACUS .orb files, or a DFTB+ runtime.
Rejects basis_type=dftb unless esolver_type=dftbnative during INPUT validation, with a direct diagnostic. The default solver and basis remain ksdft and pw.
Motivation and design
This backend is for workflows that need ABACUS INPUT/STRU/KPT handling and output conventions without packaging a DFTB+ executable or shared library. DFTB+ also offers an in-process API; using it from ABACUS would still require the external library and an adapter. The native backend is not API-compatible with DFTB+ and does not target feature parity. This trades a smaller runtime dependency footprint for additional maintenance and validation work.
The solver is included in standard builds and is opt-in at runtime through esolver_type=dftbnative; no ENABLE_DFTB_NATIVE build switch is added. This keeps the build configuration uniform while the solver's experimental status and supported scope are stated in the documentation and at runtime.
Inputs and supported scope
Use a standard ABACUS INPUT, STRU, and KPT, select basis_type=dftb and esolver_type=dftbnative, and provide a DFTB-native control file (default: dftb_native.in) pointing to the SKF parameter set. DFTB-specific controls include SCC convergence, mixing, temperature, third-order correction, and an optional band-path file. The default DFTB3 correction is off; enabling it requires a Hubbard derivative for each species.
The current model supports periodic 3D cells, legacy SKF files with a repulsive Spline section, an s+p basis, neutral valence electron counts, spin-degenerate calculations (nspin=1), monopole SCC charges, undamped gamma corrections, dense diagonalization, and frozen-potential band paths. Hydrogen-labelled species are rejected because the DFTB+ HCorrection = Damping model and its third-order derivatives are not implemented. Spin polarization, shell-resolved charges, modern SKF formats, dispersion, DOS/PDOS, restart, forces/stress, structural relaxation, and molecular dynamics are outside the current scope. Slab calculations use 3D-periodic Ewald electrostatics and require vacuum-convergence checks.
Unit Tests and/or Case Tests for my changes
Adds three CTest variants for the 36-atom C2N-h2D DFTB3 reference: the standard one-rank run, a two-rank MPI run, and a separate one-rank run with the C/N species blocks reversed in STRU. Each compares all 17,424 frozen-SCC band eigenvalues (121 k-points × 144 bands) against the DFTB+ 25.1 reference rounded to 1 meV; none requires a DFTB+ executable.
The checked-in comparison records a maximum absolute difference of 5.12700e-4 eV, a mean absolute difference of 2.49089e-4 eV, and an RMS difference of 2.87890e-4 eV. The regression limits are 7.5e-4 eV maximum and 3.5e-4 eV RMS.
Passed on commit cb77165 in CI: ctest --test-dir build -V --timeout 1700 -R '^(integrated_test|dftb_native_c2n_reference|dftb_native_c2n_mpi_2rank|dftb_native_c2n_reversed_species_order)$'; the integration/native DFTB regression step passed with all three C2N variants.
Passed on commit cb77165 in CI: ctest --test-dir build --output-on-failure --timeout 300 -R '^MODULE_DFTB_native$' (DFTB unit target passed, including the periodic self-image half-list regression).
Passed on commit cb77165 in CI: ctest --test-dir build -V --timeout 1700 -R MODULE_IO; the MODULE_IO step passed, including the updated general-help test.
Unit tests cover the generalized eigensolver, finite-temperature occupation endpoints and zero-weight k-points, charge mixing, periodic SCC, frozen-SCC bands, energy consistency, non-finite input handling, periodic self-image repulsion under the canonical half-list convention, incompatible DFTB basis/solver rejection, and the default Kohn–Sham selection.
Updated the general CLI --help text to list basis_type=dftb. The generated INPUT parameter reference already documents this value, so no generated parameter documentation needed regeneration for the help-text correction.
Contributor checklist
Reviewed AGENTS.md and the repository governance guide.
No matching existing issue was found; this PR adds an experimental solver and does not close an existing issue.
Added unit tests and a reproducible numerical regression.
Listed verification commands and results.
Described user-visible behavior and the effects on solver selection, parameter parsing, and cell/species setup.
Frankly speaking, I dislike the duplication. If there's already dftb+ library as a code path that performs well, why do we need then an internal code path which is possibly not in sync with the other one and thus causing an additional maintenance burden. Moreover this feature isn't expected to be widely used. I vote for an external dftb+ dependency.
Thanks for explicitly documenting the tradeoff. I'm okay with this design.
Regarding CMake option, however, I would keep my opinion against adding it. Actually, the new explanation reinforces my thought: if there is no dependency reason (e.g. enabling DFT+D4 pulls in dftd4 library as dependency) or significant compile-time or binary-size reason (e.g. enabling an optional and non-essential feature pulls in a large number of objects to build with) for disabling it, then this option is not really expressing a build configuration; it is being used to encode a release/support policy in CMake, which definitely shouldn't be the case.
Once an internal implementation is merged into ABACUS, it should be compiled as part of normal builds. esolver_type=dftbnative is already an explicit runtime opt-in, and its experimental status can be clearly documented and warned about at runtime. Keeping it OFF by default also creates one more unnecessarily different ABACUS binaries depending on how they were configured. If the implementation is not yet ready to be present in a standard build, I would rather regard that as a merge-readiness issue than introduce another build-time feature switch.
P.S. In fact, I had previously wanted to make the same argument against ENABLE_LCAO, but that option has existed for years and I wasn't sure whether the maintainers would be willing to change such long-standing behavior.
Rule: User-facing INPUT help must stay consistent with registered parameter values.
Severity: warning
Location: source/source_io/module_parameter/read_inp_estruc.cpp:15-22
Reason: This registration adds the dftb basis, but ParameterHelp::show_general_help() still prints basis_type - Basis set type (pw, lcao) (source/source_io/input_help.cpp:461). A user invoking the general CLI help is therefore told that the newly valid native DFTB basis is unsupported.
Suggested action: update the hard-coded general help (and its coverage if applicable) to mention dftb and the native solver, or generate this summary from the parameter registry.
Exception: not allowed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature DiscussedThe features will be discussed first but will not be implemented soon
4 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
No linked issue. This PR proposes an experimental native DFTB backend and does not close an existing issue.
What's changed?
basis_type=dftbandesolver_type=dftbnative. The default Kohn–Sham path is unchanged.ThirdOrderFull, within the supported undamped-gamma model. The implementation includes a legacy SKFs+pbasis, generalized Hermitian eigensolving, Mulliken SCC charges, linear/Pulay/modified-Broyden mixing, finite-temperature occupations, SKF spline repulsion, 3D Ewald electrostatics, and an optional frozen-SCC band path.OUT.{suffix}/dftb.logwith setup, parameter, SCC-iteration, energy, and Mulliken-population data, alongside eigenvalue, occupation, charge, and optional band files. The DFTB log is flushed at each SCC iteration. This solver requires SKF parameter files, but does not require UPF pseudopotentials, ABACUS.orbfiles, or a DFTB+ runtime.basis_type=dftbunlessesolver_type=dftbnativeduring INPUT validation, with a direct diagnostic. The default solver and basis remainksdftandpw.Motivation and design
This backend is for workflows that need ABACUS
INPUT/STRU/KPThandling and output conventions without packaging a DFTB+ executable or shared library. DFTB+ also offers an in-process API; using it from ABACUS would still require the external library and an adapter. The native backend is not API-compatible with DFTB+ and does not target feature parity. This trades a smaller runtime dependency footprint for additional maintenance and validation work.The solver is included in standard builds and is opt-in at runtime through
esolver_type=dftbnative; noENABLE_DFTB_NATIVEbuild switch is added. This keeps the build configuration uniform while the solver's experimental status and supported scope are stated in the documentation and at runtime.Inputs and supported scope
Use a standard ABACUS
INPUT,STRU, andKPT, selectbasis_type=dftbandesolver_type=dftbnative, and provide a DFTB-native control file (default:dftb_native.in) pointing to the SKF parameter set. DFTB-specific controls include SCC convergence, mixing, temperature, third-order correction, and an optional band-path file. The default DFTB3 correction is off; enabling it requires a Hubbard derivative for each species.The current model supports periodic 3D cells, legacy SKF files with a repulsive
Splinesection, ans+pbasis, neutral valence electron counts, spin-degenerate calculations (nspin=1), monopole SCC charges, undamped gamma corrections, dense diagonalization, and frozen-potential band paths. Hydrogen-labelled species are rejected because the DFTB+HCorrection = Dampingmodel and its third-order derivatives are not implemented. Spin polarization, shell-resolved charges, modern SKF formats, dispersion, DOS/PDOS, restart, forces/stress, structural relaxation, and molecular dynamics are outside the current scope. Slab calculations use 3D-periodic Ewald electrostatics and require vacuum-convergence checks.Unit Tests and/or Case Tests for my changes
STRU. Each compares all 17,424 frozen-SCC band eigenvalues (121 k-points × 144 bands) against the DFTB+ 25.1 reference rounded to 1 meV; none requires a DFTB+ executable.5.12700e-4 eV, a mean absolute difference of2.49089e-4 eV, and an RMS difference of2.87890e-4 eV. The regression limits are7.5e-4 eVmaximum and3.5e-4 eVRMS.cb77165in CI:ctest --test-dir build -V --timeout 1700 -R '^(integrated_test|dftb_native_c2n_reference|dftb_native_c2n_mpi_2rank|dftb_native_c2n_reversed_species_order)$'; the integration/native DFTB regression step passed with all three C2N variants.cb77165in CI:ctest --test-dir build --output-on-failure --timeout 300 -R '^MODULE_DFTB_native$'(DFTB unit target passed, including the periodic self-image half-list regression).cb77165in CI:ctest --test-dir build -V --timeout 1700 -R MODULE_IO; the MODULE_IO step passed, including the updated general-help test.--helptext to listbasis_type=dftb. The generated INPUT parameter reference already documents this value, so no generated parameter documentation needed regeneration for the help-text correction.Contributor checklist
AGENTS.mdand the repository governance guide.