DeMonNanoPy Quickstart

Install

  • Python >= 3.11
  • a deMonNano executable (deMon.x) available on the machine
  • basis / Slater-Koster files accessible from the chosen working directory

Python dependencies (NumPy and ASE) are declared in pyproject.toml and are installed automatically. The dev optional group adds the ruff linter.

Note: the distribution is named DeMonNanoPy but the import package is deMonPy. You install DeMonNanoPy and import deMonPy.

Create and activate a virtual environment, then install the project:

python -m venv .venv
source .venv/bin/activate

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

pip install .
# or, for development (adds the ruff linter):
pip install -e ".[dev]"

This installs the Python dependencies declared in pyproject.toml and makes the deMonPy package importable from the environment. The installed version is exposed as deMonPy.__version__.

Build metadata is defined in pyproject.toml using setuptools (the version is derived from deMonPy.__version__).

Tests

Run the testing commande pytest with options:

keyword Description
--all Perform all tests
--forces Gradient tests
--optim Test about optimization of geometry
--dynamics Dynamics calculation test
--references Comparison with external references calculations
--optional Optionnal test (some)
--freq Test for frequencies analysis
--beta Beta keywords, use carfully
--3OB= 3OB parameters directory for some QMMM tests

To get all clean test output, try:

pytest -vv --tb=short --color=yes --all

Basic Usage

Single-Point Calculation

import numpy as np
from ase.atoms import Atoms

from deMonPy.deMonNano import deMonNano


parameters = {
    "DEMON_EXECUTABLE": "~/Documents/dev_deMon/deMon.x",
    "BASIS": {
        "PTYPE": "BIO",
        "SKFILE": "../basis",
    },
    "DEMON_PARAMETERS": {
        "ACTIVE": {
            "DFTB": {
                "SCC": True,
            },
        },
    },
}

image = Atoms(
    ["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],
            [3.2478, -0.4185, 3.4049],
            [3.5946, -1.5204, 3.3886],
            [2.9008, -0.3341, 2.6062],
        ]
    ),
)

calculator = deMonNano(
    title="CALCULATION DEMONANO",
    workdir=".run/",
    **parameters,
)

calculator.calculate(
    symbols=image.symbols,
    positions=image.positions,
)

print(calculator.results)
calculator.print_results()

Typical parsed entries include:

  • results["energy"]
  • results["input_geometry"]
  • results["output_geometry"]
  • results["trajectory"] when trajectory output is enabled

First example

import numpy as np
from ase.atoms import Atoms

from deMonPy.deMonNano import deMonNano


parameters = {
    "DEMON_EXECUTABLE": "~/Documents/dev_deMon/deMon.x",
    "BASIS": {
        "PTYPE": "BIO",
        "SKFILE": "../basis",
    },
    "DEMON_PARAMETERS": {
        "ACTIVE": {
            "DFTB": {
                "SCC": True,
            },
        },
    },
}

image = Atoms(
    ["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],
            [3.2478, -0.4185, 3.4049],
            [3.5946, -1.5204, 3.3886],
            [2.9008, -0.3341, 2.6062],
        ]
    ),
)

calculator = deMonNano(
    title="CALCULATION DEMONANO",
    workdir=".run/",
    **parameters,
)

calculator.calculate(
    symbols=image.symbols,
    positions=image.positions,
)

print(calculator.results)
calculator.print_results()