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.
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 θ.
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:
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\).
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.
Check
Mean 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.
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.
Evaluate the network at the chosen positions.
Calculate equation residuals and errors in boundary or initial values. Compare with measurements when available.
Combine squared errors into a loss.
Differentiate that loss with respect to the adjustable parameters, then let an optimizer update them.
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.
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.
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
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.
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)\).
Fit the profile first. This gives the coupled optimization a useful starting point.
Add the transformed diffusion equation. Adjust the profile network and the constitutive coefficients using profile, terminal-value and equation errors.
Add three independent diffusivity measurements. Repeat from the same pretrained profile and compare the inferred diffusivity curves, not just how well the concentration fits.
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.
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.
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.
The question to ask: what independent information would distinguish two mobility models that both reproduce our profile?
WHAT CHANGES WITH AN OPERATOR?
One field, or a family of problems?
Method
What it represents
What teaches it
OLS
Coefficients in a chosen basis
Observed input–output pairs
Ordinary NN
A flexible function
Usually observed pairs
PINN
Usually one solution field, coordinates → values
Equation, conditions, optional measurements
FNO
A map from input fields to solution fields
Paired solved examples across a family
PINO
A solution operator across a family
Equation 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. We 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.
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.
Technical details
We 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.