PyAMG: Algebraic Multigrid Solvers in Python
Project description
Installation
PyAMG requires numpy
and scipy
pip install pyamg
or from source:
pip install .
(python setup.py install
will no longer work)
or with conda (see details below)
conda config --add channels conda-forge
conda install pyamg
Introduction
PyAMG is a library of Algebraic Multigrid (AMG) solvers with a convenient Python interface.
PyAMG is currently developed and maintained by
Luke Olson,
Jacob Schroder, and
Ben Southworth.
The organization of the project can be found in organization.md
and
examples of use can be found in pyamg-examples
.
Acknowledgements: PyAMG was created by Nathan Bell, Luke Olson, and Jacob Schroder. Portions of the project were partially supported by the NSF under award DMS-0612448.
Citing
If you use PyAMG in your work, please consider using the following citation:
@article{pyamg2023, author = {Nathan Bell and Luke N. Olson and Jacob Schroder and Ben Southworth}, title = {{PyAMG}: Algebraic Multigrid Solvers in Python}, journal = {Journal of Open Source Software}, year = {2023}, publisher = {The Open Journal}, volume = {8}, number = {87}, pages = {5495}, doi = {10.21105/joss.05495}, url = {https://doi.org/10.21105/joss.05495}, }
Getting Help
-
For documentation see http://pyamg.readthedocs.io/en/latest/.
-
Create an issue.
-
Look at the Tutorial or the examples (for instance the 0_start_here example).
-
Run the unit tests (
pip install pytest
):- With PyAMG installed and from a non-source directory:
import pyamg pyamg.test()
- From the PyAMG source directory and installed (e.g. with
pip install -e .
):
pytest .
What is AMG?
AMG is a multilevel technique for solving large-scale linear systems with optimal or near-optimal efficiency. Unlike geometric multigrid, AMG requires little or no geometric information about the underlying problem and develops a sequence of coarser grids directly from the input matrix. This feature is especially important for problems discretized on unstructured meshes and irregular grids.
PyAMG Features
PyAMG features implementations of:
- Ruge-Stuben (RS) or Classical AMG
- AMG based on Smoothed Aggregation (SA)
and experimental support for:
- Adaptive Smoothed Aggregation (αSA)
- Compatible Relaxation (CR)
The predominant portion of PyAMG is written in Python with a smaller amount of supporting C++ code for performance critical operations.
Example Usage
PyAMG is easy to use! The following code constructs a two-dimensional Poisson problem and solves the resulting linear system with Classical AMG.
import pyamg
import numpy as np
A = pyamg.gallery.poisson((500,500), format='csr') # 2D Poisson problem on 500x500 grid
ml = pyamg.ruge_stuben_solver(A) # construct the multigrid hierarchy
print(ml) # print hierarchy information
b = np.random.rand(A.shape[0]) # pick a random right hand side
x = ml.solve(b, tol=1e-10) # solve Ax=b to a tolerance of 1e-10
print("residual: ", np.linalg.norm(b-A*x)) # compute norm of residual vector
Program output:
multilevel_solver Number of Levels: 9 Operator Complexity: 2.199 Grid Complexity: 1.667 Coarse Solver: 'pinv2' level unknowns nonzeros 0 250000 1248000 [45.47%] 1 125000 1121002 [40.84%] 2 31252 280662 [10.23%] 3 7825 70657 [ 2.57%] 4 1937 17971 [ 0.65%] 5 483 4725 [ 0.17%] 6 124 1352 [ 0.05%] 7 29 293 [ 0.01%] 8 7 41 [ 0.00%] residual: 1.24748994988e-08
Conda
More information can be found at conda-forge/pyamg-feedstock.
Installing pyamg
from the conda-forge
channel can be achieved by adding conda-forge
to your channels with:
conda config --add channels conda-forge
Once the conda-forge
channel has been enabled, pyamg
can be installed with:
conda install pyamg
It is possible to list all of the versions of pyamg
available on your platform with:
conda search pyamg --channel conda-forge
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 Distributions
Built Distributions
Hashes for pyamg-5.2.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37b8d59a3ab6497d74dd8e2f68cfd9dc8574b5102a6df92f512e3f21ff5df51b |
|
MD5 | 017519cf875b890c57016f869cecbb54 |
|
BLAKE2b-256 | 9fc0656ba218b48b21bfed8426eee7db5865568f0800a1ac4ef48673459eb6c0 |
Hashes for pyamg-5.2.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ed1d06e979d28689cf91147dee871c9d528af5e4b893dd8f9ebc469af5b890d |
|
MD5 | 6d36dc6607830b5bf34ae6921c82b79a |
|
BLAKE2b-256 | b38ec2a9f1f4a25f64871e6f9c12ab7b6c26dbf44b9e0b9490ef5cba402432c2 |
Hashes for pyamg-5.2.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fe85494ab14e90cdd0f20b4ad861f8fa48e37f081899af0ca8f9ee43d5df753 |
|
MD5 | 4dd5e678c0cd5f8b1a35ed0dcab1ee09 |
|
BLAKE2b-256 | fee3aaec6fabad484a2578822332e330c36fbca9650b0db5e6dbaecffa0d384a |
Hashes for pyamg-5.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e433f4a771eeba666937c29740568afc5984dfe107f0b60077077a4bc433400b |
|
MD5 | 37c05569296a2b7423121b08691ffdee |
|
BLAKE2b-256 | f3dbf23637368f9c8f7b3920e018870d038e32d6c7d66ea209f045b5815db6d3 |
Hashes for pyamg-5.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c23b4b7778d097943db01fe70b34ef25cdff82543a60f05e73b55a34af35aa1e |
|
MD5 | 98a7b255e3db9ec7d2d18c038f4a768e |
|
BLAKE2b-256 | e4882654c6d08b01b2c26b7a80255f5c79f5370f9961659cb6cfcb4a58b287fe |
Hashes for pyamg-5.2.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 016d682474a5e8a7d6fb15038b91e6db23ed464f9f99b26af6bf944ae155a4c8 |
|
MD5 | 0eda7e6201b0b26de6496f3129df784d |
|
BLAKE2b-256 | a5cdc5f24aa5b71b500484256bbccec34d44ebecc5d50a22ca18136d133389e7 |
Hashes for pyamg-5.2.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2ef2a2a5253405930ed9e7f5d540abfa1d4569b0c38afa60bc01d07966f5abd |
|
MD5 | b7557e73aa12fecd9617f4f6b35a6f98 |
|
BLAKE2b-256 | 36d79df2ae08619a011d08ea9c47050aabf1991cd7c322570207b2c2132748d4 |
Hashes for pyamg-5.2.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11a2510e8906c7d16c8a5f6f2844e17b11f416cbb74300df1dbd2931de5c0cb3 |
|
MD5 | f0dca5fb6abdd16f37e9f9868715ba5a |
|
BLAKE2b-256 | ce19b60fdd922866e8e28a1253a5df41fb8b123219764e1a316de02e443b0344 |
Hashes for pyamg-5.2.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d4f263e476698b79750983194a85c23db18fcab2c90d0fcd17888ae8bc95c34 |
|
MD5 | f809bddfb089b55c9a8a9c1de9293590 |
|
BLAKE2b-256 | 89952e054748c9fae1f8cbe239217e7431cc1059e3d23baad59714bc641dfb17 |
Hashes for pyamg-5.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b57c43b0b07a47adfd31d64b2ee758257e4522d75f6da3c585fbd3831752c79f |
|
MD5 | a9014e8c0e3caa5eb1455c1ae97b4da6 |
|
BLAKE2b-256 | 0508bc563c3e11c3a098a31defde2c77adcfc68484db88f21e60a8a581f99592 |
Hashes for pyamg-5.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c1394586b06365770fa0bbfb40e7dd49be949618594b526f9c92a7869b796ea |
|
MD5 | 8d23972985c61677666312f17943a929 |
|
BLAKE2b-256 | 153c1748249355d9f4f2faabd02069376f4024ca2e73b00e29343bb5049e3267 |
Hashes for pyamg-5.2.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcd2ac60faf3cd106ae8379e8e4e168fa5825247ad2269d73540727ec500b54a |
|
MD5 | 1a0db262c6ed8d6b71bac3d038f34c7e |
|
BLAKE2b-256 | 9e74e3f6c2a377d40ffc643ed417835e6346374ade3c8fb251cbd99700673bd1 |
Hashes for pyamg-5.2.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e0dcd3650ea083feb458a69cdd17089b1e74d57294a462380ce7768a5e3e5da |
|
MD5 | b18d6716fc9383b0f23b71db41602da6 |
|
BLAKE2b-256 | 22971098e6f97782452403fb6cdc7106a1695267fb50f926c306ecd3ba88140c |
Hashes for pyamg-5.2.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 285f15dede1c1172dc833624a792edace5e77dce5896a7516fc01f64c8ab68a8 |
|
MD5 | 60d22b037bdc0413f0c57be8a670811d |
|
BLAKE2b-256 | b231a44b62bbfb2cb1d5663f908f828a1d4ea978bc332afacc636bd38d1b07c1 |
Hashes for pyamg-5.2.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3406514db5ef8f1154377a6af5cd976167e4c5c03a7cde3be8191b9aab44916e |
|
MD5 | 344cc9d3bc7a55c653145f98c9611fa6 |
|
BLAKE2b-256 | ed83257851aab8ce62ad9e8a4c3ec5e153233013fb3d5b102abbafc847f02cea |
Hashes for pyamg-5.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a132f74c80bfe0404aa5b9916b36429cceb93af1c5b4f9fa14f6ad5daeeebc3 |
|
MD5 | 35b2079e123078012f0d44f39cfc646a |
|
BLAKE2b-256 | fd72cf0b5b175f578566b9e51ab6a203838f5f6ce0e95c01a98ec13cce29ec02 |
Hashes for pyamg-5.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d910ccc5258ea2c48c6b2d285fee575f3d03e6401d30896530ffe1fc2748486c |
|
MD5 | 64873b56ed069b0daa141cb9d975e3e8 |
|
BLAKE2b-256 | fb92af283acf786a7f815e274de5b89f875f78d87b487561b929508cb934c157 |
Hashes for pyamg-5.2.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad017b480e9c7afab296dbdc8a6fe7c3689741f671a2c41fadafabaf38516bf5 |
|
MD5 | a2391a51fb2920f75fb9f28e7f261721 |
|
BLAKE2b-256 | f35b0423f221e74eb49da6019d51ebb02e9d432343c28eb17be9544b2db76e24 |
Hashes for pyamg-5.2.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5c101def02e7525320f78c6255928ec89fce02aa573923eca9fefc87c2aa79a |
|
MD5 | a16c30f0fb6b6c1ea9b5209fc77a4feb |
|
BLAKE2b-256 | 421f531245d4d4e75b5dd96897b22553d0035c0cd6cad31a861b535c41f79319 |
Hashes for pyamg-5.2.0-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 274e5b1229570da49e9ed79c762624845e0509594041cbdc0946eba4b9cbf382 |
|
MD5 | 23f9512e503b7c22ba0ebd325b1d259b |
|
BLAKE2b-256 | 38468b67a14270036e812ad306a8e1070e9cfb2dd176f4576a5130e64614be0d |
Hashes for pyamg-5.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac72f0569509c962e4f7cfdb63ed273b5d0afc22c89a1b52a31ca6745f43df01 |
|
MD5 | bd6e234e89bdf0a2c273f781876094fd |
|
BLAKE2b-256 | 75c77afe42155349079311e37751b7d46679bc1a4d3951d33d5b377a46b399fc |
Hashes for pyamg-5.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77bb217e2a902b514b69fd2b518021d68cedc5defc11bd93d0103a75cfd5c38b |
|
MD5 | 7a8271b849226c65c2de73b1f5bfd7cb |
|
BLAKE2b-256 | d24f75511ca7ba3c81adfeb07742293650c08653750478ecb47fe7921d796737 |
Hashes for pyamg-5.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f67852cf636952d26a4363823177d66bb492292fb36f71d7d653d6a92b5feb4 |
|
MD5 | 79cbf815796b1557c9f0338c48f72c74 |
|
BLAKE2b-256 | 03be4eb7056a3b8eedca678fa0b5ab5e31aa4c9c751c57f90035870bfa79e5b4 |