Skip to main content

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

  • [v0.3.2]Agentic PINA: Added AI agents that guide users through the PINA pipeline, with dedicated skills for problem setup, model and solver selection, and training configuration.
  • [v0.3]New solvers: autoregressive solver for sequential prediction tasks and multi-model solver support. Internals redesigned around a mixin architecture — lightweight, single-responsibility mixins (preprocessing, forward, postprocessing) that can be freely composed, with residual computation and loss aggregation clearly separated.
  • [v0.3]Conditions refactoring: evaluation logic moved out of the solver and into the condition itself via a dedicated evaluate method, decoupling the training loop from problem-specific logic and enabling fully modular, solver-agnostic conditions.
  • [v0.3]Time-dependent conditions: added dedicated time series and graph time series conditions to support time-dependent problems and autoregressive formulations across sequential and graph-structured data.
  • [v0.3]Code cleanup: core internals migrated to the _src pattern; interfaces and base classes introduced across conditions, problems (AbstractProblemBaseProblem), losses, and data module; equation zoo reorganized with Burgers added.
  • [v0.3]KAN support: Kolmogorov–Arnold Networks with fully vectorized spline basis and analytical derivatives.

Want the full history? See the Releases page.


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.

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

PINA pipeline


Installation

      

Install a stable release

pip install "pina-mathlab"

Install from source

git clone https://github.com/pina-org/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:

  • dev for development purposes
  • test for running tests locally
  • doc for building documentation locally
  • tutorial for running tutorials

Getting started with PINA

           

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

  1. Define the problem and constraints using the Problem API.
  2. Design your model using PyTorch, PyTorch Geometric, or import from the Model API.
  3. Select or build a Solver using the Solver API.
  4. Train with the Trainer API, powered by PyTorch Lightning.
flowchart LR
    STEP1["<h2>Problem and Data</h2> Define the mathematical problem<br>Identify constraints or import data"]
    STEP2["<h2>Model Design</h2> Build a PyTorch module Choose or customize a model"]
    STEP3["<h2>Solver Selection</h2> Use available solvers or define your own strategy"]
    STEP4["<h2>Training</h2> Optimize the model with PyTorch Lightning"]

    STEP1 e1@--> STEP2
    STEP2 e2@--> STEP3
    STEP3 e3@--> STEP4
    e1@{ animate: true }
    e2@{ animate: true }
    e3@{ animate: true }

Want to dive deeper? Check out the official Tutorials.


PINA by Examples

      

Data-Driven Modeling Example

import torch
from pina import Trainer
from pina.model import FeedForward
from pina.problem.zoo import SupervisedProblem
from pina.solver import SupervisedSingleModelSolver

input_tensor  = torch.rand((10, 1))
target_tensor = input_tensor.pow(3)

# Step 1. Define problem
problem = SupervisedProblem(input_tensor, target_tensor)

# Step 2. Define model
model = FeedForward(input_dimensions=1, output_dimensions=1, layers=[64, 64])

# Step 3. Define solver
solver = SupervisedSingleModelSolver(problem, model, use_lt=False)

# Step 4. Train
trainer = Trainer(solver, max_epochs=1000, accelerator="gpu")
trainer.train()

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

In PINA, this can be implemented as:

from pina.operator import grad
from pina.model import FeedForward
from pina.equation import Equation
from pina import Trainer, Condition
from pina.domain import CartesianDomain
from pina.problem import SpatialProblem
from pina.equation.zoo import FixedValue
from pina.solver import PhysicsInformedSingleModelSolver

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

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()
problem.discretise_domain(n=100, mode="grid", domains=["D", "x0"])

# Step 2. Define model
model = FeedForward(input_dimensions=1, output_dimensions=1, layers=[64, 64])

# Step 3. Define solver
solver = PhysicsInformedSingleModelSolver(problem, model)

# Step 4. Train
trainer = Trainer(solver, max_epochs=1000, accelerator="gpu")
trainer.train()

AI-Assisted Development

This repository includes AI agent skills (guides for opencode, Claude Code, Cursor) that walk you through the full PINA workflow — from problem definition to trained solver — through natural conversation.

Skills are located at .opencode/skills/<name>/SKILL.md and cover:

  • pina-workflow — Orchestrates a complete session (entry point)
  • create-problem — Setting up physics-driven or data-driven problems
  • define-domains — Creating and discretising domains
  • define-equations — Writing PDEs/ODEs and using the equation zoo
  • condition-setup — Binding equations to domains
  • select-model, select-solver, select-trainer — Architecture and training

Just open the project in a compatible agent and start describing your problem — the agent will guide you step by step.

Or type /pina-agentic (in opencode or Claude Code) to launch an interactive session that walks you through the full workflow end-to-end.


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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pina_mathlab-0.3.2.post2608.tar.gz (195.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pina_mathlab-0.3.2.post2608-py3-none-any.whl (328.0 kB view details)

Uploaded Python 3

File details

Details for the file pina_mathlab-0.3.2.post2608.tar.gz.

File metadata

  • Download URL: pina_mathlab-0.3.2.post2608.tar.gz
  • Upload date:
  • Size: 195.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pina_mathlab-0.3.2.post2608.tar.gz
Algorithm Hash digest
SHA256 f180b083f142d2a126bfdc222200ddf7d24bf74907ef6f915d7838d70bdf3c58
MD5 550cb2212c22e238e0778212ae56ee3d
BLAKE2b-256 7d9c4ba444a195996d06f494017ba6557ad825410a8df5dbb033dd9ce4c69356

See more details on using hashes here.

File details

Details for the file pina_mathlab-0.3.2.post2608-py3-none-any.whl.

File metadata

File hashes

Hashes for pina_mathlab-0.3.2.post2608-py3-none-any.whl
Algorithm Hash digest
SHA256 d8e72a6b3789eac618828966efd3caf5f858a9192da94924ff2ac29a0dbcc845
MD5 d89588ca9fc5e55394989f34b09e3603
BLAKE2b-256 2c28fdbea316e9dae80186b7ec019b02532f57d73186c9b423d82bbf4eb964eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page