Molten salt simulation package employing universal machine-learned interatomic potentials (uMLIPs)
Project description
MoltenSaltCalc
A Python package for running and analyzing molecular dynamics (MD) simulations of molten salts using machine-learned interatomic potentials (MLIPs) within the Atomic Simulation Environment (ASE).
Authors
Daniel Isler, Lei Zhang, Max van Brenk, Süleyman Er
Features
- System Construction: Construct molten salt systems with customizable compositions in ASE
- MLIP Integration: Support for FAIRCHEM, MACE, GRACE, ... MLIPs (other MLIPs can also be added by the user)
- Molecular Dynamics: Run NPT (constant pressure-temperature) and NVT (constant volume-temperature) simulations
- Property Analysis: Compute thermodynamic and transport properties such as density, diffusion coefficients, viscosity, and heat capacity
Installation
Create a virtual environment and install the package with the desired MLIP backend. Each MLIP backend has separate and potentially conflicting dependencies. Therefore, only one backend should be installed per environment.
Tested on Python 3.10, 3.11, 3.12, 3.13 and 3.14. All uMLIPs work on Python 3.12, but some of them do not work on the lower / higher versions. E.g. the fairchem (uma), grace and upet uMLIPs do not work with Python 3.10. On python 3.14, so far only chgnet, mattersim and upet work.
By default, the installation is shipped along with the torch-dftd3 calculator for long-range interactions. If you want to use the dftd4 calculator instead, add -dftd4 to the pip command, e.g. pip install moltensaltcalc[grace-dftd4] or if you do not wish to use the calculator at all, install with -nodisp instead, e.g. pip install moltensaltcalc[grace-nodisp].
GRACE
python3 -m venv .venv # Or any other name
source .venv/bin/activate # Linux/macOS
# or
.venv\Scripts\activate # Windows
pip install moltensaltcalc[grace]
FAIRCHEM
pip install moltensaltcalc[fairchem]
MACE
pip install moltensaltcalc[mace]
MatterSim
pip install moltensaltcalc[mattersim]
7net
pip install moltensaltcalc[7net]
Nequip
pip install moltensaltcalc[nequip]
Nequix
pip install moltensaltcalc[nequix]
UPET
pip install moltensaltcalc[upet]
CHGNet
pip install moltensaltcalc[chgnet]
Development
If you want to contribute or make modifications to the code, clone the repo and install in edit mode. For further details, please check our contributing guidelines.
git clone https://github.com/leiapple/moltensaltcalc.git
cd moltensaltcalc
python3 -m venv .venv # Or any other name
source .venv/bin/activate # Linux/macOS
# or
.venv\Scripts\activate # Windows
pip install -e .[dev,grace] # Installs the selected MLIP backend and all development dependencies (pytest, etc.) in editable mode
Usage
Quick start
pip install moltensaltcalc[grace]
import numpy as np
from moltensaltcalc import MoltenSaltSimulator, MoltenSaltAnalyzer
np.random.seed(42) # Ensure reproducibility (initial random placements)
sim = MoltenSaltSimulator(model_name="GRACE", model_parameters={"model_size": "small", "num_layers": 1, "model_task": "OAM"})
atoms = sim.build_system(
salt_anion=["F", "Cl"],
salt_cation=["Na"],
n_anions=[10, 5], # 10 F atoms and 5 Cl atoms
n_cations=[15], # 15 Na atoms
density_guess=2.0, # g/cm³
)
sim.run_npt_simulation(
atoms,
T=1100, # K
steps=1000, # MD steps
timestep_fs=1.0, # fs
traj_file="npt_simulation.traj", # Trajectory file
)
analyzer = MoltenSaltAnalyzer(
traj_files_npt=["npt_simulation.traj"], # Trajectory file(s)
temperatures_npt=[1100], # K
)
density = analyzer.compute_eq_density(T=1100) # 1.31 g/cm³
C = analyzer.compute_heat_capacity(T=1100, eq_fraction=0.2) # 0.19 J/g/K
Demo
Run the example notebooks in the demo/ directory to explore:
- system setup
- running MD simulations
- post-processing and analysis
Workflow
The workflow of the MoltenSaltCalc aims to provide an optimized environment for molecular dynamics (MD) simulations of molten salts. A typical simulation starts by loading the MLIP backend, done in a lazy manner so the package could also be used without it (e.g. only for analysis or system setup). Next, the system is built starting out from the rocksalt structure, which is different from the usually applied random placements (which can still be used by setting the parameter lattice in build_system to "random") in order to ensure the absence of clusters of ions with the same charge which typically lead to an initial volume expansion thus requiring a longer volume equilibration simulation. Since the rocksalt contains two atoms per unit cell, but we want to allow an arbitrary number of anions and cations, some random positions are removed from the larger lattice to match the desired composition. The volume of the resulting system is adjusted to match the desired density guess (input variable density_guess in g/cm3).
Before starting the MD simulation, the velocities are initialized with a Maxwell-Boltzmann distribution according to the desired temperature, while keeping the center of mass and the overall rotation fixed to ensure the temperature is not under-shot because the whole system is moving. Starting out from this, first an NPT (constant particles, pressure, temperature) simulation is run to equilibrate the system volume and obtain the density and thermal expansion of the molten salt (MoltenSaltAnalyzer). Then an NVT (constant particles, volume, temperature) simulation is run to obtain more properties such as diffusion, viscosity or heat capacity of the molten salt (MoltenSaltAnalyzer). The workflow is illustrated below:
Project Structure
moltensaltcalc/
├── moltensaltcalc/ # Source code
│ ├── __init__.py # Package exports and available models
│ ├── simulator.py # MoltenSaltSimulator class
│ ├── analyzer.py # MoltenSaltAnalyzer class
│ ├── model_discovery.py # Discovery of available MLIPs
│ ├── model_errors.py # Error formatting
│ ├── registry.py # MLIP model registration
| └── models/ # MLIP model implementations
| ├── __init__.py
| ├── 7net.py
| ├── chgnet.py
| ├── fairchem.py
| ├── grace.py
| ├── mace.py
| ├── mattersim.py
| ├── nequip.py
| ├── nequix.py
| └── upet.py
├── demo/
│ ├── simulator.ipynb # Demo notebook for the simulator
│ ├── analyzer.ipynb # Demo notebook for the analyzer
| └── demo_simulation_results/ # Example trajectory used by the demo
├── tests/ # PyTests
│ ├── __init__.py
│ ├── test_simulator.py # Tests for the simulator using the GRACE uMLIP
│ ├── test_analyzer.py # Tests for the analyzer using the stored trajectories
| ├── test_uMLIPs.py # Tests for the different uMLIP backends
│ ├── test_analyzer_trajectories/ # Example trajectories used by the tests
| └── test_uMLIP_precompiled/ # Precompiled models used by the tests
├── noxfile.py # Nox configuration for uMLIP testing in different environments
├── pyproject.toml # Build configuration
├── requirements_*.txt # These files contain exact dependency snapshots used during testing for each MLIP backend.
├── .gitattributes
├── .gitignore # Gitignore file: Python template + some custom rules at the end
├── .pre-commit-config.yaml # Pre-commit configuration
├── CITATION.cff # Citation file
├── CONTRIBUTING.md # Contributing guidelines
├── LICENSE # License file
└── README.md # This file
License
This project is licensed under the MIT License, see the LICENSE file for details.
Support
For questions, bug reports, or feature requests, please open an issue on GitHub.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file moltensaltcalc-0.1.3.tar.gz.
File metadata
- Download URL: moltensaltcalc-0.1.3.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8ed12a26894972467596f01712618a34b5c32f280fc74c6e87a2d7f712a4cc0
|
|
| MD5 |
f62dc887fe95916a2590dbce9322ffe9
|
|
| BLAKE2b-256 |
e901396cf8bc66c6807ce5481dc59f8e88799cd2e8e1296b43ac147527dee6c7
|
File details
Details for the file moltensaltcalc-0.1.3-py3-none-any.whl.
File metadata
- Download URL: moltensaltcalc-0.1.3-py3-none-any.whl
- Upload date:
- Size: 33.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
353731a7ac1b0cfa60af5be4ade2274966e1c0cbee7a2e3f2288ac0cc7c06d1f
|
|
| MD5 |
3ac35c54eaeb8c3ba0dfe66f82610c4d
|
|
| BLAKE2b-256 |
1b8cc0e76a963ff5641c3c9bcbbe8d5030827b32c7f61a273e58efd8e4456a9b
|