Add optional external DFTB+ backend#139
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a43721415
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| grad_array = np.asarray(flat, dtype=np.float64) | ||
| ffi.memmove(mol.data._data.grad, grad_array, grad_array.nbytes) | ||
| except Exception: |
There was a problem hiding this comment.
Persist DFTB gradients in mol.grads on successful runs
When method=dftb and runtype=grad, the normal path is the try branch (NumPy + oqp.ffi available), but that branch only memmoves into the C buffer and never updates mol.grads. This leaves Python-level results inconsistent (PyOQP.results() returns grad: None), and downstream code that expects mol.grads after a gradient run can fail or silently miss gradient data.
Useful? React with 👍 / 👎.
| _SYMBOLS = { | ||
| 1: "H", 2: "He", 3: "Li", 4: "Be", 5: "B", 6: "C", 7: "N", 8: "O", 9: "F", 10: "Ne", | ||
| 11: "Na", 12: "Mg", 13: "Al", 14: "Si", 15: "P", 16: "S", 17: "Cl", 18: "Ar", | ||
| 19: "K", 20: "Ca", 35: "Br", 53: "I", | ||
| } |
There was a problem hiding this comment.
Include Zn in DFTB element symbol mapping
The hardcoded _SYMBOLS table omits atomic number 30 (Zn), so _symbols_for_atoms() raises DFTBPlusError for Zn-containing systems before DFTB+ is invoked. This blocks valid workflows with common parameter sets (including 3ob-family usage implied by the new backend) and is an avoidable regression introduced by the new external runner.
Useful? React with 👍 / 👎.
|
Closing this upstream PR per Cheol’s request. GPU/DFTB coding should remain on the fork first rather than going directly to upstream. |
Summary
method=dftbinput/schema support and[dftb]execution settingsdftb_in.hsd/geo.genwriter, fixture parsers fordetailed.outandresults.tag, and a shell-out runnermethod=dftbDFTB+ availability and skip/error behavior
DFTBPlusErrormessages if the configured executable is missing/not executable, if[dftb] sk_pathis unset or missing, if DFTB+ exits nonzero, or if expected output files are absent.dftb+is not installed, and Homebrew does not provide a straightforwarddftbplusformula (brew search dftbonly returneddfmt), so no live DFTB+ numerical reference is included.Tests
python3 -m unittest tests.test_dftbplus_backend -v(9 tests)python3 -m py_compile pyoqp/oqp/library/dftbplus.py pyoqp/oqp/library/runfunc.py pyoqp/oqp/molecule/oqpdata.py pyoqp/oqp/utils/input_checker.py tests/test_dftbplus_backend.pypython3 -m unittest tests.test_opentrustregion_linalg_config -v(3 tests)tests.test_geometric_optimizeris not present on this branch.python3 -m unittest tests.test_single_point_scf_fallback -vcould not import because this scheduled-runner Python (/Users/cheolhochoi/.hermes/hermes-agent/venv/bin/python3) lacksnumpy; this is unrelated to the DFTB+ code path.Scope note
This PR is kept independent of the geomeTRIC optimizer work; it only adds the external DFTB+ energy/gradient backend and optional manual example.