kmcpy 0.2.3__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kmcpy-0.3.0/PKG-INFO +314 -0
- kmcpy-0.3.0/README.md +262 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy/__init__.py +23 -10
- kmcpy-0.3.0/kmcpy/api.py +29 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy/cli/gui_wrapper.py +129 -52
- kmcpy-0.3.0/kmcpy/cli/init.py +156 -0
- kmcpy-0.3.0/kmcpy/cli/main.py +55 -0
- kmcpy-0.3.0/kmcpy/cli/run_kmc.py +212 -0
- kmcpy-0.3.0/kmcpy/event/__init__.py +25 -0
- kmcpy-0.2.3/kmcpy/event/event.py → kmcpy-0.3.0/kmcpy/event/base.py +151 -139
- kmcpy-0.3.0/kmcpy/event/generators.py +633 -0
- kmcpy-0.3.0/kmcpy/event/hop.py +97 -0
- kmcpy-0.3.0/kmcpy/io/__init__.py +13 -0
- {kmcpy-0.2.3/kmcpy/external → kmcpy-0.3.0/kmcpy/io}/cif.py +57 -6
- kmcpy-0.3.0/kmcpy/io/neb/__init__.py +5 -0
- kmcpy-0.3.0/kmcpy/io/neb/data.py +520 -0
- kmcpy-0.3.0/kmcpy/io/registry.py +10 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy/models/__init__.py +14 -6
- kmcpy-0.3.0/kmcpy/models/base.py +245 -0
- kmcpy-0.3.0/kmcpy/models/composite_lce_model.py +440 -0
- kmcpy-0.3.0/kmcpy/models/fitting/fitter.py +404 -0
- kmcpy-0.3.0/kmcpy/models/fitting/registry.py +28 -0
- kmcpy-0.3.0/kmcpy/models/local_barrier_model.py +1095 -0
- kmcpy-0.3.0/kmcpy/models/local_cluster_expansion.py +875 -0
- kmcpy-0.3.0/kmcpy/models/parameters.py +204 -0
- kmcpy-0.3.0/kmcpy/models/site_energy.py +822 -0
- kmcpy-0.3.0/kmcpy/simulator/__init__.py +15 -0
- kmcpy-0.3.0/kmcpy/simulator/config.py +704 -0
- kmcpy-0.3.0/kmcpy/simulator/kmc.py +564 -0
- kmcpy-0.3.0/kmcpy/simulator/property.py +425 -0
- kmcpy-0.3.0/kmcpy/simulator/results.py +166 -0
- kmcpy-0.3.0/kmcpy/simulator/state.py +231 -0
- kmcpy-0.3.0/kmcpy/simulator/tracker.py +538 -0
- kmcpy-0.3.0/kmcpy/structure/__init__.py +94 -0
- kmcpy-0.3.0/kmcpy/structure/active_site_order.py +403 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy/structure/basis.py +254 -118
- kmcpy-0.3.0/kmcpy/structure/cluster.py +678 -0
- kmcpy-0.3.0/kmcpy/structure/lattice_structure.py +411 -0
- kmcpy-0.3.0/kmcpy/structure/local_environment_enumerator.py +813 -0
- kmcpy-0.3.0/kmcpy/structure/local_lattice_structure.py +299 -0
- kmcpy-0.3.0/kmcpy/structure/local_site_order.py +173 -0
- kmcpy-0.3.0/kmcpy/structure/neighbors.py +144 -0
- kmcpy-0.3.0/kmcpy/structure/sites.py +219 -0
- kmcpy-0.3.0/kmcpy/structure/species.py +63 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy/tools/gather_mc_data.py +4 -4
- kmcpy-0.3.0/kmcpy/tools/get_data.py +142 -0
- kmcpy-0.3.0/kmcpy/units.py +84 -0
- kmcpy-0.3.0/kmcpy.egg-info/PKG-INFO +314 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy.egg-info/SOURCES.txt +41 -17
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy.egg-info/entry_points.txt +1 -0
- kmcpy-0.3.0/kmcpy.egg-info/requires.txt +31 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/pyproject.toml +18 -12
- kmcpy-0.3.0/tests/test_active_site_order.py +78 -0
- kmcpy-0.3.0/tests/test_api.py +52 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/tests/test_basis.py +69 -67
- {kmcpy-0.2.3 → kmcpy-0.3.0}/tests/test_basis_registry.py +56 -95
- kmcpy-0.3.0/tests/test_cli_init.py +65 -0
- kmcpy-0.3.0/tests/test_cli_run_kmc.py +91 -0
- kmcpy-0.3.0/tests/test_cluster_matcher.py +126 -0
- kmcpy-0.3.0/tests/test_comparator_integration.py +46 -0
- kmcpy-0.3.0/tests/test_fitting.py +121 -0
- kmcpy-0.3.0/tests/test_hop_direction.py +80 -0
- kmcpy-0.3.0/tests/test_imports.py +91 -0
- kmcpy-0.3.0/tests/test_integration.py +256 -0
- kmcpy-0.3.0/tests/test_kmc_state_tracker_boundaries.py +408 -0
- kmcpy-0.3.0/tests/test_lattice_model.py +370 -0
- kmcpy-0.3.0/tests/test_local_barrier_model.py +231 -0
- kmcpy-0.3.0/tests/test_local_environment.py +288 -0
- kmcpy-0.3.0/tests/test_local_environment_enumerator.py +231 -0
- kmcpy-0.3.0/tests/test_model_file_api.py +172 -0
- kmcpy-0.3.0/tests/test_model_serialization.py +320 -0
- kmcpy-0.3.0/tests/test_monty_conventions.py +45 -0
- kmcpy-0.3.0/tests/test_multicomponent_chebyshev.py +122 -0
- kmcpy-0.3.0/tests/test_na3sbs4.py +167 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/tests/test_nasicon_bulk.py +130 -141
- kmcpy-0.3.0/tests/test_neb_data_loader.py +200 -0
- kmcpy-0.3.0/tests/test_occupation_management.py +178 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/tests/test_phase_development.py +55 -56
- kmcpy-0.3.0/tests/test_property.py +133 -0
- kmcpy-0.3.0/tests/test_site_energy_models.py +427 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/tests/test_utils.py +23 -27
- kmcpy-0.2.3/PKG-INFO +0 -196
- kmcpy-0.2.3/README.md +0 -127
- kmcpy-0.2.3/kmcpy/cli/run_kmc.py +0 -123
- kmcpy-0.2.3/kmcpy/event/__init__.py +0 -19
- kmcpy-0.2.3/kmcpy/event/event_generator.py +0 -1077
- kmcpy-0.2.3/kmcpy/event/modern_event_generator.py +0 -423
- kmcpy-0.2.3/kmcpy/external/__init__.py +0 -1
- kmcpy-0.2.3/kmcpy/external/local_env.py +0 -228
- kmcpy-0.2.3/kmcpy/external/structure.py +0 -342
- kmcpy-0.2.3/kmcpy/fitting.py +0 -215
- kmcpy-0.2.3/kmcpy/io/__init__.py +0 -2
- kmcpy-0.2.3/kmcpy/io/config_io.py +0 -385
- kmcpy-0.2.3/kmcpy/io/data_loader.py +0 -245
- kmcpy-0.2.3/kmcpy/io/io.py +0 -133
- kmcpy-0.2.3/kmcpy/models/cluster.py +0 -152
- kmcpy-0.2.3/kmcpy/models/composite_lce_model.py +0 -298
- kmcpy-0.2.3/kmcpy/models/fitting/fitter.py +0 -205
- kmcpy-0.2.3/kmcpy/models/local_cluster_expansion.py +0 -384
- kmcpy-0.2.3/kmcpy/models/model.py +0 -142
- kmcpy-0.2.3/kmcpy/models/parameters.py +0 -162
- kmcpy-0.2.3/kmcpy/simulator/__init__.py +0 -10
- kmcpy-0.2.3/kmcpy/simulator/condition.py +0 -46
- kmcpy-0.2.3/kmcpy/simulator/config.py +0 -606
- kmcpy-0.2.3/kmcpy/simulator/kmc.py +0 -344
- kmcpy-0.2.3/kmcpy/simulator/state.py +0 -258
- kmcpy-0.2.3/kmcpy/simulator/tracker.py +0 -528
- kmcpy-0.2.3/kmcpy/structure/__init__.py +0 -42
- kmcpy-0.2.3/kmcpy/structure/lattice_structure.py +0 -328
- kmcpy-0.2.3/kmcpy/structure/local_environment_comparator.py +0 -361
- kmcpy-0.2.3/kmcpy/structure/local_lattice_structure.py +0 -197
- kmcpy-0.2.3/kmcpy/structure/vacancy.py +0 -12
- kmcpy-0.2.3/kmcpy/tools/get_data.py +0 -160
- kmcpy-0.2.3/kmcpy.egg-info/PKG-INFO +0 -196
- kmcpy-0.2.3/kmcpy.egg-info/requires.txt +0 -22
- kmcpy-0.2.3/tests/test_comparator_integration.py +0 -216
- kmcpy-0.2.3/tests/test_imports.py +0 -73
- kmcpy-0.2.3/tests/test_integration.py +0 -246
- kmcpy-0.2.3/tests/test_lattice_model.py +0 -60
- kmcpy-0.2.3/tests/test_local_environment.py +0 -90
- kmcpy-0.2.3/tests/test_modern_event_generator.py +0 -441
- kmcpy-0.2.3/tests/test_na3sbs4.py +0 -138
- kmcpy-0.2.3/tests/test_occupation_management.py +0 -284
- {kmcpy-0.2.3 → kmcpy-0.3.0}/LICENSE +0 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy/_version.py +0 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy/structure/comparator.py +0 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy/tools/gather_kmc_data.py +0 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy.egg-info/dependency_links.txt +0 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/kmcpy.egg-info/top_level.txt +0 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/setup.cfg +0 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/tests/test_kmc_integration.py +0 -0
- {kmcpy-0.2.3 → kmcpy-0.3.0}/tests/test_simulation_state.py +0 -0
kmcpy-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kmcpy
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Kinetic Monte Carlo Simulation using Python (kMCpy)
|
|
5
|
+
Author-email: kMCpy Development Team <dengzeyu@gmail.com>
|
|
6
|
+
Maintainer-email: Zeyu Deng <dengzeyu@gmail.com>, Weihang Xie <david.xie1998@gmail.com>, Pieremanuele Canepa <pieremanuele.canepa@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/caneparesearch/kmcpy
|
|
9
|
+
Project-URL: Repository, https://github.com/caneparesearch/kmcpy
|
|
10
|
+
Project-URL: Issues, https://github.com/caneparesearch/kmcpy/issues
|
|
11
|
+
Project-URL: Documentation, https://kmcpy.readthedocs.io/
|
|
12
|
+
Keywords: kinetic monte carlo,kmc,simulation,materials science,condensed matter physics,chemistry
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Operating System :: OS Independent
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: glob2>=0.7
|
|
28
|
+
Requires-Dist: joblib>=1.5.3
|
|
29
|
+
Requires-Dist: monty>=2025.3.3
|
|
30
|
+
Requires-Dist: numba<0.63,>=0.62; sys_platform == "darwin" and platform_machine == "x86_64"
|
|
31
|
+
Requires-Dist: numba>=0.63.1; sys_platform != "darwin" or platform_machine != "x86_64"
|
|
32
|
+
Requires-Dist: numpy>=1.26
|
|
33
|
+
Requires-Dist: pandas>=2.2
|
|
34
|
+
Requires-Dist: pymatgen>=2025.10.7
|
|
35
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
36
|
+
Requires-Dist: scipy>=1.13
|
|
37
|
+
Requires-Dist: scikit-learn>=1.8.0
|
|
38
|
+
Provides-Extra: dev
|
|
39
|
+
Requires-Dist: pytest>=9.0; extra == "dev"
|
|
40
|
+
Requires-Dist: pytest-cov>=7.0; extra == "dev"
|
|
41
|
+
Provides-Extra: doc
|
|
42
|
+
Requires-Dist: sphinx>=7.0; extra == "doc"
|
|
43
|
+
Requires-Dist: furo; extra == "doc"
|
|
44
|
+
Requires-Dist: nbsphinx; extra == "doc"
|
|
45
|
+
Requires-Dist: sphinx-autodoc-typehints; extra == "doc"
|
|
46
|
+
Requires-Dist: myst-parser; extra == "doc"
|
|
47
|
+
Requires-Dist: tqdm; extra == "doc"
|
|
48
|
+
Requires-Dist: psutil; extra == "doc"
|
|
49
|
+
Provides-Extra: gui
|
|
50
|
+
Requires-Dist: gooey; extra == "gui"
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
<h1 align="center">
|
|
55
|
+
<picture>
|
|
56
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/caneparesearch/kMCpy/master/docs/source/_static/kmcpy_logo_dark.svg">
|
|
57
|
+
<img alt="Logo" src="https://raw.githubusercontent.com/caneparesearch/kMCpy/master/docs/source/_static/kmcpy_logo.svg" height="120">
|
|
58
|
+
</picture>
|
|
59
|
+
</h1>
|
|
60
|
+
|
|
61
|
+
[](https://GitHub.com/caneparesearch/kmcpy/releases/)
|
|
62
|
+
[](https://kmcpy.readthedocs.io/en/latest/?badge=latest)
|
|
63
|
+
[](https://github.com/caneparesearch/kmcpy/actions/workflows/test-ubuntu.yml)
|
|
64
|
+
[](https://pypi.org/project/kmcpy)
|
|
65
|
+
[](https://python.org/downloads)
|
|
66
|
+
[](https://doi.org/10.1016/j.commatsci.2023.112394)
|
|
67
|
+
|
|
68
|
+
Kinetic Monte Carlo Simulation with Python (kMCpy) is an open-source Python package for studying ion diffusion using the kinetic Monte Carlo (kMC) technique. It offers a comprehensive Python-based approach to compute kinetic properties, suitable for research, development, and prediction of new functional materials.
|
|
69
|
+
|
|
70
|
+
Key features include a local cluster expansion model toolkit, a rejection-free kinetic Monte Carlo (rf-kMC) solver, and tools to extract ion transport properties like diffusivities and conductivities. The local cluster expansion model toolkit facilitates model fitting from ab initio or empirical barrier calculations. Post-training, the local cluster expansion model can compute migration barriers in crystalline materials within the transition state theory.
|
|
71
|
+
|
|
72
|
+
Advantages of using kMCpy:
|
|
73
|
+
|
|
74
|
+
1. Written entirely in Python with a modular design, promoting developer-centricity and easy feature addition.
|
|
75
|
+
2. Cross-platform compatibility, supporting Windows, macOS, and Linux.
|
|
76
|
+
3. Performance-optimized kMC routines using [Numba](https://numba.pydata.org/), resulting in significant speed improvements.
|
|
77
|
+
|
|
78
|
+
> [!WARNING]
|
|
79
|
+
> kMCpy is under active development.
|
|
80
|
+
>
|
|
81
|
+
> APIs and serialized file formats may change before a stable release. Check the release notes and current documentation when updating existing workflows.
|
|
82
|
+
|
|
83
|
+
Release notes are maintained in the [changelog](https://github.com/caneparesearch/kmcpy/blob/master/CHANGELOG.md).
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
### Install with `pip`
|
|
88
|
+
|
|
89
|
+
You can install the latest PyPI release directly into a Python environment:
|
|
90
|
+
|
|
91
|
+
```shell
|
|
92
|
+
pip install kmcpy
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Using a virtual environment is recommended:
|
|
96
|
+
|
|
97
|
+
```shell
|
|
98
|
+
python -m venv kmcpy-env
|
|
99
|
+
source kmcpy-env/bin/activate # On Windows use `kmcpy-env\Scripts\activate`
|
|
100
|
+
pip install kmcpy
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Install with `uv pip`
|
|
104
|
+
|
|
105
|
+
If you manage Python environments with [uv](https://docs.astral.sh/uv/), use
|
|
106
|
+
the same PyPI package:
|
|
107
|
+
|
|
108
|
+
```shell
|
|
109
|
+
uv venv kmcpy-env
|
|
110
|
+
source kmcpy-env/bin/activate
|
|
111
|
+
uv pip install kmcpy
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Install with Conda
|
|
115
|
+
|
|
116
|
+
Use Conda to create the Python environment, then install the PyPI package
|
|
117
|
+
inside that environment:
|
|
118
|
+
|
|
119
|
+
```shell
|
|
120
|
+
conda create -n kmcpy python=3.11 pip
|
|
121
|
+
conda activate kmcpy
|
|
122
|
+
python -m pip install kmcpy
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Install from source
|
|
126
|
+
|
|
127
|
+
You can install kMCpy from source using either `pip` or `uv`. First, clone the
|
|
128
|
+
repository and navigate to its root directory.
|
|
129
|
+
|
|
130
|
+
To install normally with `pip`:
|
|
131
|
+
|
|
132
|
+
```shell
|
|
133
|
+
pip install .
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
For development with `pip`:
|
|
137
|
+
|
|
138
|
+
```shell
|
|
139
|
+
pip install -e ".[dev]"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
For development with `uv`:
|
|
143
|
+
|
|
144
|
+
```shell
|
|
145
|
+
uv sync
|
|
146
|
+
uv sync --extra dev
|
|
147
|
+
uv pip install -e .
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
> [!WARNING]
|
|
151
|
+
> Windows users
|
|
152
|
+
>
|
|
153
|
+
> Windows users (not applicable to WSL) need to install [Microsoft C++ build tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) for `pymatgen`.
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
## Build documentation
|
|
157
|
+
You can access the documentation at [https://kmcpy.readthedocs.io/](https://kmcpy.readthedocs.io/). However, if you want to build the documentation locally, you can do so by following these steps:
|
|
158
|
+
```shell
|
|
159
|
+
uv sync --extra doc
|
|
160
|
+
python scripts/build_doc.py
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Quickstart
|
|
164
|
+
Run a minimal end-to-end simulation with bundled example files:
|
|
165
|
+
|
|
166
|
+
```shell
|
|
167
|
+
uv sync
|
|
168
|
+
uv run python -c "from kmcpy.simulator.config import Configuration; Configuration.help_fields()"
|
|
169
|
+
uv run python example/minimal_example.py
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`Configuration` routes arguments into two groups:
|
|
173
|
+
|
|
174
|
+
1. `system` fields define what you simulate after loader inputs have been read.
|
|
175
|
+
2. `runtime` fields define how you simulate (temperature, passes, random seed).
|
|
176
|
+
|
|
177
|
+
If you pass an unknown keyword, kMCpy raises a clear error and points to `Configuration.help_fields()`.
|
|
178
|
+
|
|
179
|
+
Unit conventions are explicit in code via `kmcpy.units`,
|
|
180
|
+
`Configuration.field_units()`, and `tracker.result_units`. Common units are:
|
|
181
|
+
barriers in meV, rates/probabilities in Hz, time in s, distance in Angstrom,
|
|
182
|
+
diffusivity in cm^2/s, and conductivity in mS/cm.
|
|
183
|
+
|
|
184
|
+
## Run kMCpy
|
|
185
|
+
### API usage
|
|
186
|
+
You can run kMC through API. See the `example` directory for scripts and notebook workflows covering setup, event generation, and simulations.
|
|
187
|
+
|
|
188
|
+
For a one-call simulation:
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
from kmcpy import Configuration, run
|
|
192
|
+
|
|
193
|
+
config = Configuration.from_file("input.yaml")
|
|
194
|
+
tracker = run(config)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
You can also attach custom property callbacks during a run:
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
from kmcpy.simulator.kmc import KMC
|
|
201
|
+
|
|
202
|
+
kmc = KMC.from_config(config)
|
|
203
|
+
|
|
204
|
+
def custom_property(state, step, sim_time):
|
|
205
|
+
occupied = sum(1 for occ in state.occupations if occ < 0)
|
|
206
|
+
return occupied / len(state.occupations)
|
|
207
|
+
|
|
208
|
+
kmc.attach(custom_property, interval=100, name="occupied_fraction")
|
|
209
|
+
kmc.set_property_enabled("conductivity", False) # Optional: disable selected built-in fields
|
|
210
|
+
tracker = kmc.run()
|
|
211
|
+
|
|
212
|
+
# Stored custom callback records
|
|
213
|
+
records = tracker.get_property_records("occupied_fraction")
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Command line usage
|
|
217
|
+
A wrapper is provided if you want to run kMCpy from the command line.
|
|
218
|
+
|
|
219
|
+
1. Generate a commented template input file:
|
|
220
|
+
```shell
|
|
221
|
+
kmcpy init --output input_template.yaml
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
2. Edit the required file paths and simulation settings in `input_template.yaml`.
|
|
225
|
+
|
|
226
|
+
3. Run the simulation:
|
|
227
|
+
```shell
|
|
228
|
+
run_kmc --input input_template.yaml
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
To print out all arguments, you can run:
|
|
232
|
+
```shell
|
|
233
|
+
run_kmc --help
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Build local barrier models
|
|
237
|
+
For direct barrier logic, use `LocalBarrierModel`. It supports constant barriers,
|
|
238
|
+
count rules, species-count rules, wildcard patterns, and exact catalog-style
|
|
239
|
+
matches. Barrier values are in meV.
|
|
240
|
+
|
|
241
|
+
Constant barrier:
|
|
242
|
+
```python
|
|
243
|
+
from kmcpy.models import LocalBarrierModel
|
|
244
|
+
|
|
245
|
+
model = LocalBarrierModel.constant_barrier(300.0)
|
|
246
|
+
model.to("model.json")
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Species-count rule, for example "more than 3 Si in the local environment":
|
|
250
|
+
```python
|
|
251
|
+
model = LocalBarrierModel(
|
|
252
|
+
default_barrier=300.0,
|
|
253
|
+
site_species={
|
|
254
|
+
1: {-1: "P", 1: "Si"},
|
|
255
|
+
2: {-1: "Si", 1: "P"},
|
|
256
|
+
3: {-1: "Si", 1: "P"},
|
|
257
|
+
4: {-1: "Al", 1: "Si"},
|
|
258
|
+
},
|
|
259
|
+
)
|
|
260
|
+
model.add_species_count_rule(
|
|
261
|
+
name="si_rich",
|
|
262
|
+
sites="local_env",
|
|
263
|
+
species="Si",
|
|
264
|
+
min_count=4,
|
|
265
|
+
barrier=420.0,
|
|
266
|
+
)
|
|
267
|
+
model.to("model.json")
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Exact catalog-style match:
|
|
271
|
+
```python
|
|
272
|
+
model = LocalBarrierModel.from_exact_entries([
|
|
273
|
+
{
|
|
274
|
+
"mobile_ion_indices": [0, 1],
|
|
275
|
+
"local_env_indices": [1, 2, 3],
|
|
276
|
+
"occupations": [1, -1, 1, -1],
|
|
277
|
+
"properties": {"barrier": 250.0},
|
|
278
|
+
}
|
|
279
|
+
])
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Use the generated model file in simulation config by pointing to it:
|
|
283
|
+
```yaml
|
|
284
|
+
model_file: "model.json"
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Exact catalog-style data should be represented as `LocalBarrierModel` exact
|
|
288
|
+
rules rather than a separate catalog model.
|
|
289
|
+
|
|
290
|
+
## Citation
|
|
291
|
+
If you use kMCpy in your research, please cite it as follows:
|
|
292
|
+
|
|
293
|
+
```bibtex
|
|
294
|
+
@article{deng2022fundamental,
|
|
295
|
+
title={Fundamental investigations on the sodium-ion transport properties of mixed polyanion solid-state battery electrolytes},
|
|
296
|
+
author={Deng, Zeyu and Mishra, Tara P and Mahayoni, Eunike and Ma, Qianli and Tieu, Aaron Jue Kang and Guillon, Olivier and Chotard, Jean-No{\"e}l and Seznec, Vincent and Cheetham, Anthony K and Masquelier, Christian and Gautam, Gopalakrishnan Sai and Canepa, Pieremanuele},
|
|
297
|
+
journal={Nature Communications},
|
|
298
|
+
volume={13},
|
|
299
|
+
number={1},
|
|
300
|
+
pages={1--14},
|
|
301
|
+
year={2022},
|
|
302
|
+
publisher={Nature Publishing Group}
|
|
303
|
+
}
|
|
304
|
+
@article{deng2023kmcpy,
|
|
305
|
+
title = {kMCpy: A python package to simulate transport properties in solids with kinetic Monte Carlo},
|
|
306
|
+
journal = {Computational Materials Science},
|
|
307
|
+
volume = {229},
|
|
308
|
+
pages = {112394},
|
|
309
|
+
year = {2023},
|
|
310
|
+
issn = {0927-0256},
|
|
311
|
+
doi = {https://doi.org/10.1016/j.commatsci.2023.112394},
|
|
312
|
+
author = {Zeyu Deng and Tara P. Mishra and Weihang Xie and Daanyal Ahmed Saeed and Gopalakrishnan Sai Gautam and Pieremanuele Canepa},
|
|
313
|
+
}
|
|
314
|
+
```
|
kmcpy-0.3.0/README.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
|
|
2
|
+
<h1 align="center">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/caneparesearch/kMCpy/master/docs/source/_static/kmcpy_logo_dark.svg">
|
|
5
|
+
<img alt="Logo" src="https://raw.githubusercontent.com/caneparesearch/kMCpy/master/docs/source/_static/kmcpy_logo.svg" height="120">
|
|
6
|
+
</picture>
|
|
7
|
+
</h1>
|
|
8
|
+
|
|
9
|
+
[](https://GitHub.com/caneparesearch/kmcpy/releases/)
|
|
10
|
+
[](https://kmcpy.readthedocs.io/en/latest/?badge=latest)
|
|
11
|
+
[](https://github.com/caneparesearch/kmcpy/actions/workflows/test-ubuntu.yml)
|
|
12
|
+
[](https://pypi.org/project/kmcpy)
|
|
13
|
+
[](https://python.org/downloads)
|
|
14
|
+
[](https://doi.org/10.1016/j.commatsci.2023.112394)
|
|
15
|
+
|
|
16
|
+
Kinetic Monte Carlo Simulation with Python (kMCpy) is an open-source Python package for studying ion diffusion using the kinetic Monte Carlo (kMC) technique. It offers a comprehensive Python-based approach to compute kinetic properties, suitable for research, development, and prediction of new functional materials.
|
|
17
|
+
|
|
18
|
+
Key features include a local cluster expansion model toolkit, a rejection-free kinetic Monte Carlo (rf-kMC) solver, and tools to extract ion transport properties like diffusivities and conductivities. The local cluster expansion model toolkit facilitates model fitting from ab initio or empirical barrier calculations. Post-training, the local cluster expansion model can compute migration barriers in crystalline materials within the transition state theory.
|
|
19
|
+
|
|
20
|
+
Advantages of using kMCpy:
|
|
21
|
+
|
|
22
|
+
1. Written entirely in Python with a modular design, promoting developer-centricity and easy feature addition.
|
|
23
|
+
2. Cross-platform compatibility, supporting Windows, macOS, and Linux.
|
|
24
|
+
3. Performance-optimized kMC routines using [Numba](https://numba.pydata.org/), resulting in significant speed improvements.
|
|
25
|
+
|
|
26
|
+
> [!WARNING]
|
|
27
|
+
> kMCpy is under active development.
|
|
28
|
+
>
|
|
29
|
+
> APIs and serialized file formats may change before a stable release. Check the release notes and current documentation when updating existing workflows.
|
|
30
|
+
|
|
31
|
+
Release notes are maintained in the [changelog](https://github.com/caneparesearch/kmcpy/blob/master/CHANGELOG.md).
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
### Install with `pip`
|
|
36
|
+
|
|
37
|
+
You can install the latest PyPI release directly into a Python environment:
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
pip install kmcpy
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Using a virtual environment is recommended:
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
python -m venv kmcpy-env
|
|
47
|
+
source kmcpy-env/bin/activate # On Windows use `kmcpy-env\Scripts\activate`
|
|
48
|
+
pip install kmcpy
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Install with `uv pip`
|
|
52
|
+
|
|
53
|
+
If you manage Python environments with [uv](https://docs.astral.sh/uv/), use
|
|
54
|
+
the same PyPI package:
|
|
55
|
+
|
|
56
|
+
```shell
|
|
57
|
+
uv venv kmcpy-env
|
|
58
|
+
source kmcpy-env/bin/activate
|
|
59
|
+
uv pip install kmcpy
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Install with Conda
|
|
63
|
+
|
|
64
|
+
Use Conda to create the Python environment, then install the PyPI package
|
|
65
|
+
inside that environment:
|
|
66
|
+
|
|
67
|
+
```shell
|
|
68
|
+
conda create -n kmcpy python=3.11 pip
|
|
69
|
+
conda activate kmcpy
|
|
70
|
+
python -m pip install kmcpy
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Install from source
|
|
74
|
+
|
|
75
|
+
You can install kMCpy from source using either `pip` or `uv`. First, clone the
|
|
76
|
+
repository and navigate to its root directory.
|
|
77
|
+
|
|
78
|
+
To install normally with `pip`:
|
|
79
|
+
|
|
80
|
+
```shell
|
|
81
|
+
pip install .
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
For development with `pip`:
|
|
85
|
+
|
|
86
|
+
```shell
|
|
87
|
+
pip install -e ".[dev]"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
For development with `uv`:
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
uv sync
|
|
94
|
+
uv sync --extra dev
|
|
95
|
+
uv pip install -e .
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
> [!WARNING]
|
|
99
|
+
> Windows users
|
|
100
|
+
>
|
|
101
|
+
> Windows users (not applicable to WSL) need to install [Microsoft C++ build tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/) for `pymatgen`.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
## Build documentation
|
|
105
|
+
You can access the documentation at [https://kmcpy.readthedocs.io/](https://kmcpy.readthedocs.io/). However, if you want to build the documentation locally, you can do so by following these steps:
|
|
106
|
+
```shell
|
|
107
|
+
uv sync --extra doc
|
|
108
|
+
python scripts/build_doc.py
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Quickstart
|
|
112
|
+
Run a minimal end-to-end simulation with bundled example files:
|
|
113
|
+
|
|
114
|
+
```shell
|
|
115
|
+
uv sync
|
|
116
|
+
uv run python -c "from kmcpy.simulator.config import Configuration; Configuration.help_fields()"
|
|
117
|
+
uv run python example/minimal_example.py
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`Configuration` routes arguments into two groups:
|
|
121
|
+
|
|
122
|
+
1. `system` fields define what you simulate after loader inputs have been read.
|
|
123
|
+
2. `runtime` fields define how you simulate (temperature, passes, random seed).
|
|
124
|
+
|
|
125
|
+
If you pass an unknown keyword, kMCpy raises a clear error and points to `Configuration.help_fields()`.
|
|
126
|
+
|
|
127
|
+
Unit conventions are explicit in code via `kmcpy.units`,
|
|
128
|
+
`Configuration.field_units()`, and `tracker.result_units`. Common units are:
|
|
129
|
+
barriers in meV, rates/probabilities in Hz, time in s, distance in Angstrom,
|
|
130
|
+
diffusivity in cm^2/s, and conductivity in mS/cm.
|
|
131
|
+
|
|
132
|
+
## Run kMCpy
|
|
133
|
+
### API usage
|
|
134
|
+
You can run kMC through API. See the `example` directory for scripts and notebook workflows covering setup, event generation, and simulations.
|
|
135
|
+
|
|
136
|
+
For a one-call simulation:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from kmcpy import Configuration, run
|
|
140
|
+
|
|
141
|
+
config = Configuration.from_file("input.yaml")
|
|
142
|
+
tracker = run(config)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
You can also attach custom property callbacks during a run:
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from kmcpy.simulator.kmc import KMC
|
|
149
|
+
|
|
150
|
+
kmc = KMC.from_config(config)
|
|
151
|
+
|
|
152
|
+
def custom_property(state, step, sim_time):
|
|
153
|
+
occupied = sum(1 for occ in state.occupations if occ < 0)
|
|
154
|
+
return occupied / len(state.occupations)
|
|
155
|
+
|
|
156
|
+
kmc.attach(custom_property, interval=100, name="occupied_fraction")
|
|
157
|
+
kmc.set_property_enabled("conductivity", False) # Optional: disable selected built-in fields
|
|
158
|
+
tracker = kmc.run()
|
|
159
|
+
|
|
160
|
+
# Stored custom callback records
|
|
161
|
+
records = tracker.get_property_records("occupied_fraction")
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Command line usage
|
|
165
|
+
A wrapper is provided if you want to run kMCpy from the command line.
|
|
166
|
+
|
|
167
|
+
1. Generate a commented template input file:
|
|
168
|
+
```shell
|
|
169
|
+
kmcpy init --output input_template.yaml
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
2. Edit the required file paths and simulation settings in `input_template.yaml`.
|
|
173
|
+
|
|
174
|
+
3. Run the simulation:
|
|
175
|
+
```shell
|
|
176
|
+
run_kmc --input input_template.yaml
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
To print out all arguments, you can run:
|
|
180
|
+
```shell
|
|
181
|
+
run_kmc --help
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Build local barrier models
|
|
185
|
+
For direct barrier logic, use `LocalBarrierModel`. It supports constant barriers,
|
|
186
|
+
count rules, species-count rules, wildcard patterns, and exact catalog-style
|
|
187
|
+
matches. Barrier values are in meV.
|
|
188
|
+
|
|
189
|
+
Constant barrier:
|
|
190
|
+
```python
|
|
191
|
+
from kmcpy.models import LocalBarrierModel
|
|
192
|
+
|
|
193
|
+
model = LocalBarrierModel.constant_barrier(300.0)
|
|
194
|
+
model.to("model.json")
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Species-count rule, for example "more than 3 Si in the local environment":
|
|
198
|
+
```python
|
|
199
|
+
model = LocalBarrierModel(
|
|
200
|
+
default_barrier=300.0,
|
|
201
|
+
site_species={
|
|
202
|
+
1: {-1: "P", 1: "Si"},
|
|
203
|
+
2: {-1: "Si", 1: "P"},
|
|
204
|
+
3: {-1: "Si", 1: "P"},
|
|
205
|
+
4: {-1: "Al", 1: "Si"},
|
|
206
|
+
},
|
|
207
|
+
)
|
|
208
|
+
model.add_species_count_rule(
|
|
209
|
+
name="si_rich",
|
|
210
|
+
sites="local_env",
|
|
211
|
+
species="Si",
|
|
212
|
+
min_count=4,
|
|
213
|
+
barrier=420.0,
|
|
214
|
+
)
|
|
215
|
+
model.to("model.json")
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Exact catalog-style match:
|
|
219
|
+
```python
|
|
220
|
+
model = LocalBarrierModel.from_exact_entries([
|
|
221
|
+
{
|
|
222
|
+
"mobile_ion_indices": [0, 1],
|
|
223
|
+
"local_env_indices": [1, 2, 3],
|
|
224
|
+
"occupations": [1, -1, 1, -1],
|
|
225
|
+
"properties": {"barrier": 250.0},
|
|
226
|
+
}
|
|
227
|
+
])
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Use the generated model file in simulation config by pointing to it:
|
|
231
|
+
```yaml
|
|
232
|
+
model_file: "model.json"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Exact catalog-style data should be represented as `LocalBarrierModel` exact
|
|
236
|
+
rules rather than a separate catalog model.
|
|
237
|
+
|
|
238
|
+
## Citation
|
|
239
|
+
If you use kMCpy in your research, please cite it as follows:
|
|
240
|
+
|
|
241
|
+
```bibtex
|
|
242
|
+
@article{deng2022fundamental,
|
|
243
|
+
title={Fundamental investigations on the sodium-ion transport properties of mixed polyanion solid-state battery electrolytes},
|
|
244
|
+
author={Deng, Zeyu and Mishra, Tara P and Mahayoni, Eunike and Ma, Qianli and Tieu, Aaron Jue Kang and Guillon, Olivier and Chotard, Jean-No{\"e}l and Seznec, Vincent and Cheetham, Anthony K and Masquelier, Christian and Gautam, Gopalakrishnan Sai and Canepa, Pieremanuele},
|
|
245
|
+
journal={Nature Communications},
|
|
246
|
+
volume={13},
|
|
247
|
+
number={1},
|
|
248
|
+
pages={1--14},
|
|
249
|
+
year={2022},
|
|
250
|
+
publisher={Nature Publishing Group}
|
|
251
|
+
}
|
|
252
|
+
@article{deng2023kmcpy,
|
|
253
|
+
title = {kMCpy: A python package to simulate transport properties in solids with kinetic Monte Carlo},
|
|
254
|
+
journal = {Computational Materials Science},
|
|
255
|
+
volume = {229},
|
|
256
|
+
pages = {112394},
|
|
257
|
+
year = {2023},
|
|
258
|
+
issn = {0927-0256},
|
|
259
|
+
doi = {https://doi.org/10.1016/j.commatsci.2023.112394},
|
|
260
|
+
author = {Zeyu Deng and Tara P. Mishra and Weihang Xie and Daanyal Ahmed Saeed and Gopalakrishnan Sai Gautam and Pieremanuele Canepa},
|
|
261
|
+
}
|
|
262
|
+
```
|
|
@@ -3,15 +3,23 @@ import datetime
|
|
|
3
3
|
import logging
|
|
4
4
|
|
|
5
5
|
from ._version import __version__
|
|
6
|
+
from .api import run
|
|
6
7
|
|
|
7
8
|
# Import main classes for convenient access
|
|
8
|
-
from .models import
|
|
9
|
+
from .models import (
|
|
10
|
+
BaseModel,
|
|
11
|
+
LocalClusterExpansion,
|
|
12
|
+
CompositeLCEModel,
|
|
13
|
+
LocalBarrierModel,
|
|
14
|
+
MappedOccupationChange,
|
|
15
|
+
SiteEnergyModel,
|
|
16
|
+
)
|
|
9
17
|
from .simulator.kmc import KMC
|
|
10
|
-
from .event import Event, EventGenerator
|
|
11
|
-
from .simulator.
|
|
12
|
-
from .simulator.
|
|
13
|
-
from .simulator.state import SimulationState
|
|
18
|
+
from .event import Event, EventGenerator
|
|
19
|
+
from .simulator.config import Configuration, SystemConfig, RuntimeConfig
|
|
20
|
+
from .simulator.state import State
|
|
14
21
|
from .simulator.tracker import Tracker
|
|
22
|
+
from .units import UNIT_CONVENTIONS, TRANSPORT_PROPERTY_UNITS, unit_for
|
|
15
23
|
|
|
16
24
|
__author__ = "kMCpy Development Team"
|
|
17
25
|
__author_email__ = "dengzeyu@gmail.com"
|
|
@@ -19,20 +27,25 @@ __author_email__ = "dengzeyu@gmail.com"
|
|
|
19
27
|
# Expose the main classes and functions as the public API
|
|
20
28
|
__all__ = [
|
|
21
29
|
"__version__",
|
|
30
|
+
"run",
|
|
22
31
|
"get_logo",
|
|
23
32
|
"BaseModel",
|
|
24
33
|
"LocalClusterExpansion",
|
|
34
|
+
"LocalBarrierModel",
|
|
25
35
|
"CompositeLCEModel",
|
|
36
|
+
"MappedOccupationChange",
|
|
37
|
+
"SiteEnergyModel",
|
|
26
38
|
"KMC",
|
|
27
39
|
"Event",
|
|
28
40
|
"EventGenerator",
|
|
29
|
-
"
|
|
30
|
-
"SimulationCondition",
|
|
31
|
-
"SimulationConfig",
|
|
41
|
+
"Configuration",
|
|
32
42
|
"SystemConfig",
|
|
33
43
|
"RuntimeConfig",
|
|
34
|
-
"
|
|
35
|
-
"Tracker"
|
|
44
|
+
"State",
|
|
45
|
+
"Tracker",
|
|
46
|
+
"UNIT_CONVENTIONS",
|
|
47
|
+
"TRANSPORT_PROPERTY_UNITS",
|
|
48
|
+
"unit_for",
|
|
36
49
|
]
|
|
37
50
|
|
|
38
51
|
|
kmcpy-0.3.0/kmcpy/api.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Public high-level API helpers for kMCpy."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from kmcpy.simulator.config import Configuration
|
|
9
|
+
from kmcpy.simulator.tracker import Tracker
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def run(config: "Configuration", label: str | None = None) -> "Tracker":
|
|
13
|
+
"""Run a KMC simulation from a ``Configuration`` in one call.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
config: Simulation configuration.
|
|
17
|
+
label: Optional output label. If ``None``, ``config.name`` is used.
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
Tracker with simulation results.
|
|
21
|
+
"""
|
|
22
|
+
from kmcpy.simulator.config import Configuration
|
|
23
|
+
from kmcpy.simulator.kmc import KMC
|
|
24
|
+
|
|
25
|
+
if not isinstance(config, Configuration):
|
|
26
|
+
raise TypeError("config must be a Configuration instance")
|
|
27
|
+
|
|
28
|
+
kmc = KMC.from_config(config)
|
|
29
|
+
return kmc.run(label=label)
|