PHYSICS-INFORMED LEARNING · A WORKED INTRODUCTION

A curve that learns
to obey an equation.

A PINN is an adjustable mathematical function trained to match the information we give it, including physical equations. Let us build that idea one step at a time.

FIRST, AN ORDINARY FIT

A model, its parameters and the data.

Suppose we measure grain size and yield strength. The Hall–Petch model supplies a particular rule:

\[\widehat\sigma_y(d)=\sigma_0+k d^{-1/2}.\]

Ordinary least squares chooses two numbers, σ₀ and k, to reduce the squared differences between predictions and measurements. The fitting procedure does not invent the Hall–Petch relation: we supplied its form and its physical interpretation.

In the accompanying notebook, 500 synthetic observations follow the ordinary branch and 10 small-grain observations follow a softening branch. Removing those ten points can make the fit look excellent while hiding another regime. A small fitting error only speaks about the data and range actually examined.

A MORE FLEXIBLE FUNCTION

What is the neural network?

Think of a curve with many adjustable knobs. A neural network combines simple operations (multiplication, addition and applying a nonlinear function) to make that curve flexible. Its weights and biases are the knobs. Together we call them θ.

\[x\ \longrightarrow\ u_\theta(x),\qquad h=\tanh(wx+b).\]

The first expression means “give the network a position; receive a predicted value.” The second shows one small building block. Evaluating the network is a forward calculation. Training is the separate process of changing its knobs to reduce an error. A flexible fitted curve does not, by itself, identify a physical mechanism.

THE PHYSICS TEST

The equation does not know the boundary values.

Consider steady diffusion in one dimension, with constant diffusivity and no sources. In dimensionless form, the field must satisfy:

\[-u''(x)=0,\quad 0<x<1,\qquad u(0)=0,\quad u(1)=1.\]

The equation says the curvature is zero. Every straight line passes that test, regardless of its slope or offset! The two boundary values select one particular line, \(u(x)=x\).

Three knobs. Two independent tests.

\[u_{a,b,c}(x)=ax+b+cx(1-x),\qquad r(x)=-u''(x)=2c.\]

Here a sets the linear slope, b shifts the field, and c adds curvature. This small trial function illustrates the loss; it is not a neural network being trained in your browser.

CheckMean squared error
Equation at 64 interior points
Two endpoint values

Blue: trial field. Dashed gray: exact reference u = x. Green rings: required endpoint values. Orange: residual, on a fixed scale. Each button loads a complete example, so its meaning stays the same whatever you clicked before.

\[\mathcal L_f=4c^2,\qquad \mathcal L_b=\frac{b^2+(a+b-1)^2}{2}.\]

Equation only: c = 0 makes any straight line pass, even with incorrect endpoints. Boundaries only: a = 1 and b = 0 fix both endpoints, but leave c free. Both tests pass only when a = 1, b = 0 and c = 0.

A network can be designed to satisfy boundary values automatically, for example \(u_\theta=x+x(1-x)N_\theta(x)\). That is a deliberate constraint in its construction. It does not mean that the differential equation supplies the boundary values.

HOW TRAINING WORKS

Predict, check, adjust, repeat.

A real PINN replaces the three-knob curve with a network containing many weights and biases. Automatic differentiation applies the chain rule to that network expression to calculate its derivatives. It does not supply the unknown exact solution.

  1. Evaluate the network at the chosen positions.
  2. Calculate equation residuals and errors in boundary or initial values. Compare with measurements when available.
  3. Combine squared errors into a loss.
  4. Differentiate that loss with respect to the adjustable parameters, then let an optimizer update them.
\[\mathcal L=w_f\langle r_\theta^2\rangle+w_b\mathcal L_{\mathrm{boundary}}+w_i\mathcal L_{\mathrm{initial}}+w_d\mathcal L_{\mathrm{data}}.\]

Only include terms needed for the problem. This steady diffusion example has no initial condition and needs no interior solution labels. The weights balance numerical terms; they are not material constants. Variables and residuals should be scaled sensibly before comparing their sizes.

The notebook uses a different problem: \(-u^{\prime\prime}=\pi^2\sin(\pi x)\), with zero values at both ends. It uses tanh hidden layers, 64 training collocation points and separate coordinates for validation. It compares the final field with the known answer sin(πx). A low training residual is not enough: check unsampled points, boundary errors and the solution against an independent reference. Optimization can fail, and an incorrect equation can produce a convincingly wrong result.

See the essential PyTorch calculation
x = x.detach().clone().requires_grad_(True)
u = model(x)
ux = torch.autograd.grad(u, x, torch.ones_like(u),
                         create_graph=True)[0]
uxx = torch.autograd.grad(ux, x, torch.ones_like(ux),
                          create_graph=True)[0]
