Skip to main content

Automated Descriptor Engine for SNCI, SCDI, and 9D KNF

Project description

KNF-CORE (KNF-GPU Branch)

KNF-CORE is an automated computational chemistry pipeline that generates:

  • SNCI
  • SCDI variance
  • 9D KNF vector (f1 to f9)

from molecular structure files using xTB + NCI backend + KNF post-processing.

Current package version in this branch: 1.0.3

Branch Highlights

This KNF-GPU branch includes:

  • Torch-based NCI backend (--nci-backend torch) with CPU/CUDA execution.
  • Multiwfn backend still supported (--nci-backend multiwfn).
  • GPU overlap scheduler in batch mode (CPU pre-NCI + single GPU post-NCI lane) when using torch + cuda.
  • Storage-efficient default output behavior (intermediates removed by default, keep with --full-files).
  • Robust filename/path artifact handling for mojibake/Unicode path variants.
  • xTB optimization capped to 50 cycles (--cycles 50) and pipeline continues if xtbopt.xyz exists.
  • Batch aggregate outputs: batch_knf.json and batch_knf.csv.

Fragment Handling

  • 1 fragment: f1 = 0.0, f2 = 180.0
  • 2 fragments: f1 = COM distance, f2 = detected H-bond angle
  • >2 fragments: f1 = average COM distance over unique pairs, f2 = 180.0

Requirements

  • Python >=3.8
  • External tools in PATH:
    • xtb
    • obabel (Open Babel)
  • Multiwfn is required only when using --nci-backend multiwfn

Optional:

  • torch (for Torch NCI backend; CUDA optional)

Install

From source:

git clone https://github.com/Prasanna163/KNF.git
cd KNF
pip install -e .

Install with Torch extra:

pip install -e ".[torch-nci]"

From PyPI:

pip install KNF

First-Run Setup

On first execution, KNF runs one-time setup that:

  • checks external dependencies
  • attempts automatic install for some tools (when available)
  • computes multiprocessing recommendation

State file:

  • ~/.knf/first_run_state.json

Force refresh:

knf <input_path> --refresh-first-run

Multiwfn Detection and Path Registration

Search order:

  • current PATH
  • KNF_MULTIWFN_PATH env var
  • saved path ~/.knf/tool_paths.json
  • common local locations + shallow scan

Manual registration:

knf <input_path> --multiwfn-path "E:\path\to\Multiwfn.exe"

You can also pass a folder containing Multiwfn.exe.

CLI Usage

Basic:

knf input_molecule.sdf

Core options

  • --charge <int>
  • --spin <int>
  • --force
  • --clean
  • --debug
  • --processing <auto|single|multi>
  • --multi / --single (shortcuts)
  • --workers <int>
  • --output-dir <path>
  • --ram-per-job <MB>
  • --refresh-autoconfig
  • --quiet-config
  • --full-files
  • --refresh-first-run
  • --multiwfn-path <path>

Backend options

  • --gpu shortcut: sets torch + cuda + float64
  • --multiwfn shortcut: sets multiwfn + auto
  • --nci-backend <torch|multiwfn>

Advanced NCI options (hidden in default --help, but supported)

  • --nci-grid-spacing <float>
  • --nci-grid-padding <float>
  • --nci-device <cpu|cuda|auto>
  • --nci-dtype <float32|float64>
  • --nci-batch-size <int>
  • --nci-eig-batch-size <int>
  • --nci-rho-floor <float>
  • --nci-apply-primitive-norm

Examples

knf example.mol --force
knf ./molecules --processing multi --workers 4 --ram-per-job 200
knf example.mol --nci-backend torch --nci-device cuda --nci-dtype float64
knf example.mol --gpu
knf example.mol --multiwfn

Torch NCI Backend Notes

  • Uses internal Molden parser + grid + RDG pipeline.
  • Supports Cartesian shells for basis expansion.
  • Spherical d/f/g shell Molden inputs are currently not supported.
  • SNCI/statistics can be computed from either text grid (.txt) or compressed grid (.npz).

Output Layout

Default output root:

  • file input: <input_parent>/Results/<input_stem>/
  • directory input: <input_dir>/Results/<file_stem>/

Final outputs:

  • knf.json
  • output.txt

Batch root outputs:

  • batch_knf.json
  • batch_knf.csv

When --full-files is used, intermediate artifacts are retained (for example NCI grid artifacts and xTB/Multiwfn intermediates). Without it, storage-efficient cleanup runs automatically.

Compare Script

Use scripts/compare_nci.py to compare Multiwfn and Torch NCI outputs/correlation and timing behavior.

Docker

Build:

docker build -t knf-core:latest .

Run:

docker run --rm -v "$(pwd):/work" -w /work knf-core:latest example.mol --charge 0 --force

Compose:

docker compose up --build

See README.DOCKER.md for full details.

Releasing

Release steps are documented in RELEASE.md.

License

MIT (LICENSE)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

knf-1.0.3.tar.gz (40.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

knf-1.0.3-py3-none-any.whl (47.2 kB view details)

Uploaded Python 3

File details

Details for the file knf-1.0.3.tar.gz.

File metadata

  • Download URL: knf-1.0.3.tar.gz
  • Upload date:
  • Size: 40.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for knf-1.0.3.tar.gz
Algorithm Hash digest
SHA256 cf99885893323f5721e900e3fe9229b517e2ae57baca47d6111d9ab105fee18f
MD5 8211003c633724c6f87671a0491f0ac8
BLAKE2b-256 045185e9adddcab522b027b0ef8c4ee631e7f13ac82a9234c3d2eb66b48f1ffb

See more details on using hashes here.

File details

Details for the file knf-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: knf-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 47.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for knf-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d194608aba1fa241ba64ca477128eb9cbe8558e1910ba37f6920791eaa8673a7
MD5 d237bf351de20ec2544668cd019f22e4
BLAKE2b-256 d4f54899dd46e290844ed81fcc1b6674f943a634287e0c85c64c426b74e529f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page