← All projects

Modernizing 1980s Chemical-Equilibrium Solvers

Ported two 1982 FORTRAN 77 chemical-equilibrium programs to modular modern Fortran, keeping the original input formats and matching the original numerical results.

Client
Engineering client (via Fiverr)
Year
2025
Category
Other
Stack
  • Fortran 77
  • Fortran 90/95
  • gfortran
  • Make
  • Python
  • NumPy
  • PyInstaller

The problem

The client relied on two equilibrium solvers written in 1982: one known as BNR and one known as VCS. The fixed-form FORTRAN 77 code used COMMON blocks and dozens of GOTOs, and was hard to read and extend. The new code still had to give the same answers.

What I built

  • Code analysis: a written walk-through of the original algorithm’s logic and data flow before any rewrite.
  • BNR port: free-form modern Fortran, with COMMON blocks replaced by modules and GOTO jumps replaced by structured loops and branches.
  • VCS rewrite: split into modules for data types, utilities, chemical potentials, basis selection and stoichiometry, equilibrium iteration, and I/O.
  • Format compatibility: the modern program reads the original BNR-format input files unchanged and writes output in the exact layout the client expected, including phase split, Lagrange multipliers and convergence values.
  • Verification: three reference cases (hydrazine combustion, a chlorine–water solution and a blast-furnace problem) set up as test inputs and checked against the 1982 output.
  • Python version: an equilibrium calculator in Python with input validation, packaged as a standalone Windows executable.
  • Delivery: a Makefile, command-line executables, a user guide and sample runs.

Details

The hydrazine case reproduces the original iteration count, equilibrium mole numbers and G/RT to at least six significant figures.