r = -uxx - torch.pi**2 * torch.sin(torch.pi*x)
loss = (r**2).mean() + w_boundary * (model(x_boundary)**2).mean()
optimizer.zero_grad()
loss.backward()
optimizer.step()

This excerpt assumes the model, coordinates, loss weight and optimizer have already been defined. The downloadable notebook supplies the complete setup.

THE INVERSE QUESTION

Can we learn the diffusivity too?

Forward: given the diffusivity and the initial and boundary conditions, predict how concentration evolves. Inverse: given measured concentration profiles and suitable conditions, infer the diffusivity within an assumed model family.

\[\frac{\partial c}{\partial t}=\frac{\partial}{\partial x}\left[\widetilde D(c;\boldsymbol\alpha)\frac{\partial c}{\partial x}\right].\]

Now there are two fitted objects. The network weights θ describe a smooth concentration profile. Separate coefficients α describe the diffusivity. The diffusion equation links them. Neither object should be mistaken for the other.

A simple example of missing information: in the steady diffusion experiment above, any positive constant diffusivity gives the same straight concentration profile. The diffusivity cancels from the steady equation. A flux measurement or time-dependent data would supply information that this profile alone cannot provide.

The notebook’s staged example

  1. Choose the constitutive family. Use \(\widetilde D(c)=D_0e^{-Q(c)/(RT)}\Phi(c)\), with \(Q(c)=a_0+a_1c+a_2c^2\). Here D₀, temperature and the thermodynamic factor are supplied; three coefficients are inferred.
  2. Represent the observed profile. Locate the Matano plane and use the similarity coordinate \(\lambda=(x-x_M)/\sqrt t\). Under the diffusion-couple similarity assumptions, learn one profile \(c_\theta(\lambda)\).
  3. Fit the profile first. This gives the coupled optimization a useful starting point.
  4. Add the transformed diffusion equation. Adjust the profile network and the constitutive coefficients using profile, terminal-value and equation errors.
  5. Add three independent diffusivity measurements. Repeat from the same pretrained profile and compare the inferred diffusivity curves, not just how well the concentration fits.
The equation after the change of coordinate
\[-\frac{\lambda}{2}\frac{dc}{d\lambda}=\frac{d}{d\lambda}\left(\widetilde D(c)\frac{dc}{d\lambda}\right).\]

This similarity reduction assumes the appropriate diffusion-couple setting, including a composition-dependent diffusivity at fixed temperature and compatible initial and far-field conditions. The notebook also scales λ for training; derivative scale factors must be retained.

Pose it as multiobjective optimization.

We ask the same model to do several things: fit measured concentrations, satisfy the diffusion equation, respect the initial and boundary conditions, and reproduce independent diffusivity measurements when available. Each requirement gives a separate objective.

\[\min_{\boldsymbol\theta,\boldsymbol\alpha}\left(\widehat{\mathcal L}_{\mathrm{profile}},\;\widehat{\mathcal L}_{\mathrm{equation}},\;\widehat{\mathcal L}_{\mathrm{conditions}},\;\widehat{\mathcal L}_{\mathrm{diffusivity}}\right).\]

The hats indicate that the errors are scaled to meaningful, dimensionless quantities. The network parameters \(\boldsymbol\theta\) describe the concentration field; \(\boldsymbol\alpha\) describes the composition-dependent diffusivity at the specified temperature. For the Boltzmann similarity example, the conditions include the terminal compositions and the assumptions that permit the similarity reduction.

A weighted sum is one way to solve this problem: minimize \(\mathcal L=\sum_j w_j\widehat{\mathcal L}_j\). This is the approach used in the teaching notebook. A multiobjective method can instead explore a set of compromises: a Pareto-optimal solution is one for which improving an objective requires worsening at least one other objective. The notebook does not compute a Pareto front.

The weights and error scales affect the answer, especially with noisy or incomplete data. Inspect every objective separately and check parameter sensitivity and uncertainty. A small combined loss does not establish a unique diffusivity or replace validation with independent diffusion couples.

A good profile fit is not proof of a unique diffusivity.

Finite, noisy profiles and limited sampling can leave the diffusivity parameters weakly constrained. Independent diffusivity measurements provide additional information; they do not guarantee uniqueness. In an ideal scalar binary problem, an exact sufficiently resolved similarity profile and the required assumptions can support classical diffusivity reconstruction. The practical uncertainty here should not be mistaken for a claim that every binary inverse problem is fundamentally non-unique.

Stay within the Boltzmann-scaling regime. At a fixed temperature, the model uses \(\widetilde D(c;T)\), with no explicit dependence on annealing time. Profiles from the same diffusion couple at different times should collapse when plotted against \(\lambda=(x-x_M)/\sqrt t\), within experimental uncertainty and the similarity assumptions. Additional times check this scaling and experimental consistency; they do not imply a different diffusivity at each time.

