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 version
pip install sphericart[torch]      # including also the torch bindings
pip install sphericart[jax]        # JAX bindings (CPU-only)

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]

Building from source is also necessary to use sphericart's PyTorch GPU functionalities, and it requires a CUDA compiler.

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.2.tar.gz (61.1 kB view details)

Uploaded Source

Built Distributions

sphericart-1.0.2-py3-none-manylinux_2_28_x86_64.whl (392.6 kB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

sphericart-1.0.2-py3-none-macosx_11_0_x86_64.whl (175.9 kB view details)

Uploaded Python 3macOS 11.0+ x86-64

sphericart-1.0.2-py3-none-macosx_11_0_arm64.whl (156.1 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: sphericart-1.0.2.tar.gz
  • Upload date:
  • Size: 61.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sphericart-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d871882902ee45a8692fe54e9cef37e6b8732582f4f0323021e76811e9eeebfd
MD5 5c9f5c982c4585572ee846de6c5f88f8
BLAKE2b-256 58db391f9b0d5cbbb03e09824911804e6572c4b0c76cefceee8bc306b64c3f10

See more details on using hashes here.

File details

Details for the file sphericart-1.0.2-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for sphericart-1.0.2-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a77d5a11c4ecaa80431dccc65cb4d7aee3999ac1603a7a7d883b54dd45404711
MD5 b1f2891908fae24fb97af0641f02a578
BLAKE2b-256 753b02e7bb6f7131f2b1c8da15688ea6ddf9cd9ad3b483e622cd7b462ece01db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sphericart-1.0.2-py3-none-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 fe3cf924a6929ecc3ec0e1c21ad3cc39daa4543a0d24aeb5c560f417b3d36a3e
MD5 4ce1bb4ebb37c71a860856bd905b001b
BLAKE2b-256 35e2edc2e5604a506740e40e86f4519266658f60eb500ad2cb975ef18898f117

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sphericart-1.0.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1d6129267af74144f5fb09f54346ce4c807bb1688a532683ec089bd15bd195dd
MD5 6b19f06fa6279773a6ba67ef73d2de85
BLAKE2b-256 6a9fd695dacdee5cfd100e8f08a69b965fc453a081b1597459354c8bfd553310

See more details on using hashes here.

Supported by

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