mcpy-gcmc 1.5.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.
- mcpy_gcmc-1.5.0/LICENSE +21 -0
- mcpy_gcmc-1.5.0/PKG-INFO +157 -0
- mcpy_gcmc-1.5.0/README.md +118 -0
- mcpy_gcmc-1.5.0/mcpy/__init__.py +12 -0
- mcpy_gcmc-1.5.0/mcpy/calculators/__init__.py +24 -0
- mcpy_gcmc-1.5.0/mcpy/calculators/alchemi.py +975 -0
- mcpy_gcmc-1.5.0/mcpy/calculators/base_calculator.py +50 -0
- mcpy_gcmc-1.5.0/mcpy/calculators/mace_f_calculator.py +59 -0
- mcpy_gcmc-1.5.0/mcpy/cell/__init__.py +8 -0
- mcpy_gcmc-1.5.0/mcpy/cell/base_cell.py +91 -0
- mcpy_gcmc-1.5.0/mcpy/cell/cell.py +271 -0
- mcpy_gcmc-1.5.0/mcpy/cell/custom_cell.py +98 -0
- mcpy_gcmc-1.5.0/mcpy/cell/dome_cell.py +109 -0
- mcpy_gcmc-1.5.0/mcpy/cell/null_cell.py +41 -0
- mcpy_gcmc-1.5.0/mcpy/cell/spherical_cell.py +132 -0
- mcpy_gcmc-1.5.0/mcpy/ensembles/__init__.py +13 -0
- mcpy_gcmc-1.5.0/mcpy/ensembles/base_ensemble.py +356 -0
- mcpy_gcmc-1.5.0/mcpy/ensembles/batched_replica_exchange.py +534 -0
- mcpy_gcmc-1.5.0/mcpy/ensembles/canonical_ensemble.py +193 -0
- mcpy_gcmc-1.5.0/mcpy/ensembles/grand_canonical_ensemble.py +568 -0
- mcpy_gcmc-1.5.0/mcpy/ensembles/replica_exchange.py +473 -0
- mcpy_gcmc-1.5.0/mcpy/moves/__init__.py +27 -0
- mcpy_gcmc-1.5.0/mcpy/moves/alchemi_brownian_move.py +91 -0
- mcpy_gcmc-1.5.0/mcpy/moves/base_move.py +71 -0
- mcpy_gcmc-1.5.0/mcpy/moves/brownian_move.py +91 -0
- mcpy_gcmc-1.5.0/mcpy/moves/deletion_move.py +62 -0
- mcpy_gcmc-1.5.0/mcpy/moves/displacement_move.py +82 -0
- mcpy_gcmc-1.5.0/mcpy/moves/insertion_move.py +58 -0
- mcpy_gcmc-1.5.0/mcpy/moves/molecule_deletion_move.py +52 -0
- mcpy_gcmc-1.5.0/mcpy/moves/molecule_displacement_move.py +107 -0
- mcpy_gcmc-1.5.0/mcpy/moves/molecule_insertion_move.py +73 -0
- mcpy_gcmc-1.5.0/mcpy/moves/molecule_utils.py +98 -0
- mcpy_gcmc-1.5.0/mcpy/moves/move_selector.py +163 -0
- mcpy_gcmc-1.5.0/mcpy/moves/permutation_move.py +63 -0
- mcpy_gcmc-1.5.0/mcpy/moves/shake_move.py +47 -0
- mcpy_gcmc-1.5.0/mcpy/utils/__init__.py +23 -0
- mcpy_gcmc-1.5.0/mcpy/utils/chunking.py +26 -0
- mcpy_gcmc-1.5.0/mcpy/utils/logging.py +56 -0
- mcpy_gcmc-1.5.0/mcpy/utils/md_trajectory.py +28 -0
- mcpy_gcmc-1.5.0/mcpy/utils/phase_diagram.py +747 -0
- mcpy_gcmc-1.5.0/mcpy/utils/random_number_generator.py +42 -0
- mcpy_gcmc-1.5.0/mcpy/utils/reference_mu.py +106 -0
- mcpy_gcmc-1.5.0/mcpy/utils/set_unit_constant.py +106 -0
- mcpy_gcmc-1.5.0/mcpy_gcmc.egg-info/PKG-INFO +157 -0
- mcpy_gcmc-1.5.0/mcpy_gcmc.egg-info/SOURCES.txt +78 -0
- mcpy_gcmc-1.5.0/mcpy_gcmc.egg-info/dependency_links.txt +1 -0
- mcpy_gcmc-1.5.0/mcpy_gcmc.egg-info/requires.txt +20 -0
- mcpy_gcmc-1.5.0/mcpy_gcmc.egg-info/top_level.txt +1 -0
- mcpy_gcmc-1.5.0/pyproject.toml +74 -0
- mcpy_gcmc-1.5.0/setup.cfg +4 -0
- mcpy_gcmc-1.5.0/tests/test_acceptance.py +278 -0
- mcpy_gcmc-1.5.0/tests/test_ag111_gcmc_golden.py +351 -0
- mcpy_gcmc-1.5.0/tests/test_atom_limits.py +85 -0
- mcpy_gcmc-1.5.0/tests/test_audit_2026_10.py +443 -0
- mcpy_gcmc-1.5.0/tests/test_audit_2026_10_calculators.py +348 -0
- mcpy_gcmc-1.5.0/tests/test_audit_2026_10_ensembles.py +463 -0
- mcpy_gcmc-1.5.0/tests/test_audit_regressions.py +535 -0
- mcpy_gcmc-1.5.0/tests/test_batched_re_acceptance.py +433 -0
- mcpy_gcmc-1.5.0/tests/test_calculator_gcmc_equivalence.py +152 -0
- mcpy_gcmc-1.5.0/tests/test_canonical_nvt.py +145 -0
- mcpy_gcmc-1.5.0/tests/test_chunking.py +33 -0
- mcpy_gcmc-1.5.0/tests/test_compound_moves.py +127 -0
- mcpy_gcmc-1.5.0/tests/test_constraint_rollback.py +114 -0
- mcpy_gcmc-1.5.0/tests/test_cueq_padding.py +199 -0
- mcpy_gcmc-1.5.0/tests/test_custom_cell_region.py +147 -0
- mcpy_gcmc-1.5.0/tests/test_dome_cell.py +111 -0
- mcpy_gcmc-1.5.0/tests/test_logging.py +266 -0
- mcpy_gcmc-1.5.0/tests/test_molecule_moves.py +617 -0
- mcpy_gcmc-1.5.0/tests/test_mpi_re_acceptance.py +316 -0
- mcpy_gcmc-1.5.0/tests/test_optimizations.py +186 -0
- mcpy_gcmc-1.5.0/tests/test_phase_diagram.py +278 -0
- mcpy_gcmc-1.5.0/tests/test_reference_mu.py +70 -0
- mcpy_gcmc-1.5.0/tests/test_review_2026_10_calc.py +278 -0
- mcpy_gcmc-1.5.0/tests/test_review_2026_10_cells.py +114 -0
- mcpy_gcmc-1.5.0/tests/test_review_2026_10_core.py +697 -0
- mcpy_gcmc-1.5.0/tests/test_review_2026_10_golden_rng.py +45 -0
- mcpy_gcmc-1.5.0/tests/test_review_2026_10_re.py +343 -0
- mcpy_gcmc-1.5.0/tests/test_review_2026_10_thermo.py +73 -0
- mcpy_gcmc-1.5.0/tests/test_species_radii_recipe.py +28 -0
- mcpy_gcmc-1.5.0/tests/test_zero_free_volume.py +63 -0
mcpy_gcmc-1.5.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Riccardo Farris, Emanuele Telari
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
mcpy_gcmc-1.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcpy-gcmc
|
|
3
|
+
Version: 1.5.0
|
|
4
|
+
Summary: A python package to run atomistic Monte Carlo simulations
|
|
5
|
+
Author: Riccardo Farris, Emanuele Telari, Konstantin M. Neyman, Albert Bruix
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/farrisric/mcpy
|
|
8
|
+
Project-URL: Documentation, https://mc-py.readthedocs.io
|
|
9
|
+
Project-URL: Issues, https://github.com/farrisric/mcpy/issues
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: ase>=3.23.0
|
|
24
|
+
Requires-Dist: numpy>=1.22
|
|
25
|
+
Requires-Dist: scipy>=1.8
|
|
26
|
+
Provides-Extra: mace
|
|
27
|
+
Requires-Dist: mace-torch>=0.3.9; extra == "mace"
|
|
28
|
+
Provides-Extra: alchemi
|
|
29
|
+
Requires-Dist: nvalchemi-toolkit[mace]<0.3,>=0.2.0; extra == "alchemi"
|
|
30
|
+
Provides-Extra: mpi
|
|
31
|
+
Requires-Dist: mpi4py>=4.0; extra == "mpi"
|
|
32
|
+
Provides-Extra: plot
|
|
33
|
+
Requires-Dist: matplotlib>=3.5; extra == "plot"
|
|
34
|
+
Provides-Extra: test
|
|
35
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
36
|
+
Requires-Dist: pytest-cov>=4.0; extra == "test"
|
|
37
|
+
Requires-Dist: mcpy-gcmc[plot]; extra == "test"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
[](https://github.com/farrisric/mcpy/actions/workflows/tests.yml)
|
|
41
|
+
[](https://opensource.org/licenses/mit)
|
|
42
|
+
[](https://GitHub.com/farrisric/mcpy/issues)
|
|
43
|
+
[](https://mc-py.readthedocs.io/en/latest/index.html)
|
|
44
|
+
|
|
45
|
+
# mcpy
|
|
46
|
+
|
|
47
|
+
`mcpy` runs Grand Canonical Monte Carlo (GCMC) simulations of atomistic systems on top of the Atomic Simulation Environment (ASE).
|
|
48
|
+
It predicts the composition and structure of surfaces and nanoparticles in contact with a gas or metal reservoir, with any ASE calculator: classical potentials, DFT, or machine-learned interatomic potentials such as MACE.
|
|
49
|
+
|
|
50
|
+
Documentation: <https://mc-py.readthedocs.io>
|
|
51
|
+
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
- **Grand-canonical Monte Carlo**: atomic insertion and deletion at fixed chemical potential, with the free volume of the insertion region estimated from per-species exclusion radii.
|
|
55
|
+
- **Molecular adsorbates**: whole-molecule insertion, deletion and rigid translate+rotate moves (O2, H2O, CO, NH3, any ASE-buildable template), with per-atom `molecule_id` bookkeeping that survives rollback, trajectories and restarts.
|
|
56
|
+
Atomic and molecular species can coexist in one run.
|
|
57
|
+
- **Insertion regions** for every common geometry: the periodic box, a window over a slab, a sphere around a nanoparticle, and a dome over a supported particle.
|
|
58
|
+
- **Replica exchange** along a temperature or chemical-potential ladder, over MPI or in one process on one GPU with batched energy evaluation.
|
|
59
|
+
- **Relaxed trial energies** (the hybrid GCMC scheme of Senftle et al.): each trial can be relaxed before the acceptance test, which makes GCMC workable on dense metal surfaces.
|
|
60
|
+
- **Canonical Monte Carlo and basin hopping**: permutation, displacement, shake and Brownian moves, and a running file of the lowest-energy configurations.
|
|
61
|
+
- **Optional GPU backend**: MACE evaluation and relaxation (FIRE by default, `optimizer=` for FIRE2 or LBFGS) through NVIDIA's `nvalchemi-toolkit`.
|
|
62
|
+
- **Phase diagrams**: post-processing of a chemical-potential sweep into surface and nanoparticle phase diagrams.
|
|
63
|
+
|
|
64
|
+
## Validation
|
|
65
|
+
|
|
66
|
+
mcpy's GCMC sampler reproduces LAMMPS `fix gcmc` for atomic and rigid-molecule Lennard-Jones systems, and the ideal gas against its analytic result.
|
|
67
|
+
The tables, the rerunnable scripts and a MACE comparison are in [`benchmark/README.md`](benchmark/README.md).
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
mcpy needs Python 3.11 or later.
|
|
72
|
+
The distribution is named `mcpy-gcmc` (the `mcpy` name on PyPI belongs to an unrelated package).
|
|
73
|
+
You still write `import mcpy`.
|
|
74
|
+
Until the first PyPI release, install from the repository:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
git clone https://github.com/farrisric/mcpy.git
|
|
78
|
+
cd mcpy
|
|
79
|
+
pip install -e .
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The base install (ASE, NumPy, SciPy) runs the CPU examples `examples/00` to `examples/02`.
|
|
83
|
+
Optional extras:
|
|
84
|
+
|
|
85
|
+
| Extra | Adds | Needed for |
|
|
86
|
+
| --- | --- | --- |
|
|
87
|
+
| `.[mace]` | `mace-torch` | `MACE_F_Calculator` |
|
|
88
|
+
| `.[alchemi]` | `nvalchemi-toolkit[mace]` | `AlchemiCalculator`, `AlchemiFCalculator`, `examples/03` and `examples/04` (CUDA GPU) |
|
|
89
|
+
| `.[plot]` | `matplotlib` | the phase-diagram utilities |
|
|
90
|
+
| `.[mpi]` | `mpi4py` | `ReplicaExchange` over MPI |
|
|
91
|
+
| `.[test]` | `pytest` | the test suite |
|
|
92
|
+
|
|
93
|
+
A conda-installed `mpi4py` (`conda install mpi4py`) is often the safer choice, because it links the MPI library it was built for.
|
|
94
|
+
The [installation guide](https://mc-py.readthedocs.io/en/latest/installation.html) covers the GPU backend and the MPI launch.
|
|
95
|
+
|
|
96
|
+
## Quickstart (CPU, about three minutes)
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
python examples/00_hello_gcmc.py
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The script fills an empty periodic box with Lennard-Jones particles from a reservoir and prints the average particle count next to the LAMMPS value for the same conditions.
|
|
103
|
+
Here is the core of it:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from ase import Atoms
|
|
107
|
+
from ase.calculators.lj import LennardJones
|
|
108
|
+
|
|
109
|
+
from mcpy.cell import Cell
|
|
110
|
+
from mcpy.ensembles import GrandCanonicalEnsemble
|
|
111
|
+
from mcpy.moves import DeletionMove, DisplacementMove, InsertionMove, MoveSelector
|
|
112
|
+
|
|
113
|
+
atoms = Atoms(cell=[9.0, 9.0, 9.0], pbc=True) # an empty periodic box
|
|
114
|
+
cell = Cell(atoms, seed=6) # insert and delete anywhere in it
|
|
115
|
+
|
|
116
|
+
move_selector = MoveSelector(
|
|
117
|
+
[1, 1, 1],
|
|
118
|
+
[InsertionMove(cell, species=['H'], seed=1),
|
|
119
|
+
DeletionMove(cell, species=['H'], seed=2),
|
|
120
|
+
DisplacementMove(species=['H'], max_displacement=0.3, seed=3)],
|
|
121
|
+
seed=4,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
gcmc = GrandCanonicalEnsemble(
|
|
125
|
+
atoms=atoms,
|
|
126
|
+
cells=[cell],
|
|
127
|
+
calculator=LennardJones(sigma=1.0, epsilon=1.0, rc=3.0, smooth=False),
|
|
128
|
+
mu={'H': -3.0}, # reduced chemical potential
|
|
129
|
+
species=['H'],
|
|
130
|
+
units_type='LJ',
|
|
131
|
+
temperature=2.0, # reduced temperature
|
|
132
|
+
move_selector=move_selector,
|
|
133
|
+
random_seed=5, # every random stream is seeded: the run repeats exactly
|
|
134
|
+
outfile='hello_gcmc.out',
|
|
135
|
+
traj_file='hello_gcmc.xyz',
|
|
136
|
+
outfile_write_interval=100,
|
|
137
|
+
trajectory_write_interval=100,
|
|
138
|
+
)
|
|
139
|
+
gcmc.run(6000)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The [tutorial](https://mc-py.readthedocs.io/en/latest/getting_started.html) takes the same loop to an O/Ag(111) oxidation phase diagram with MACE.
|
|
143
|
+
[`examples/`](examples/README.md) has the other runnable scripts, and [`notebooks/`](notebooks/) has worked case studies with executed output.
|
|
144
|
+
|
|
145
|
+
## Citing mcpy
|
|
146
|
+
|
|
147
|
+
If you use mcpy in published work, please cite it with the metadata in [`CITATION.cff`](CITATION.cff) (GitHub shows a "Cite this repository" button for it).
|
|
148
|
+
|
|
149
|
+
## Contributing
|
|
150
|
+
|
|
151
|
+
Contributions are welcome.
|
|
152
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup, the tests, and how to submit changes.
|
|
153
|
+
Bug reports and feature requests go to the [issue tracker](https://github.com/farrisric/mcpy/issues).
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
mcpy is licensed under the MIT License; see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
[](https://github.com/farrisric/mcpy/actions/workflows/tests.yml)
|
|
2
|
+
[](https://opensource.org/licenses/mit)
|
|
3
|
+
[](https://GitHub.com/farrisric/mcpy/issues)
|
|
4
|
+
[](https://mc-py.readthedocs.io/en/latest/index.html)
|
|
5
|
+
|
|
6
|
+
# mcpy
|
|
7
|
+
|
|
8
|
+
`mcpy` runs Grand Canonical Monte Carlo (GCMC) simulations of atomistic systems on top of the Atomic Simulation Environment (ASE).
|
|
9
|
+
It predicts the composition and structure of surfaces and nanoparticles in contact with a gas or metal reservoir, with any ASE calculator: classical potentials, DFT, or machine-learned interatomic potentials such as MACE.
|
|
10
|
+
|
|
11
|
+
Documentation: <https://mc-py.readthedocs.io>
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Grand-canonical Monte Carlo**: atomic insertion and deletion at fixed chemical potential, with the free volume of the insertion region estimated from per-species exclusion radii.
|
|
16
|
+
- **Molecular adsorbates**: whole-molecule insertion, deletion and rigid translate+rotate moves (O2, H2O, CO, NH3, any ASE-buildable template), with per-atom `molecule_id` bookkeeping that survives rollback, trajectories and restarts.
|
|
17
|
+
Atomic and molecular species can coexist in one run.
|
|
18
|
+
- **Insertion regions** for every common geometry: the periodic box, a window over a slab, a sphere around a nanoparticle, and a dome over a supported particle.
|
|
19
|
+
- **Replica exchange** along a temperature or chemical-potential ladder, over MPI or in one process on one GPU with batched energy evaluation.
|
|
20
|
+
- **Relaxed trial energies** (the hybrid GCMC scheme of Senftle et al.): each trial can be relaxed before the acceptance test, which makes GCMC workable on dense metal surfaces.
|
|
21
|
+
- **Canonical Monte Carlo and basin hopping**: permutation, displacement, shake and Brownian moves, and a running file of the lowest-energy configurations.
|
|
22
|
+
- **Optional GPU backend**: MACE evaluation and relaxation (FIRE by default, `optimizer=` for FIRE2 or LBFGS) through NVIDIA's `nvalchemi-toolkit`.
|
|
23
|
+
- **Phase diagrams**: post-processing of a chemical-potential sweep into surface and nanoparticle phase diagrams.
|
|
24
|
+
|
|
25
|
+
## Validation
|
|
26
|
+
|
|
27
|
+
mcpy's GCMC sampler reproduces LAMMPS `fix gcmc` for atomic and rigid-molecule Lennard-Jones systems, and the ideal gas against its analytic result.
|
|
28
|
+
The tables, the rerunnable scripts and a MACE comparison are in [`benchmark/README.md`](benchmark/README.md).
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
mcpy needs Python 3.11 or later.
|
|
33
|
+
The distribution is named `mcpy-gcmc` (the `mcpy` name on PyPI belongs to an unrelated package).
|
|
34
|
+
You still write `import mcpy`.
|
|
35
|
+
Until the first PyPI release, install from the repository:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
git clone https://github.com/farrisric/mcpy.git
|
|
39
|
+
cd mcpy
|
|
40
|
+
pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The base install (ASE, NumPy, SciPy) runs the CPU examples `examples/00` to `examples/02`.
|
|
44
|
+
Optional extras:
|
|
45
|
+
|
|
46
|
+
| Extra | Adds | Needed for |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| `.[mace]` | `mace-torch` | `MACE_F_Calculator` |
|
|
49
|
+
| `.[alchemi]` | `nvalchemi-toolkit[mace]` | `AlchemiCalculator`, `AlchemiFCalculator`, `examples/03` and `examples/04` (CUDA GPU) |
|
|
50
|
+
| `.[plot]` | `matplotlib` | the phase-diagram utilities |
|
|
51
|
+
| `.[mpi]` | `mpi4py` | `ReplicaExchange` over MPI |
|
|
52
|
+
| `.[test]` | `pytest` | the test suite |
|
|
53
|
+
|
|
54
|
+
A conda-installed `mpi4py` (`conda install mpi4py`) is often the safer choice, because it links the MPI library it was built for.
|
|
55
|
+
The [installation guide](https://mc-py.readthedocs.io/en/latest/installation.html) covers the GPU backend and the MPI launch.
|
|
56
|
+
|
|
57
|
+
## Quickstart (CPU, about three minutes)
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
python examples/00_hello_gcmc.py
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The script fills an empty periodic box with Lennard-Jones particles from a reservoir and prints the average particle count next to the LAMMPS value for the same conditions.
|
|
64
|
+
Here is the core of it:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from ase import Atoms
|
|
68
|
+
from ase.calculators.lj import LennardJones
|
|
69
|
+
|
|
70
|
+
from mcpy.cell import Cell
|
|
71
|
+
from mcpy.ensembles import GrandCanonicalEnsemble
|
|
72
|
+
from mcpy.moves import DeletionMove, DisplacementMove, InsertionMove, MoveSelector
|
|
73
|
+
|
|
74
|
+
atoms = Atoms(cell=[9.0, 9.0, 9.0], pbc=True) # an empty periodic box
|
|
75
|
+
cell = Cell(atoms, seed=6) # insert and delete anywhere in it
|
|
76
|
+
|
|
77
|
+
move_selector = MoveSelector(
|
|
78
|
+
[1, 1, 1],
|
|
79
|
+
[InsertionMove(cell, species=['H'], seed=1),
|
|
80
|
+
DeletionMove(cell, species=['H'], seed=2),
|
|
81
|
+
DisplacementMove(species=['H'], max_displacement=0.3, seed=3)],
|
|
82
|
+
seed=4,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
gcmc = GrandCanonicalEnsemble(
|
|
86
|
+
atoms=atoms,
|
|
87
|
+
cells=[cell],
|
|
88
|
+
calculator=LennardJones(sigma=1.0, epsilon=1.0, rc=3.0, smooth=False),
|
|
89
|
+
mu={'H': -3.0}, # reduced chemical potential
|
|
90
|
+
species=['H'],
|
|
91
|
+
units_type='LJ',
|
|
92
|
+
temperature=2.0, # reduced temperature
|
|
93
|
+
move_selector=move_selector,
|
|
94
|
+
random_seed=5, # every random stream is seeded: the run repeats exactly
|
|
95
|
+
outfile='hello_gcmc.out',
|
|
96
|
+
traj_file='hello_gcmc.xyz',
|
|
97
|
+
outfile_write_interval=100,
|
|
98
|
+
trajectory_write_interval=100,
|
|
99
|
+
)
|
|
100
|
+
gcmc.run(6000)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The [tutorial](https://mc-py.readthedocs.io/en/latest/getting_started.html) takes the same loop to an O/Ag(111) oxidation phase diagram with MACE.
|
|
104
|
+
[`examples/`](examples/README.md) has the other runnable scripts, and [`notebooks/`](notebooks/) has worked case studies with executed output.
|
|
105
|
+
|
|
106
|
+
## Citing mcpy
|
|
107
|
+
|
|
108
|
+
If you use mcpy in published work, please cite it with the metadata in [`CITATION.cff`](CITATION.cff) (GitHub shows a "Cite this repository" button for it).
|
|
109
|
+
|
|
110
|
+
## Contributing
|
|
111
|
+
|
|
112
|
+
Contributions are welcome.
|
|
113
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup, the tests, and how to submit changes.
|
|
114
|
+
Bug reports and feature requests go to the [issue tracker](https://github.com/farrisric/mcpy/issues).
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
mcpy is licensed under the MIT License; see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
3
|
+
|
|
4
|
+
try:
|
|
5
|
+
__version__ = version('mcpy-gcmc')
|
|
6
|
+
except PackageNotFoundError: # not installed, e.g. run from a source checkout
|
|
7
|
+
__version__ = '0.0.0.unknown'
|
|
8
|
+
|
|
9
|
+
# Library convention: attach a NullHandler to the top-level package logger so
|
|
10
|
+
# importing mcpy has no side effects on the host application's logging config.
|
|
11
|
+
# Users opt in to logging via mcpy.utils.logging.configure(...).
|
|
12
|
+
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from .base_calculator import BaseCalculator
|
|
2
|
+
|
|
3
|
+
# The backend calculators import lazily (PEP 562): mace-torch and nvalchemi
|
|
4
|
+
# pull in torch, which costs seconds and, in a misconfigured env, kills the
|
|
5
|
+
# process with SIGBUS. Accessing one without its backend raises the real
|
|
6
|
+
# ImportError (install with: pip install -e .[mace] or .[alchemi]).
|
|
7
|
+
_LAZY = {
|
|
8
|
+
'MACE_F_Calculator': 'mace_f_calculator',
|
|
9
|
+
'AlchemiCalculator': 'alchemi',
|
|
10
|
+
'AlchemiFCalculator': 'alchemi',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
__all__ = ['BaseCalculator', *_LAZY]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def __getattr__(name):
|
|
17
|
+
if name in _LAZY:
|
|
18
|
+
from importlib import import_module
|
|
19
|
+
return getattr(import_module(f'.{_LAZY[name]}', __name__), name)
|
|
20
|
+
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def __dir__():
|
|
24
|
+
return sorted({*globals(), *__all__})
|