PhysicsInformedNeuralNetwork<T>
Models & Types · AiDotNet.PhysicsInformed.PINNs
Represents a Physics-Informed Neural Network (PINN) for solving PDEs.
Inheritance: NeuralNetworkBase<T> → PhysicsInformedNeuralNetwork<T>
Known derived types: DomainDecompositionPINN<T>, MultiFidelityPINN<T>
How It Works
For Beginners: A Physics-Informed Neural Network (PINN) is a neural network that learns to solve Partial Differential Equations (PDEs) by incorporating physical laws directly into the training process.
Traditional Approach (Finite Elements/Differences):
- Discretize the domain into a grid
- Approximate derivatives using neighboring points
- Solve a large system of equations
- Works well but can be slow for complex geometries
PINN Approach:
- Neural network represents the solution u(x,t)
- Use automatic differentiation to compute ∂u/∂x, ∂²u/∂x², etc.
- Train the network to minimize:
- PDE residual (how much the PDE is violated)
- Boundary condition errors
- Initial condition errors
- Data fitting errors (if measurements are available)
Key Advantages:
- Meshless: No need to discretize the domain
- Data-efficient: Can work with sparse or noisy data
- Flexible: Easy to handle complex geometries and boundary conditions
- Interpolation: Get solution at any point by evaluating the network
- Inverse problems: Can discover unknown parameters in the PDE
Key Challenges:
- Training can be difficult (multiple objectives to balance)
- May require careful tuning of loss weights
- Network architecture affects accuracy
- Computational cost during training (many derivative evaluations)
Applications:
- Fluid dynamics (Navier-Stokes equations)
- Heat transfer
- Structural mechanics
- Quantum mechanics
- Financial modeling (Black-Scholes PDE)
- Climate and weather modeling
Historical Context: PINNs were introduced by Raissi, Perdikaris, and Karniadakis in 2019. They’ve revolutionized scientific machine learning by showing that deep learning can be guided by physics rather than just data.
Example
var architecture = new NeuralNetworkArchitecture<float>(
inputType: InputType.OneDimensional,
taskType: NeuralNetworkTaskType.Regression,
inputSize: 2, outputSize: 1);
var pde = new HeatEquation<float>();
// No IBoundaryCondition implementation ships with the library: write your own with
// IsOnBoundary, ComputeBoundaryResidual and Name, then put instances in this array.
var bc = Array.Empty<IBoundaryCondition<float>>();
var pinn = new PhysicsInformedNeuralNetwork<float>(architecture, pde, bc);
Constructors
| Constructor | Summary |
|---|---|
PhysicsInformedNeuralNetwork(NeuralNetworkArchitecture<T> architecture, IPDESpecification<T> pdeSpecification, IBoundaryCondition<T>[] boundaryConditions, IInitialCondition<T> initialCondition, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, PhysicsInformedNeuralNetworkOptions options) |
Initializes a new instance of the PINN class. |
Properties
| Property | Summary |
|---|---|
Tensor<T> CollocationPoints { get; } |
Gets the collocation points the PDE residual is enforced at, [numPoints, inputDim]. |
bool SupportsTraining { get; } |
Serializes PINN-specific data. |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
Gets metadata about the PINN model. |
T EvaluatePDEResidual(Vector<T> point) |
Evaluates the PDE residual at a point (for validation). |
Tensor<T> Forward(Tensor<T> input) |
Performs a forward pass through the network. |
Vector<T> GetSolution(Vector<T> point) |
Gets the solution at a specific point in the domain. |
void SetCollocationPoints(Tensor<T> points) |
Sets custom collocation points (for advanced users who want specific sampling). |