Skip to main content

Python implementation of the MGRIT algorithm

Project description

Test Status Lint Status Docs Status Publish Status

Introduction

PyMGRIT is a package for the Multigrid-Reduction-in-Time (MGRIT) algorithm in Python.

PyMGRIT is currently developed by Jens Hahne and Stephanie Friedhoff.

What is MGRIT?

The MGRIT algorithm is a reduction-based time-multigrid method for solving time-dependent problems. A reduction-based method attempts to reduce the solving of one problem to equivalently solving two smaller problems. Reduction-based multigrid methods are iterative solvers that consist of two parts: relaxation and coarse-grid correction, which are, in the spirit of reduction, designed to be complementary in reducing error associated with different degrees of freedom. Applying this idea in the time domain, MGRIT combines local time stepping on the discretized temporal domain, the fine grid, for a relaxation scheme, with time stepping on a coarse temporal mesh (or a hierarchy of coarse temporal meshes) that uses a larger time step for the coarse-grid correction.

PyMGRIT Features

PyMGRIT features:

  • Classical Multigrid-Reduction-in-Time (MGRIT) for solving evolutionary systems of equations

    • Non-intrusive approach

    • Optimal time-multigrid algorithm

    • A variety of cycling strategies, relaxation schemes, and coarsening strategies

  • Time parallelism

  • Specific to space-time problems

    • Space & time parallelism

    • Additional coarsening in space

Citing

@MISC{PyMGRIT,
  author = "Hahne, J. and Friedhoff, S.",
  title = "{PyMGRIT}: Multigrid-Reduction-in-Time in {Python} v1.0",
  year = "2020",
  url = "https://github.com/pymgrit/pymgrit",
  note = "Release 1.0"
  }

Installation

PyMGRIT requires mpicc (from openmpi or mpich)

>>> pip3 install pymgrit

or

>>> pip3 install .

Example Usage

PyMGRIT is easy to use! The following code generates a discrete Dahlquist test problem and solves the resulting linear system using a two-level MGRIT algorithm.:

# Import PyMGRIT
from pymgrit import *

# Create Dahlquist's test problem with 101 time steps in the interval [0, 5]
dahlquist = Dahlquist(t_start=0, t_stop=5, nt=101)

# Construct a two-level multigrid hierarchy for the test problem using a coarsening factor of 2
dahlquist_multilevel_structure = simple_setup_problem(problem=dahlquist, level=2, coarsening=2)

# Set up the MGRIT solver for the test problem and set the solver tolerance to 1e-10
mgrit = Mgrit(problem=dahlquist_multilevel_structure, tol=1e-10)

# Solve the test problem
info = mgrit.solve()

Program output:

INFO - 21-02-20 16:18:43 - Start setup
INFO - 21-02-20 16:18:43 - Setup took 0.009232759475708008 s
INFO - 21-02-20 16:18:43 - Start solve
INFO - 21-02-20 16:18:43 - iter 1  | conv: 7.186185937031941e-05  | conv factor: -                       | runtime: 0.013237237930297852 s
INFO - 21-02-20 16:18:43 - iter 2  | conv: 1.2461067076355103e-06 | conv factor: 0.017340307063501627    | runtime: 0.010195493698120117 s
INFO - 21-02-20 16:18:43 - iter 3  | conv: 2.1015566145245807e-08 | conv factor: 0.016864981158092696    | runtime: 0.008922338485717773 s
INFO - 21-02-20 16:18:43 - iter 4  | conv: 3.144127445017594e-10  | conv factor: 0.014960945726074891    | runtime: 0.0062139034271240234 s
INFO - 21-02-20 16:18:43 - iter 5  | conv: 3.975214076032893e-12  | conv factor: 0.01264329816633959     | runtime: 0.006150722503662109 s
INFO - 21-02-20 16:18:43 - Solve took 0.05394101142883301 s
INFO - 21-02-20 16:18:43 - Run parameter overview
  time interval             : [0.0, 5.0]
  number of time points     : 101
  max dt                    : 0.05000000000000071
  number of levels          : 2
  coarsening factors        : [2]
  cf_iter                   : 1
  nested iteration          : True
  cycle type                : V
  stopping tolerance        : 1e-10
  time communicator size    : 1
  space communicator size   : -99

Getting Help

For documentation see https://pymgrit.github.io/pymgrit/

Create an issue.

Look at the Quickstart, Tutorial or the Examples.

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

pymgrit-0.1.2.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

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

pymgrit-0.1.2-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file pymgrit-0.1.2.tar.gz.

File metadata

  • Download URL: pymgrit-0.1.2.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for pymgrit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 74d9104e6618a1e813368a2848793dcacd891fc9c26d4db884b8d19f2a540c7c
MD5 22f331e261b014e3d9679f239db077ae
BLAKE2b-256 b0903385c7bf7811902243f300c2f653064d9893b89aaf2a0f59c712f47b3997

See more details on using hashes here.

File details

Details for the file pymgrit-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pymgrit-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for pymgrit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d659c7e6a9dbbdd9f630daa60b50d061599a75157bec71842d8baa6e0ae426b8
MD5 18d7f8d8a5b942686784962fe9819e11
BLAKE2b-256 14e450d70b12a4f2ecc2ea96ec1465f7a38b1949d300be5f847c1130dbc1d0c9

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