Example 1 — DFTB single point: water
DFTB single-point energy of a water molecule.
Prerequisites: a deMonNano installation + global.json (see the
DeMonNanoPy Quickstart page).
Run with:
python3 example_dftb.py
The code below is the full script, split by part. Runnable version: demonnano/examples/example_dftb.py.
Parameters & geometry
The DFTB parameters and the water geometry for the single-point energy calculation. deMonPy.configure_from_file("global.json") loads the deMonNano environment (DEMON_EXECUTABLE, DEMON_BASIS), parameters selects the BIO basis and activates SCC-DFTB (self-consistent-charge variant) for a neutral molecule, and the geometry is an ASE Atoms object with the symbols and positions of the three atoms.
"""DFTB single-point energy of a water molecule.
Run with:
python3 example_dftb.py
Requires a deMonNano installation and a global.json file (see the
DeMonNanoPy README).
"""
import numpy as np
from ase.atoms import Atoms
import deMonPy
from deMonPy.deMonNano import deMonNano
deMonPy.configure_from_file("global.json")
parameters = {
"BASIS": "BIO",
"DEMON_PARAMETERS": {
"ACTIVE": {
"DFTB": {"SCC": True},
"CHARGE": 0.0,
},
},
}
water = Atoms(
["O", "H", "H"],
positions=np.array(
[
[1.2478, -0.5185, 3.4049],
[1.5946, -1.4204, 3.3886],
[0.9008, -0.3341, 2.5062],
]
),
)
Run & result
Run the calculation and print the total energy in Hartree. A deMonNano object is created for the working directory .run/example-dftb; its calculate() method writes the input, runs the deMonNano binary, and parses the output, and the total energy is read back from dem.results["energy"]["energy"].
WORKDIR = ".run/example-dftb"
def exemple_run_dftb():
dem = deMonNano(title="CALCULATION DEMONANO", workdir=WORKDIR, **parameters)
dem.calculate(symbols=water.symbols, positions=water.positions)
energy = dem.results["energy"]["energy"]
print(f" > Energy (Hartree) : {energy}")
if __name__ == "__main__":
exemple_run_dftb()
Summary
The script computes the DFTB single-point energy of a neutral water molecule: SCC-DFTB with the BIO basis runs in the working directory .run/example-dftb, and the total energy read from the parsed results is printed in Hartree.