PINA: Physics-Informed Neural networks for Advance modeling

repository·master·Indexed 21 days ago

https://github.com/mathlab/pina

A unified Python framework for Scientific Machine Learning (SciML) built on PyTorch, PyTorch Lightning, and PyTorch Geometric. PINA simplifies the development of Physics-Informed Neural Networks (PINNs), Neural Operators, and data-driven models through a four-step pipeline: Problem definition, Model design, Solver selection, and Training. It supports supervised learning, Graph Neural Networks (GNNs), and operator learning architectures like FNO and DeepONet.

Tokens
58K
Snippets
218
Records
266
Agent score
72%

What's inside PINA

  1. Overview of PINA modules and components

    master

    PINA is organized into several functional modules that support the differential equation solving pipeline:

    • Trainer, Data Loader and Data Module: Handles training loops, data loading, and data management (e.g., Trainer, Data Module, Aggregator).
    • Data Types: Core data structures like LabelTensor, Graph, and LabelBatch.
    • Graphs Structures: Tools for building graph representations, such as GraphBuilder, RadiusGraph, and KNNGraph.
    • Conditions: Defines constraints and requirements via the Condition interface (e.g., Domain Equation Condition, Time Series Condition).
    • Batch and Data Managers: Manages how data is batched and accessed (e.g., Batch Manager, Graph Data Manager).
    • Solvers: The core execution logic, ranging from Single-Model Solver to specialized Physics-Informed and Autoregressive solvers.
    • Mixins: Reusable logic components for solvers (e.g., Physics-Informed Mixin, Ensemble Mixin).
    • Models: Neural architectures including FeedForward, DeepONet, FNO (Fourier Neural Operator), and KAN (Kolmogorov-Arnold Network).
    • Blocks: Modular building blocks for models (e.g., Residual Block, Spectral Convolution Block, KAN Block).
    • Message Passing: Specialized blocks for graph-based learning (e.g., Interaction Network Block, E(n) Equivariant Network Block).
    • Reduction and Embeddings: Techniques for dimensionality reduction and feature embedding (e.g., POD Block, Fourier Feature Embedding).
    • Optimizers and Schedulers: Interfaces for optimization logic, including wrappers for Torch Optimizer and Torch Scheduler.
    • Adaptive Functions: Specialized activation functions (e.g., Adaptive ReLU, Adaptive Sine).
    • Equations and Differential Operators: Definitions for mathematical equations and operators.
    • Problems: High-level problem definitions (e.g., InverseProblem, ParametricProblem).
    • Geometrical Domains: Definitions of the spatial/temporal domains (e.g., CartesianDomain, SimplexDomain).
    • Domain Operations: Operations to manipulate domains like Union, Intersection, and Difference.
    • Callbacks: Hooks to modify training behavior (e.g., Switch Optimizer, Metric Tracker).
  2. Tutorials for Supervised Learning

    master

    PINA extends beyond physics-informed methods into general supervised learning for scientific data, including:

    • Graph Neural Networks (GNNs): Chemical property prediction and Reduced Order Modeling (ROM) for unstructured domains.
    • System Identification: Data-driven identification using SINDy.
    • Autoencoders: Unstructured Convolutional Autoencoders with continuous convolution.
    • Reduced Order Modeling (ROM): POD-RBF and POD-NN approaches for fluid dynamics.
  3. Tutorials for Physics Informed Neural Networks (PINNs)

    master

    PINA supports advanced Physics Informed Neural Network (PINN) workflows, including:

    • Basic PINNs: Introductory tutorials for standard PINN implementations.
    • Constraint Handling: Applying hard constraints and periodic boundary conditions (e.g., for Helmholtz problems).
    • Advanced Features: Enhancing PINNs for specific problems like Poisson or Wave equations.
    • Inverse Problems: Using PINNs to solve inverse problems where parameters are unknown.
    • Specialized Architectures: Using Fourier Feature Networks for multiscale PDEs or Deep Ensembles for bifurcating solutions.
  4. Use BaseCondition as a foundation for custom conditions

    master
    The BaseCondition class in pina.condition.base_condition serves as the abstract base class for all condition implementations within the library. When building custom logic to define constraints or requirements for a problem, you should inherit from BaseCondition to ensure compatibility with the Pina framework's execution engine.
  5. The PINA workflow pipeline

    master

    Solving differential problems in PINA follows a consistent four-step pipeline:

    1. Define the Problem: Use the Problem API to define the mathematical problem, identify constraints, and import data.
    2. Model Design: Build or customize a model using PyTorch, PyTorch Geometric, or the Model API.
    3. Solver Selection: Select or build a strategy using the Solver API.
    4. Training: Optimize the model using the Trainer API, which is powered by PyTorch Lightning.
  6. Use BaseWeighting as a foundation for custom weighting logic

    master

    In pina, BaseWeighting is the abstract base class used to implement custom weighting strategies. When you need to define how different components or parameters are weighted during the optimization or training process, you should subclass BaseWeighting and implement its required interface. This allows your custom logic to be integrated into the pina workflow seamlessly.

    from pina.weighting.base_weighting import BaseWeighting
    
    class MyCustomWeighting(BaseWeighting):
        # Implement required methods from BaseWeighting here
        pass
  7. Standard PINA Tutorial Workflow

    master

    PINA tutorials follow a structured pedagogical workflow designed to guide users from problem definition to error analysis. When working through a tutorial, expect the following sequence:

    1. Problem Definition: Understanding the scientific application or dataset.
    2. Data Generation/Loading: Loading datasets or generating simulation data, including visualization of the domain.
    3. Main Body (The PINA Workflow): A step-by-step implementation of the problem-solving process using PINA components (e.g., defining models, solvers, and training).
    4. Results and Analysis: Visualizing predictions against ground truth and quantifying performance using metrics like loss or relative error.
  8. PINA project disclosure and confidentiality policy

    master
    PINA operates under a No Confidentiality policy. Any information disclosed in connection with PINA activities—including meetings, contributions, and submissions—is considered non-confidential, regardless of any markings or statements to the contrary.
  9. Getting started with PINA

    master

    PINA provides a structured workflow for Scientific Machine Learning (SciML). To build a complete simulation or learning task, you should follow these core conceptual steps:

    1. Define the Problem: Specify the physical domain and the governing equations.
    2. Define the Model: Choose the neural architecture (e.g., PINNs, Neural Operators, or GNNs).
    3. Define the Solver: Select the optimization or integration strategy.
    4. Train: Execute the training loop using the Trainer class.

    For beginners, the following tutorial paths are recommended:

    • Foundations: Learn how to build a Problem, use Solver classes, and utilize the Trainer class.
    • Data Structures: Understand SciML-specific tensors like Tensor, LabelTensor, Data, and Graph.
    • Geometry: Learn to build domains using the DomainInterface class.
    • Equations: Learn to define physics using the PINA Equation class.
  10. Getting started with PINA core components

    master

    PINA provides several core classes and data structures for Scientific Machine Learning (SciML). To build a complete workflow, you should explore tutorials covering the following fundamental components:

    • Problem: The central object used to define the scientific problem.
    • Solver: Classes responsible for executing the optimization or solving process.
    • Trainer: The class used to manage the training loop.
    • Equation: The class used to define the governing equations.
    • BaseDomain: The class used for building physical domains.
    • Data Structures: PINA uses specific structures for SciML data, including Tensor, LabelTensor, Data, and Graph.