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},
}
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