MultiScalePINN<T>
Models & Types · AiDotNet.PhysicsInformed.PINNs
Implements a Multi-Scale Physics-Informed Neural Network for solving PDEs with multiple scales.
Inheritance: NeuralNetworkBase<T> → MultiScalePINN<T>
How It Works
For Beginners: Multi-scale problems are challenging because features span vastly different sizes. A single neural network struggles to capture both large-scale trends and fine details.
Solution: Multi-Scale PINN Uses multiple sub-networks, each specialized for a different scale:
- Coarse network: Captures large-scale, smooth variations
- Fine network(s): Capture small-scale details and fluctuations
Architecture: Input (x,t) → [Coarse Net] → u_coarse(x,t) → [Fine Net 1] → u_fine1(x,t) → [Fine Net 2] → u_fine2(x,t) → …
Total solution: u(x,t) = u_coarse + u_fine1 + u_fine2 + …
Training Strategy:
- Progressive Training: Train coarse first, then add finer scales
- Simultaneous Training: Train all scales together with adaptive weights
- Alternating Training: Alternate between scales during training
Key Features:
- Fourier feature encoding at different frequencies for each scale
- Adaptive loss weighting to balance scale contributions
- Scale coupling terms to ensure consistency
- Progressive activation of finer scales during training
Applications:
- Turbulence modeling (large eddies + small vortices)
- Composite materials (macroscopic + fiber-scale behavior)
- Multi-physics problems (thermal + mechanical + chemical)
- Climate modeling (global + regional + local scales)
Example
var architecture = new NeuralNetworkArchitecture<double>(
InputType.OneDimensional, NeuralNetworkTaskType.Regression,
inputSize: 2, outputSize: 1);
// The same physics at a coarse and a fine length scale, coupled where they overlap.
var pde = new MultiScaleReactionDiffusion<double>(
coarseDiffusivity: 1.0,
fineDiffusivity: 0.01);
// Held at zero on both edges of the domain.
var boundaryConditions = new IBoundaryCondition<double>[]
{
new DirichletBoundaryCondition<double>(boundaryValue: 0.0, lowerBound: 0.0, upperBound: 1.0)
};
var msPinn = new MultiScalePINN<double>(architecture, pde, boundaryConditions);
Constructors
| Constructor | Summary |
|---|---|
MultiScalePINN(NeuralNetworkArchitecture<T> architecture, IMultiScalePDE<T> multiScalePDE, IBoundaryCondition<T>[] boundaryConditions, IInitialCondition<T> initialCondition, MultiScaleTrainingOptions<T> trainingOptions, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, MultiScalePINNOptions options) |
Initializes a new instance of the Multi-Scale PINN. |
Properties
| Property | Summary |
|---|---|
T[] ScaleCharacteristicLengths { get; } |
Gets the characteristic length scales. |
bool SupportsTraining { get; } |
|
int NumberOfScales { get; } |
Gets the number of scales in this multi-scale PINN. |
Methods
| Method | Summary |
|---|---|
ModelMetadata<T> GetModelMetadata() |
|
Tensor<T> Forward(Tensor<T> input) |
Forward pass through all scale networks: the sum of the active scales’ outputs. |
Tensor<T> ForwardForTraining(Tensor<T> input) |
|
Tensor<T> ForwardWithMemory(Tensor<T> input) |
|
TrainingHistory<T> Solve(int epochs, double learningRate, bool verbose) |
Solves the multi-scale PDE using physics-informed training. |
Vector<T> GetGradients() |