This repository contains Python implementations of the examples presented in the paper "Log-Linear Reaction Quotient Dynamics" by Steven Diamond (arXiv:2508.18523).
This framework introduces a novel approach to modeling chemical reaction networks where reaction quotients (Q) evolve exponentially toward equilibrium when viewed on a logarithmic scale. Unlike traditional mass action kinetics, this yields analytically tractable linear dynamics in log-space.
For a single reaction, the dynamics follow:
d ln Q/dt = -k ln(Q/Keq)
Where:
- Q: Reaction quotient measuring distance from equilibrium
- Keq: Equilibrium constant
- k: Relaxation rate constant
- Analytical Solutions: Exact solutions exist for arbitrary network topologies
- Thermodynamic Integration: Automatic incorporation of constraints via ΔG = RT ln(Q/Keq)
- Decoupled Dynamics: Conservation laws separate from reaction quotient evolution
- Linear Control: External energy sources (e.g., ATP) couple linearly to dynamics
- Tractable Analysis: Decades of linear systems theory become applicable
File: simple_AB_example.py
Figure: AB_reaction_comparison.png
Section: 4 (Mass action comparison)
Validates the log-linear framework against traditional mass action kinetics for the simplest reversible reaction. The parameter matching k = kr(1 + Keq) ensures agreement near equilibrium, while far from equilibrium the log-linear model shows faster relaxation due to exponential decay in log-space.
Key Insights:
- Near equilibrium: virtually indistinguishable from mass action
- Far from equilibrium: faster convergence due to log-space dynamics
- Analytical solution: Q(t) = Keq(Q0/Keq)^exp(-kt)
File: feedback_simple.py
Figure: feedback_simple.png
Section: 4 (Feedback inhibition)
Demonstrates the minimal feedback motif where product B inhibits its own formation from A. Feedback effectively increases the relaxation rate from k to k + α, implementing a natural robustness-responsiveness tradeoff.
Key Features:
- Steady state: Qss = Keq exp(u/(k + α))
- Feedback prevents unlimited accumulation despite constant drive
- Reduced sensitivity to drive fluctuations with stronger feedback
- System remains stable for all α > 0
File: atp_drive_reaction.py
Figure: hexokinase_ATP_drive.png
Section: 4 (ATP-driven reaction)
Models the first step of glycolysis where glucose is phosphorylated using ATP energy. Demonstrates how cellular energy state can drive reactions far from chemical equilibrium through thermodynamic coupling.
Highlights:
- Control input: u = kATP ln([ATP]/[ADP])
- Sharp sigmoid response between ATP/ADP ratios of 1-10
- At cellular conditions: 98% glucose trapped as G6P despite unfavorable chemistry
- Biological switching behavior emerges from thermodynamic coupling
File: coupled_transport.py
Figure: coupled_transport.png
Section: 4 (Coupled transport)
Illustrates two membrane transporters (Na+ and H+) sharing membrane potential through off-diagonal coupling in the rate matrix K. Demonstrates emergence of complex non-monotonic dynamics.
Phenomena:
- Overshoot behavior in H+ transport
- Eigenmode decomposition explains dynamics
- Fast mode (λ = 2.2): transporters oppose
- Slow mode (λ = 0.8): transporters move together
- Interference between modes creates transient overshoot
File: glycolysis.py
Figure: glycolytic_oscillations.png
Section: 4 (Glycolytic oscillations)
Models oscillatory behavior in a simplified glycolytic pathway with FBP feedback activation. Shows how metabolic rhythms arise from linear dynamics in log-space without requiring Hill functions.
Analysis:
- Eigenvalues λ = 0.5 ± 2i determine oscillation properties
- Period: τ = 2π/ω ≈ 3.1 seconds (matches yeast experiments)
- Damping without ATP drive
- Sustained limit cycle with resonant ATP forcing
- Analytical solution available for transient and steady-state behavior
File: ab_cd_example.py
Figures: ab_cd_reaction.png, ab_cd_Q_relaxation.png
Section: Extension of framework
Models the A + B ⇌ C + D reaction under log-linear dynamics. Demonstrates quadratic root-finding to recover species concentrations from reaction quotient Q(t), with physically valid solutions ensuring all concentrations remain nonnegative.
Key Features:
- Closed-form Q(t) = Keq(Q0/Keq)^exp(-kt) solution
- Quadratic solver for extent of reaction ξ(t) from Q(t)
- Continuity enforcement for smooth concentration trajectories
- Mass-action comparison
File: push_pull.py
Figures: push_pull_fraction_vs_ATP.png, push_pull_step_response.png
Section: 4 (Linear control / energy-driven switching)
Shows a thermodynamic push–pull (futile) phosphorylation cycle driven by ATP/ADP.
In log-space the dynamics are linear:
File: single_reaction_general.py
Figures: general_single_reaction_conc.png, general_single_reaction_Q.png
Section: Framework extension
Demonstrates the log-linear framework for arbitrary single reactions with general stoichiometry. Uses the example reaction 2A + B ⇌ C + 2D, showing how to solve for species concentrations from reaction quotient Q(t) via root-finding on the extent of reaction ξ.
Key Features:
- General stoichiometric coefficients: α (reactants), β (products)
- Root-finding solution: S(ξ) = ln Q(t) with feasibility constraints
- Robust numerical methods with boundary clamping
- Direct comparison to mass-action kinetics
- Demonstrates crossing dynamics as system evolves toward equilibrium
File: receptor_competition.py
Figure: receptor_competition_dose_response.png
Section: Classical binding equilibrium
Models competitive binding between agonist ligand L and antagonist C for the same receptor R. Demonstrates classic pharmacology dose-response shifts using normalized binding equilibrium equations.
Key Features:
- Competitive binding: f_L = Lk/(1 + Lk + Ck) with normalized concentrations
- Parallel rightward shifts in dose-response curves with increasing antagonist
- Dose ratio relationship: EC50(C)/EC50(0) = 1 + Ck
- Demonstrates receptor occupancy vs. ligand concentration across antagonist levels
- Standard binding assay assumptions with ligand excess conditions
File: longevity_tradeoff.py
Figure: longevity_tradeoff.png
Section: Biological applications
Models the cellular tradeoff between maintenance/autophagy and anabolic growth using two coupled reaction-quotient modes driven by energy state (NAD+/NADH) and nutrient signaling (mTOR). Demonstrates how caloric restriction vs. ad libitum feeding affects the balance between longevity-promoting and growth-promoting cellular processes.
Key Features:
- Maintenance mode Q1: AMPK/Sirtuin-driven autophagy and cellular repair
- Growth mode Q2: mTOR-driven anabolic processes
- Coupled dynamics: d/dt ln Q = -K ln(Q/Keq) + u with off-diagonal coupling
- Control inputs: u1 ∝ ln(NAD+/NADH), u2 ∝ ln(nutrient) - ln(NAD+/NADH)
- Two conditions: ad libitum (high nutrients, low NAD+/NADH) vs. caloric restriction (low nutrients, high NAD+/NADH)
- Demonstrates how energy state drives cellular resource allocation between competing pathways
File: conservation_decoupling.py
Figures: reaction_quotient_dynamics.png, concentration_dynamics.png
Section: Framework fundamentals
Demonstrates the core property of log-linear reaction quotient dynamics: the trajectory of Q(t) is independent of conserved pool size. For the simplest A ⇌ B reaction, different total concentrations (Ctot = [A] + [B]) produce different concentration time-courses while sharing the same Q(t) evolution.
Key Features:
- State variable: Q = [B]/[A] evolves independently of conservation constraints
- Log-linear dynamics: d/dt ln Q = -k ln(Q/Keq) with analytical solution
- Concentration reconstruction: [A] = Ctot/(1+Q), [B] = CtotQ/(1+Q)
- Conservation-decoupling principle: changing Ctot alters concentrations but not Q(t)
- Clean separation of thermodynamic relaxation from matter bookkeeping
File: t_jump.py
Figure: t_jump.png
Section: Experimental kinetics
Demonstrates classic temperature-jump relaxation kinetics using the log-linear framework. Shows how reaction quotient Q tracks a time-varying equilibrium constant Keq(T) through exponential relaxation in log-space, providing a direct method to measure relaxation rates from experimental data.
Key Features:
- Single ODE: d/dt ln Q = -k[ln Q - ln Keq(T)]
- van 't Hoff temperature dependence: ln Keq(T) = -ΔH/RT + ΔS/R
- Exponential decay of deviation δ(t) = ln(Q/Keq) after each temperature step
- Direct measurement of relaxation rate k from semi-log plots
- Temperature protocol: step changes (298K → 330K → 298K) with customizable timing
- Parameter estimation from experimental-style data fitting
File: mm_log_linear_demo.py
Figure: mm_rq_comparison.png
Section: Enzyme kinetics connection
Demonstrates how classic Michaelis-Menten enzyme kinetics emerges naturally from log-linear reaction quotient dynamics in the fast-binding equilibrium limit. Shows the connection between thermodynamic reaction quotient evolution and enzymatic rate laws.
Key Features:
- Enzyme system: E + S ⇌ ES → E + P with binding quotient Q₁ = [ES]/([E][S])
- Fast binding assumption: Q₁ rapidly equilibrates to K (u₁ = 0)
- MM derivation: v = k_cat × [ES] with [ES] = E_tot × S/(K_D + S)
- Control input effects: u ≠ 0 drives system away from thermal equilibrium
- Analytical solution: Q(t) = K × exp(x₀×exp(-kt) + (u/k)(1-exp(-kt)))
- Steady-state equivalence: RQ framework reproduces MM rate law exactly
- Dynamic demonstration: Shows exponential relaxation to MM equilibrium with timescale τ = 1/k
pip install numpy scipy matplotlibEach example can be run independently:
python simple_AB_example/simple_AB_example.py
python feedback_inhibition/feedback_simple.py
python ATP_driven_reaction/atp_drive_reaction.py
python coupled_transport/coupled_transport.py
python glycolitic_oscillations/glycolysis.py
python bimolecular_exchange/ab_cd_example.py
python single_reaction_general/single_reaction_general.py
python receptor_competition/receptor_competition.py
python longevity_tradeoff/longevity_tradeoff.py
python conservation_decoupling/conservation_decoupling.py
python t_jump_relaxation/t_jump.py
python michaelis_menten/mm_log_linear_demo.pyAll examples include adjustable parameters at the top of each file. Modify these to explore different dynamical regimes:
- Relaxation rates (k)
- Equilibrium constants (Keq)
- Coupling strengths (α, kATP)
- Initial conditions (Q0)
Solution: Q(t) = Keq * (Q0/Keq)^exp(-kt)
With control input u:
Q(t) = Keq * exp[ln(Q0/Keq - u/k) * exp(-kt) + u/k]
Vector form: d/dt ln Q = -K ln(Q/Keq) + u
Where K is the relaxation rate matrix determining:
- Diagonal elements: individual reaction rates
- Off-diagonal elements: reaction coupling
- Eigenvalues: stability and oscillation properties
The framework naturally incorporates free energy:
- ΔG = RT ln(Q/Keq)
- Dynamics become: dΔG/dt = -kΔG
- Control inputs represent external energy gradients
This framework may enable:
- Metabolic Engineering: Optimize pathway design using K as design variable
- Drug Discovery: Predict drug effects throughout metabolic networks
- Systems Medicine: Classify metabolic disorders via eigenvalue analysis
- Control Theory: Apply optimal control to cellular metabolism
If you use this code in your research, please cite:
@article{diamond2025loglinear,
title={Log-Linear Reaction Quotient Dynamics},
author={Diamond, Steven},
journal={arXiv preprint arXiv:2508.18523},
year={2025}
}This code is licensed under the Apache License 2.0. See the LICENSE file for details.
- Paper: arXiv:2508.18523
- Repository: github.com/reactionquotient/examples
- Contact: steven@gridmatic.com