Partial pressures of A and B
Rates of the forward and back reactions converge
Net forward rate
The reaction quotient Q approaches K
How this is calculated
For the elementary reaction 2 A ⇌ B, written with partial pressures (ideal gases):
At equilibrium the two rates are equal, which gives K = kf/kr = P(B)/P(A)². The reaction quotient Q = P(B)/P(A)² has the same form but uses whatever pressures are present at the moment. When Q < K the net reaction forms B; when Q > K it forms A.
The perturbations. Compressing the gas by a factor n multiplies both partial pressures by n. Because Q has P(A) squared in the denominator, Q falls by a factor n, so the reaction shifts toward B, the side with fewer molecules. Adding A or B changes one partial pressure suddenly; the amounts added are given as partial pressures at the volume in effect at the time. If a removal would make a pressure negative, it is set to zero.
How fast equilibrium returns. Near equilibrium, a small displacement decays with relaxation time
Because of the P(A) term, the reaction re-equilibrates faster at higher pressure. The page uses this formula, with the larger of the starting and post-addition pressures, to choose the time scale, as the MATLAB version does.
Numerical integration. Because the forward rate depends on P(A)², the rate equations are nonlinear and the page solves them numerically, stepping forward in time with the fourth-order Runge–Kutta method. The step size is kept small compared with the local relaxation time, so the result matches MATLAB's ode45.
Web version of the MATLAB function Sim_twoAtoBr3 (J. Kahn, UMD). Doing the real experiment would need magical tanks of A and B that do not react while being added.