Physics-Informed AI · Lesson 4 of 6
Adding a Physics Constraint
~15 min
The Concept
Time to fix it. Your supervisor's approach: instead of throwing away the flexible model, blend it with a version that is forced to obey Darcy's Law, a hybrid that can still bend to fit real local variation, but can never produce a physically impossible curve.
A physics-informed model adds a penalty, sometimes called a physics loss (a scorekeeping rule that punishes the model for breaking a known physical law), that punishes the model whenever its predictions violate the governing equation, alongside the usual penalty for missing the data. The model then has to satisfy both: match the observations reasonably well, and never violate the physics, even between measurements where you have no data at all.
The Analogy
It is like grading a student on two things at once: did they get the right answer, and did they show their work following the actual rules of math. A student who gets the right number by breaking the rules still loses points. The model is graded the same way, on fitting the data and on respecting the physics.
The Math (optional)
A physics-informed loss function adds a physics penalty term to the ordinary data-fitting loss:
Physics-informed loss
Total loss combines how well predictions match observed data with how much the predictions violate Darcy's Law, weighted by λ, the physics constraint weight you'll control in the simulation below.
Try It
Drag the physics constraint weight from 0 (data only) toward 1 (fully physics-constrained) and watch the impossible curve disappear.
At weight 0, the curve fits only the eight noisy points — with so little data it can bend upward, which is physically impossible for steady flow to a pumping well. Increasing the weight blends in Darcy's Law's monotonic drawdown shape as a constraint.
Why Real Researchers Care
This λ-weighted combination is exactly the structure used in real Physics-Informed Neural Networks (PINNs), a technique now used in hydrology, climate modelling, and materials science to combine sparse real-world measurements with known governing equations.
Quick Check
Q1. What happens as λ (the physics weight) increases toward 1 in the simulation?
Your Goal
Find the smallest physics weight in the simulation where the warning message changes from a violation to a valid, monotonic curve. What does that tell you about how much physics constraint this particular dataset needs?
Hint: You're looking for the tipping point, not the extreme ends of the slider.
Teach It Back
Explain to a non-technical stakeholder why 'blending in physics' produces a more trustworthy model than either pure data-fitting or pure physics alone.