Skip to main content

KBKit: Kirkwood-Buff Analysis Toolkit

Project description

KBKit: Kirkwood-Buff Analysis Toolkit

License PyPI version Powered by: Pixi Code style: ruff codecov docs python 3.12

KBKit is a Python package for automated Kirkwood-Buff (KB) analysis of molecular simulation data. It provides tools to parse simulation outputs, compute Kirkwood-Buff integrals, and extract thermodynamic properties for binary and multicomponent systems. KBKit supports flexible workflows, including:

  • Parsing and processing of simulation data (e.g., RDFs, densities)
  • Calculation of KB integrals and related thermodynamic quantities
  • Integration of activity coefficient derivatives (numerical or polynomial)
  • Automated pipelines for batch analysis
  • Calculation of static structure factor and X-ray intensities in the limit of q → 0
  • Visualization tools for KB integrals, thermodynamic properties, and static structure factors

KBKit is designed for researchers in computational chemistry, soft matter, and statistical mechanics who need robust, reproducible KB analysis from simulation data. The package is modular, extensible, and integrates easily with Jupyter notebooks and Python scripts.

Installation

Quick install via PyPI

pip install kbkit

Developer install (recommended for contributors or conda users)

Clone the GitHub repository and use the provided Makefile to set up your development environment:

git clone https://github.com/anl-sepsci/kbkit.git
cd kbkit
make setup-dev

This one-liner creates the kbkit-dev conda environment, installs kbkit in editable mode, and runs the test suite.

To install without running tests:

make dev-install

To build and install the package into a clean user environment:

make setup-user

For a full list of available commands:

make help

File Organization

For running kbkit.Pipeline or its dependencies, the following file structure is required: a structured directory layout that separates mixed systems from pure components. This organization enables automated parsing, reproducible KB integrals, and scalable analysis across chemical systems.

  • NOTE: KBKit currently only supports parsing for GROMACS files.

An example of file structure:

kbi_dir/
├── project/
   └── system/
       ├── rdf_dir/
          ├── mol1_mol1.xvg
          ├── mol1_mol2.xvg
          └── mol1_mol2.xvg
       ├── system_npt.edr
       ├── system_npt.gro
       └── system.top
└── pure_components/
    └── molecule1/
        ├── molecule1_npt.edr
        └── molecule1.top

Requirements:

  • Each system to be analyzed must include:
    • rdf_dir/ containing .xvg RDF files for all pairwise interactions
      • Both molecule IDs in RDF calculation MUST BE in filename
    • either .top topology file or .gro structure file (.gro is recommended)
    • .edr energy file
  • Each pure component must include:
    • either .top topology file or .gro structure file (.gro is recommended)
    • .edr energy file
    • all other files (optional)

Examples

Below are several examples on various ways to implement KBKit. See examples for a more complete example on the ethanol/water binary system.

Calculating Kirkwood-Buff integrals on a single RDF

import os
from kbkit.kbi import KBIntegrator
from kbkit.systems import SystemProperties
from kbkit.io import RdfParser

syspath = "./examples/test_data/ethanol_water_26C/sys_405"
rdf_path = os.path.join(sys_path, "kbi_rdf_files_gmx25", "rdf_ETHOL_SPCEW.xvg")

# create integrator object from single RDF file
rdf = RDFParser(path=rdf_path)
integrator = KBIntegrator.from_system_properties(
    rdf=rdf,
    system_properties=SystemProperties(sys_path),
)

# calculate KBI in thermodynamic limit
kbi = integrator.compute_kbi(mol_j="SPCEW")

Run an automated pipeline for batch analysis

from kbkit.api import Pipeline

# Set up and run the pipeline
pipe = Pipeline(
    base_path="./examples/test_data/ethanol_water_26C", 
    pure_path="./examples/test_data/pure_components",   
    pure_systems=["ETHOL_300", "SPCEW_300"],            
    include_mode="npt",                                 
    activity_integration_type="numerical",                 
)

# Access the properties in PropertyResults objects
res = pipe.results

# Convert units from kJ/mol -> kcal/mol
# current units will be read from existing PropertyResult object
g_ex_res = res["g_ex"].to("kJ/mol")

# make figures for KBI analysis and select thermodynamic properties
pipe.make_figures(xmol="ETHOL")

Credits

This package was created with Cookiecutter and the jevandezande/pixi-cookiecutter project template.

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

kbkit-1.0.23.tar.gz (119.6 kB view details)

Uploaded Source

File details

Details for the file kbkit-1.0.23.tar.gz.

File metadata

  • Download URL: kbkit-1.0.23.tar.gz
  • Upload date:
  • Size: 119.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for kbkit-1.0.23.tar.gz
Algorithm Hash digest
SHA256 943ad9c401ee00016f6f46d0da9600971dafc4d7a0780eda550067ae45d229e5
MD5 d82880a88dade8f3207a2edef8445215
BLAKE2b-256 db96ea555faa56dfd9318ebe5b6a597ac78d894728d68d991b185c6377406267

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