diff --git a/README.md b/README.md index c5c7406b7..300fda05e 100644 --- a/README.md +++ b/README.md @@ -4,38 +4,79 @@ Copyright Contributors to the Pyro project. SPDX-License-Identifier: Apache-2.0 --> - - - - - -
- - PINA logo - - -

- A Unified Framework for Scientific Machine Learning -

-
- - ------------------------------------------ - -[![pages-build-deployment](https://github.com/mathLab/PINA/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/mathLab/PINA/actions/workflows/pages/pages-build-deployment) -[![Version](https://img.shields.io/pypi/v/pina-mathlab?label=version&logo=pypi)](https://pypi.org/project/pina-mathlab/) -[![Downloads](https://img.shields.io/pypi/dm/pina-mathlab?label=downloads&logo=pypi)](https://pypi.org/project/pina-mathlab/) -[![JOSS](https://img.shields.io/badge/JOSS-10.21105/JOSS.05352-blue?logo=open-access)](https://joss.theoj.org/papers/10.21105/joss.05352) -[![LICENSE](https://img.shields.io/github/license/mathLab/PINA)](https://github.com/mathLab/PINA/blob/main/LICENSE.rst) - - -[Getting Started](https://github.com/mathLab/PINA/tree/master/tutorials#pina-tutorials) | -[Documentation](https://mathlab.github.io/PINA/) | -[Contributing](https://github.com/mathLab/PINA/blob/master/CONTRIBUTING.md) - -**PINA** is an open-source Python library designed to simplify and accelerate the development of Scientific Machine Learning (SciML) solutions. Built on top of [PyTorch](https://pytorch.org/), [PyTorch Lightning](https://lightning.ai/docs/pytorch/stable/), and [PyTorch Geometric](https://pytorch-geometric.readthedocs.io/en/latest/), PINA provides an intuitive framework for defining, experimenting with, and solving complex problems using Neural Networks, Physics-Informed Neural Networks (PINNs), Neural Operators, and more. +
+

+ + PyPI downloads +
+ + + + + +

+ + PINA + + +

+ A Unified Framework for Scientific Machine Learning +

+ + + +

+ PINA is an open-source Python library designed to simplify and accelerate the development of + Scientific Machine Learning (SciML) solutions, including PINNs, Neural Operators, + data-driven modeling, and more. +

+ +

+

Built on top of

+ + + + + +

+
+
+ + +

News & Announcements

+ +
+ +
+ +

+ Want the full history? + See the Releases page and the + Changelog (if present). +

+ +
+ +

What's PINA

+ +PINA provides an intuitive framework for defining, experimenting with, and solving complex problems using Neural Networks, Physics-Informed Neural Networks (PINNs), Neural Operators, and more. - **Modular Architecture**: Designed with modularity in mind and relying on powerful yet composable abstractions, PINA allows users to easily plug, replace, or extend components, making experimentation and customization straightforward. @@ -45,51 +86,117 @@ SPDX-License-Identifier: Apache-2.0 -## Installation + -### Installing a stable PINA release -**Install using pip:** -```sh -pip install "pina-mathlab" -``` -**Install from source:** -```sh -git clone https://github.com/mathLab/PINA +
+ +
+ +

Installation

+        + +
+ +

Install a stable release

+ +
pip install "pina-mathlab"
+ +

Install from source

+ +
git clone https://github.com/mathLab/PINA
 cd PINA
 git checkout master
 pip install .
-```
+
+ +Install with extra dependencies + +

+To install additional packages required for development, tests, docs, or tutorials: +

+ +
pip install "pina-mathlab[extras]"
+ +

Available extras:

+ + + +
+
+ + +
+ +

PINA for Dummies

+        + +
+ +

+Solving a differential problem in PINA follows a clean four-step pipeline: +

+ +
    +
  1. + Define the problem and constraints using the + Problem API. +
  2. +
  3. + Design your model using PyTorch, PyTorch Geometric, or import from the + Model API. +
  4. +
  5. + Select or build a Solver using the + Solver API. +
  6. +
  7. + Train with the + Trainer API, + powered by PyTorch Lightning. +
  8. +
-**Install with extra packages:** +```mermaid +flowchart LR + STEP1["

Problem and Data

Define the mathematical problem
Identify constraints or import data"] + STEP2["

Model Design

Build a PyTorch module Choose or customize a model"] + STEP3["

Solver Selection

Use available solvers or define your own strategy"] + STEP4["

Training

Optimize the model with PyTorch Lightning"] -To install extra dependencies required to run tests or tutorials directories, please use the following command: -```sh -pip install "pina-mathlab[extras]" + STEP1 e1@--> STEP2 + STEP2 e2@--> STEP3 + STEP3 e3@--> STEP4 + e1@{ animate: true } + e2@{ animate: true } + e3@{ animate: true } ``` -Available extras include: -* `dev` for development purpuses, use this if you want to [Contribute](https://github.com/mathLab/PINA/blob/master/CONTRIBUTING.md#contributing-to-pina). -* `test` for running test locally. -* `doc` for building documentation locally. -* `tutorial` for running [Tutorials](https://github.com/mathLab/PINA/tree/master/tutorials#pina-tutorials). - -## Quick Tour for New Users -Solving a differential problem in **PINA** follows the *four steps pipeline*: -1. Define the problem to be solved with its constraints using the [Problem API](https://mathlab.github.io/PINA/_rst/_code.html#problems). +

+Want to dive deeper? Check out the official +Tutorials. +

-2. Design your model using PyTorch, or for graph-based problems, leverage PyTorch Geometric to build Graph Neural Networks. You can also import models directly from the [Model API](https://mathlab.github.io/PINA/_rst/_code.html#models). +
+
-3. Select or build a Solver for the Problem, e.g., supervised solvers, or physics-informed (e.g., PINN) solvers. [PINA Solvers](https://mathlab.github.io/PINA/_rst/_code.html#solvers) are modular and can be used as-is or customized. +
+ +

PINA by Examples

+        + +
-4. Train the model using the [Trainer API](https://mathlab.github.io/PINA/_rst/trainer.html) class, built on PyTorch Lightning, which supports efficient, scalable training with advanced features. +
+

Data-Driven Modeling Example

-Do you want to learn more about it? Look at our [Tutorials](https://github.com/mathLab/PINA/tree/master/tutorials#pina-tutorials). - -### Solve Data Driven Problems -Data driven modelling aims to learn a function that given some input data gives an output (e.g. regression, classification, ...). In PINA you can easily do this by: -```python +```python import torch from pina import Trainer from pina.model import FeedForward @@ -101,25 +208,37 @@ target_tensor = input_tensor.pow(3) # Step 1. Define problem problem = SupervisedProblem(input_tensor, target_tensor) -# Step 2. Design model (you can use your favourite torch.nn.Module in here) -model = FeedForward(input_dimensions=1, output_dimensions=1, layers=[64, 64]) -# Step 3. Define Solver -solver = SupervisedSolver(problem, model, use_lt=False) + +# Step 2. Define model +model = FeedForward(input_dimensions=1, output_dimensions=1, layers=[64, 64]) + +# Step 3. Define solver +solver = SupervisedSolver(problem, model, use_lt=False) + # Step 4. Train -trainer = Trainer(solver, max_epochs=1000, accelerator='gpu') +trainer = Trainer(solver, max_epochs=1000, accelerator="gpu") trainer.train() ``` -### Solve Physics Informed Problems -Physics-informed modeling aims to learn functions that not only fit data, but also satisfy known physical laws, such as differential equations or boundary conditions. For example, the following differential problem: +
+ +
+ +
+ +

Physics-Informed Example

+ +

+Consider the following differential problem: +

-$$ -\begin{cases} -\frac{d}{dx}u(x) &= u(x) \quad x \in(0,1)\\ -u(x=0) &= 1 -\end{cases} -$$ +

+ ODE equation +

-in PINA, can be easily implemented by: +

+In PINA, this can be implemented as: +

```python from pina import Trainer, Condition @@ -135,7 +254,6 @@ def ode_equation(input_, output_): u = output_.extract(["u"]) return u_x - u -# build the problem class SimpleODE(SpatialProblem): output_variables = ["u"] spatial_domain = CartesianDomain({"x": [0, 1]}) @@ -151,18 +269,90 @@ class SimpleODE(SpatialProblem): # Step 1. Define problem problem = SimpleODE() problem.discretise_domain(n=100, mode="grid", domains=["D", "x0"]) -# Step 2. Design model (you can use your favourite torch.nn.Module in here) -model = FeedForward(input_dimensions=1, output_dimensions=1, layers=[64, 64]) -# Step 3. Define Solver -solver = PINN(problem, model) + +# Step 2. Define model +model = FeedForward(input_dimensions=1, output_dimensions=1, layers=[64, 64]) + +# Step 3. Define solver +solver = PINN(problem, model) + # Step 4. Train -trainer = Trainer(solver, max_epochs=1000, accelerator='gpu') +trainer = Trainer(solver, max_epochs=1000, accelerator="gpu") trainer.train() ``` - -## PINA Modules Structure -Here's a quick look at PINA's main module. For a better experience and full details, check out the [documentation](https://mathlab.github.io/PINA/). - +
+
+
+ +
+ +

Contributing & Community

+        + +
+

+We would love to develop PINA together with the community. +A great place to start is the list of + + good-first-issue + +issues. +

+ +

+If you would like to contribute, please read the +Contributing Guide. +

+ +

+ + Contributors + +

+ +

+ Made with contrib.rocks. +

+ +
+
+ +
+ +

Citation

+        + +
+

+If PINA has been significant in your research and you would like to acknowledge it, please cite: +

+ +
Coscia, D., Ivagnes, A., Demo, N., & Rozza, G. (2023).
+Physics-Informed Neural networks for Advanced modeling.
+Journal of Open Source Software, 8(87), 5352.
+ +

Or in BibTeX format:

+ +
@article{coscia2023physics,
+  title={Physics-Informed Neural networks for Advanced modeling},
+  author={Coscia, Dario and Ivagnes, Anna and Demo, Nicola and Rozza, Gianluigi},
+  journal={Journal of Open Source Software},
+  volume={8},
+  number={87},
+  pages={5352},
+  year={2023}
+}
+
+ + +

API(NA)

+ + +Here is a high-level overview of PINA’s main modules. For full details, refer to the +documentation. + ```mermaid flowchart TB PINA["

pina

The basic module including `Condition`, LabelTensor, `Graph` and `Trainer` API"] @@ -205,54 +395,4 @@ flowchart TB BLOCK --> ADAPT OPTIM --> LOSS DATA --> CONDITION - -``` -### Steps to Follow - -```mermaid -flowchart LR - STEP1["

Problem and Data

Define the mathematical problem
Identify constraints or import data"] - STEP2["

Model Design

Build a PyTorch module Choose or customize a model"] - STEP3["

Solver Selection

Use available solvers or define your own strategy"] - STEP4["

Training

Optimize the model with PyTorch Lightning"] - - STEP1 e1@--> STEP2 - STEP2 e2@--> STEP3 - STEP3 e3@--> STEP4 - e1@{ animate: true } - e2@{ animate: true } - e3@{ animate: true } -``` -## Contributing and Community - -We would love to develop PINA together with our community! Best way to get 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. - -We warmly thank all the contributors that have supported PINA so far: - - - Contributors - - -Made with [contrib.rocks](https://contrib.rocks). - -## Citation -If **PINA** has been significant in your research, and you would like to acknowledge the project in your academic publication, we suggest citing the following paper: - -``` -Coscia, D., Ivagnes, A., Demo, N., & Rozza, G. (2023). Physics-Informed Neural networks for Advanced modeling. Journal of Open Source Software, 8(87), 5352. -``` - -Or in BibTex format -``` -@article{coscia2023physics, - title={Physics-Informed Neural networks for Advanced modeling}, - author={Coscia, Dario and Ivagnes, Anna and Demo, Nicola and Rozza, Gianluigi}, - journal={Journal of Open Source Software}, - volume={8}, - number={87}, - pages={5352}, - year={2023} - } ``` diff --git a/pina2 (1).gif b/pina2 (1).gif new file mode 100644 index 000000000..52d8b1d49 Binary files /dev/null and b/pina2 (1).gif differ diff --git a/readme/pina.svg b/readme/pina.svg new file mode 100644 index 000000000..73da49573 --- /dev/null +++ b/readme/pina.svg @@ -0,0 +1 @@ + \ No newline at end of file