From b555994a05fa407044814e587ed082da583e8f99 Mon Sep 17 00:00:00 2001 From: Ben Hourahine Date: Fri, 27 Mar 2026 16:22:51 +0000 Subject: [PATCH] Start of using dptools components in scripts --- docs/interfaces/pyapi/pyapi.rst | 48 +++++++++++++++++++++++++++++++++ docs/introduction.rst | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/docs/interfaces/pyapi/pyapi.rst b/docs/interfaces/pyapi/pyapi.rst index d8685762..15914cc9 100644 --- a/docs/interfaces/pyapi/pyapi.rst +++ b/docs/interfaces/pyapi/pyapi.rst @@ -445,3 +445,51 @@ registration of the callback functions is still missing: Please consult the associated archive with this tutorial to obtain the full corresponding example. + + +Extra tools for DFTB data +========================= + +The ``dftbplus-tools`` package (see the +:ref:`conda install `) also contains routines to +handle some of the common file formats that DFTB+ uses. + +A geometry can be read from file in `gen` format + +.. code-block:: python + + import numpy as np + from dptools.gen import Gen + + try: + gen = Gen.fromfile("structure.gen") + except OSError: + raise ScriptError('Input file does not exist.') + + geometry = gen.geometry + + if geometry.periodic: + print("This is a periodic structure") + + + +The `geometry` structure includes variables for + + +----------------+------------------------------------------------+ + | element | description | + +================+================================================+ + | speciesnames | Names of the atoms present in the geometry | + +----------------+------------------------------------------------+ + | nspecies | Number of different chemical species | + +----------------+------------------------------------------------+ + | indexes | The species index of each atom in speciesnames | + +----------------+------------------------------------------------+ + | natom | Number of atoms present in the geometry | + +----------------+------------------------------------------------+ + | coords | xyz coordinates of the atoms (in Angstrom) | + +----------------+------------------------------------------------+ + | periodic | True if the structure is periodic | + +----------------+------------------------------------------------+ + | latvecs | Lattice vectors in Angstrom (variable is | + | | `None` for non-periodic structures) | + +----------------+------------------------------------------------+ diff --git a/docs/introduction.rst b/docs/introduction.rst index e0a2ed2e..3d448ffb 100644 --- a/docs/introduction.rst +++ b/docs/introduction.rst @@ -52,7 +52,7 @@ script file in the directory to run examples of multistage calculations, called ``run.sh`` which contains the individual commands needed to run the full example. - +.. _subsec-condainstall: Installing DFTB+ from conda-forge ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~