Leanpub Header

Skip to main content

Physics-Informed Machine Learning: A Practical Guide

The instructor has published 100% of this course.Last updated on 2026-11-20

Minimum price

$39.00

$69.00

You pay

Author earns

$

Also available for 1 course credit with a Learner Membership

PDF
EPUB
WEB
About

About

About the Course

Share this course

Instructor

About the Instructor

Kompri

Kompri is an academic, author, investor, and educator based in Jambi, Indonesia. He holds a doctorate in Education Management and a bachelor’s degree in Physics, and has written and published dozens of books along with numerous other scholarly works. An avid reader, he is one of today’s most productive researchers. Alongside his academic career, he publishes both theoretical and practical books for readers around the world. His work rests on one conviction: knowledge is most valuable when it is clear, usable, and shared, so that anyone, in any country, can put it to work.

Material

Course Material

  • Welcome to the Course

  • How the Course Works

  • Using the Code

  • Earning the Certificate

  • Chapter 1: Why Physics-Informed Machine Learning?

  • 1.1 The Black-Box Problem: When Pure Machine Learning Meets Science

  • How a black box breaks physics

  • The real problem is missing information

  • Why physics makes data go further

  • 1.2 A Short History: From Early Neural Solvers to Modern Scientific Machine Learning

  • The early work

  • What changed

  • The modern synthesis

  • The wider landscape

  • 1.3 PIML vs. Pure Machine Learning vs. Classical Numerical Simulation

  • Classical numerical simulation

  • Pure machine learning

  • Physics-informed machine learning

  • Inverse problems: the natural home

  • These tools are not mutually exclusive

  • The economics of a trained model

  • 1.4 Roadmap and Prerequisites

  • How the book is organized

  • A thread to follow

  • A note on notation and code

  • What this book is not

  • How to get the most out of this book

  • Lesson 1 Quiz

    10 attempts allowed

  • Chapter 2: Essential Mathematics — PDEs, Optimization, and Automatic Differentiation

  • 2.1 A Review of the PDEs You’ll Meet — Heat, Wave, and Diffusion

  • The heat and diffusion equation

  • From one dimension to several

  • The wave equation

  • Why classification matters

  • Linear and nonlinear, and a look ahead

  • 2.2 Boundary and Initial Conditions: The Other Half of the Problem

  • Initial conditions

  • Boundary conditions

  • Well-posedness, and why you should check it first

  • A complete problem, written out

  • How conditions enter a PINN

  • 2.3 Automatic Differentiation: The Engine Under the Hood

  • Three ways to compute a derivative, two of them traps

  • The idea: a graph of elementary operations

  • Tracing the graph by hand

  • Forward mode and reverse mode

  • Higher-order derivatives and a concrete look

  • The price of reverse mode

  • An honest warning

  • 2.4 Gradient Descent and Its Variants: How the Network Actually Learns

  • Plain gradient descent

  • Momentum and Adam

  • L-BFGS, and the standard recipe

  • 2.5 The Loss Landscape: Why PINNs Are Hard to Optimize

  • What the landscape is, and why a sum makes it worse

  • Stiffness and ill-conditioning

  • Spectral bias

  • Failures are usually optimization, not capacity

  • What this means in practice

  • Lesson 2 Quiz

    10 attempts allowed

  • Chapter 3: Setting Up Your Environment — Python, PyTorch, and the PIML Toolkit

  • 3.1 Installing Your Environment

  • Python, and a choice of isolation tool

  • Installing PyTorch

  • A note on GPUs

  • Scripts or notebooks?

  • Verifying the install

  • 3.2 Choosing a Framework: PyTorch, JAX, and TensorFlow for PIML

  • What any PIML framework must provide

  • PyTorch

  • JAX

  • TensorFlow

  • The recommendation, honestly stated

  • 3.3 DeepXDE and NVIDIA PhysicsNeMo: Library or From Scratch?

  • DeepXDE

  • NVIDIA PhysicsNeMo (formerly Modulus)

  • Why this book builds from scratch first

  • A decision guide

  • 3.4 The Book’s Project Structure

  • A layout to grow into

  • Reproducibility is not optional

  • One last check: end to end

  • Lesson 3 Quiz

    10 attempts allowed

  • Chapter 4: The Anatomy of a Physics-Informed Neural Network

  • 4.1 The Network: A Multilayer Perceptron as the Solution

  • Activations beyond tanh

  • Why tanh, and how big

  • The network in code

  • 4.2 The Two Losses: Physics and Data

  • The data loss

  • The physics loss

  • Combining them

  • 4.3 Collocation Points: Where the Physics Is Enforced

  • Sampling the points

  • Points for the conditions

  • 4.4 Putting It Together: From Input to Combined Backpropagation

  • One loss, one backward pass

  • Why create_graph matters here

  • The assembled step

  • Key Takeaways

  • Lesson 4 Quiz

    10 attempts allowed

  • Chapter 5: Your First PINN — Solving the Heat Equation

  • 5.1 The Problem and Its Exact Solution

  • 5.2 The Complete Training Loop

  • Setting up

  • Stage one: Adam

  • Stage two: L-BFGS

  • The whole program

  • 5.3 Watching It Train

  • 5.4 Did It Work? Comparing Against the Exact Solution

  • The solution, side by side

  • Putting a number on it

  • How does this compare to a classical solver?

  • Where the error lives

  • 5.5 Experiments and What to Take Away

  • Using and saving the trained model

  • A first taste of the inverse problem

  • Where to go next

  • An honest assessment

  • A note on cost and reproducibility

  • Key Takeaways

  • References

  • Lesson 5 Quiz

    10 attempts allowed

  • Chapter 6: Boundary and Initial Conditions — Hard and Soft Constraints

  • 6.1 Soft Constraints: Conditions as Penalties

  • The strengths of the soft approach

  • The soft loss in code

  • The weaknesses you must respect

  • 6.2 Hard Constraints: Building the Conditions Into the Architecture

  • A concrete construction

  • Non-homogeneous conditions and the lifting function

  • Where hard constraints get difficult

  • 6.3 Beyond Dirichlet: Neumann and Periodic Conditions

  • Neumann conditions: fixing a flux

  • Periodic conditions: wrapping the domain

  • Robin conditions: the hardest of the three

  • A short taxonomy of hard constructions

  • 6.4 A Head-to-Head Comparison

  • Reading the numbers

  • When soft constraints are the right choice

  • 6.5 The Art of Loss Weighting

  • Why the naive choice fails

  • Manual weighting: the first thing to try

  • Adaptive weighting: letting the training tune itself

  • Adaptive weighting, applied

  • A note on why this works: the NTK view

  • Annealing the weights

  • A concrete diagnosis

  • Which to reach for

  • 6.6 A Complete Worked Example: A Rod With One Fixed and One Insulated End

  • Constructing the mixed ansatz

  • Training it

  • Experiments worth running

  • Key Takeaways

  • Lesson 6 Quiz

    10 attempts allowed

  • Chapter 7: Case Studies — The Burgers and Navier– Stokes Equations

  • 7.1 Burgers’ Equation in One Dimension

  • Why this equation earns its place

  • From one equation to a system

  • Setting up the problem

  • Training and the two-stage recipe

  • The full training driver

  • What you should see

  • Watching the shock form

  • Experiments worth running

  • 7.2 A Steady Two-Dimensional Navier–Stokes Flow

  • The velocity–pressure formulation and its challenge

  • A concrete flow: the lid-driven cavity

  • The corner singularity, and a note on boundary conflicts

  • Monitoring a coupled training

  • What you should see

  • A cleaner formulation: the stream function

  • The Reynolds number and the limits of laminar flow

  • 7.3 Handling Nonlinearity: Why It Is Hard and What Helps

  • Remedies that help

  • Curriculum training by viscosity annealing

  • Normalizing a flow problem in practice

  • 7.4 Validating Against a Conventional Solver

  • Building your own reference for Burgers

  • Experiments worth running on the cavity

  • Key Takeaways

  • Lesson 7 Quiz

    10 attempts allowed

  • Chapter 8: Debugging and the Common Pitfalls of PINNs

  • 8.1 Spectral Bias: Why PINNs Struggle With High Frequencies

  • Recognizing it

  • Why it happens: the kernel view

  • Pushing back against it

  • Reproducing the bias for yourself

  • Choosing the frequency scale

  • An alternative: sinusoidal activation networks

  • Adaptive sampling: putting points where the error is

  • 8.2 Convergence Failure and How to Diagnose It

  • Read the loss terms separately

  • A gallery of loss-curve signatures

  • The trivial-solution trap

  • Common causes and their cures

  • Finding a workable learning rate

  • Fixed versus resampled collocation points

  • When the solution overfits the collocation points

  • When the second-order phase misbehaves

  • The silent failure: a missing create_graph

  • 8.3 Numerical Instability and the Cure of Normalization

  • Normalize the inputs and outputs

  • Other stabilizers

  • Gradient clipping and precision, in code

  • A note on the derivative bookkeeping

  • Instability from broken causality in time

  • 8.4 A Practical Debugging Checklist

  • The checklist

  • A worked debugging session

  • Preventing failures before they start

  • Quick reference: symptom, cause, cure

  • Instrumentation you should build once

  • Key Takeaways

  • Lesson 8 Quiz

    10 attempts allowed

  • Chapter 9: Neural Operators — DeepONet and the Fourier Neural Operator

  • 9.1 Operator Learning: A Different Target

  • Tracing the idea through, concretely

  • Why this is hard, and the key theorem

  • Operators in the wider landscape

  • Function in, function out

  • Why bother: the amortization argument

  • 9.2 The Deep Operator Network (DeepONet)

  • Training a DeepONet

  • Generating the training data

  • The training loop

  • Evaluating on an unseen input

  • Physics-informed DeepONet

  • The trunk as a learned basis

  • Sizing a DeepONet

  • Batching the branch efficiently

  • Where to place the sensors

  • 9.3 The Fourier Neural Operator (FNO)

  • Why frequency space is the right idea

  • The FNO data pipeline and training

  • Resolution invariance in action

  • Why the pointwise path is there

  • Seeing what the FNO learns

  • Measuring operator accuracy honestly

  • Extending to two dimensions

  • Where the FNO struggles

  • 9.4 When to Use a Neural Operator — and When Not To

  • Making the crossover concrete

  • Choosing between DeepONet and FNO

  • Common pitfalls of operator learning

  • Combining operators with PINNs

  • Key Takeaways

  • Lesson 9 Quiz

    10 attempts allowed

  • Chapter 10: Inverse Problems — Discovering Physics From Data

  • 10.1 Formulating the Inverse Problem

  • Forward and inverse as one machine

  • The data term, precisely

  • What counts as data

  • A taxonomy of inverse problems

  • Well-posed, or not: a first look

  • 10.2 A Worked Example: Recovering a Diffusion Coefficient

  • Making the parameter learnable

  • Generating synthetic measurements

  • The joint training loop

  • Reading the training trace

  • How close is close enough?

  • 10.3 Joint Optimization: Subtleties and Strategies

  • Balancing the data and physics terms

  • Learning rates and parameter scaling

  • A staged schedule: field first, then parameter

  • Escaping a bad initial guess

  • Diagnosing a stuck parameter

  • 10.4 Recovering Several Parameters at Once

  • A reaction–diffusion example

  • The identifiability problem, made concrete

  • Breaking the degeneracy with richer data

  • A two-mode recovery, end to end

  • Nonlinear reaction: when nonlinearity helps

  • Recovering functions, not just constants

  • Practical tactics for multiple unknowns

  • 10.5 Working With Noisy and Sparse Data

  • How noise sets the error floor

  • The bias–variance view of data weighting

  • Robust losses for outliers

  • A noise-robustness experiment in code

  • Sparse and unevenly sampled data

  • Random noise versus systematic error

  • 10.6 Validation and Uncertainty in the Recovered Answer

  • Basic validation

  • Held-out validation in code

  • Uncertainty by repeated inversion

  • Cheap error bars from curvature

  • Toward Bayesian inversion

  • When the data is not enough

  • Reporting an inverse result

  • Key Takeaways

  • References

  • Lesson 10 Quiz

    10 attempts allowed

  • Chapter 11: Quantifying Uncertainty — How Much Should You Trust a PINN?

  • 11.1 Two Kinds of Uncertainty

  • Aleatoric uncertainty: noise in the world

  • Epistemic uncertainty: gaps in the model’s knowledge

  • 11.2 The Bayesian Ideal and Its Practical Approximations

  • Bayesian PINNs: the principled route

  • 11.3 Practical Methods You Can Run Today

  • Deep ensembles: train several, compare

  • Monte Carlo dropout: one network, many masks

  • 11.4 Reading, Trusting, and Reporting Uncertainty

  • Calibration: does the band mean what it says?

  • Honest reporting

  • Key Takeaways

  • Lesson 11 Quiz

    10 attempts allowed

  • Chapter 12: Multi-Fidelity Methods — Getting the Most From Scarce Good Data

  • 12.1 The Core Idea: Learn the Correction, Not the Answer

  • The classical foundation: autoregressive co-kriging

  • 12.2 The Composite Multi-Fidelity Network

  • Training on two datasets at once

  • 12.3 Multi-Fidelity Physics-Informed Networks

  • A different route: transfer learning across fidelities

  • 12.4 Multi-Fidelity Operators and Uncertainty

  • Multi-fidelity operators

  • Multi-fidelity uncertainty

  • 12.5 When Multi-Fidelity Pays Off — and When It Doesn’t

  • Key Takeaways

  • Lesson 12 Quiz

    10 attempts allowed

  • Chapter 13: Case Study — Aerodynamics

  • 13.1 The Aerodynamic Setting and Why PINNs Fit It

  • Where the fit holds and where it fails

  • 13.2 Reconstructing a Flow Field From Sparse Data

  • How robust is the reconstruction?

  • 13.3 The High-Speed Complication: Shocks and Compressibility

  • Why shocks defeat a naive PINN

  • 13.4 A Worked Airfoil: The Transonic RAE2822

  • Computing the forces that matter

  • 13.5 Toward Design: Many-Query Aerodynamics

  • 13.6 What This Case Study Teaches

  • Key Takeaways

  • Lesson 13 Quiz

    10 attempts allowed

  • Chapter 14: Case Study — Materials Science

  • 14.1 The Equations of a Deforming Solid

  • A note on formulation choices

  • 14.2 Elasticity Imaging: Finding Hidden Material Properties

  • 14.3 Inferring Stress and Detecting Defects

  • 14.4 The Frontier: Discovering Constitutive Laws

  • 14.5 What This Case Study Teaches

  • Key Takeaways

  • Lesson 14 Quiz

    10 attempts allowed

  • Chapter 15: Case Study — Biomedical Modeling

  • 15.1 Why Biomedical Problems Suit — and Test — PINNs

  • Where biomedical problems test the method hardest

  • 15.2 Reconstructing Blood Flow and Pressure From Imaging

  • Wall shear stress: a quantity you cannot measure but must know

  • From a dye image to a flow: the aneurysm

  • 15.3 Cardiac Electrophysiology: Mapping the Heart’s Activation

  • Uncertainty that guides the next measurement

  • Beyond spatial fields: physiological time series

  • 15.4 The Ethics of a Model That Informs a Diagnosis

  • What clinical validation actually looks like

  • 15.5 What This Case Study Teaches

  • Key Takeaways

  • Lesson 15 Quiz

    10 attempts allowed

  • Chapter 16: Production Pipelines — From Notebook to Deployed System

  • 16.1 Build or Buy: Libraries Versus From Scratch

  • When to reach for a library, and when not to

  • A recommended path: prototype, then productionize

  • 16.2 Scaling Up: Domain Decomposition

  • Parallelism: the production payoff

  • Adaptive sampling as production infrastructure

  • 16.3 Engineering the Training: Reproducibility and Monitoring

  • Reproducibility

  • Monitoring

  • Testing the code, not just the model

  • 16.4 Deployment and the Inference-Time Advantage

  • 16.5 Maintenance: The Model in a Changing World

  • 16.6 What This Chapter Teaches

  • Key Takeaways

  • Lesson 16 Quiz

    10 attempts allowed

  • Chapter 17: Future Trends — Where the Field Is Going

  • 17.1 Beyond the MLP: New Architectures

  • How to judge a new architecture

  • 17.2 Foundation Models for Physics

  • The honest limits of physics foundation models

  • 17.3 The Honest Frontier: Why PINNs Still Fail

  • 17.4 The Broader Integration of Physics and Learning

  • From solving to designing: inverse design

  • Blurring the line: differentiable and hybrid solvers

  • 17.5 What This Means for You

  • 17.6 A Closing Word on the Whole Journey

  • Key Takeaways

  • Lesson 17 Quiz

    10 attempts allowed

  • Consolidated Bibliography

  • References

  • A Note on Sources and Further Reading

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub