fast-poisson-solver


Namefast-poisson-solver JSON
Version 0.1.14 PyPI version JSON
download
home_pagehttps://github.com/matthiasnwt/fast-poisson-solver
SummaryA fast solver for the Poisson equation.
upload_time2023-06-02 20:38:49
maintainer
docs_urlNone
authorMatthias Neuwirth
requires_python>=3.8,<4.0
licenseGNUv3
keywords poisson solver fast python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

<div align="center">
    <img src="https://raw.githubusercontent.com/matthiasnwt/fast-poisson-solver/main/assets/perlin.png" height="200"/>
    <img src="https://raw.githubusercontent.com/matthiasnwt/fast-poisson-solver/main/assets/sin.png" height="200"/>
</div>

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. 

<div align="center">
<img src="https://raw.githubusercontent.com/matthiasnwt/fast-poisson-solver/main/assets/execution_time_vs_precision.png" height="320" />
</div>

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.

```bash
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:

```bash
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:

```python
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](https://fast-poisson-solver.readthedocs.io/en/latest/)

## 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
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/matthiasnwt/fast-poisson-solver",
    "name": "fast-poisson-solver",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "Poisson,solver,fast,python",
    "author": "Matthias Neuwirth",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/93/f0/8c335250cac4ac9b0ac1ef1d7f77b1f49f73c34c0eecc34ef4d33e339ab8/fast_poisson_solver-0.1.14.tar.gz",
    "platform": null,
    "description": "# Fast Poisson Solver\n\nThe Poisson equation is an integral part of many physical phenomena, yet its computation\nis often time-consuming. This module presents an efficient method using\nphysics-informed neural networks (PINNs) to rapidly solve arbitrary 2D Poisson\nproblems. Focusing on the 2D Poisson equation, the\nmethod used in this module shows significant speed improvements over the finite difference\nmethod while maintaining high accuracy in various test scenarios.\n\n<div align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/matthiasnwt/fast-poisson-solver/main/assets/perlin.png\" height=\"200\"/>\n    <img src=\"https://raw.githubusercontent.com/matthiasnwt/fast-poisson-solver/main/assets/sin.png\" height=\"200\"/>\n</div>\n\nThe improved efficiency comes from the possibility to pre-compute domain specific steps.\nThis means, for a given domain, the poisson equation can be efficiently solved for different source functions and boundary conditions.\nThe basic usage example below illustrates this.\nThis 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. \n\n<div align=\"center\">\n<img src=\"https://raw.githubusercontent.com/matthiasnwt/fast-poisson-solver/main/assets/execution_time_vs_precision.png\" height=\"320\" />\n</div>\n\nThis module comes with an easy-to-use method for solving arbitrary 2D Poisson problems.\nIt also includes a numerical solver and an analyzing function to quantify the results.\nFor visual inspection, the module offers a plotting function.\n\nIn its current version this module supports only 2D Poisson problems with Dirichlet boundary conditions.\nThe boundary conditions should be a constant value.\n\n## Installation\n\nThis project is available on PyPI and can be installed with pip.\n\n```bash\npip install fast-poisson-solver\n```\nEnsure that you have the latest version of pip; if you're unsure, you can upgrade pip with the following command:\n\n```bash\npip install --upgrade pip\n```\n\nYou might need to use `pip3` instead of `pip`, depending on your system.\n\n## Basic Usage\nThe 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.\n\nThe 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.\n\nOnce the pre-computation for each domain and boundary region is done, it can be used for unlimited different source functions and boundary condition values.\n\nHere is a basic example:\n\n```python\nfrom fast_poisson_solver import Solver\n\nsolver = Solver()\nsolver.precompute(x_pde, y_pde, x_bc, y_bc)\n\nu_ml, u_ml_pde, u_ml_bc, f_ml, t_ml = solver.solve(f1, u_bc1)\nu_ml, u_ml_pde, u_ml_bc, f_ml, t_ml = solver.solve(f2, u_bc2)\nu_ml, u_ml_pde, u_ml_bc, f_ml, t_ml = solver.solve(f3, u_bc3)\n# ...\n```\n\nPlease replace x_pde, y_pde, x_bc, y_bc, f, and u_bc with your actual data or variables.\n\nAs the approach works best for coordinates that lie between 0 and 1, is it hard limited on this interval.\nThe order of the coordinates does not matter as long as the `x`, `y` and corresponding source term or value for the boundary condition match.\nIt is also not important for the coordinates to lie on a grid (Note: The numeric function needs a grid).\n\nFor more details see the [Documentation](https://fast-poisson-solver.readthedocs.io/en/latest/)\n\n## Contributing\nWe warmly welcome contributions to this module. \nIf you have ideas for improvements, new features, or bug fixes, please feel free to submit a pull request.\nWe appreciate your support in making this module more useful for everyone. \nWhen making a contribution, please ensure your code adheres to our guidelines, which can also be found in the repository.\n\n## License\nCopyright (C) 2023 Matthias Neuwirth\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see <https://www.gnu.org/licenses/>.\n\n## Contact\nIf 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.\n\n## Roadmap and Future Enhancements\n* Dirichlet boundary conditions with multiple values or multiple regions of Dirichlet boundary conditions\n* Neuman, Robin, and mixed boundary conditions\n* Extend this approach to 1D and 3D or even nD\n* Easy to compute force term",
    "bugtrack_url": null,
    "license": "GNUv3",
    "summary": "A fast solver for the Poisson equation.",
    "version": "0.1.14",
    "project_urls": {
        "Documentation": "https://fast-poisson-solver.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/matthiasnwt/fast-poisson-solver",
        "Repository": "https://github.com/matthiasnwt/fast-poisson-solver"
    },
    "split_keywords": [
        "poisson",
        "solver",
        "fast",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dc5d399fbfc72cea947c4405683e364965f556ee6b07dd647488a36549b047d1",
                "md5": "4fd4bc0e4d53a0d5a6b939bc87f82556",
                "sha256": "4ac1c6ab9c98d669995658bd2a5a5b72480bf845af586618edd673a05a594469"
            },
            "downloads": -1,
            "filename": "fast_poisson_solver-0.1.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4fd4bc0e4d53a0d5a6b939bc87f82556",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 12316698,
            "upload_time": "2023-06-02T20:35:24",
            "upload_time_iso_8601": "2023-06-02T20:35:24.587114Z",
            "url": "https://files.pythonhosted.org/packages/dc/5d/399fbfc72cea947c4405683e364965f556ee6b07dd647488a36549b047d1/fast_poisson_solver-0.1.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "93f08c335250cac4ac9b0ac1ef1d7f77b1f49f73c34c0eecc34ef4d33e339ab8",
                "md5": "3a0a2a90e5925c2d0b05ad21a916b6db",
                "sha256": "2041cbb806955f8d244e6e079f07e2baacb55d97d694ea45104ef5f72c662be0"
            },
            "downloads": -1,
            "filename": "fast_poisson_solver-0.1.14.tar.gz",
            "has_sig": false,
            "md5_digest": "3a0a2a90e5925c2d0b05ad21a916b6db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 12297325,
            "upload_time": "2023-06-02T20:38:49",
            "upload_time_iso_8601": "2023-06-02T20:38:49.750042Z",
            "url": "https://files.pythonhosted.org/packages/93/f0/8c335250cac4ac9b0ac1ef1d7f77b1f49f73c34c0eecc34ef4d33e339ab8/fast_poisson_solver-0.1.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-02 20:38:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "matthiasnwt",
    "github_project": "fast-poisson-solver",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "fast-poisson-solver"
}
        
Elapsed time: 0.07414s