- Notifications
You must be signed in to change notification settings - Fork91
Physics-Informed Neural networks for Advanced modeling
License
mathLab/PINA
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
![]() |
Getting Started |Documentation |Contributing
PINA is an open-source Python library designed to simplify and accelerate the development of Scientific Machine Learning (SciML) solutions. Built on top ofPyTorch,PyTorch Lightning, andPyTorch Geometric, 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.
Install using pip:
pip install"pina-mathlab"Install from source:
git clone https://github.com/mathLab/PINAcd PINAgit checkout masterpip install.
Install with extra packages:
To install extra dependencies required to run tests or tutorials directories, please use the following command:
pip install"pina-mathlab[extras]"Available extras include:
devfor development purpuses, use this if you want toContribute.testfor running test locally.docfor building documentation locally.tutorialfor runningTutorials.
Solving a differential problem inPINA follows thefour steps pipeline:
Define the problem to be solved with its constraints using theProblem API.
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 theModel API.
Select or build a Solver for the Problem, e.g., supervised solvers, or physics-informed (e.g., PINN) solvers.PINA Solvers are modular and can be used as-is or customized.
Train the model using theTrainer API class, built on PyTorch Lightning, which supports efficient, scalable training with advanced features.
Do you want to learn more about it? Look at ourTutorials.
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:
importtorchfrompinaimportTrainerfrompina.modelimportFeedForwardfrompina.solverimportSupervisedSolverfrompina.problem.zooimportSupervisedProbleminput_tensor=torch.rand((10,1))target_tensor=input_tensor.pow(3)# Step 1. Define problemproblem=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 Solversolver=SupervisedSolver(problem,model,use_lt=False)# Step 4. Traintrainer=Trainer(solver,max_epochs=1000,accelerator='gpu')trainer.train()
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:
in PINA, can be easily implemented by:
frompinaimportTrainer,Conditionfrompina.problemimportSpatialProblemfrompina.operatorimportgradfrompina.solverimportPINNfrompina.modelimportFeedForwardfrompina.domainimportCartesianDomainfrompina.equationimportEquation,FixedValuedefode_equation(input_,output_):u_x=grad(output_,input_,components=["u"],d=["x"])u=output_.extract(["u"])returnu_x-u# build the problemclassSimpleODE(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 problemproblem=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 Solversolver=PINN(problem,model)# Step 4. Traintrainer=Trainer(solver,max_epochs=1000,accelerator='gpu')trainer.train()
Here's a quick look at PINA's main module. For a better experience and full details, check out thedocumentation.

We would love to develop PINA together with our community! Best way to get started is to select any issue from thegood-first-issue label. If you would like to contribute, please review ourContributing Guide for all relevant details.
We warmly thank all the contributors that have supported PINA so far:
Made withcontrib.rocks.
IfPINA 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} }About
Physics-Informed Neural networks for Advanced modeling
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
