Home

Batch Reactor Simulator

I built a batch reactor solver that follows concentration and conversion over time. For these simple kinetics, an analytical answer is available, so I can check the numerical result directly.

GitHubSaved results

ScopeA single reactant with zero-, first-, or second-order kinetics. Each case uses a constant rate coefficient.

The calculation

I solve dC/dt = −kCⁿ with SciPy’s solve_ivp, then calculate conversion from the concentration change. Cases are read from CSV or Excel, which makes it straightforward to change the initial concentration or run time and compare the results.

The program saves the time history as well as a summary for each case. If the numerical solver reports a failure, it stops rather than saving that result.

Checking against the exact solution

At each reported time, I compare the numerical concentration with the analytical solution for that reaction order. The summary records the largest absolute difference over the run.

Maximum concentration error in the repository’s saved example cases, each run for 500 seconds.
CaseMaximum error (mol/L)
Zero order1.11 × 10⁻¹⁶
First order3.57 × 10⁻⁴
Second order8.30 × 10⁻⁴

The program reports the error without an automatic pass/fail tolerance. I still need to choose an acceptable error for the intended calculation.

Model limits

This is a simple kinetics model. It has no energy balance or temperature-dependent rate coefficient, and it does not represent a reaction network.

The code clips negative numerical concentrations to zero. That prevents negative output, but behavior near complete depletion needs a closer check before extending the model. Agreement with the analytical equations verifies those calculations; it is not a comparison with reactor measurements.

Code and results

The repository contains the solver and example inputs. Detailed CSV and Excel outputs keep the numerical and analytical concentrations side by side.

Based on the public code and saved outputs reviewed September 10, 2026.