CausalPINN#
- class CausalPINN(problem, model, extra_features=None, loss=MSELoss(), optimizer=<class 'torch.optim.adam.Adam'>, optimizer_kwargs={'lr': 0.001}, scheduler=<class 'torch.optim.lr_scheduler.ConstantLR'>, scheduler_kwargs={'factor': 1, 'total_iters': 0}, eps=100)[source]#
Bases:
PINN
Causal Physics Informed Neural Network (PINN) solver class. This class implements Causal Physics Informed Neural Network solvers, using a user specified
model
to solve a specificproblem
. It can be used for solving both forward and inverse problems.The Causal Physics Informed Network aims to find the solution \(\mathbf{u}:\Omega\rightarrow\mathbb{R}^m\) of the differential problem:
\[\begin{split}\begin{cases} \mathcal{A}[\mathbf{u}](\mathbf{x})=0\quad,\mathbf{x}\in\Omega\\ \mathcal{B}[\mathbf{u}](\mathbf{x})=0\quad, \mathbf{x}\in\partial\Omega \end{cases}\end{split}\]minimizing the loss function
\[\mathcal{L}_{\rm{problem}} = \frac{1}{N_t}\sum_{i=1}^{N_t} \omega_{i}\mathcal{L}_r(t_i),\]where:
\[\mathcal{L}_r(t) = \frac{1}{N}\sum_{i=1}^N \mathcal{L}(\mathcal{A}[\mathbf{u}](\mathbf{x}_i, t)) + \frac{1}{N}\sum_{i=1}^N \mathcal{L}(\mathcal{B}[\mathbf{u}](\mathbf{x}_i, t))\]and,
\[\omega_i = \exp\left(\epsilon \sum_{k=1}^{i-1}\mathcal{L}_r(t_k)\right).\]\(\epsilon\) is an hyperparameter, default set to \(100\), while \(\mathcal{L}\) is a specific loss function, default Mean Square Error:
\[\mathcal{L}(v) = \| v \|^2_2.\]See also
Original reference: Wang, Sifan, Shyam Sankaran, and Paris Perdikaris. “Respecting causality for training physics-informed neural networks.” Computer Methods in Applied Mechanics and Engineering 421 (2024): 116813. DOI 10.1016.
Note
This class can only work for problems inheriting from at least
TimeDependentProblem
class.- Parameters:
problem (AbstractProblem) – The formulation of the problem.
model (torch.nn.Module) – The neural network model to use.
loss (torch.nn.Module) – The loss function used as minimizer, default
torch.nn.MSELoss
.extra_features (torch.nn.Module) – The additional input features to use as augmented input.
optimizer (torch.optim.Optimizer) – The neural network optimizer to use; default is
torch.optim.Adam
.optimizer_kwargs (dict) – Optimizer constructor keyword args.
scheduler (torch.optim.LRScheduler) – Learning rate scheduler.
scheduler_kwargs (dict) – LR scheduler constructor keyword args.
eps (int | float) – The exponential decay parameter. Note that this value is kept fixed during the training, but can be changed by means of a callback, e.g. for annealing.
- loss_phys(samples, equation)[source]#
Computes the physics loss for the Causal PINN solver based on given samples and equation.
- Parameters:
samples (LabelTensor) – The samples to evaluate the physics loss.
equation (EquationInterface) – The governing equation representing the physics.
- Returns:
The physics loss calculated based on given samples and equation.
- Return type:
- property eps#
The exponential decay parameter.