Code from: Physics-constrained neural networks for direct parameter identification under model-form uncertainty
Data files
Jul 17, 2026 version files 939.81 KB
-
attpin_lite.py
58 KB
-
model_additive.pt
831.14 KB
-
pbdw_attpin_lite.py
44.28 KB
-
README.md
6.34 KB
-
requirements.txt
45 B
Abstract
This deposit contains the core implementation of the PBDW-AttPIN framework, which combines the Parameterized-Background Data-Weak (PBDW) formulation with an attention-based physics-informed neural network for real-time parameter estimation of systems under model bias ("unknown unknowns").
The code accompanies the article:
Y. Sungtaek Ju, "Physics-Constrained Neural Networks for Direct Parameter Identification under Model-Form Uncertainty," Machine Learning: Science and Technology (2026).
The Python code files and associated data files can be used to replicate the results in the article for the thermoacoustic system. The framework can also be extended by the broad scientific and engineering communities to study and model other problems and systems. We do not anticipate any legal or ethical issues associated with the deposit.
This deposit contains the core implementation of the PBDW-AttPIN framework, which combines the Parameterized-Background Data-Weak (PBDW) formulation with an attention-based physics-informed neural network for real-time parameter estimation of thermoacoustic systems under model bias ("unknown unknowns").
Parameter identification in nonlinear dynamical systems is complicated by model-form uncertainty arising from systematic biases that violate the zero-mean error assumption of standard data assimilation methods. Recent neural-network-based approaches learn arbitrary bias corrections online. However, they require careful regularization to ensure unique solutions and carry computational overhead from ensemble propagation and in-situ training. The code in the deposit implements a framework that integrates the Parametrized-Background Data-Weak (PBDW) formulation with attention-based parameter identification networks (AttPIN). It projects model error onto a dictionary of physically motivated spatial templates rather than learning arbitrary corrections. This provides uniqueness through hard subspace constraints rather than soft regularization penalties, albeit at the cost of restricting the representable bias space to patterns anticipated from domain knowledge.
The framework is demonstrated on parameter estimation in the Rijke tube model, achieving robust generalization to out-of-distribution bias patterns not seen during training. Ablation studies confirm the importance of state supervision for amplitude-sensitive parameters and temporal bias modeling for phase-sensitive parameters. Performance degrades gradually when bias patterns lie outside the template span. This indicates that the attention encoder extracts parameter information from bias-invariant features rather than relying critically on template-based bias capture. The physics-constrained and universal approximator approaches represent complementary points on the flexibility--efficiency tradeoff, suited to different operational contexts.
The code accompanies the article:
Y. Sungtaek Ju, "Physics-Constrained Neural Networks for Direct Parameter Identification under Model-Form Uncertainty," Machine Learning: Science and Technology (2026).
Please cite the article when using this code.
Contents
| File | Description |
|---|---|
attpin_lite.py |
Base module: attention-based neural architecture (window encoder → attention → decoder) and Rijke tube data generator with a self-contained Galerkin/Chebyshev solver. |
pbdw_attpin_lite.py |
Main framework: POD background basis, PBDW state decomposition, physics-informed bias template library (with optional orthogonalization), residual-based additive bias estimation, optional multiplicative gain estimation, training loop, and command-line interface. |
model_additive.pt |
Trained model checkpoint used to produce the results reported in the article. |
requirements.txt |
Python package dependencies. |
Requirements
- Python ≥ 3.9
- PyTorch, NumPy, Matplotlib
pip install -r requirements.txt
The code runs on CPU; a CUDA-capable GPU is used automatically if available.
Usage
Load the trained checkpoint and run a quick test
python pbdw_attpin_lite.py --load model_additive.pt
This loads the deposited model and evaluates it on freshly generated test trajectories, reporting β and τ estimation errors.
Train a model from scratch (configuration used in the article)
python pbdw_attpin_lite.py --n-train 300 --epochs 400 --save model.pt --seed 42
This reproduces the training setup reported in the article: 300 training trajectories with parameters sampled uniformly over β ∈ [2.5, 5.0] and τ ∈ [1.0, 2.0] ms, biases injected according to the five template patterns at 20% of signal amplitude, and observation noise σ = 0.1. The default configuration matches the published model: residual-based additive bias estimation enabled, multiplicative gain estimation and template orthogonalization disabled.
Programmatic use
from pbdw_attpin_lite import PBDWAttPINLiteConfig, train_pbdw_attpin_lite, load_pbdw_attpin_lite
# Train
config = PBDWAttPINLiteConfig()
model = train_pbdw_attpin_lite(config=config, n_train=300, n_epochs=400,
save_path="model.pt", seed=42)
# Load and infer
model = load_pbdw_attpin_lite("model.pt")
outputs = model(y_windows) # returns β, τ, POD coefficients z(t), bias coefficients α(t)
Configuration options
Key options in PBDWAttPINLiteConfig (see the dataclass definitions in the source for the full list):
use_residual_bias(defaultTrue): estimate the additive bias from the observation residual rather than the raw signal.use_state_dependent_bias(defaultFalse): additionally estimate a time-varying multiplicative gain g(t).orthogonalize_templates(defaultFalse): project the bias templates onto the orthogonal complement of the POD background space. This variant is analyzed in the article; the published primary results use the default (non-orthogonalized) templates, which preserve the physical interpretability of the template coefficients.
Data generation
Training and test data are generated on the fly by the Rijke tube simulator in attpin_lite.py; no external datasets are required. Optionally, if the public repository accompanying Novoa, Racca & Magri (2024), real-time-bias-aware-DA, is placed in or adjacent to the working directory, the data generator will use that solver instead of the built-in one; otherwise it falls back automatically to the equivalent standalone implementation.
