Update README.md

This commit is contained in:
Nicola Demo
2023-07-17 18:51:21 +02:00
parent 9cbd1bddbe
commit 1c0323c272

332
README.md
View File

@@ -1,64 +1,171 @@
<p align="center"> <!-- PROJECT SHIELDS -->
<a href="http://mathlab.github.io/PINA/" target="_blank" > <!--
<img alt="Physics-Informed Neural networks for Advanced modeling" src="readme/pina_logo.png" width="200" /> *** I'm using markdown "reference style" links for readability.
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
*** See the bottom of this document for the declaration of the reference variables
*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->
<div align="center">
[![PyPi][pypi-shield]][pypi-url]
[![PyPi][pypiversion-shield]][pypi-url]
[![PyPi][downloads-shield]][downloads-url]
[![License][license-shield]][license-url]
</div>
<!-- [![Contributors][contributors-shield]][contributors-url] -->
<!-- [![Build][build-shield]][build-url] -->
<!-- [![CodeCov][codecov-shield]][codecov-url] -->
<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[pypi-shield]: https://img.shields.io/pypi/pyversions/pina-mathlab?style=for-the-badge
[pypi-url]: https://pypi.org/project/pina-mathlab/
[pypiversion-shield]: https://img.shields.io/pypi/v/pina-mathlab?style=for-the-badge
[downloads-shield]: https://img.shields.io/pypi/dm/pina-mathlab?style=for-the-badge
[downloads-url]: https://pypi.org/project/zenml/
[codecov-shield]: https://img.shields.io/codecov/c/gh/zenml-io/zenml?style=for-the-badge
[codecov-url]: https://codecov.io/gh/zenml-io/zenml
[contributors-shield]: https://img.shields.io/github/contributors/zenml-io/zenml?style=for-the-badge
[contributors-url]: https://github.com/othneildrew/Best-README-Template/graphs/contributors
[license-shield]: https://img.shields.io/github/license/mathLab/pina?style=for-the-badge
[license-url]: https://github.com/mathLab/PINA/blob/main/LICENSE.rst
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
<!-- [linkedin-url]: https://www.linkedin.com/company/zenml/
[twitter-shield]: https://img.shields.io/twitter/follow/zenml_io?style=for-the-badge
[twitter-url]: https://twitter.com/zenml_io -->
[slack-shield]: https://img.shields.io/badge/-Slack-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[slack-url]: https://zenml.io/slack-invite
[build-shield]: https://img.shields.io/github/workflow/status/zenml-io/zenml/Build,%20Lint,%20Unit%20&%20Integration%20Test/develop?logo=github&style=for-the-badge
[build-url]: https://github.com/zenml-io/zenml/actions/workflows/ci.yml
<!-- PROJECT LOGO -->
<br />
<div align="center">
<a href="https://zenml.io">
<img alt="ZenML Logo" src="https://github.com/mathLab/PINA/raw/master/readme/pina_logo.png" alt="Logo" width="200">
</a> </a>
</p>
<p align="center"> <h3 align="center">Solve equations, intuitively.</h3>
<a href="https://github.com/mathLab/PINA/blob/master/LICENSE" target="_blank">
<img alt="Software License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"> <p align="center">
A simple framework to solve difficult problems with neural networks.
<br />
<a href="https://mathlab.github.io/PINA/"><strong>Explore the docs »</strong></a>
<br />
<!-- <div align="center">
Join our <a href="https://zenml.io/slack-invite" target="_blank">
<img width="25" src="https://cdn3.iconfinder.com/data/icons/logos-and-brands-adobe/512/306_Slack-512.png" alt="Slack"/>
<b>Slack Community</b> </a> and be part of the ZenML family.
</div> -->
<br />
<!-- <a href="https://zenml.io/features">Features</a>
·
<a href="https://zenml.io/roadmap">Roadmap</a>
·
<a href="https://github.com/zenml-io/zenml/issues">Report Bug</a>
·
<a href="https://zenml.io/discussion">Vote New Features</a>
·
<a href="https://blog.zenml.io/">Read Blog</a>
·
<a href="#-meet-the-team">Meet the Team</a> -->
<!-- <br />
🎉 Version 0.41.0 is out. Check out the release notes
<a href="https://github.com/zenml-io/zenml/releases">here</a>.
<br />
<br />
<a href="https://www.linkedin.com/company/zenml/">
<img src="https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555" alt="Logo">
</a> </a>
<a href="https://badge.fury.io/py/pina-mathlab"> <a href="https://twitter.com/zenml_io">
<img src="https://badge.fury.io/py/pina-mathlab.svg" alt="PyPI version" height="18"> <img src="https://img.shields.io/badge/-Twitter-black.svg?style=for-the-badge&logo=twitter&colorB=555" alt="Logo">
</a> </a>
<a href="https://github.com/mathLab/PINA/actions/workflows/ci.yml" target="_blank"> <a href="https://www.youtube.com/c/ZenML">
<img alt="Build Status" src="https://github.com/mathLab/PINA/actions/workflows/ci.yml/badge.svg"> <img src="https://img.shields.io/badge/-YouTube-black.svg?style=for-the-badge&logo=youtube&colorB=555" alt="Logo">
</a> </a> -->
<a href="https://www.codacy.com/gh/mathLab/PINA/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=mathLab/PINA&amp;utm_campaign=Badge_Grade"> </p>
<img src="https://app.codacy.com/project/badge/Grade/1ed0b0279cbe44cc8207575fe6e55f91"/> </div>
</a>
<a href="https://www.codacy.com/gh/mathLab/PINA/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=mathLab/PINA&amp;utm_campaign=Badge_Coverage"> <!-- TABLE OF CONTENTS -->
<img src="https://app.codacy.com/project/badge/Coverage/1ed0b0279cbe44cc8207575fe6e55f91"/> <details>
</a> <summary>🏁 Table of Contents</summary>
</p> <ol>
<li><a href="#-introduction">Introduction</a></li>
<li><a href="#-quickstart">Quickstart</a></li>
<li>
<a href="#%EF%B8%8F-solve-your-differential-problem">Solve Your Differential Problem</a>
<ul>
<li><a href="#-1-formulate-the-problem">Formulate the Problem</a></li>
<li><a href="#-2-solve-the-problem">Solve the Problem</a></li>
</ul>
</li>
<!-- <li><a href="#-roadmap">Roadmap</a></li> -->
<li><a href="#-contributing-and-community">Contributing and Community</a></li>
<!-- <li><a href="#-getting-help">Getting Help</a></li> -->
<li><a href="#-license">License</a></li>
</ol>
</details>
<br />
# 🤖 Introduction
🤹 PINA is a Python package providing an easy interface to deal with *physics-informed neural networks* (PINN) for the approximation of (differential, nonlinear, ...) functions. Based on Pytorch, PINA offers a simple and intuitive way to formalize a specific problem and solve it using PINN.
- 👨‍💻 Formulate your differential problem in few lines of code, just translating the mathematical equations into Python
- 📄 Training your neural network in order to solve the problem
- 🚀 Use the model to visualize and analyze the solution!
**PINA**: Physics-Informed Neural networks for Advanced modeling <br>
## Table of contents # 🤸 Quickstart
* [Description](#description)
* [Problem definition](#problem-definition)
* [Problem solution](#problem-solution)
* [Dependencies and installation](#dependencies-and-installation)
* [Installing via PIP](#installing-via-pip)
* [Installing from source](#installing-from-source)
<!-- * [Documentation](#documentation) -->
<!-- * [Testing](#testing) -->
* [Examples and Tutorials](#examples-and-tutorials)
* [References](#references)
<!-- * [Recent works with PyDMD](#recent-works-with-pydmd) -->
* [Authors and contributors](#authors-and-contributors)
* [How to contribute](#how-to-contribute)
* [Submitting a patch](#submitting-a-patch)
* [License](#license)
## Description [Install PINA](https://mathlab.github.io/PINA/_rst/installation.html) via
**PINA** is a Python package providing an easy interface to deal with *physics-informed neural networks* (PINN) for the approximation of (differential, nonlinear, ...) functions. Based on Pytorch, PINA offers a simple and intuitive way to formalize a specific problem and solve it using PINN. The approximated solution of a differential equation can be implemented using PINA in a few lines of code thanks to the intuitive and user-friendly interface. [PyPI](https://pypi.org/project/pina-mathlab/). Python 3 is required:
<p align="center"> ```bash
<a href="http://mathlab.github.io/PINA/" target="_blank" > pip install "pina-mathlab"
<img alt="PINA interface for solving problems." src="readme/API_color.png" width="400" /> ```
</a> <br>
</p>
# 🖼️ Solve Your Differential Problem
#### Physics-informed neural network PINN is a novel approach that involves neural networks to solve supervised learning tasks while respecting any given law of physics described by general nonlinear differential equations. Proposed in [Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations](https://www.sciencedirect.com/science/article/pii/S0021999118307125?casa_token=p0BAG8SoAbEAAAAA:3H3r1G0SJ7IdXWm-FYGRJZ0RAb_T1qynSdfn-2VxqQubiSWnot5yyKli9UiH82rqQWY_Wzfq0HVV), such framework aims to solve problems in a continuous and nonlinear settings.
PINN is a novel approach that involves neural networks to solve supervised learning tasks while respecting any given law of physics described by general nonlinear differential equations. Proposed in *"Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations"*, such framework aims to solve problems in a continuous and nonlinear settings.
## 🔋 1. Formulate the Problem
#### Problem definition
First step is formalization of the problem in the PINA framework. We take as example here a simple Poisson problem, but PINA is already able to deal with **multi-dimensional**, **parametric**, **time-dependent** problems. First step is formalization of the problem in the PINA framework. We take as example here a simple Poisson problem, but PINA is already able to deal with **multi-dimensional**, **parametric**, **time-dependent** problems.
Consider: Consider:
$$\begin{cases} \Delta u = \sin(\pi x)\sin(\pi y)\quad& \text{in} \\ D \\\\ u = 0& \text{on} \\ \partial D \end{cases}$$ $$
\begin{cases}
\Delta u = \sin(\pi x)\sin(\pi y)\quad& \text{in}\, D \\
u = 0& \text{on}\, \partial D \end{cases}$$
where $D = [0, 1]^2$ is a square domain, $u$ the unknown field, and $\partial D = \Gamma_1 \cup \Gamma_2 \cup \Gamma_3 \cup \Gamma_4$, where $\Gamma_i$ are the boundaries of the square for $i=1,\cdots,4$. The translation in PINA code becomes a new class containing all the information about the domain, about the `conditions` and nothing more: where $D = [0, 1]^2$ is a square domain, $u$ the unknown field, and $\partial D = \Gamma_1 \cup \Gamma_2 \cup \Gamma_3 \cup \Gamma_4$, where $\Gamma_i$ are the boundaries of the square for $i=1,\cdots,4$. The translation in PINA code becomes a new class containing all the information about the domain, about the `conditions` and nothing more:
@@ -86,7 +193,7 @@ class Poisson(SpatialProblem):
} }
``` ```
#### Problem solution ## 👨‍🍳 2. Solve the Problem
After defining it, we want of course to solve such a problem. The only things we need is a `model`, in this case a feed forward network, and some samples of the domain and boundaries, here using a Cartesian grid. In these points we are going to evaluate the residuals, which is nothing but the loss of the network. After defining it, we want of course to solve such a problem. The only things we need is a `model`, in this case a feed forward network, and some samples of the domain and boundaries, here using a Cartesian grid. In these points we are going to evaluate the residuals, which is nothing but the loss of the network.
```python ```python
@@ -108,68 +215,35 @@ After the training we can infer our model, save it or just plot the PINN approxi
<p align="center"> <p align="center">
<img alt="Poisson approximation" src="readme/poisson_plot.png" width="100%" /> <img alt="Poisson approximation" src="readme/poisson_plot.png" width="100%" />
</p> </p>
<br>
<!-- # 🗺 Roadmap
## Dependencies and installation ZenML is being built in public. The [roadmap](https://zenml.io/roadmap) is a
**PINA** requires `numpy`, `scipy`, `matplotlib`, `future`, `torch`, `sphinx` (for the documentation) and `pytest` (for local test). The code is tested for Python 3, while compatibility of Python 2 is not guaranteed anymore. It can be installed using `pip` or directly from the source code. regularly updated source of truth for the ZenML community to understand where
the product is going in the short, medium, and long term.
### Installing via PIP ZenML is managed by a [core team](https://zenml.io/company#CompanyTeam) of
Mac and Linux users can install pre-built binary packages using pip. developers that are responsible for making key decisions and incorporating
To install the package just type: feedback from the community. The team oversees feedback via various channels,
```bash and you can directly influence the roadmap as follows:
> pip install git+https://github.com/mathLab/PINA.git
```
To uninstall the package:
```bash
> pip uninstall pina
```
### Installing from source - Vote on your most wanted feature on our [Discussion
The official distribution is on GitHub, and you can clone the repository using board](https://zenml.io/discussion).
```bash - Start a thread in our [Slack channel](https://zenml.io/slack-invite).
> git clone https://github.com/mathLab/PINA - [Create an issue](https://github.com/zenml-io/zenml/issues/new/choose) on our
``` Github repo.
-->
To install the package just type: # 🙌 Contributing and Community
```bash
> pip install -e .
```
<!-- ## Documentation --> We would love to develop PINA together with our community! Best way to get
<!-- **PyDMD** uses [Sphinx](http://www.sphinx-doc.org/en/stable/) for code documentation. You can view the documentation online [here](http://mathlab.github.io/PyDMD/). To build the html version of the docs locally simply: --> started is to select any issue from the [`good-first-issue`
label](https://github.com/mathLab/PINA/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22). If you
would like to contribute, please review our [Contributing
Guide](CONTRIBUTING.md) for all relevant details.
<!-- ```bash --> We warmly thank all the contributors that have supported PINA so far:
<!-- > cd docs -->
<!-- > make html -->
<!-- ``` -->
<!-- The generated html can be found in `docs/build/html`. Open up the `index.html` you find there to browse. -->
<!-- ## Testing -->
<!-- We are using Travis CI for continuous intergration testing. You can check out the current status [here](https://travis-ci.org/mathLab/PyDMD). -->
<!-- To run tests locally (`pytest` is required): -->
<!-- ```bash -->
<!-- > pytest -->
<!-- ``` -->
## Examples and Tutorials
The directory `Examples` contains some examples showing Poisson and Burgers problems solved in the PINN context.
### References
To implement the package we follow these works:
* Raissi, Maziar, Paris Perdikaris, and George E. Karniadakis.
*Physics-informed neural networks: A deep learning framework for solving
forward and inverse problems involving nonlinear partial differential
equations.* Journal of Computational Physics 378 (2019): 686-707.
## Authors and contributors
We warmly thank all the contributors that have supported PINA!
<a href="https://github.com/mathLab/PINA/graphs/contributors"> <a href="https://github.com/mathLab/PINA/graphs/contributors">
<img src="https://contrib.rocks/image?repo=mathLab/PINA" /> <img src="https://contrib.rocks/image?repo=mathLab/PINA" />
@@ -178,48 +252,18 @@ We warmly thank all the contributors that have supported PINA!
Made with [contrib.rocks](https://contrib.rocks). Made with [contrib.rocks](https://contrib.rocks).
## How to contribute <!-- # 🆘 Getting Help
We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow.
### Submitting a patch The first point of call should
be [our Slack group](https://zenml.io/slack-invite/).
1. It's generally best to start by opening a new issue describing the bug or Ask your questions about bugs or specific use cases, and someone from
feature you're intending to fix. Even if you think it's relatively minor, the [core team](https://zenml.io/company#CompanyTeam) will respond.
it's helpful to know what people are working on. Mention in the initial Or, if you
issue that you are planning to work on that bug or feature so that it can prefer, [open an issue](https://github.com/zenml-io/zenml/issues/new/choose) on
be assigned to you. our GitHub repo. -->
2. Follow the normal process of [forking][] the project, and setup a new
branch to work in. It's important that each group of changes be done in
separate branches in order to ensure that a pull request only includes the
commits related to that bug or feature.
3. To ensure properly formatted code, please make sure to use 4
spaces to indent the code. The easy way is to run on your bash the provided
script: ./code_formatter.sh. You should also run [pylint][] over your code.
It's not strictly necessary that your code be completely "lint-free",
but this will help you find common style issues.
4. Any significant changes should almost always be accompanied by tests. The
project already has good test coverage, so look at some of the existing
tests if you're unsure how to go about it. We're using [coveralls][] that
is an invaluable tools for seeing which parts of your code aren't being
exercised by your tests.
5. Do your best to have [well-formed commit messages][] for each change.
This provides consistency throughout the project, and ensures that commit
messages are able to be formatted properly by various git tools.
6. Finally, push the commits to your fork and submit a [pull request][]. Please,
remember to rebase properly in order to maintain a clean, linear git history.
[forking]: https://help.github.com/articles/fork-a-repo
[pylint]: https://www.pylint.org/
[coveralls]: https://coveralls.io
[well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
[pull request]: https://help.github.com/articles/creating-a-pull-request
## License # 📜 License
See the [LICENSE](LICENSE.rst) file for license rights and limitations (MIT). PINA is distributed under the terms of the MIT License.
A complete version of the license is available in the [LICENSE.rst](LICENSE.rst) file in this repository. Any contribution made to this project will be licensed under the MIT License.