Skip to main content

multipoles

PyPI version Python versions Build status Code coverage License

multipoles computes multipole expansions of the solutions of the Poisson equation, such as electrostatic or gravitational potentials. Instead of integrating over the whole charge or mass distribution for every point where you need the potential, you compute a few multipole moments once and evaluate the expansion cheaply anywhere outside (or, for the interior expansion, inside) the distribution.

Documentation · Changelog

Features

  • Discrete (point charges) and continuous (charge density on a grid) distributions
  • Exterior and interior expansions, about the center of charge or any point you choose
  • The potential and its field E = -∇Φ, computed analytically, at single points or for whole arrays
  • Spherical multipole moments, plus total charge, dipole vector and quadrupole tensor
  • Warnings when you evaluate the expansion where it does not converge

Installation

pip install --upgrade multipoles

Quickstart

Two point charges +1 and -1 on the z-axis:

from multipoles import MultipoleExpansion

charge_dist = {
    'discrete': True,
    'charges': [
        {'q': 1, 'xyz': (0, 0, 1)},
        {'q': -1, 'xyz': (0, 0, -1)},
    ],
}

Phi = MultipoleExpansion(charge_dist, l_max=8)

Phi(0, 0, 10)            # 0.0202020199..., exact: 1/9 - 1/11 = 0.0202020202...
Phi(0, 0, 10, l_max=1)   # 0.02, only monopole and dipole
Phi.field(0, 0, 10)      # [0, 0, 0.004081], the field E = -∇Φ
Phi.dipole_moment        # [0, 0, 2]

For charge densities on a grid, gravity, the interior expansion and more, see the usage guide.

Units

multipoles computes Φ = Σ q / r, i.e. the potential in Gaussian units. Multiply by 1 / (4πε₀) for the electrostatic potential in SI units. For the gravitational potential, pass the masses as charges and multiply by -G.

Contributing

Bug reports, ideas and pull requests are welcome, see CONTRIBUTING.md.

Metadata

Release files for multipoles 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for multipoles 0.5.0
File Size Uploaded Provenance Actions
multipoles-0.5.0.tar.gz 289.3 kB Without provenance Details for multipoles-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for multipoles 0.5.0
File Interpreter ABI Platform Actions
multipoles-0.5.0-py3-none-any.whl Python 3 none any Details for multipoles-0.5.0-py3-none-any.whl

Total release size: 301.4 kB

Release files / multipoles-0.5.0.tar.gz

Download URL multipoles-0.5.0.tar.gz
Size 289.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a2a68852d99d37e8ace38fad83181d5d9c56f572e3cac448c577ba202e8b8638
BLAKE2b-256 checksum
How to use checksums
854ddaef01ccbdd0cae466e43c0a8653dbf2993159e6767f38b27708ea653667
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / multipoles-0.5.0-py3-none-any.whl

Download URL multipoles-0.5.0-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7674b3b00e9302e3b1379780fc6a3d7f3cf411c6fbbb5329a874a9d9d415f797
BLAKE2b-256 checksum
How to use checksums
1fcadfd347be5d1ad9d1101913fd1175219a5d05e9910312bd315064b8d408d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for multipoles 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page