DEV Community

Cover image for How I Taught Myself CFD Using an AI Code Agent

How I Taught Myself CFD Using an AI Code Agent

During my bachelor's in Aerospace Engineering, my professors introduced me to subjects like Computational Fluid Dynamics and Aerodynamics. I was genuinely struck by how people use mathematics to understand the real things happening around us. I tried to study CFD on my own but couldn't find a way to understand the physical meaning behind the equations. So I joined a master's in Thermal Engineering, believing that studying fluid and thermal systems would help me understand the governing equations properly.

My master's helped me understand the importance of the continuity, momentum, and energy equations — and gave me an introduction to the Navier-Stokes equations. At first they looked manageable, so I thought CFD would be straightforward from there. But I ended up in the same place again — not understanding the physical meaning behind the equations and their derivations. This wasn't from lack of effort. The real problem was that I had no mentor or resource that could answer my doubts in the moment, while I was actually looking at the equation.

That's when I got the idea to use AI tools like Claude Code to teach me. I was already very comfortable with Python, so I decided to use an AI agent to teach me CFD from scratch, step by step, using code.

Building the Curriculum

I searched for reference material to structure my learning and found Lorena A. Barba's work — CFD Python: 12 Steps to Navier-Stokes Equations. Using that as a foundation, I worked with Claude Code to build a structured curriculum of 24 lessons, starting from the basics of the Finite Difference Method all the way to advanced concepts like turbulence modelling and Physics-Informed Neural Networks.

Module 1 — Foundations

  1. What is CFD? — Physical intuition, where CFD is used, why we need it
  2. Python for CFD — NumPy arrays, matplotlib, vectorized operations
  3. Conservation Laws — Mass, momentum, energy; physical meaning
  4. The Continuity Equation — Derivation, physical meaning, 1D examples
  5. Finite Difference Method — Forward, backward, central differences; truncation error; order of accuracy
  6. 1D Linear Advection — CFL condition; upwinding; numerical diffusion
  7. 1D Diffusion Equation — Explicit vs implicit schemes; stability analysis
  8. 1D Burgers' Equation — Nonlinearity; shock formation; conservative form

Module 2 — Core CFD Methods

  1. 2D Scalar Transport — Extending to 2D; structured grids; boundary conditions
  2. Finite Volume Method — Control volumes, flux computation, upwind scheme
  3. The Navier-Stokes Equations — Derivation, physical meaning, non-dimensionalization
  4. Pressure-Velocity Coupling — The incompressibility constraint
  5. SIMPLE Algorithm — Pressure correction; step-by-step implementation
  6. Lid-Driven Cavity Flow — The "Hello World" of CFD; implemented from scratch
  7. Flow Over Objects — Cylinder flow; drag and lift; von Kármán vortex street
  8. Boundary Conditions — Dirichlet, Neumann, periodic, outflow; ghost cells

Module 3 — Advanced Topics

  1. Turbulence Basics — Reynolds decomposition, RANS, closure problem
  2. Turbulence Models — Spalart-Allmaras, k-ε, k-ω SST
  3. Mesh Generation — Structured vs unstructured; quality metrics; y+ estimation
  4. Higher-Order Schemes — QUICK, TVD, MUSCL; limiters
  5. Multigrid Methods — V-cycle, W-cycle; convergence acceleration
  6. Unsteady Flows — Time-stepping; dual time-stepping; Courant number
  7. Compressible Flow — Euler equations; Riemann problem; shock capturing
  8. Physics-Informed Neural Networks — Where machine learning meets CFD

How the Agent Teaches

I instructed Claude Code to act as a CFD tutor using two specific methods — the Socratic method and the Feynman technique.

The Socratic method means the agent always asks me a question before explaining anything. Before teaching upwinding, for example, it asked: "If information is travelling rightward, which neighbouring cell should you look at to estimate the flux?" I had to answer from physical intuition before any equation was shown. This forced me to think rather than just read.

The Feynman technique means after every lesson, I have to explain the concept back in plain words as if teaching someone else. If I get it wrong or miss something, the agent corrects me and tracks the gap. It never moves on until the concept is clear.

The agent is calm and patient. It gives analogies before equations, equations before code, and exercises before moving on. Every mistake I make gets noted and revisited.

What Actually Works — and What Doesn't

What works well: The question-first approach genuinely changes how you engage with material. Because you have to answer before being told, you can't passively read and feel like you understood. Either you know it or you don't — and the gap becomes visible immediately.

The physical analogy before equation ordering also made a real difference. Understanding why upwinding looks upstream before seeing the FTBS formula meant the formula made sense when it appeared, rather than being something to memorise.

The honest limitations: The agent has no memory between sessions. Every new session starts fresh, which means you have to maintain your own progress file and hand it back to the agent at the start of each session. This is more work than it sounds — if you skip it, the agent doesn't know what you've already covered.

The agent also cannot verify whether you actually ran the code or just said you did. The accountability is entirely on you.

How I Structured the Repos

I maintain two things that make this system work:
A CLAUDE.md file in the repo root that tells the agent exactly how to teach — the Socratic + Feynman ordering, the physical analogy first approach, and the student's background level. This gets read at the start of every session.

A LEARNING_PROGRESS.md file that tracks every lesson covered, quiz scores, bugs caught, misconceptions corrected, and what's next. This is the session-to-session handoff document. Without it the agent starts from scratch every time.

Both files are public in my GitHub repo: harishragul/cfd

What I Built in Three Months

At the time of writing I have completed Modules 1 and 2 fully and am mid-way through Module 3. In that time I built from scratch:

  • A finite difference solver for 1D advection, diffusion, and Burgers' equation
  • A 2D Navier-Stokes solver using the projection method and SIMPLE algorithm
  • A lid-driven cavity solver validated against Ghia et al. (1982) — a standard CFD benchmark
  • A turbulent channel flow simulation implementing k-ω SST from scratch
  • Mesh generation exercises including snappyHexMesh on a sphere geometry in OpenFOAM I also submitted a paper describing this curriculum to the Journal of Open Source Education (JOSE), currently under review.

Who This Is For

This approach works if you learn by building rather than reading, you're comfortable with Python, and you can hold yourself accountable between sessions. It won't work if you need someone to check that you actually ran the code, or if you want to move fast without gaps.

The repo and curriculum are publicly available at harishragul/cfd. If you're trying to learn CFD from scratch and find yourself stuck in the same place I was — equations without physical meaning — this might be the structure you're looking for.

Top comments (0)