Validate with additional diffusion couples. Use independent couples to test the recovered composition dependence, check parameter sensitivity and uncertainty, and verify the inferred coefficients with an independent forward solver. Alternating points from one measured profile mainly tests interpolation.

One temperature gives isothermal coefficients at that temperature. Diffusion measurements at several temperatures are needed to establish temperature dependence and infer activation parameters. Writing the fitted coefficients in an Arrhenius-like form at a single temperature does not, by itself, establish their temperature dependence. In the synthetic notebook the true diffusivity curve is available for checking; experimental validation requires independent evidence.

FROM A PROFILE TO DIFFUSION PHYSICS

Which diffusivity have we learned?

The research papers discussed below are collaborative work. The teaching codes on this page and in the downloadable notebook are mine. Our collaborative work with Prof. Aloke Paul’s Diffusion–Microstructure–Properties group at IISc connects diffusion experiments with PINN inverse modeling. Prof. Paul’s group leads the experimental diffusion studies and measurements; my group at IIT Hyderabad develops the PINN and numerical inverse-modeling methods.

Interdiffusion, intrinsic diffusion and tracer diffusion are different quantities. A concentration profile constrains the combined transport. Reproducing it does not automatically establish the individual atomic mobilities. Additional measurements must constrain the particular coefficients we want to learn.

What Hemanth’s work showed

Hemanth’s work on NiCoFeCr showed that reproducing concentration profiles and interdiffusion coefficients does not necessarily recover the correct intrinsic diffusivities. The initial optimization matched the profiles and interdiffusion coefficients, but the inferred intrinsic coefficients disagreed with experiment. Including measured intrinsic diffusivities at the Kirkendall plane supplied the additional constraints. The lesson is to check the coefficients we want to learn, not just the profile they reproduce.

Hemanth Kumar, Anuj Dash, Aloke Paul and Saswata Bhattacharyya. A physics-informed neural network-based numerical inverse method for optimization of diffusion coefficients in NiCoFeCr multi principal element alloy. Scripta Materialia 214 (2022), 114639.

Further reading: Hemanth Kumar, Neelamegan Esakkiraja, Anuj Dash, Aloke Paul and Saswata Bhattacharyya, Utilising physics-informed neural networks for optimisation of diffusion coefficients in pseudo-binary diffusion couples. Philosophical Magazine 103 (2023), 1717–1737.

What Suman’s work demonstrated

Suman’s work on NiCoFeCrMn demonstrated how strategically designed diffusion couples, combined with PINN inverse modeling, can recover composition-dependent diffusion coefficients over a broad composition range. The method brings together measured concentration profiles, independent diffusivity information and the governing diffusion equations. The result shows why experimental design matters: the measurements must provide the information needed to constrain the inverse model.

Suman Sadhu, Saswata Bhattacharyya and Aloke Paul. Extracting composition-dependent diffusion coefficients over a very large composition range in NiCoFeCrMn high entropy alloy following strategic design of diffusion couples and physics informed neural network numerical method. Acta Materialia 302 (2026), 121649. Read the open preprint ↗

The question to ask: what independent information would distinguish two mobility models that both reproduce my profile?

WHAT CHANGES WITH AN OPERATOR?

One field, or a family of problems?

MethodWhat it representsWhat teaches it
OLSCoefficients in a chosen basisObserved input–output pairs
Ordinary NNA flexible functionUsually observed pairs
PINNUsually one solution field, coordinates → valuesEquation, conditions, optional measurements
FNOA map from input fields to solution fieldsPaired solved examples across a family
PINOA solution operator across a familyEquation information and possibly solved examples

The notebook’s FNO learns forcing field → Poisson solution field. Its PINO adds an equation residual to the same operator architecture. Fourier layers alone do not make a model physics-informed. For operator-assisted inversion, freeze the trained operator and adjust its input parameters; check the recovered answer with the original solver.

Inverse design goes one step further: choose material or process settings to achieve a desired performance. That is a different question from identifying diffusivity. It can use surrogates and optimization, but it is not automatically a PINN.

READ · EXPERIMENT · CHECK

Work through the notebook.

I wrote the teaching codes in my OLS → NN → PINN → FNO → PINO notebook for my AI4SE/IISc teaching. I prepared this sequence to explain how regression, neural networks and physical equations can be used to solve forward and inverse problems. This page introduces the steps before you run the notebook.

Download the teaching notebook ↓

Open it in Jupyter, or upload it to Google Colab, and run cells in order. It uses NumPy, Matplotlib and PyTorch; a GPU is optional. Saved outputs have been cleared for a fresh run. I executed the notebook from beginning to end, and it passed its implementation checks.

The steady diffusion exercise above illustrates the logic of a PINN. The notebook contains the actual neural-network implementations and the more demanding inverse calculation.

Foundational reading: Raissi, Perdikaris and Karniadakis: Physics Informed Deep Learning. Continue to PINN inverse modeling in my research.