LaTex2Web logo

Documents Live, a web authoring and publishing system

If you see this, something is wrong

Table of contents

First published on Tuesday, Jun 2, 2026 and last modified on Friday, Jun 5, 2026 by François Chaplais.

A study of Physics-Informed Neural Networks

François Chaplais WebMagic

1 Introduction


\[ \frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2} \]
\[ u_t - \alpha u_{xx} \neq 0 \]

\[ \mathcal{L}_{data} = \sum |u_{pred} - u_{true}|^2 \]
\[ \mathcal{L}_{physics} = \sum |f(x,t)|^2 \]
\[ f(x,t) = u_t - \alpha u_{xx} \]
\[ \mathcal{L}_{BC} = \sum |u_{pred} - u_{boundary}|^2 \]
\[ \mathcal{L} = \mathcal{L}_{data} + \mathcal{L}_{physics} + \mathcal{L}_{BC} \]






\[ u'(x) = -u(x), ~ u(0)=1 \]
\[ u(x)=e^{-x} \]

\[ \frac{du}{dx} + u = 0 \]
\[ u(0)=1 \]

import torch
import torch.nn as nn
import torch.optim as optim
import matplotlib.pyplot as plt

# -----------------------------
# Neural network
# -----------------------------
class PINN(nn.Module):
    def __init__(self):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(1, 20),
            nn.Tanh(),
            nn.Linear(20, 20),
            nn.Tanh(),
            nn.Linear(20, 1)
        )

    def forward(self, x):
        return self.net(x)

# -----------------------------
# Create model
# -----------------------------
model = PINN()

# Optimizer
optimizer = optim.Adam(model.parameters(), lr=0.01)

# -----------------------------
# Training loop
# -----------------------------
for epoch in range(5000):
    optimizer.zero_grad()

    # Collocation points inside the domain [0, 1]
    x_phys = torch.rand(100, 1, requires_grad=True)

    # Network prediction
    u = model(x_phys)

    # Compute du/dx using autograd
    du_dx = torch.autograd.grad(
        u,
        x_phys,
        grad_outputs=torch.ones_like(u),
        create_graph=True
    )[0]

    # Physics residual: u' + u = 0
    physics_residual = du_dx + u
    physics_loss = torch.mean(physics_residual**2)

    # Boundary condition u(0) = 1
    x_bc = torch.tensor([[0.0]])
    u_bc = model(x_bc)
    bc_loss = (u_bc - 1.0)**2

    # Total loss
    loss = physics_loss + bc_loss

    loss.backward()
    optimizer.step()

    if epoch         print(f"Epoch {epoch}, Loss: {loss.item():.6f}")

# -----------------------------
# Test and plot
# -----------------------------
x_test = torch.linspace(0, 1, 100).reshape(-1, 1)
u_pred = model(x_test).detach().numpy()

u_exact = torch.exp(-x_test).numpy()

plt.plot(x_test.numpy(), u_pred, label="PINN prediction")
plt.plot(x_test.numpy(), u_exact, "--", label="Exact solution")
plt.legend()
plt.xlabel("x")
plt.ylabel("u(x)")
plt.title("PINN solving u'(x) = -u(x), u(0)=1")
plt.show()


\[ u'(x) + u(x) = 0 \]
physics_residual = du_dx + u

\[ u(0)=1 \]
x_bc = torch.tensor([[0.0]])
u_bc = model(x_bc)
bc_loss = (u_bc - 1.0)**2

loss = physics_loss + bc_loss


\[ e^{-x} \]

\[ u_t = u_{xx} \]

2 Proposed bibliography

3 The plan

@misc{babić2026differentiablechemistrypinnssolving,
      title={Differentiable Chemistry in PINNs for Solving Parameterized and Stiff Reaction Systems}, 
      author={Miloš Babić and Franz M. Rohrhofer and Stefan Posch},
      year={2026},
      eprint={2605.04708},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2605.04708}, 
}