Skip to main content

Fast Poisson Solver

The Poisson equation is an integral part of many physical phenomena, yet its computation is often time-consuming. This module presents an efficient method using physics-informed neural networks (PINNs) to rapidly solve arbitrary 2D Poisson problems. Focusing on the 2D Poisson equation, the method used in this module shows significant speed improvements over the finite difference method while maintaining high accuracy in various test scenarios.

The improved efficiency comes from the possibility to pre-compute domain specific steps. This means, for a given domain, the poisson equation can be efficiently solved for different source functions and boundary conditions. The basic usage example below illustrates this. This approach is therefore only faster, if the Poisson equation needs to solved for the same domain with different source functions and boundary values, e.g. in simulation software.

This module comes with an easy-to-use method for solving arbitrary 2D Poisson problems. It also includes a numerical solver and an analyzing function to quantify the results. For visual inspection, the module offers a plotting function.

In its current version this module supports only 2D Poisson problems with Dirichlet boundary conditions. The boundary conditions should be a constant value.

Installation

This project is available on PyPI and can be installed with pip.

pip install fast-poisson-solver

Ensure that you have the latest version of pip; if you're unsure, you can upgrade pip with the following command:

pip install --upgrade pip

You might need to use pip3 instead of pip, depending on your system.

Basic Usage

The Fast Poisson Solver is designed to be highly adaptable and flexible. It can accept a variety of input formats, including lists, numpy arrays, and PyTorch tensors. Please note that currently, only 2D domains are supported.

The solver requires x and y coordinates for both the PDE domain and the boundary region. The order of these coordinates does not matter. For each pair of x and y coordinates, the PDE domain needs a value for the source function, and the boundary domain needs a value for the boundary condition.

Once the pre-computation for each domain and boundary region is done, it can be used for unlimited different source functions and boundary condition values.

Here is a basic example:

from fast_poisson_solver import Solver

solver = Solver()
solver.precompute(x_pde, y_pde, x_bc, y_bc)

u_ml, u_ml_pde, u_ml_bc, f_ml, t_ml = solver.solve(f1, u_bc1)
u_ml, u_ml_pde, u_ml_bc, f_ml, t_ml = solver.solve(f2, u_bc2)
u_ml, u_ml_pde, u_ml_bc, f_ml, t_ml = solver.solve(f3, u_bc3)
# ...

Please replace x_pde, y_pde, x_bc, y_bc, f, and u_bc with your actual data or variables.

As the approach works best for coordinates that lie between 0 and 1, is it hard limited on this interval. The order of the coordinates does not matter as long as the x, y and corresponding source term or value for the boundary condition match. It is also not important for the coordinates to lie on a grid (Note: The numeric function needs a grid).

For more details see the Documentation

Contributing

We warmly welcome contributions to this module. If you have ideas for improvements, new features, or bug fixes, please feel free to submit a pull request. We appreciate your support in making this module more useful for everyone. When making a contribution, please ensure your code adheres to our guidelines, which can also be found in the repository.

License

Copyright (C) 2023 Matthias Neuwirth

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Contact

If you encounter any issues while using this module, or if you have suggestions for improvements or new features, please report them to us through the "Issues" tab.

Roadmap and Future Enhancements

  • Dirichlet boundary conditions with multiple values or multiple regions of Dirichlet boundary conditions
  • Neuman, Robin, and mixed boundary conditions
  • Extend this approach to 1D and 3D or even nD
  • Easy to compute force term

Metadata

Release files for fast-poisson-solver 0.1.14

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

Source distribution (sdist)

Source distribution for fast-poisson-solver 0.1.14
File Size Uploaded
fast_poisson_solver-0.1.14.tar.gz 12.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for fast-poisson-solver 0.1.14
File Interpreter ABI Platform
fast_poisson_solver-0.1.14-py3-none-any.whl Python 3 none any Details

Total release size: 24.6 MB

Release files / fast_poisson_solver-0.1.14.tar.gz

Download URL fast_poisson_solver-0.1.14.tar.gz
Size 12.3 MB
Tags Source
SHA-256 checksum
How to use checksums
2041cbb806955f8d244e6e079f07e2baacb55d97d694ea45104ef5f72c662be0
BLAKE2b-256 checksum
How to use checksums
93f08c335250cac4ac9b0ac1ef1d7f77b1f49f73c34c0eecc34ef4d33e339ab8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.13 Windows/10

Release files / fast_poisson_solver-0.1.14-py3-none-any.whl

Download URL fast_poisson_solver-0.1.14-py3-none-any.whl
Size 12.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4ac1c6ab9c98d669995658bd2a5a5b72480bf845af586618edd673a05a594469
BLAKE2b-256 checksum
How to use checksums
dc5d399fbfc72cea947c4405683e364965f556ee6b07dd647488a36549b047d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.9.13 Windows/10

Release history Release notifications | RSS feed

This release

0.1.14 This release

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

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