Metadata-Version: 2.4
Name: aiida-dftbplus
Version: 0.1.0
Summary: AiiDA plugin for DFTB+ calculations
Project-URL: Source, https://github.com/Quantum-ARISE-Acad/aiida-dftbplus
Project-URL: Documentation, https://aiida-dftbplus.readthedocs.io
Project-URL: Bug Tracker, https://github.com/Quantum-ARISE-Acad/aiida-dftbplus/issues
Author-email: Quantum ARISE <sitouamu510@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Quantum ARISE.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: aiida,plugin
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: AiiDA
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Requires-Python: >=3.9
Requires-Dist: aiida-core<3,>=2.5
Requires-Dist: voluptuous
Provides-Extra: pre-commit
Requires-Dist: pre-commit~=3.5; extra == 'pre-commit'
Provides-Extra: tests
Requires-Dist: coverage>=7; extra == 'tests'
Requires-Dist: ipdb; extra == 'tests'
Requires-Dist: pgtest>=1.3.1,~=1.3; extra == 'tests'
Requires-Dist: pytest-cov>=4.1; extra == 'tests'
Requires-Dist: pytest>=7; extra == 'tests'
Description-Content-Type: text/markdown

[![CI/CD Status][ci-badge]][ci-link]
[![Coverage Status][cov-badge]][cov-link]
[![Docs status][docs-badge]][docs-link]
[![PyPI version][pypi-badge]][pypi-link]

# aiida-dftbplus

Run [DFTB+](https://dftbplus.org/) from [AiiDA](https://www.aiida.net/): the
plugin writes `dftb_in.hsd`, submits the job, brings every output file back and
stores the input parameters as queryable database attributes.

One calculation in, one calculation out — no workflows, no error recovery.

## Install

```shell
pip install aiida-dftbplus
verdi quicksetup          # if you do not have a profile yet
```

DFTB+ itself comes separately (e.g. `conda install -c conda-forge dftbplus`).
Register it once:

```shell
verdi code create core.code.installed \
    --label dftb+ --computer localhost \
    --default-calc-job-plugin dftbplus \
    --filepath-executable $(which dftb+)
```

## Run something

```shell
verdi daemon start
cd examples
./example_01.py --code dftb+@localhost --skf-dir /path/to/skf/
```

## Describe the input

Write the HSD as a nested dictionary — every setting stays queryable:

```python
from aiida import engine, orm
from aiida.plugins import CalculationFactory, DataFactory

DftbParameters = DataFactory("dftbplus")

parameters = DftbParameters({
    "Geometry": {"GenFormat": {"_raw": open("geometry.gen").read()}},
    "Hamiltonian": {"DFTB": {
        "SCC": True,
        "MaxSCCIterations": 100,
        "SCCTolerance": 1e-5,
        "_raw_1": 'SlaterKosterFiles = Type2FileNames {\n'
                  '  Prefix = "/opt/skf/mio-1-1/"\n'
                  '  Separator = "-"\n  Suffix = ".skf"\n}',
    }},
    "Analysis": {"CalculateForces": True},
})

engine.submit(CalculationFactory("dftbplus"), code=code, parameters=parameters)
```

Anything the dictionary form does not cover goes through verbatim under a
`_raw*` key, so nothing in DFTB+ is out of reach. Dictionaries are validated
before submission — `print(DftbParameters.schema.schema)` lists the blocks.

Already have a file? Hand it over instead:

```python
inputs["dftb_input"] = DataFactory("core.singlefile")(file="dftb_in.hsd")
```

Exactly one of `parameters` or `dftb_input` is required.

## Slater-Koster files

Two options, and the choice matters for speed:

* `use_remote_skf_path=True` — the files already sit on the machine, keep the
  absolute path in the HSD and upload nothing. Best for a full parameter set.
* `skf_files` (a `FolderData`) — ship the files with the job, but **only the
  pairs the run reads**. A full set is copied into every working directory and
  turns a one-second job into a several-minute one; a two-element material needs
  four files:

  ```python
  skf_files = orm.FolderData()
  for name in (f"{a}-{b}.skf" for a in ["O", "S"] for b in ["O", "S"]):
      skf_files.put_object_from_file(str(skf_dir / name), name)
  ```

## Get the results

```shell
verdi process list -a
verdi calcjob res <PK>        # parsed scalars: energies, Fermi level, forces
verdi calcjob outputls <PK>   # every retrieved file
verdi process report <PK>     # why it failed, if it did
```

`output_parameters` carries `total_energy_H`, `total_energy_eV`,
`fermi_energy_eV`, `scc_converged`, `n_scc_iterations`, `forces_eV_Ang` and
`max_force_eV_Ang`. Failures come back as exit codes: **300** output missing,
**310** DFTB+ error, **320** SCC not converged, **330** geometry not converged.

Inspect the stored input nodes with the bundled `verdi` commands:

```shell
verdi data dftbplus list
verdi data dftbplus hsd <PK>    # render the node as the dftb_in.hsd it produces
```

## Documentation

Full documentation — getting started, tutorials, how-to guides, architecture and
API reference — at
[quantum-arise-acad.github.io/aiida-dftbplus](https://quantum-arise-acad.github.io/aiida-dftbplus/).

Start here:

* [Prerequisites](https://quantum-arise-acad.github.io/aiida-dftbplus/getting-started/prerequisites.html) — the four things you need before anything runs
* [Slater–Koster parameter sets](https://quantum-arise-acad.github.io/aiida-dftbplus/getting-started/skf-parameter-sets.html) — which files, where to get them, how to point the plugin at them
* [Your first calculation](https://quantum-arise-acad.github.io/aiida-dftbplus/getting-started/first-calculation.html)
* [Architecture](https://quantum-arise-acad.github.io/aiida-dftbplus/architecture/index.html) — for maintainers

Build it locally with `pip install -e . --group docs && make -C docs`.

## License

MIT — see [LICENSE](LICENSE).

## Contact

sitouamu510@gmail.com

[ci-badge]: https://github.com/Quantum-ARISE-Acad/aiida-dftbplus/actions/workflows/release.yml/badge.svg?branch=main
[ci-link]: https://github.com/Quantum-ARISE-Acad/aiida-dftbplus/actions
[cov-badge]: https://coveralls.io/repos/github/Quantum-ARISE-Acad/aiida-dftbplus/badge.svg?branch=main
[cov-link]: https://coveralls.io/github/Quantum-ARISE-Acad/aiida-dftbplus?branch=main
[docs-badge]: https://github.com/Quantum-ARISE-Acad/aiida-dftbplus/actions/workflows/docs.yml/badge.svg?branch=main
[docs-link]: https://quantum-arise-acad.github.io/aiida-dftbplus/
[pypi-badge]: https://badge.fury.io/py/aiida-dftbplus.svg
[pypi-link]: https://badge.fury.io/py/aiida-dftbplus
