Basics about deMonNanoPy

Basics about deMonNanoPy

A. Base about DFTB model

The Density Functional based Tight-Binding model derived from Density Functional Theory model. The energy of DFTB is expressed as

$$ E_\mathrm{DFTB} = V^{rep} + \underset{i}{\sum^\mathrm{occ}} f_i<\psi_i| H^0|\psi_i> + \frac{1}{2} \underset{ab}{\sum}\Delta q_a\Delta q_b \gamma_\mathrm{ab} $$

where the first term is strictly fitted repulsive terms as a sum of pair potential. In the second terms, \(H^0\) is the hamiltonian operator and \(f_i\) is occupations. Molecular orbitals are expressed in a minimal basis of valence atomic orbitals \(\{\phi_\mu(\textbf{r})\}\), in a linear combination of atomic orbitals

$$ |\psi_i> = \underset{\mu }{\sum} c_\mu^i |\phi_\mu> $$

The third terms in energy expression is the second order contributions to the energy.

B. Setup your calculation environment

1. Download deMonNano

Get the tutorial documents typing :

$ mkdir tuto_demon_2026
$ cd tuto_demon_2026
$ wget https://demon-nano.ups-tlse.fr/doc/handson_deMonNano2026.tar.gz

$ tar -xzvf handson_deMonNano2026.tar.gz
$ vi TPvars.sh

Change the correct paths to deMonNano :

$ source TPvars.sh

All the calculations are expected to be run in non-parallel : type : export OMP_NUM_THREADS=1

You can now perform your first deMonNano calculation as indicated in tutorial-basic.ipynb.

2. Install DeMonNanoPy library

Get the DeMonNanoPy from source

$ git clone https://github.com/guib-l/DeMonNanoPy.git

then

$ cd DeMonNanoPy

Setup environment and install dependencies it needed

$ python3 -m venv .env
$ source .env/bin/activate
$ pip install .

3. Setup calculation

Choose if you prefer to keep these 2 following lines at the start of each file :

These two variables define the path to the deMonNano executable and the path to the Slater-Koster basis directory used by every calculation.

EXECUTABLE = "~/tuto_demon_2026/deMonNano/deMon.x"
BASIS = "~/tuto_demon_2026/deMonNano/basis"

or you create a file global.json (change the path if it exists) in the working directory as follows:

The two keys store the same executable and basis paths; deMonPy.configure_from_file reads them from this file.

{
    "DEMON_EXECUTABLE": "~/tuto_demon_2026/deMonNano/deMon.x",
    "DEMON_BASIS": "~/tuto_demon_2026/deMonNano/basis"
}

Note: Add this line at start of your file (replace the global.json namefile location by your file with your binary location and your basis set location). When you want to use it, call this line before starting some calculation:

At the beginning of each *.py file, add the following lines :

This imports the deMonPy package and loads the global configuration — the executable and basis paths — from global.json.

import deMonPy

deMonPy.configure_from_file("global.json")

C. First calculation

Now, setup your first calculation with DeMonNanoPy. In a script tutorial_0.py, write the following instructions.

1. Setup small molecule

This declares the atoms of the system: symbols lists the atomic symbols and positions holds their Cartesian coordinates as a NumPy array. The configure_from_file call is the mandatory setup line.

import numpy as np

import deMonPy

deMonPy.configure_from_file("global.json") # mandatory line

symbols = ["O", "H", "H", "O", "H", "H"]
positions = np.array(
    [[1.2478, -0.5185, 3.4049], [1.5946, -1.4204, 3.3886], [0.9008, -0.3341, 2.5062]]
)

The first line corresponds to the symbols in the molecule and positions is a numpy array object.

2. The calculation

Add this script in a new file tutorial_0.py.

This builds the parameter dictionary — deMonNano executable, Slater-Koster basis (PTYPE=NSC) and the DFTB keyword requesting a simple DFTB calculation — then runs the calculation in the working directory. A single calculate() call writes the input file, runs the binary and stores the parsed results in dem.results.

from deMonPy.deMonNano import deMonNano

WORKDIR = ".run/tutorial-0/" # working directory

parameters = {
    "DEMON_EXECUTABLE": deMonPy.DEMON_EXECUTABLE,
    "BASIS": {"PTYPE": "NSC", "SKFILE": deMonPy.DEMON_BASIS},
    "DEMON_PARAMETERS": {
        "ACTIVE": {
            "DFTB": {},
        },
    },
}

dem = deMonNano(title="CALCULATION DEMONANO", workdir=WORKDIR, **parameters)

dem.calculate(symbols=symbols, positions=positions)

dem.print_results()

In terminal, run the command :

$ python3 tutorial_0.py

Note: Further explanations will be provided in the upcoming tutorials.

Next steps

Tutorial 1 — Electronic structure of water molecule picks up the water molecule: simple DFTB versus the self-consistent-charge (SCC) variant, a geometry optimization and the debug output. The DeMonNanoPy Examples section offers short standalone scripts of similar single-point calculations, and the DeMonNanoPy Quickstart page revisits the installation if needed.