pina-mathlab


Namepina-mathlab JSON
Version 0.2.2.post2508 PyPI version JSON
download
home_pageNone
SummaryPhysic Informed Neural networks for Advance modeling.
upload_time2025-08-01 04:05:51
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT
keywords machine-learning deep-learning modeling pytorch ode neural-networks differential-equations pde hacktoberfest pinn physics-informed physics-informed-neural-networks neural-operators equation-learning lightining
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!--
Copyright Contributors to the Pyro project.

SPDX-License-Identifier: Apache-2.0
-->

<table>
  <tr>
    <td>
      <a href="https://github.com/mathLab/PINA/raw/master/readme/pina_logo.png">
        <img src="https://github.com/mathLab/PINA/raw/master/readme/pina_logo.png"
             alt="PINA logo"
             style="width: 220px; aspect-ratio: 1 / 1; object-fit: contain;">
      </a>
    </td>
    <td>
      <h2 style="margin-left: 20px; font-size: 1.8rem; line-height: 1.2;">
        Solving Scientific Problems with Machine Learning, Intuitively
      </h2>
    </td>
  </tr>
</table>


-----------------------------------------

[![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.

- **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.

- **Scalable Performance**: With native support for multi-device training, PINA handles large datasets efficiently, offering performance close to hand-crafted implementations with minimal overhead.

- **Highly Flexible**: Whether you're looking for full automation or granular control, PINA adapts to your workflow. High-level abstractions simplify model definition, while expert users can dive deep to fine-tune every aspect of the training and inference process.



## 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
cd PINA
git checkout master
pip install .
```

**Install with extra packages:**

To install extra dependencies required to run tests or tutorials directories, please use the following command:
```sh
pip install "pina-mathlab[extras]" 
```
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).

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.

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.

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
from pina import Trainer
from pina.model import FeedForward
from pina.solver import SupervisedSolver
from pina.problem.zoo import SupervisedProblem

input_tensor  = torch.rand((10, 1))
output_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)
# Step 4. Train
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:

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

in PINA, can be easily implemented by:

```python
from pina import Trainer, Condition
from pina.problem import SpatialProblem
from pina.operator import grad
from pina.solver import PINN
from pina.model import FeedForward
from pina.domain import CartesianDomain
from pina.equation import Equation, FixedValue

def ode_equation(input_, output_):
    u_x = grad(output_, input_, components=["u"], d=["x"])
    u = output_.extract(["u"])
    return u_x - u

# build the problem
class SimpleODE(SpatialProblem):
    output_variables = ["u"]
    spatial_domain = CartesianDomain({"x": [0, 1]})
    domains = {
        "x0": CartesianDomain({"x": 0.0}),
        "D": CartesianDomain({"x": [0, 1]}),
    }
    conditions = {
        "bound_cond": Condition(domain="x0", equation=FixedValue(1.0)),
        "phys_cond": Condition(domain="D", equation=Equation(ode_equation)),
    }

# Step 1. Define problem
problem = SimpleODE()
# 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 4. Train
trainer = Trainer(solver, max_epochs=1000, accelerator='gpu')
trainer.train()
```

## Application Programming Interface
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/).

<a href="https://github.com/mathLab/PINA/readme/PINA_API.png">
  <img src="./readme/PINA_API.png" />
</a>

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

<a href="https://github.com/mathLab/PINA/graphs/contributors">
  <img src="https://contrib.rocks/image?repo=mathLab/PINA"
       alt="Contributors"
       style="max-width: 100%; height: auto; display: block;">
</a>

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}
        }
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pina-mathlab",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "machine-learning, deep-learning, modeling, pytorch, ode, neural-networks, differential-equations, pde, hacktoberfest, pinn, physics-informed, physics-informed-neural-networks, neural-operators, equation-learning, lightining",
    "author": null,
    "author_email": "PINA Contributors <pina.mathlab@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/37/9b/42d0ca63ad9ee0aec93be381c4fe52cfb4aee784211a57769ecc2d48374b/pina_mathlab-0.2.2.post2508.tar.gz",
    "platform": null,
    "description": "<!--\nCopyright Contributors to the Pyro project.\n\nSPDX-License-Identifier: Apache-2.0\n-->\n\n<table>\n  <tr>\n    <td>\n      <a href=\"https://github.com/mathLab/PINA/raw/master/readme/pina_logo.png\">\n        <img src=\"https://github.com/mathLab/PINA/raw/master/readme/pina_logo.png\"\n             alt=\"PINA logo\"\n             style=\"width: 220px; aspect-ratio: 1 / 1; object-fit: contain;\">\n      </a>\n    </td>\n    <td>\n      <h2 style=\"margin-left: 20px; font-size: 1.8rem; line-height: 1.2;\">\n        Solving Scientific Problems with Machine Learning, Intuitively\n      </h2>\n    </td>\n  </tr>\n</table>\n\n\n-----------------------------------------\n\n[![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)\n[![Version](https://img.shields.io/pypi/v/pina-mathlab?label=version&logo=pypi)](https://pypi.org/project/pina-mathlab/)\n[![Downloads](https://img.shields.io/pypi/dm/pina-mathlab?label=downloads&logo=pypi)](https://pypi.org/project/pina-mathlab/)\n[![JOSS](https://img.shields.io/badge/JOSS-10.21105/JOSS.05352-blue?logo=open-access)](https://joss.theoj.org/papers/10.21105/joss.05352)\n[![LICENSE](https://img.shields.io/github/license/mathLab/PINA)](https://github.com/mathLab/PINA/blob/main/LICENSE.rst)\n\n\n[Getting Started](https://github.com/mathLab/PINA/tree/master/tutorials#pina-tutorials) |\n[Documentation](https://mathlab.github.io/PINA/) |\n[Contributing](https://github.com/mathLab/PINA/blob/master/CONTRIBUTING.md)\n\n**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.\n\n- **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.\n\n- **Scalable Performance**: With native support for multi-device training, PINA handles large datasets efficiently, offering performance close to hand-crafted implementations with minimal overhead.\n\n- **Highly Flexible**: Whether you're looking for full automation or granular control, PINA adapts to your workflow. High-level abstractions simplify model definition, while expert users can dive deep to fine-tune every aspect of the training and inference process.\n\n\n\n## Installation\n\n### Installing a stable PINA release\n\n**Install using pip:**\n```sh\npip install \"pina-mathlab\"\n```\n\n**Install from source:**\n```sh\ngit clone https://github.com/mathLab/PINA\ncd PINA\ngit checkout master\npip install .\n```\n\n**Install with extra packages:**\n\nTo install extra dependencies required to run tests or tutorials directories, please use the following command:\n```sh\npip install \"pina-mathlab[extras]\" \n```\nAvailable extras include:\n* `dev` for development purpuses, use this if you want to [Contribute](https://github.com/mathLab/PINA/blob/master/CONTRIBUTING.md#contributing-to-pina).\n* `test` for running test locally.\n* `doc` for building documentation locally.\n* `tutorial` for running [Tutorials](https://github.com/mathLab/PINA/tree/master/tutorials#pina-tutorials).\n\n## Quick Tour for New Users\nSolving a differential problem in **PINA** follows the *four steps pipeline*:\n\n1. Define the problem to be solved with its constraints using the [Problem API](https://mathlab.github.io/PINA/_rst/_code.html#problems).\n\n2. 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).\n\n3. 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.\n\n4. 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.\n\nDo you want to learn more about it? Look at our [Tutorials](https://github.com/mathLab/PINA/tree/master/tutorials#pina-tutorials).\n\n### Solve Data Driven Problems\nData 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:\n```python\nfrom pina import Trainer\nfrom pina.model import FeedForward\nfrom pina.solver import SupervisedSolver\nfrom pina.problem.zoo import SupervisedProblem\n\ninput_tensor  = torch.rand((10, 1))\noutput_tensor = input_tensor.pow(3)\n\n# Step 1. Define problem\nproblem = SupervisedProblem(input_tensor, target_tensor)\n# Step 2. Design model (you can use your favourite torch.nn.Module in here)\nmodel   = FeedForward(input_dimensions=1, output_dimensions=1, layers=[64, 64])\n# Step 3. Define Solver\nsolver  = SupervisedSolver(problem, model)\n# Step 4. Train\ntrainer = Trainer(solver, max_epochs=1000, accelerator='gpu')\ntrainer.train()\n```\n### Solve Physics Informed Problems\nPhysics-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:\n\n$$\n\\begin{cases}\n\\frac{d}{dx}u(x) &=  u(x) \\quad x \\in(0,1)\\\\\nu(x=0) &= 1\n\\end{cases}\n$$\n\nin PINA, can be easily implemented by:\n\n```python\nfrom pina import Trainer, Condition\nfrom pina.problem import SpatialProblem\nfrom pina.operator import grad\nfrom pina.solver import PINN\nfrom pina.model import FeedForward\nfrom pina.domain import CartesianDomain\nfrom pina.equation import Equation, FixedValue\n\ndef ode_equation(input_, output_):\n    u_x = grad(output_, input_, components=[\"u\"], d=[\"x\"])\n    u = output_.extract([\"u\"])\n    return u_x - u\n\n# build the problem\nclass SimpleODE(SpatialProblem):\n    output_variables = [\"u\"]\n    spatial_domain = CartesianDomain({\"x\": [0, 1]})\n    domains = {\n        \"x0\": CartesianDomain({\"x\": 0.0}),\n        \"D\": CartesianDomain({\"x\": [0, 1]}),\n    }\n    conditions = {\n        \"bound_cond\": Condition(domain=\"x0\", equation=FixedValue(1.0)),\n        \"phys_cond\": Condition(domain=\"D\", equation=Equation(ode_equation)),\n    }\n\n# Step 1. Define problem\nproblem = SimpleODE()\n# Step 2. Design model (you can use your favourite torch.nn.Module in here)\nmodel   = FeedForward(input_dimensions=1, output_dimensions=1, layers=[64, 64])\n# Step 3. Define Solver\nsolver  = PINN(problem, model)\n# Step 4. Train\ntrainer = Trainer(solver, max_epochs=1000, accelerator='gpu')\ntrainer.train()\n```\n\n## Application Programming Interface\nHere'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/).\n\n<a href=\"https://github.com/mathLab/PINA/readme/PINA_API.png\">\n  <img src=\"./readme/PINA_API.png\" />\n</a>\n\n## Contributing and Community\n\nWe 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.\n\nWe warmly thank all the contributors that have supported PINA so far:\n\n<a href=\"https://github.com/mathLab/PINA/graphs/contributors\">\n  <img src=\"https://contrib.rocks/image?repo=mathLab/PINA\"\n       alt=\"Contributors\"\n       style=\"max-width: 100%; height: auto; display: block;\">\n</a>\n\nMade with [contrib.rocks](https://contrib.rocks).\n\n## Citation\nIf **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:\n\n```\nCoscia, D., Ivagnes, A., Demo, N., & Rozza, G. (2023). Physics-Informed Neural networks for Advanced modeling. Journal of Open Source Software, 8(87), 5352.\n```\n\nOr in BibTex format\n```\n@article{coscia2023physics,\n        title={Physics-Informed Neural networks for Advanced modeling},\n        author={Coscia, Dario and Ivagnes, Anna and Demo, Nicola and Rozza, Gianluigi},\n        journal={Journal of Open Source Software},\n        volume={8},\n        number={87},\n        pages={5352},\n        year={2023}\n        }\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Physic Informed Neural networks for Advance modeling.",
    "version": "0.2.2.post2508",
    "project_urls": {
        "Homepage": "https://mathlab.github.io/PINA/",
        "Repository": "https://github.com/mathLab/PINA"
    },
    "split_keywords": [
        "machine-learning",
        " deep-learning",
        " modeling",
        " pytorch",
        " ode",
        " neural-networks",
        " differential-equations",
        " pde",
        " hacktoberfest",
        " pinn",
        " physics-informed",
        " physics-informed-neural-networks",
        " neural-operators",
        " equation-learning",
        " lightining"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d231251737d24f5f71761752f31fca52dc5806f604a52c1aef3901b9ce1206b1",
                "md5": "37462cf823ffacaa778844c5ff5c6c81",
                "sha256": "6b2369db45d536d27ab14afb15af96a5364e700ed3b12276d126dc196b07eebf"
            },
            "downloads": -1,
            "filename": "pina_mathlab-0.2.2.post2508-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "37462cf823ffacaa778844c5ff5c6c81",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 200595,
            "upload_time": "2025-08-01T04:05:50",
            "upload_time_iso_8601": "2025-08-01T04:05:50.670758Z",
            "url": "https://files.pythonhosted.org/packages/d2/31/251737d24f5f71761752f31fca52dc5806f604a52c1aef3901b9ce1206b1/pina_mathlab-0.2.2.post2508-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "379b42d0ca63ad9ee0aec93be381c4fe52cfb4aee784211a57769ecc2d48374b",
                "md5": "7b092de3e027937cd36038fca65a7e40",
                "sha256": "60ff8aeb7e3e3a7c1ec017561dc0d449e22075670b4dd9841375a29632edf582"
            },
            "downloads": -1,
            "filename": "pina_mathlab-0.2.2.post2508.tar.gz",
            "has_sig": false,
            "md5_digest": "7b092de3e027937cd36038fca65a7e40",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 137962,
            "upload_time": "2025-08-01T04:05:51",
            "upload_time_iso_8601": "2025-08-01T04:05:51.710299Z",
            "url": "https://files.pythonhosted.org/packages/37/9b/42d0ca63ad9ee0aec93be381c4fe52cfb4aee784211a57769ecc2d48374b/pina_mathlab-0.2.2.post2508.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-01 04:05:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mathLab",
    "github_project": "PINA",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pina-mathlab"
}
        
Elapsed time: 0.51955s