kmos
kMC modeling on steroids
A vigorous attempt to make lattice kinetic Monte Carlo modeling more accessible.
kmos is a tool for kinetic Monte Carlo (kMC) modeling focused on lattice models for surface science applications.
Copyright (C) 2009-2025 Max J. Hoffmann mjhoffmann@gmail.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
Features
- Lattice-based kinetic Monte Carlo simulations
- Support for complex surface chemistry models
- Written in Python with Fortran backend for performance
- Integration with ASE (Atomic Simulation Environment)
- Interactive GUI for model editing and visualization
- High-performance kMC solver with multiple backends
Installation
pip install kmos
Quickstart
Create a minimal input file mini_101.ini:
[Meta]
author = Your Name
email = you@server.com
model_dimension = 2
model_name = fcc_100
[Species empty]
color = #FFFFFF
[Species CO]
representation = Atoms("CO", [[0, 0, 0], [0, 0, 1.17]])
color = #FF0000
[Lattice]
cell_size = 3.5 3.5 10.0
[Layer simple_cubic]
site hollow = (0.5, 0.5, 0.5)
color = #FFFFFF
[Parameter k_CO_ads]
value = 100
adjustable = True
min = 1
max = 1e13
scale = log
[Parameter k_CO_des]
value = 100
adjustable = True
min = 1
max = 1e13
scale = log
[Process CO_ads]
rate_constant = k_CO_ads
conditions = empty@hollow
actions = CO@hollow
tof_count = {'adsorption':1}
[Process CO_des]
rate_constant = k_CO_des
conditions = CO@hollow
actions = empty@hollow
tof_count = {'desorption':1}
Then run:
kmos export mini_101.ini
cd mini_101_local_smart
kmos benchmark
You should see output like:
Using the [local_smart] backend.
1000000 steps took 1.51 seconds
Or 6.62e+05 steps/s
Try running kmos view to watch the model run, or kmos shell to interact with it interactively. Explore more commands with kmos help.
Development
Quick Start for Contributors
# Clone the repository
git clone https://github.com/mhoffman/kmos.git
cd kmos
# Install dev dependencies
uv sync --all-extras
# Install pre-commit hooks (automatic code formatting & linting)
uv run pre-commit install
# Run tests
make test
Available Make Commands
The project includes a Makefile for common development tasks:
make help # Show all available commands
make test # Run tests
make test-coverage # Run tests with coverage report
make lint # Lint code with ruff
make format # Format code with ruff
make clean # Clean build artifacts and caches
make docs # Build documentation
make all # Run full CI pipeline locally
Code Quality Tools
This project uses modern Python tooling:
- ruff - Fast linting and formatting (replaces black, isort, flake8)
- mypy - Type checking
- pre-commit - Automatic checks before commits
- pytest - Testing framework
- coverage - Test coverage reporting
After installing pre-commit hooks with uv run pre-commit install, your code will automatically be formatted and linted before each commit.
Running Tests
# Quick test run
make test
# Verbose output
make test-verbose
# With coverage report
make test-coverage
Manual Commands (if not using Make)
# Run tests
PYTHONPATH=. uv run pytest tests/
# Lint code
uv run ruff check kmos/ tests/
# Format code
uv run ruff format kmos/ tests/
# Type check
uv run mypy kmos/
Requirements
- Python >= 3.9
- Tested on Python 3.9, 3.10, 3.11, 3.12, 3.13, and 3.14
- Fortran compiler (gfortran recommended)
- Meson build system (automatically installed with Python >= 3.12)
Publishing
To publish a new version to PyPI:
# 1. Bump version
uv run bump-my-version bump patch # or minor, or major
# 2. Build the package
uv build
# 3. Upload to PyPI (requires PyPI credentials)
uv publish
# Or upload to Test PyPI first
uv publish --publish-url https://test.pypi.org/legacy/
After publishing, users can install with:
pip install kmos
# or
uv add kmos
Documentation
For tutorials, user guides, API reference, and troubleshooting:
Bugs, Issues, Questions
This is research software for scientists by scientists. If you encounter bugs, have feature requests, or need help:
- Open an issue
- Join the mailing list
Acknowledgments
This project builds upon several excellent open-source Python projects:
License
GPL-3.0-or-later
Release files for python-kmos 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python_kmos-0.5.1.tar.gz | 216.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_kmos-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 435.2 kB
Release files / python_kmos-0.5.1.tar.gz
| Download URL | python_kmos-0.5.1.tar.gz |
|---|---|
| Size | 216.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55ef5141ad44bf0952ed2ef26a3bafa3c469992dda930540b7d9133a06971d70
|
|
BLAKE2b-256 checksum How to use checksums |
a2e36f8855a6b9dc10d8502a864f3cb6d5e7a37c28ff94d1b362c0fafbaf1164
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / python_kmos-0.5.1-py3-none-any.whl
| Download URL | python_kmos-0.5.1-py3-none-any.whl |
|---|---|
| Size | 218.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ccd385380408eae0cfdeb31c017e1435690e75bf152de67372e6d9b5ea32234
|
|
BLAKE2b-256 checksum How to use checksums |
c996708d9b8385451a10932500a473b3720bc0653724bfbe54f755a7e550afee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|