A Python project demonstrating multi-agent / agentic coding workflows with two solvers:
- 1D scalar advection — toy solver with analytic-solution verification
- 2D compressible Euler — CPU full-field CFD solver MVP
This project showcases a new engineering paradigm where AI agents handle analysis, design, implementation, testing, and review in a structured workflow:
| Traditional (script) | Agentic (this project) |
|---|---|
| Human reads the request | repo-analyst agent reads the repo |
| Human designs the scheme | scheme-designer agent creates a plan |
| Human writes code | implementer agent makes minimal edits |
| Human writes tests | test-engineer agent adds and runs tests |
| Human reviews | reviewer agent checks the diff |
| Human follows a checklist | skill encodes the workflow once, runs every time |
| Human remembers rules | hooks enforce rules automatically |
git clone git@gitee.com:gpiii/workflow_sample.git
cd workflow_sample
tools/run_in_project_env.sh python --version
make test
make demo-hll-workflowThe HLL Riemann solver is the first method implemented through the full paper-to-code workflow with deterministic approval gating:
| Artifact | Path |
|---|---|
| Case study | docs/case_studies/hll_flux_paper_to_code.md |
| Approved spec | docs/scheme_specs/hll_flux.md |
| Validation output | results/cfd_hll_validation/ |
| Traceability | docs/tasks/hll_flux_implementation/traceability.md |
Run the demo: make demo-hll-workflow
A full paper-to-code demo derived from Zhou-Dong-Pan (2025), Phys. Fluids 37, 106131. Implements scalar linear CFWENO3 (3rd-order) and scalar Burgers CFWENO3 (pre-shock, ~2nd-order). Run the unified demo:
make demo-real-paper-cfweno| Artifact | Path |
|---|---|
| Case study | docs/case_studies/cfweno_real_paper_demo.md |
| Roadmap | docs/roadmaps/v1_real_paper_demo.md |
| Scalar spec (approved) | docs/scheme_specs/cfweno_scalar_subset.md |
| Burgers spec (approved) | docs/scheme_specs/cfweno_scalar_burgers_subset.md |
Key results: CFWENO3 linear advection achieves ~3rd-order convergence; Burgers achieves ~2nd-order (documented limitation from per-cell nu variation). See the case study for full details.
The CFWENO3 scalar prototype is the second method implemented through the paper-to-code workflow, derived from Zhou-Dong-Pan (2025):
# Single run with baseline comparison
make cfweno-scalar-demo
# Convergence study (40/80/160/320 cells)
make cfweno-scalar-convergence
# Full demo (both + validation index)
make demo-real-paper-scalar| Artifact | Path |
|---|---|
| Approved spec | docs/scheme_specs/cfweno_scalar_subset.md |
| Extraction report | docs/paper_reviews/cfweno_pof_2025/extraction_report.md |
| Validation output | results/cfweno_scalar_demo/ |
| Convergence study | results/cfweno_scalar_convergence/ |
| Traceability | docs/tasks/cfweno_scalar_prototype/traceability.md |
The CFWENO3 Burgers prototype extends the scalar CFWENO3 to nonlinear Burgers.
The nonlinear flux uses the simplified form f_hat = f(ubar) = ubar^2/2, which
is an exact algebraic identity of the SFM two-step form for scalar Burgers
(not an approximation). The two-step SFM form f_hat = a*ubar - f* is only
needed for the Euler system extension.
# Single run with baseline comparison
make cfweno-burgers-demo
# Convergence study (40/80/160/320 cells)
make cfweno-burgers-convergence
# Full demo (both + validation index)
make demo-real-paper-burgers| Artifact | Path |
|---|---|
| Approved spec | docs/scheme_specs/cfweno_scalar_burgers_subset.md |
| Validation output | results/cfweno_burgers_demo/ |
| Convergence study | results/cfweno_burgers_convergence/ |
| Traceability | docs/tasks/cfweno_burgers_prototype/traceability.md |
make validation-index
# Output: docs/validation_index.mdmake health
# Checks: old env commands, spec approval, HLL artifacts, README pathsThe toy solver solves the 1D linear advection equation with a known analytic solution:
- PDE: u_t + a * u_x = 0, a = 1.0
- Domain: x in [0, 1), periodic boundary
- IC: u(x, 0) = sin(2pix) + 1
- Analytic: u_exact(x, t) = sin(2pi(x - a*t)) + 1
- Schemes: upwind (1st order), Lax-Wendroff (2nd order), CFWENO3 (3rd order), CFWENO3 Burgers (nonlinear)
tools/run_in_project_env.sh pytest -q
tools/run_in_project_env.sh python examples/compare_advection_schemes.pyA minimal but complete 2D compressible Euler solver for an ideal gas (gamma = 1.4), implemented entirely in NumPy.
dU/dt + dF(U)/dx + dG(U)/dy = 0
U = [rho, rho*u, rho*v, E]
p = (gamma - 1) * (E - 0.5 * rho * (u^2 + v^2))
| Component | Current | Extensible to |
|---|---|---|
| Numerical flux | Rusanov (local Lax-Friedrichs), HLL | HLLC, Roe |
| Reconstruction | Piecewise constant, MUSCL (2nd order) | WENO |
| Limiters | minmod, van Leer | superbee, MC |
| Time integration | Forward Euler, SSP RK2 | RK3, RK4 |
| Boundary conditions | Periodic, transmissive, reflective | Inlet, outlet, far-field |
cfd/
config.py — Solver configuration (CFDConfig dataclass)
constants.py — Index constants, gamma
mesh/
structured.py — 2D uniform Cartesian grid with ghost cells
variables/
conversion.py — Primitive <-> Conservative conversion
physics/
eos.py — Equation of state (ideal gas)
fluxes.py — Euler physical flux F(U), G(U)
wavespeeds.py — Wave speed estimation
boundary/
conditions.py — Periodic, transmissive, reflective BCs
ghost_cells.py — BC dispatch
numerics/
reconstruction.py — Piecewise constant, MUSCL (2nd order)
limiters.py — minmod, van Leer slope limiters
riemann.py — Rusanov and HLL numerical fluxes
timestep.py — CFL dt computation
update.py — Spatial residual + Euler update
time_integration.py — Time loop (Euler, SSP RK2)
cases/
uniform_flow.py — Uniform flow preservation test
sod_shock_tube_2d.py — 2D Sod shock tube
entropy_wave.py — Advected entropy wave (analytic)
isentropic_vortex.py — Isentropic vortex (analytic)
io/
output.py — CSV, NPZ, PNG, MD output
solver.py — Orchestration entry point
# Uniform flow preservation (should be exact to machine precision)
tools/run_in_project_env.sh python examples/run_cfd_uniform_flow.py
# 2D Sod shock tube
tools/run_in_project_env.sh python examples/run_cfd_sod_2d.py
# HLL vs Rusanov validation
tools/run_in_project_env.sh python examples/run_cfd_hll_validation.pyResults are saved to results/:
| Case | Directory | Outputs |
|---|---|---|
| Uniform flow | results/cfd_uniform_flow/ |
summary.csv, final_state.npz, analysis.md, density.png, pressure.png |
| Sod 2D | results/cfd_sod_2d/ |
summary.csv, final_state.npz, analysis.md, density.png, pressure.png, centerline_density.png |
| HLL validation | results/cfd_hll_validation/ |
error_summary.csv, analysis.md |
tools/run_in_project_env.sh python tools/generate_cfd_api_docs.pySee docs/cfd_iteration_guide.md for detailed instructions. Quick reference:
| To add... | Modify... |
|---|---|
| New flux | cfd/numerics/riemann.py, cfd/numerics/update.py |
| New reconstruction | cfd/numerics/reconstruction.py |
| New limiter | cfd/numerics/limiters.py |
| New time integrator | cfd/numerics/time_integration.py |
| New boundary condition | cfd/boundary/conditions.py, cfd/boundary/ghost_cells.py |
| New test case | cfd/cases/, examples/ |
- No turbulence modelling (Euler equations only)
- No adaptive mesh refinement
- No parallelisation (single CPU thread)
- No moving meshes or complex geometries
- Rusanov is available but diffusive; HLL is implemented and less diffusive on smooth problems; HLLC/Roe are not yet implemented
The isentropic vortex is a nonlinear smooth analytic solution of the 2D compressible Euler equations, used to verify second-order convergence of MUSCL + SSP RK2.
r = sqrt((x - x0 - u_inf*t)^2 + (y - y0 - v_inf*t)^2)
T = T_inf - (gamma-1)*beta^2/(8*pi^2*gamma) * exp(1 - r^2)
rho = T_inf^(1/(gamma-1)) * (T/T_inf)^(1/(gamma-1))
u = u_inf - beta/(2*pi) * (y - y0 - v_inf*t) * exp((1 - r^2)/2)
v = v_inf + beta/(2*pi) * (x - x0 - u_inf*t) * exp((1 - r^2)/2)
p = rho * T
Default parameters: rho_inf=1, u_inf=1, v_inf=1, p_inf=1, beta=5, x0=5, y0=5. Domain [0,10]x[0,10], periodic BCs.
tools/run_in_project_env.sh python examples/run_cfd_isentropic_vortex.py
tools/run_in_project_env.sh python examples/run_cfd_isentropic_vortex_convergence.py| Method | nx=32 L2 | nx=64 L2 | nx=128 L2 |
|---|---|---|---|
| baseline (piecewise_constant + euler) | 1.97e-01 | 1.14e-01 | 6.16e-02 |
| MUSCL + minmod + SSP_RK2 | 7.41e-02 | 2.66e-02 | 8.31e-03 |
MUSCL + SSP RK2 achieves ~2nd-order convergence on the isentropic vortex, a significant improvement over the baseline first-order method.
The entropy wave is an exact solution of the 2D compressible Euler equations with periodic boundary conditions, used to verify solver correctness and measure convergence order.
rho(x,y,t) = rho0 + eps * sin(2*pi*(kx*(x - u0*t) + ky*(y - v0*t)))
u(x,y,t) = u0
v(x,y,t) = v0
p(x,y,t) = p0
E = p0/(gamma-1) + 0.5*rho*(u0^2 + v0^2)
Default parameters: rho0=1, eps=0.1, u0=1, v0=0.5, p0=1, kx=1, ky=1, gamma=1.4.
This case is ideal for validation because:
- The exact solution is known at all times
- Periodic BCs are exact (no boundary artifacts)
- It tests the full Euler solver (conservative/primitive conversion, fluxes, CFL, update)
- Grid convergence can be measured against the analytic solution
tools/run_in_project_env.sh python examples/run_cfd_entropy_wave.pytools/run_in_project_env.sh python examples/run_cfd_entropy_wave_convergence.pycat results/cfd_entropy_wave/error_summary.csv
cat results/cfd_entropy_wave/analysis.md
cat results/cfd_entropy_wave_convergence/convergence_summary.csv
cat results/cfd_entropy_wave_convergence/convergence_analysis.mdPlots (if matplotlib is available):
results/cfd_entropy_wave/density_initial.png— initial density fieldresults/cfd_entropy_wave/density_numerical.png— numerical solutionresults/cfd_entropy_wave/density_exact.png— analytic solutionresults/cfd_entropy_wave/density_error.png— error fieldresults/cfd_entropy_wave/density_centerline_comparison.png— overlayresults/cfd_entropy_wave_convergence/density_l2_convergence.png— convergence plot
With Rusanov + piecewise constant + forward Euler:
| nx=ny | rho L2 error | Observed order |
|---|---|---|
| 32 | 1.37e-02 | — |
| 64 | 7.19e-03 | 0.93 |
| 128 | 3.69e-03 | 0.96 |
Close to first-order, as expected for a first-order scheme.
git clone git@gitee.com:gpiii/workflow_sample.git
cd workflow_sampleEnvironment Setup:
tools/run_in_project_env.shauto-discovers the project conda environment. No manualpip installis needed when using the wrapper script. If running outside the wrapper, install dependencies withpip install numpy pytest matplotlib(matplotlib is optional).
tools/run_in_project_env.sh pytest -q使用 add-numerical-scheme skill,根据 docs/feature_request_lax_wendroff.md 完成需求。
要求先分析仓库,再设计方案,再实现,再补测试,再审查。
不要修改无关文件。完成后运行 pytest -q,并给出最终报告。
| Document | Description |
|---|---|
CHANGELOG.md |
Release history |
docs/releases/ |
Release notes (v0.1, v1.0) |
CLAUDE.md |
Project rules |
docs/cfd_architecture.md |
CFD solver architecture overview |
docs/cfd_module_interfaces.md |
Public interface reference |
docs/cfd_iteration_guide.md |
How to extend the solver |
docs/cfd_definition_of_done.md |
Completion checklists for each task type |
docs/paper_to_code_workflow.md |
Paper-to-code workflow guide |
docs/api/ |
Auto-generated API docs |
This project supports a structured workflow for implementing numerical methods from research papers. The workflow ensures formulas are verified, variable mappings are checked, and the implementation is validated before commit.
Directly jumping from a PDF to code is error-prone: formulas lose formatting, papers use different notation, and not all methods fit our solver architecture. The workflow enforces human review at the critical decision point.
1. Place the PDF:
cp ~/Downloads/paper.pdf docs/papers/2. Extract and analyze:
使用 extract-paper-scheme skill 分析 docs/papers/paper.pdf。
只生成 extraction report,不要实现代码。
3. Generate scheme spec:
使用 write-scheme-spec skill,根据 docs/paper_reviews/paper_extraction.md 生成 scheme spec。
默认不要实现代码。
4. Review and approve:
Open docs/scheme_specs/<scheme>.md, verify formulas and mappings, then set:
Approved for implementation: yes
5. Implement:
我已经确认 docs/scheme_specs/<scheme>.md,并将 Approved for implementation 改为 yes。
请使用 implement-paper-scheme skill 实现它,并运行 required validation。
6. Validate:
使用 validate-paper-scheme skill,验证实现的数值方法。
# Extract text from PDF
make paper-extract PAPER=docs/papers/<name>.pdf
# Build agent context from extracted text
make paper-context PAPER_TEXT=docs/paper_reviews/<name>_text.md- Never implement without an approved scheme spec
- Never fabricate formulas — flag unclear ones as
[AMBIGUOUS] - Always run analytic validation after implementation
- See
docs/paper_to_code_workflow.mdfor full details
This project provides 9 CFD skills in .claude/skills/ that encode the
agentic workflow. Use short prompts to trigger them:
使用 add-cfd-case skill,添加一个 Taylor-Green vortex 解析解算例,
domain [0,2π]×[0,2π],periodic BC,参考 Yee et al. 1985。
完成后运行 make compile test cfd-validation。
使用 add-numerical-method skill,添加 superbee limiter 到 cfd/numerics/limiters.py,
注册到 LIMITERS dict,添加单元测试,运行 MUSCL + superbee 的 vortex convergence study。
使用 add-numerical-method skill,实现 HLLC flux(x 和 y 方向),
在 update.py 中添加 dispatch,运行完整 validation。
使用 add-numerical-method skill,实现 SSP RK3,
参考 cfd/numerics/time_integration.py 中的 SSP RK2 模式。
使用 run-cfd-validation skill,运行完整验证套件并报告结果。
使用 review-cfd-change skill,review 当前未提交的改动。
使用 update-cfd-docs skill,更新所有文档。
| Skill | When to use |
|---|---|
add-cfd-case |
New flow problem or analytic case |
add-numerical-method |
New reconstruction, limiter, flux, or time integrator |
run-cfd-validation |
Verify correctness after changes |
update-cfd-docs |
Update docs before commit |
review-cfd-change |
Review diff before commit |
extract-paper-scheme |
Extract method info from a paper PDF |
write-scheme-spec |
Generate scheme spec from extraction report |
implement-paper-scheme |
Implement from an approved scheme spec |
validate-paper-scheme |
Validate a paper-derived implementation |
| Target | Description |
|---|---|
make compile |
Syntax-check all Python files |
make test |
Run pytest |
make docs |
Regenerate API docs |
make scalar-validation |
Run 1D advection comparison |
make cfd-uniform |
Uniform flow preservation test |
make cfd-sod |
2D Sod shock tube |
make cfd-entropy |
Entropy wave single run |
make cfd-entropy-convergence |
Entropy wave convergence (32/64/128) |
make cfd-vortex |
Isentropic vortex single run |
make cfd-vortex-convergence |
Isentropic vortex convergence (32/64/128) |
make cfd-validation |
Full CFD validation suite |
make cfweno-scalar-demo |
CFWENO3 scalar prototype demo |
make cfweno-scalar-convergence |
CFWENO3 convergence study |
make cfweno-scalar-cfl-sweep |
CFWENO3 CFL stability sweep |
make demo-real-paper-scalar |
Full CFWENO scalar demo |
make cfweno-burgers-demo |
CFWENO3 Burgers prototype demo |
make cfweno-burgers-convergence |
CFWENO3 Burgers convergence study |
make cfweno-burgers-predictor-sweep |
CFWENO3 Burgers predictor sensitivity |
make cfweno-burgers-cfl-sweep |
CFWENO3 Burgers CFL sensitivity |
make cfweno-burgers-reference-sensitivity |
CFWENO3 Burgers reference grid sensitivity |
make demo-real-paper-burgers |
Full CFWENO Burgers demo |
make demo-hll-workflow |
Run HLL paper-to-code demo end-to-end |
make validation-index |
Generate docs/validation_index.md |
make health |
Repo health check |
make release-check |
Full release checks (compile + test + health + validation-index) |
| This project | Real CFD project |
|---|---|
| 2D Euler (NumPy) | 3D RANS/LES/DNS (C++/Fortran) |
| Rusanov / HLL flux | HLLC, WENO, DG schemes |
| 50x50 uniform grid | 10M+ cells, AMR |
| Forward Euler / SSP RK2 | RK3, IMEX, dual time stepping |
| np.roll / ghost cells | MPI halo exchange |
| pytest | Regression suites + verification cases |
| 5 agents | 10-20 agents (mesh, BC, I/O, performance, etc.) |