← Back to Portfolio

V&V-Driven Development: The pyFrost-GM Workflow

What This Article Covers

  • Verification-first development: How MATLAB baselines guided and constrained the Python reimplementation from day one.
  • Incremental validation: Building only enough of the model to attempt a published figure, then letting each new figure pull in additional physics.
  • AI-agentic acceleration: Where AI helped, where physics expertise was essential, and what "physicist-in-the-loop" means in practice.
  • Capabilities unlocked: From license-locked MATLAB to containerised, cloud-ready, extensible Python.
See the detailed validation results →

Why Re-implement a Code That Already Works?

pyFrost-GM is a Python 3 reimplementation of LoKI-GM, a global model for low-temperature plasma chemistry developed at IST Lisbon and released as MATLAB code at ESCAMPIG 2026. It is licensed under GPLv3. The source code is provided to clients as part of Deep Why's consulting and simulation engineering services — get in touch to discuss your project.

LoKI-GM is current, well-documented, and actively maintained. The reimplementation exists to add capabilities that MATLAB cannot offer:

Key Insight

V&V was the development process. Validation coverage grew alongside the code, added figure by figure, motivating what got built next while ensuring previously passing figures kept passing.

Verification: MATLAB Baselines as the Development Harness

The original MATLAB code served as the numerical ground truth. Each Python module was developed against parity tests that compared outputs to MATLAB baselines:

A module was finished when it matched its baseline, and not before. Verification baselines were added incrementally as mismatches turned up during development, or as a new figure pulled in a part of the model that didn't exist yet.

E/N verification target — pyFrost-GM vs LoKI-GM
Figure 1: Reduced electric field $E/N$ convergence — an example of a verification target. pyFrost-GM (markers) vs. LoKI-GM reference (dashed). Each such comparison served as a gate before proceeding to the next development phase.

What Parity Testing Surfaced

Parity testing surfaced a subtlety invisible from inside a single codebase: 3 of 4 O₂ vibrational rate functions (VT/VV processes) had onGasTemperature dependency flags that froze rates at the initial gas temperature $T_g$ instead of updating them as $T_g$ evolved self-consistently. Whether that was an oversight or a deliberate simplification for the standard test cases doesn't matter — a second, independent implementation made it visible immediately. The cause was traced, documented, and a compatibility flag now reproduces either behaviour.

Incremental Validation: Expanding Figure by Figure

Verification establishes code-to-code agreement. Validation asks a different question: does the physics model reproduce reality?

Validation wasn't a fixed, complete target set defined at the outset. Development was incremental: starting with a small number of published figures, building only enough of the model to attempt them, checking against the data, and then letting each new figure pull in whatever additional physics it needed. Every figure that already passed had to keep passing as the code expanded.

For the oxygen DC discharge studied by Dias et al. (2023) — a cylindrical chamber (radius $R = 1$ cm, discharge current $I = 30$ mA) swept across 12 pressures from 0.19 to 10 Torr — figures were added incrementally. This produced comparisons for:

Gas temperature Tg validation
Figure 2a: Gas temperature $T_g$ vs. pressure — pyFrost-GM compared to experimental measurements from Dias et al. (2023).
O₂ Vibrational Distribution Function
Figure 2b: $O_2(X, v)$ vibrational distribution function at 0.2, 1, and 10 Torr — demonstrating VDF resolution across operating regimes.

Coverage: Input Files vs. Literature Corpus

In terms of chemistry coverage, the O₂ discharge represents 1 of 3 vibrational chemistry folders (O₂, N₂, and CO₂), with nitrogen and CO₂ next in the backlog. But counting folders understates the coverage, and it measures the wrong thing. The pressure sweep is a parametric study of 12 operating points, each producing multiple physical observables, reconstructed specifically to compare against published data.

Counting reproduced figures rather than input files gives the more meaningful measure. pyFrost-GM is currently validated against 2 publications, covering 7 reproduced figures (6 from Dias et al. 2023, plus 1 for electron density from Alves et al. 2026). Each new chemistry adds its own targets — and the gaps in the coverage map (like nitrogen, CO₂, and more oxygen cases) are the backlog for future work.

Development Timeline

The full reimplementation — from first commit to validated O₂ pressure sweep — was completed by a single developer in approximately 30 calendar days.

55
Commits
~30
Calendar Days
11.5k
Lines of Code
7
Validated Figures
Phase Dates Commits What Happened
1. Parser & Chemistry Jul 10–13 17 Input parser, chemistry file parser, state resolver, LXCat integration, reactant/product matrix generation
2. Solver & EEDF Bridge Jul 13–15 16 GlobalModelSolver core, LoKI-B-cpp wrapper, pulse functions, adaptive EEDF triggers, post-processing, first MATLAB baselines
3. Parity & Deep Dive Jul 17–31 26 C++ in-memory bridge + SHA-256 caching (28× speedup), nitrogen support, thermal model, VT/VV subtlety discovery & compatibility flag, Chantry wall transport
4. Packaging & Validation Aug 1–8 15 GPLv3 licensing, devcontainer, database migration, MATLAB-to-JSON tooling, Dias2023 pressure sweep validation

The C++ Bridge: Reuse, Don't Rewrite

The Boltzmann EEDF solver (LoKI-B-cpp, from a previous project in the LoKI-Suite) was integrated via an 85-line pybind11 bridge (lokib_bridge.cpp) rather than being reimplemented. SHA-256 input hashing eliminates redundant Boltzmann solves when input parameters haven't changed, yielding a ~28× speedup compared to the subprocess approach.

The AI-Agentic Workflow

AI coding assistants accelerated the translation — but this is not a story about AI writing physics code autonomously. It's about a physicist using AI as a force multiplier under rigorous verification constraints.

Where AI Helped

Where Physics Expertise Was Essential

Physicist-in-the-Loop

The human sets the validation targets that constrain everything the AI produces. If AI-generated code breaks a baseline, it's caught immediately. The expertise lies in knowing which baselines matter and why a failure is a real problem versus a tolerance issue.

Beyond Validation: Capabilities Unlocked

With the verified and validated Python architecture in place, new capabilities become immediately accessible — things that would be difficult or impossible in the original MATLAB framework:

Note: While this article focuses on oxygen discharges, additional chemistries such as N₂, CO₂, and more are available upon consulting request.

See the detailed O₂ validation results →

Want to build a validated, cloud-ready version of your scientific code?

Whether it's translating MATLAB/Fortran to Python, setting up automated V&V pipelines, or adopting AI-agentic workflows for your own simulation tools — I can help build the auditable, extensible architecture you need.

Contact for a Consultation

Bibliography

Validation References:
  • [1] Dias T C et al, "A reaction mechanism for oxygen plasmas" 2023 Plasma Sources Sci. Technol. 32 084003. DOI: 10.1088/1361-6595/aceaa4 — The primary validation benchmark for pyFrost-GM oxygen chemistry.
  • [2] Alves L L et al, "LoKI-GM: a global model tool for plasma chemistry studies" 2026 Plasma Sources Sci. Technol. (in preparation). DOI: 10.48550/arXiv.2607.27234
Source Code:
  • [3] LoKI-GM — Official MATLAB repository (IST Lisbon)
Boltzmann Solver:
  • [4] Tejero A et al, "The LisbOn KInetics Boltzmann solver" 2019 Plasma Sources Sci. Technol. 28 043001. DOI: 10.1088/1361-6595/ab0537 (Open Access)