Skip to main content

Fast calculation of spherical harmonics

Project description

sphericart

Test

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.

A plot of the +-1 isosurfaces of the Y^0\_3 solid harmonic, including also gradients.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphericart-1.0.9.tar.gz (61.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sphericart-1.0.9-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (393.6 kB view details)

Uploaded Python 3manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

sphericart-1.0.9-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (375.7 kB view details)

Uploaded Python 3manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

sphericart-1.0.9-py3-none-macosx_11_0_x86_64.whl (278.8 kB view details)

Uploaded Python 3macOS 11.0+ x86-64

sphericart-1.0.9-py3-none-macosx_11_0_arm64.whl (155.6 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file sphericart-1.0.9.tar.gz.

File metadata

  • Download URL: sphericart-1.0.9.tar.gz
  • Upload date:
  • Size: 61.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sphericart-1.0.9.tar.gz
Algorithm Hash digest
SHA256 c5b51cf9fd01419597cc5823b99e7d06c926568884a969a782b8a250bf8d8965
MD5 6cfcfd6054eb7138a7a950f8fb520937
BLAKE2b-256 cc040774bb31ec40682e349571548de76667816dc637198a8f3e34b6c0e10a16

See more details on using hashes here.

File details

Details for the file sphericart-1.0.9-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for sphericart-1.0.9-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0e082b74313e0ac5be6da224b4dab5d7d7e48049bcb6ac4132161f62633f6264
MD5 aee8c9178802c3d8ac62dabdc8d61685
BLAKE2b-256 e33cf90044c8ea1b00664a22593db52161c23a4edabec28f84f89a28da480075

See more details on using hashes here.

File details

Details for the file sphericart-1.0.9-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for sphericart-1.0.9-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d0f3adf9bdb6194573a3d794e9c93007a439b67b3b5dceb29b220077ed147d72
MD5 7caa26cea87080028ad94a6bfdf345f6
BLAKE2b-256 64ce8b72397021f65e22d1aa85bfcdffd340f98fd57ab8750d01f4b3bbec7eb2

See more details on using hashes here.

File details

Details for the file sphericart-1.0.9-py3-none-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for sphericart-1.0.9-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 a1168f06b50967a7871aedc964c4934787fef297823d82be17a4f6749df28cf5
MD5 57797eef8a5301a1468315ea7345ee12
BLAKE2b-256 b3c71e9128af034445581d1b6d36767ceca38a423d94cb7a18eccb7ef2df1b0b

See more details on using hashes here.

File details

Details for the file sphericart-1.0.9-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sphericart-1.0.9-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f37b8e309eb6e598d21864ac338dba7cba233ad6f2e8ff6fac1a8e0cdd113a07
MD5 05f9099f9ebfce0b05974353293b0426
BLAKE2b-256 4786bf4ee112e351727ef1b9f0030c8950b0b145a292e0f80d6a645aba50a152

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page