Developer Installation

You can install TorchSim with pip or from source.

Install using pip

You can install the basic functionality of TorchSim using pip:

pip install torch-sim-atomistic

Install from source

To install TorchSim from source, clone the repository from github

git clone https://github.com/torchsim/torch-sim
cd torch-sim
pip install . -e

Installing prek

If you’re planning on contributing to the torch-sim source, you should also install the developer requirements with:

pip install -e .
prek install
prek run --all-files

The prek command will ensure that changes to the source code match the TorchSim style guidelines by running the ruff code linters and the ty type checker automatically with each commit.

Running unit tests

Unit tests can be run from the source folder using pytest. First, the requirements to run tests must be installed:

pip install .[test]

And the tests run using:

pytest

Building the documentation

The TorchSim documentation can be built using the sphinx package. First, install the requirements:

pip install .[docs]

Next, the docs can be built to the docs_build directory:

sphinx-build docs docs_build

And launched with:

python -m http.server -d docs_build

To locally generate the tutorials, they must be copied to the docs folder, converted to .ipynb files, and executed. Then the .py files and any generated trajectory files must be cleaned up.

cp -r examples/tutorials docs/ && \
jupytext --set-formats "py:percent,ipynb" docs/tutorials/*.py && \
jupytext --set-kernel python3 docs/tutorials/*.py && \
jupytext --to notebook --execute docs/tutorials/*.py && \
rm docs/tutorials/*.py && \
rm docs/tutorials/*.h5* && \
rm docs/tutorials/*.traj*

Documentation structure based on Alex Ganose (@utf) exceptional atomate2 package.