Run open-shell species spin-polarised in DFTB+ automatically - #64
Merged
Conversation
Follow-up to #63: make the spin actually drive the DFTB+ calculation, not just the electronic-degeneracy entropy. dftbplus_thermo now resolves the spin (the electron-count guess when not given) and, when S > 0, runs Geoopt/Hessian colinear spin-polarised via _spin_kwargs: SpinPolarisation = Colinear with UnpairedElectrons = round(2S) and the 3ob-PBE SpinConstants injected for the elements present. Closed-shell (S = 0) keeps the restricted calculation unchanged. So a radical (odd electrons) is auto-detected and treated open-shell with no extra input; only even-electron triplets (O2) need an explicit spin. The 3ob spin constants are cross-verified (3ob Elstner list vs QUASINANO2015 vs DFTB+ manual/mio); elements without one (Br, I, metals) raise a clear error. Energies should be validated with a real spin-polarised run.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64 +/- ##
==========================================
+ Coverage 96.17% 96.23% +0.05%
==========================================
Files 22 22
Lines 1308 1328 +20
==========================================
+ Hits 1258 1278 +20
Misses 50 50
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
Validated end-to-end with real DFTB+ 24.1 (3ob slako), not just mocks:
So the earlier "wiring verified, energies unvalidated" caveat is resolved — the spin constants and syntax produce a correct spin-polarised calculation. |
The 3ob-3-1 set ships its own spin constants in extras/spinw.hsd (PBE, slateratom). All eight organic values already matched it exactly; extend the table with the remaining 3ob elements from that authoritative file (Na, Mg, K, Ca, Zn, Br, I) so spin-polarised calculations work for any element the tool's 3ob parameters already support. Verified a Br-containing radical runs spin-polarised and converges.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #63. #63 made the user spin drive the electronic-degeneracy entropy; this makes it drive the DFTB+ calculation, so open-shell species are treated consistently (open-shell energy and the matching multiplicity), with no extra input.
Behaviour (charge is the only per-molecule input)
dftbplus_thermoresolves the spin — the electron-count guess when not given (even→singlet, odd→doublet) — and:SpinPolarisation = Colinear { UnpairedElectrons = round(2S) }+ the 3obSpinConstantsfor the atoms present, injected intoGeoopt/Hessian.So a radical (odd electrons) is auto-detected and run spin-polarised — e.g. an anthraquinone radical anion (charge −1) just works. The same S drives the calculation and the entropy, so they stay consistent. Only even-electron triplets (O₂) need an explicit
spin=1.Spin constants
SPIN_CONSTANTSis the 3ob-3-1 PBE set — the compact single-shell form (HOMOW,ShellResolvedSpin = No) matching this tool’s atom-resolved 3ob SCC. Cross-verified across three independent sources (3ob Elstner list ↔ QUASINANO2015 arXiv:1605.01360 ↔ DFTB+ manual/mio/Köhler). Covers H, C, N, O, F, P, S, Cl; elements without an authoritative constant (Br, I, metals) raise a clear error rather than a guessed number. The constants are parameters tied to the SK set/functional — see the code comment.Tests (offline; the slako files are absent here)
_spin_kwargs: restricted for S∈(None,0) and fractional S; colinear block for a doublet; error for an untabulated element.dftbplus_thermo(mocked pipeline): an OH radical auto-spin-polarises (UnpairedElectrons=1, S passed to the analysis as 0.5); closed-shell water stays restricted; explicit O₂spin=1→UnpairedElectrons=2.178 passed, 5 skipped; pylint 8.88.
Caveat
This is a methodology change gated behind an open-shell spin (restricted stays the default). I could not validate the energies here — the 3ob slako files are gone from this machine — so the wiring and constants are verified but the numbers should be confirmed with a real spin-polarised run (restored slako). The S d-shell constant is contested upstream, but only s/p are used for organic sulfur.