Fast calculation of spherical harmonics
Project description
sphericart
This is sphericart, a multi-language library for the efficient calculation of real spherical harmonics and their derivatives in Cartesian coordinates.
For instructions and examples on the usage of the library, please refer to our documentation.
If you are using sphericart for your academic work, you can cite it as
@article{sphericart,
title={Fast evaluation of spherical harmonics with sphericart},
author={Bigi, Filippo and Fraux, Guillaume and Browning, Nicholas J. and Ceriotti, Michele},
journal={J. Chem. Phys.},
year={2023},
number={159},
pages={064802},
}
This library is dual-licensed under the Apache License 2.0 and the MIT license. You can use to use it under either of the two licenses.
Installation
Python
Pre-built (https://pypi.org/project/sphericart/).
pip install sphericart # numpy interface, CPU only
pip install sphericart[torch] # Torch (and TorchScript) interface, CPU and GPU
pip install sphericart[jax] # JAX interface, CPU and GPU
Note that the pre-built packages are compiled for a generic CPU, and might be less performant than they could be on a specific processor. To generate libraries that are optimized for the target system, you can build from source:
git clone https://github.com/lab-cosmo/sphericart
pip install .
# if you also want the torch bindings (CPU and GPU)
pip install .[torch]
# torch bindings, CPU-only version
pip install --extra-index-url https://download.pytorch.org/whl/cpu .[torch]
If you want to enable the CUDA version of the code when builing from source,
you'll need to set the CUDA_HOME environement variable. You can build a CUDA enabled sphericart, but the calculations though numpy will only run on CPU.
Julia
A native Julia implementation of sphericart is provided, called SpheriCart.
Install the package by opening a REPL, switch to the package manager by
typing ] and then add SpheriCart.
See julia/README.md for usage.
C and C++
From source
git clone https://github.com/lab-cosmo/sphericart
cd sphericart
mkdir build && cd build
cmake .. <cmake configuration options>
cmake --build . --target install
The following cmake configuration options are available:
-DSPHERICART_BUILD_TORCH=ON/OFF: build the torch bindings in addition to the main library-DSPHERICART_BUILD_TESTS=ON/OFF: build C++ unit tests-DSPHERICART_BUILD_EXAMPLES=ON/OFF: build C++ examples and benchmarks-DSPHERICART_OPENMP=ON/OFF: enable OpenMP parallelism-DCMAKE_INSTALL_PREFIX=<where/you/want/to/install>set the root path for installation
Running tests and documentation
Tests and the local build of the documentation can be run with tox.
The default tests, which are also run on the CI, can be executed by simply running
tox
in the main folder of the repository.
To run tests in a CPU-only environment you can set the environment variable
PIP_EXTRA_INDEX_URL before calling tox, e.g.
PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu tox -e docs
will build the documentation in a CPU-only environment.
Other flavors of spherical harmonics
Although sphericart natively calculates real solid and spherical harmonics from Cartesian positions, it is easy to manipulate its output it to calculate complex spherical harmonics and/or to accept spherical coordinates as inputs. You can see examples here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 sphericart-1.0.6.tar.gz.
File metadata
- Download URL: sphericart-1.0.6.tar.gz
- Upload date:
- Size: 61.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
faebf5bd9ab83fd0a511b17c8a2461bb1ee892f0c8ce14866f81a9c66dddb5a4
|
|
| MD5 |
826eb742848f9625635de69c497c3f0a
|
|
| BLAKE2b-256 |
ae77045fdcb06f4329062dc26ca72fcce67b1de90d8731f67d58742cd08e382d
|
File details
Details for the file sphericart-1.0.6-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: sphericart-1.0.6-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 393.5 kB
- Tags: Python 3, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9d74e7845e6ecfb6c8afd69e5b94817999474497a0e8a56169b6754a5822383
|
|
| MD5 |
3ede6dbd3f0865edb24dc781be8dd370
|
|
| BLAKE2b-256 |
d886c6339a387ad4ab3c6e85f0113119f128f4ac5615858b1d3cf538e67511f6
|
File details
Details for the file sphericart-1.0.6-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: sphericart-1.0.6-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 376.1 kB
- Tags: Python 3, manylinux: glibc 2.24+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55ac228ae84d524a8ec6b0ccc3dc061490949e9759964a5755b347302b4e4d4f
|
|
| MD5 |
9b8fbd271469c1eee31116e5632a0a42
|
|
| BLAKE2b-256 |
ce7110a61985753c5ef410bd540d6a5b236962711b448d41af451421a29b11f5
|
File details
Details for the file sphericart-1.0.6-py3-none-macosx_11_0_x86_64.whl.
File metadata
- Download URL: sphericart-1.0.6-py3-none-macosx_11_0_x86_64.whl
- Upload date:
- Size: 277.6 kB
- Tags: Python 3, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7f5d3e78d2a2340fa7140f698b66a0f6bb8dda9f52e66a0961267b98fd0c819
|
|
| MD5 |
e5be883175549278c63672583a2882fa
|
|
| BLAKE2b-256 |
5e1bface4d49acdef6b77e91748e06ec8846cef7d6df5cb6156e7eb0f41f33a9
|
File details
Details for the file sphericart-1.0.6-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: sphericart-1.0.6-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 156.2 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feb1f3d26a6f2bf2e176ab85e091df18131077a2f31e1ec07f03c0a91c2ba10a
|
|
| MD5 |
cc37b57c485445c83bb64e3158b1adc7
|
|
| BLAKE2b-256 |
22287da9094155268c200857f7ddbd61fccacf566e20c24be6638b1be7fb933d
|