Assemble the Navier-Stokes timestep and validate it against Ghia et al. (TASK-034) - #47
Merged
Merged
Conversation
…l. (TASK-034) Stage 5's fifth and last task, defining the MVP: pyflow.engine.simulation. navier_stokes_step assembles TASK-031/032/033 into one real predictor/ corrector/corrected-state timestep, validated by eleven scenarios covering the mechanism itself (both null tests, determinism, the ADR-003 substitution check, Couette flow), the Lid-Driven Cavity comparison against Ghia, Ghia & Shin (1982) at three real mesh resolutions, the Taylor-Green emergent-phenomenon pair, and kinetic-energy conservation. Ships with the two golden demos Stage 5 owes (Lid-Driven Cavity, Heat Diffusion) and closes two real gaps found along the way: PISO had no periodic-boundary support at all, and its Poisson matrix was rebuilt from scratch every timestep rather than cached. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 5's fifth and last task in build order — this defines the MVP.
pyflow.engine.simulation.navier_stokes_stepassembles TASK-031/032/033 into one real incompressible Navier-Stokes timestep: momentum's own two components advance through the existingsteppath with no pressure term (the predictor), the result is reassembled and handed to whicheverPressureCouplingwas configured (the corrector), and the corrected components replace the predictor's own (the corrected state).NavierStokesStepResultexposes all three parts separately.stable_timestepderives a resolution-appropriatedtfrom the CFL/diffusive stability limits (safety factor measured via a disposable prototype sweep, not guessed).tests/features/navier_stokes_timestep.feature: the predictor/corrector/corrected sequence, both null tests (uniform periodic flow, fluid at rest), determinism, the ADR-003 substitution check, Couette flow at solver tolerance, the Ghia cavity comparison, the Taylor-Green matched/mismatched pair, and step-wise kinetic-energy conservation.tests/fixtures/ghia_1982_re100.py, cross-checked against two independent public reproductions of the paper, a new committed-reference-data convention for this repo) decreasing strictly across all three resolutions, the finest resolution's primary vortex within 0.1 of Ghia's own reference point, and both downstream secondary corner vortices detected via opposite-sign discrete vorticity.bootstrap.pyvelocity-only rendering path) and Heat Diffusion (a single sinusoidal mode decaying at its exact analytic rate on a periodic domain).Two real gaps found and closed along the way
GreenGaussGradient/GreenGaussDivergence/PISOhad no periodic-boundary support at all — found while building the periodic null test, which cannot reachPISOwithout it. Both operators gained aperiodic_pairsconstructor parameter (same shapeCentralDifferenceDiffusionalready had);PISOthreads it through, including its own_rhie_chow_divergencecorrection loop. Verified directly: a uniform field measures exactly0.0divergence through this path; a non-uniform field gives a real nonzero value matching a hand-derivation. No ADR — registry-level widening, no interface change.PISO._poisson_matrixwas rebuilt from scratch every single timestep — found while timing the cavity validation's own first real run. Caching it per instance (by mesh identity) cut measured per-timestep cost by 3.5–7.7x, which is what made the three-resolution comparison fit inside an 11-minute test.A design finding, recorded rather than silently substituted
Stage 5's own design question two named
velocity_tangentialas its answer for the cavity's moving lid, butBoundaryFaceConfig.field_values/field_gradients(landed the next day) already supply the exact general mechanism needed — a per-field-name override at one wall.velocity_tangentialwas never built; this is documented explicitly in the roadmap and the test module's own docstring.Test plan
make cifully green locally: 672 tests passed, 99% coverage, all structural/scenario/status checks passingmypy --strictclean,ruffcleanubuntu-latest/windows-latest(Criterion 9 in the Stage 5 exit audit is marked pending this)🤖 Generated with Claude Code