CFD Wave Schemes Read the README
Fortran · Python · CFD

Upwind vs MacCormack, side by side.

Two classic finite-difference schemes for the 1-D linear wave equation: the original Fortran studies, a Python port tested against their output, and an error comparison against the exact solution.

Fortran · Python · CFD
cfd-wave-schemes · previewscreenshot
CFD Wave Schemes screenshot
3platforms: Fortran, Python, CFD
MITopen source licence
Why it exists

Two schemes, one pulse, an honest comparison.

The grid is 301 nodes with a spacing of 0.01 and a time step of 0.01, so the Courant number is 0.09.

This repo merges two earlier repos, Upwind-Differencing-Scheme and Explicit-Maccormack-Method.

What's inside

What the comparison shows.

Upwind

First order: smooth but strongly diffusive. At t = 15 s the pulse peak has dropped to 0.22.

MacCormack (textbook)

Second order: keeps the peak (0.73 at t = 15 s) but adds trailing wiggles from dispersion.

Exact solution

Every scheme is scored by RMS error against the exactly translated pulse.

Original Fortran

fortran/upwind.f90 and fortran/maccormack.f90 compile with any Fortran 90 compiler and write Gnuplot-ready .plt files.

Tested Python port

schemes.py reproduces the Fortran output; the tests check both ports against the committed results within 1e-5.

Two findings

Snapshots are at t = 1, 3, 6, 10, 15 ... 55 s, not 1 to 10 s, and the old MacCormack results came from a backward-difference predictor.

Run it yourself

Run the comparison.

From the README’s “Run it” section. Full options, requirements and troubleshooting are there too.

Open the README
shell
$ pip install numpy matplotlib
$ python schemes.py              # error table + comparison.png
$ python tests/test_schemes.py   # port vs Fortran output checks
Under the hood

How it's built.

Built with

Language
FortranPython
Output
Tecplot / Gnuplot data
Testing
Automated tests

37 files in the repo · last updated 8 Nov 2026.

Browse the code
Questions

Good questions.

What does it run on?

Fortran, Python, CFD.

How do I get it running?

The commands in the “Run it” box above come straight from the README. Paste them into a terminal; the README covers options and troubleshooting.

Is it free?

The source is public on GitHub under the MIT licence.

Who made it?

Juwen Lie, an R&D mechanical engineer in Batam, Indonesia, as an independent personal project.

Keep exploring

More from the same workbench.

Read the code and the numbers.

Upwind vs MacCormack, side by side.