// =============================================================================
// LE CHATELIER LAB: INTERFACE
// =============================================================================
// Built once; `render` updates it in place, so focus never jumps. Three bar charts show the mixture
// before a change, right after it, and at the new equilibrium; the line above them shows Q against
// K on a log scale. See "actions" for the beats of a click.
{
lcStyles;
const C = lcCore, api = C.build(lcData);
const H1 = !!window.__lcTitleH1, NOFS = !!window.__lcNoFs;
const reduceMotion = () => !!(window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches);
const S = { id: 'n2o4', st: null, view: null, undo: [], scale: 1, timers: [], msg: '', win: null, prevWin: null, lineW: 0 };
const esc = (t) => String(t).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
const strip = (h) => String(h).replace(/<[^>]+>/g, '').replace(/ /g, ' ').replace(/−/g, '−').replace(/×/g, '×')
.replace(/ /g, ' ').replace(/°/g, '°').replace(/∞/g, 'infinity');
const RX = () => api.RX[S.id];
const unitHTML = (s) => api.unitOf(s) === 'M' ? '<span class="unit-molar">M</span>' : api.unitOf(s);
const spName = (s) => s.name || (s.html + '(' + s.state + ')');
// ---------------------------------------------------------------- skeleton
const groups = api.GROUPS.map(([g, lab]) => '<optgroup label="' + esc(lab) + '">' +
api.list.filter(r => r.group === g).map(r => '<option value="' + r.id + '">' + esc(r.label) + '</option>').join('') + '</optgroup>').join('');
const root = document.createElement('div');
root.className = 'lcl-widget';
root.setAttribute('role', 'region');
root.setAttribute('aria-labelledby', 'lcl-title');
const hT = H1 ? 'h1' : 'h2', hS = H1 ? 'h2' : 'h3', hS2 = H1 ? 'h3' : 'h4', hS3 = H1 ? 'h4' : 'h5';
root.innerHTML =
(NOFS ? '' : '<a class="lcl-fs-btn" href="/files/ojs/le-chatelier-lab-viewer.html" target="_blank" rel="noopener" title="Open in a new tab (projector view)" aria-label="Open the Le Chatelier Lab in a new tab">⛶</a>') +
'<' + hT + ' class="lcl-title" id="lcl-title">Le Chatelier Lab</' + hT + '>' +
'<p class="lcl-sub">Disturb a reaction at equilibrium and watch it respond. Changing an amount or a volume can move <i>Q</i>. Changing the temperature moves <i>K</i>. Comparing <i>Q</i> with <i>K</i> tells you which way the reaction goes.</p>' +
'<div class="lcl-top"><label for="lcl-rx">Reaction</label><select id="lcl-rx">' + groups + '</select><span class="lcl-spacer"></span>' +
'<span class="lcl-actions"><button type="button" class="lcl-btn" id="lcl-undo">Undo</button><button type="button" class="lcl-btn" id="lcl-reset">Reset</button></span></div>' +
'<div class="lcl-body">' +
'<div class="lcl-card lcl-left"><div class="lcl-card-h"><' + hS + ' class="lcl-h" id="lcl-cond-h">Conditions</' + hS + '></div><div class="lcl-card-b">' +
'<div class="lcl-flask" aria-hidden="true"></div>' +
'<div class="lcl-group" role="group" aria-labelledby="lcl-t-lab"><p class="lcl-read"><span id="lcl-t-lab">Temperature</span> <b id="lcl-T"></b> <span class="lcl-sets" id="lcl-t-sets"></span></p>' +
'<div class="lcl-btns"><button type="button" class="lcl-btn" data-key="cool">Cool 25 K</button><button type="button" class="lcl-btn" data-key="heat">Heat 25 K</button></div>' +
'<p class="lcl-note" id="lcl-t-note"></p></div>' +
'<div class="lcl-group" role="group" aria-labelledby="lcl-v-lab"><p class="lcl-read"><span id="lcl-v-lab">Volume</span> <b id="lcl-V"></b></p>' +
'<div class="lcl-btns"><button type="button" class="lcl-btn" data-key="compress">Compress: <i>V</i> × ½</button>' +
'<button type="button" class="lcl-btn" data-key="expand">Expand: <i>V</i> × 2</button>' +
'<button type="button" class="lcl-btn" data-key="dilute">Dilute: <i>V</i> × 2</button></div></div>' +
'<div class="lcl-group" role="group" aria-labelledby="lcl-a-lab"><p class="lcl-read"><span id="lcl-a-lab">Amounts</span></p><div class="lcl-amounts" id="lcl-amounts"></div></div>' +
'<div class="lcl-group" role="group" aria-labelledby="lcl-o-lab"><p class="lcl-read"><span id="lcl-o-lab">Other changes</span></p>' +
'<p class="lcl-read" id="lcl-p-wrap">Total pressure <b id="lcl-P"></b></p>' +
'<div class="lcl-btns"><button type="button" class="lcl-btn" data-key="argon">Add argon</button><button type="button" class="lcl-btn" data-key="catalyst">Add catalyst</button></div>' +
'<p class="lcl-note" id="lcl-cat-read"></p></div>' +
'</div></div>' +
'<div class="lcl-card lcl-right">' +
'<div class="lcl-card-h"><' + hS + ' class="lcl-h lcl-eqn" id="lcl-eqn"></' + hS + '></div><div class="lcl-card-b"><p class="lcl-rxnote" id="lcl-rxnote"></p>' +
'<p class="lcl-readout" id="lcl-readout"><span class="lcl-rel" id="lcl-rel"></span><span class="lcl-kval" id="lcl-kval"></span></p>' +
'<div class="lcl-line" id="lcl-line"></div>' +
'<div class="lcl-bars-h"><' + hS2 + ' class="lcl-h" id="lcl-bars-h">Composition</' + hS2 + '></div>' +
'<div class="lcl-charts">' +
'<div class="lcl-chart" id="lcl-chart-b" role="group" aria-labelledby="lcl-cb-h"><' + hS3 + ' class="lcl-h lcl-chart-h" id="lcl-cb-h">Before the change</' + hS3 + '>' +
'<div class="lcl-bars-wrap"><div class="lcl-bars" id="lcl-bars-b"></div><p class="lcl-veil" id="lcl-veil-b" hidden>No change made yet.</p></div></div>' +
'<div class="lcl-chart" role="group" aria-labelledby="lcl-ci-h"><' + hS3 + ' class="lcl-h lcl-chart-h" id="lcl-ci-h">Right after the change</' + hS3 + '><div class="lcl-bars" id="lcl-bars-i"></div></div>' +
'<div class="lcl-chart" id="lcl-chart-e" role="group" aria-labelledby="lcl-ce-h"><' + hS3 + ' class="lcl-h lcl-chart-h" id="lcl-ce-h">New equilibrium</' + hS3 + '>' +
'<div class="lcl-bars-wrap"><div class="lcl-bars" id="lcl-bars-e"></div></div></div>' +
'</div><p class="lcl-scale" id="lcl-scale"></p>' +
'</div></div>' +
'<div class="lcl-happened"><' + hS + ' class="lcl-h lcl-wh" id="lcl-wh">What happened</' + hS + '>' +
'<div class="lcl-status" id="lcl-status" role="status" aria-live="polite"></div>' +
'</div></div>' +
'<p class="lcl-foot">The motion is schematic. It shows where the mixture ends up and says nothing about how fast it gets there. ' +
'Gases are shown as partial pressures and solutes as concentrations, and <i>K</i><sub>p</sub> uses <i>p</i>° = 1 atm. ' +
'<i>K</i> values: NIST-JANAF (N<sub>2</sub>O<sub>4</sub>), the CRC Handbook (the other gas reactions, <i>K</i><sub>sp</sub> of AgCl and <i>K</i><sub>a</sub> of acetic acid), ' +
'IAPWS-IF97 (the vapor pressure of water), and <i>J. Chem. Educ.</i> <b>1999</b>, <i>76</i>(9), 1260 (<i>K</i><sub>f</sub> of FeSCN<sup>2+</sup>). ' +
'Δ<sub>r</sub><i>H</i> values: the CRC Handbook (NIST-JANAF for N<sub>2</sub>O<sub>4</sub>), <i>J. Phys. Chem. Ref. Data</i> <b>2002</b>, <i>31</i>, 231 (acetic acid), and <i>J. Am. Chem. Soc.</i> <b>1958</b>, <i>80</i>, 2961 (FeSCN<sup>2+</sup>). ' +
'To work any of these step by step, use the <a href="/book/learning-lab-equilibrium.html">Chemical Equilibrium Explorer</a>.</p>';
const $ = (sel) => root.querySelector(sel);
const status = $('#lcl-status');
const say = (html) => { status.innerHTML = html; };
// ---------------------------------------------------------------- flask (decorative)
const flaskSVG = (rx, st) => {
let h = '<svg viewBox="0 0 240 250" xmlns="http://www.w3.org/2000/svg" focusable="false">';
const V0 = rx.start.V, lg = Math.log2(st.V / V0);
const tints = (vals, x, y, w, hgt) => rx.sp.filter(s => s.tint && api.inQ(s)).map(s => {
const v = api.value(rx, st, s.id), a = s.amax * (1 - Math.exp(-v / s.full));
return '<rect x="' + x + '" y="' + y + '" width="' + w + '" height="' + hgt + '" fill="rgba(' + s.tint.join(',') + ',' + a.toFixed(3) + ')"/>';
}).join('');
const mound = (cx, base, w, cls) => '<path class="' + cls + '" d="M' + (cx - w / 2) + ' ' + base + ' Q' + cx + ' ' + (base - w / 2.6) + ' ' + (cx + w / 2) + ' ' + base + ' Z"/>';
if (rx.kind === 'gas') {
const gh = 40 + 150 * (lg + 4) / 8, top = 232 - gh;
const liq = rx.byId.H2Ol ? st.n.H2Ol : 0;
const pool = liq > 0 ? Math.min(gh - 12, 4 + 46 * Math.sqrt(liq / 0.5)) : 0;
h += '<rect x="52" y="' + top + '" width="136" height="' + (gh - pool) + '" fill="rgba(160,170,190,0.08)"/>';
h += tints(null, 52, top, 136, gh - pool);
if (pool > 0) h += '<rect x="52" y="' + (232 - pool) + '" width="136" height="' + pool + '" fill="rgba(70,140,215,0.55)"/>';
const nAr = Math.min(40, Math.round(st.nAr * C.R * st.T / st.V / C.AR_ATM * 5));
let seed = 7;
const rnd = () => { seed = (seed * 16807) % 2147483647; return seed / 2147483647; };
for (let i = 0; i < nAr; i++) h += '<circle class="lcl-ar" r="2.4" cx="' + (60 + rnd() * 120).toFixed(1) + '" cy="' + (top + 6 + rnd() * Math.max(4, gh - pool - 12)).toFixed(1) + '"/>';
if (rx.byId.C && st.n.C > 0) h += mound(120, 232, Math.min(126, 24 + 90 * Math.sqrt(st.n.C / 0.2)), 'lcl-solid-c');
h += '<rect class="lcl-piston" x="50" y="' + (top - 11) + '" width="140" height="11" rx="2"/><line class="lcl-rod" x1="120" y1="' + (top - 11) + '" x2="120" y2="4"/>';
h += '<path class="lcl-glass" d="M50 12 V234 H190 V12"/>';
} else {
const lh = Math.min(200, 45 + 150 * lg / 4), top = 232 - lh;
h += '<rect x="57" y="' + top + '" width="126" height="' + lh + '" fill="rgba(150,195,235,0.28)"/>';
h += tints(null, 57, top, 126, lh);
if (rx.byId.AgCl && st.n.AgCl > 0) h += mound(120, 232, Math.min(120, 20 + 90 * Math.sqrt(st.n.AgCl / 0.002)), 'lcl-solid-agcl');
h += '<path class="lcl-glass" d="M48 22 Q55 22 55 30 V234 H185 V30 Q185 22 192 22"/>';
}
if (st.cat > 0) h += '<g class="lcl-cat"><rect x="' + (rx.kind === 'gas' ? 160 : 158) + '" y="214" width="18" height="14"/><path d="M' + (rx.kind === 'gas' ? 166 : 164) + ' 214 v14 M' + (rx.kind === 'gas' ? 172 : 170) + ' 214 v14 M' + (rx.kind === 'gas' ? 160 : 158) + ' 221 h18"/></g>';
return h + '</svg>';
};
// ---------------------------------------------------------------- the Q-against-K line
// A log scale of Q, drawn in CSS pixels at the panel's width (Eric, 2026-10-05). K is a red mark
// that moves only when the temperature changes. Q is a dark disk: a change of amount or volume
// moves it away from K, and the reaction carries it back. At rest a hollow Q marks where the
// change put it, with an arrow to where the reaction took it. No value of Q is printed (decision
// 2026-09-30): the scale has no numbers, only "smaller Q" and "larger Q" at its ends.
// The window (in log10 units) is kept from click to click while everything fits, so a mark that
// does not change does not move. When the marks need more room, or far less, the window is
// zoomed about the K the reader was looking at (where Q sat too, at equilibrium), which keeps
// that point at its pixel: every mark then moves on the screen the way its value moved, and a
// change of amount or volume never moves K. The window never pans during a click (a pan folded
// into the slide made Q look as if it rose when cooling lowered it, Eric 2026-10-06). When
// temperature changes have taken K toward an end, the whole line pans back to center AFTER the
// click, everything together, as a camera would (`panLine`).
const LH = 150, AY = 64, QR = 13, PAD = 16, END = 48, GAP = 64, MINSPAN = 1, FS = 13;
const finiteLogs = (lg) => [lg.kBefore, lg.k, lg.qBefore, lg.qAfter, lg.qFinal].filter(isFinite);
// w: the line's width in px, to keep a temperature change's move of K wide enough for the arrow
const chooseWin = (lg, cur, w) => {
const f = finiteLogs(lg);
const lo = Math.min.apply(null, f), hi = Math.max.apply(null, f);
const fresh = () => { const half = Math.max(MINSPAN / 2, (hi - lo) / 2 / 0.6), mid = (lo + hi) / 2; return { lo: mid - half, hi: mid + half }; };
if (!cur) return fresh();
const span = cur.hi - cur.lo, m = 0.05;
const k = lg.kBefore, fK = (k - cur.lo) / span;
// K hard against an end (only with reduced motion, where there is no pan): start again
if (!(fK >= 0.1 && fK <= 0.9)) return fresh();
// the least span, with K held at fraction fK, that keeps every mark inside the margins
const fit = Math.max((k - lo) / (fK - m), (hi - k) / (1 - fK - m)), need = Math.max(MINSPAN, fit);
let S2 = need <= span && need >= 0.3 * span ? span : need * 1.2;
// a temperature change too small to draw an arrow for: zoom in about K until the hollow Q and
// the new K are GAP px apart, drawn to scale (pushing K instead would put it off its value)
const d = Math.abs(lg.qAfter - lg.qFinal);
if (lg.k !== lg.kBefore && w && isFinite(d) && d > 1e-9) {
const most = d * (w - 2 * (PAD + END)) / GAP;
if (most < S2) S2 = Math.max(most, fit * 1.05);
}
return S2 === span ? cur : { lo: k - fK * S2, hi: k + (1 - fK) * S2 };
};
// after a temperature change: the window shifted, without zooming, to center the marks, when K has
// gone outside the middle 40 % (null when no pan is needed)
const panTarget = (lg, cur) => {
const f = finiteLogs(lg);
if (lg.k === lg.kBefore || f.length < 5) return null;
const span = cur.hi - cur.lo, fK = (lg.k - cur.lo) / span;
if (fK >= 0.3 && fK <= 0.7) return null;
const mid = (Math.min.apply(null, f) + Math.max.apply(null, f)) / 2;
return { lo: mid - span / 2, hi: mid + span / 2 };
};
const lineFrame = (win, w) => {
const xa = PAD + END, xb = w - PAD - END;
const x = (l) => l === -Infinity ? PAD + 8 : (l === Infinity ? w - PAD - 8 : xa + (l - win.lo) / (win.hi - win.lo) * (xb - xa));
return { x, xa, xb };
};
// the width of a label (an estimate: the svg is built as a string, before it can be measured)
const textW = (html, size) => strip(html).length * (size || FS) * 0.55;
// a label of width tw placed at x with the given anchor, moved as needed to stay inside the line:
// returns its left edge (it is then drawn with text-anchor start)
const fitLeft = (x, anchor, tw, w) => {
const left = anchor === 'end' ? x - tw : (anchor === 'middle' ? x - tw / 2 : x);
return Math.max(PAD, Math.min(w - PAD - tw, left));
};
// phase 'after': Q where the change put it (no hollow Q, no arrow); 'final': the rest picture.
// ease: 'move' (Q and K slide from where the last picture showed them), 'relax' (Q slides from
// where the change put it back to K, then the hollow Q and the arrow fade in), or null.
const lineSVG = (rx, v, phase, ease, w, pan) => {
const lg = api.qkLogs(rx.id, v), F = lineFrame(S.win, w);
const qT = strip(api.qSym(rx.id)), kT = strip(api.kSym(rx.id));
const start = !v.before, stuck = Number.isNaN(lg.qAfter) || Number.isNaN(lg.qFinal);
let xK = F.x(lg.k), xQa = F.x(lg.qAfter), xQf = F.x(lg.qFinal);
const still = !stuck && (lg.qAfter === lg.qFinal || Math.abs(lg.qAfter - lg.qFinal) < 1e-9);
let toScale = true;
if (!still && !stuck && lg.k === lg.kBefore && Math.abs(xQa - xQf) < GAP) {
// a change of amount or volume too small to draw an arrow for: the hollow Q is held GAP away
// from K and the note says so. Only the hollow Q moves, so K stays on its value (the next
// click starts from it). A temperature change is zoomed in instead (chooseWin).
toScale = false;
const sg = lg.qAfter > lg.qFinal ? 1 : -1;
const lim = (x) => Math.max(PAD + 8, Math.min(w - PAD - 8, x));
xQa = lim(xQf + sg * GAP);
}
const xQ = phase === 'after' ? xQa : xQf;
const anim = (!!ease || !!pan) && !reduceMotion();
let fromQ = null, fromK = null;
if (anim && ease === 'move') { const P = lineFrame(S.prevWin || S.win, w); fromQ = P.x(lg.qBefore); fromK = P.x(lg.kBefore); }
if (anim && ease === 'relax') { fromQ = xQa; fromK = xK; }
const tr = (from, to) => from == null || !isFinite(from) || Math.abs(from - to) < 0.5 ? '' : ' style="transform: translateX(' + (from - to).toFixed(1) + 'px)"';
const fade = anim && ease === 'relax' ? ' lcl-fadein' : '';
const sub = (t, size) => '<tspan font-size="' + size + 'px" font-style="normal" dy="5">' + t + '</tspan>';
// Q (with its subscript p for a gas reaction) inside svg text, then any words after it
const qWord = (lab) => '<tspan font-style="italic">Q</tspan>' + (rx.kSub === 'p'
? '<tspan font-size="11px" dy="3">p</tspan>' + (lab ? '<tspan dy="-3"> ' + lab + '</tspan>' : '')
: (lab ? ' ' + lab : ''));
// Q = 0 (a product missing) and Q with a zero denominator (a reactant missing), in words
const endWords = (l) => l === -Infinity ? qWord('is zero') : (l === Infinity ? 'denominator of ' + qWord('is zero') : '');
const label = (x, y, anchor, html) => { const tw = textW(html); return { l: fitLeft(x, anchor, tw, w), r: fitLeft(x, anchor, tw, w) + tw, y, html }; };
const put = (b, cls) => '<text class="' + (cls || 'qlab') + '" x="' + b.l.toFixed(1) + '" y="' + b.y + '" text-anchor="start">' + b.html + '</text>';
// the text alternative: what the picture shows, in words, without a value of Q. Q against K is
// stated as a condition, never as a change (decision 2026-09-30).
const relW = (c) => c > 0 ? 'greater than' : (c < 0 ? 'less than' : 'equal to');
const c0 = v.f0 > 1e-12 ? 1 : (v.f0 < -1e-12 ? -1 : 0);
const kMoved = Math.abs(lg.k - lg.kBefore) > 1e-12;
const L = v.final.lostId ? rx.byId[v.final.lostId] : null;
const endAria = lg.qAfter === -Infinity ? ' (' + qT + ' is zero)' : (lg.qAfter === Infinity ? ' (the denominator of ' + qT + ' is zero)' : '');
let aria = qT + ' against ' + kT + ', on a log scale. ';
if (stuck) aria += 'Nothing is left that can react, so ' + qT + ' is undefined.';
else if (still) aria += v.final.eq ? qT + ' equals ' + kT + ': the mixture is at equilibrium.' : qT + ' is ' + relW(c0) + ' ' + kT + (L ? ', and with no ' + strip(L.word) + ' left the reaction cannot move.' : '.');
else {
aria += (start ? 'In the starting mixture ' : 'Right after the change ') + qT + ' is ' + relW(c0) + ' ' + kT + endAria + '.' + (kMoved ? ' The temperature change moved ' + kT + '.' : '');
if (phase === 'final') aria += ' The reaction shifts ' + (v.dir > 0 ? 'right' : 'left') +
(v.final.eq ? ' until ' + qT + ' equals ' + kT + '.' : ' until the ' + (L ? strip(L.word) : 'solid') + ' runs out, with ' + qT + ' still ' + relW(c0) + ' ' + kT + '.');
if (!toScale) aria += ' The spacing is not to scale.';
}
// the bottom row: the ends of the scale and the note; the note gets its own row when the
// three would run into each other (a narrow panel)
const endL = 'smaller ' + qWord(''), endR = 'larger ' + qWord('');
const note = 'log scale' + (toScale || still ? '' : ', spacing not to scale');
const nw = textW(note), crowded = w / 2 - nw / 2 < PAD + textW(endL) + 10;
const H2 = crowded ? LH + 18 : LH;
let h = '<svg xmlns="http://www.w3.org/2000/svg" class="lclline' + (anim ? ' lcl-anim' : '') + '" viewBox="0 0 ' + w + ' ' + H2 + '" width="' + w + '" height="' + H2 + '" role="img" aria-label="' + esc(aria) + '">';
h += '<line class="ax" x1="' + PAD + '" y1="' + AY + '" x2="' + (w - PAD) + '" y2="' + AY + '"/>';
h += '<text class="endlab" x="' + PAD + '" y="' + (LH - 6) + '" text-anchor="start">' + endL + '</text>';
h += '<text class="endlab" x="' + (w - PAD) + '" y="' + (LH - 6) + '" text-anchor="end">' + endR + '</text>';
h += '<text class="note" x="' + (w / 2) + '" y="' + (crowded ? H2 - 6 : LH - 6) + '" text-anchor="middle">' + note + '</text>';
// a break in the axis before an end that stands for Q = 0 or a zero denominator, left out where
// the arrow runs across it
const arrowOn = phase === 'final' && !still && !stuck;
const across = (x) => arrowOn && Math.min(xQa, xQf) < x && x < Math.max(xQa, xQf);
const brk = (x) => across(x) ? '' : '<path class="brk" d="M' + (x - 7) + ' ' + (AY + 8) + ' l6 -16 M' + (x + 1) + ' ' + (AY + 8) + ' l6 -16"/>';
const ends = [lg.qBefore, lg.qAfter, lg.qFinal];
if (ends.includes(-Infinity)) h += brk(PAD + END - 12);
if (ends.includes(Infinity)) h += brk(w - PAD - END + 12);
// while the solid Q sits at an end, a note under it says why
if (phase === 'after' && !stuck && !isFinite(lg.qAfter)) h += put(label(xQa, AY + 42, lg.qAfter < 0 ? 'start' : 'end', endWords(lg.qAfter)), 'note');
// the marks, in one group that a pan slides as a whole
h += '<g class="lcl-pan"' + (pan && anim ? ' style="transform: translateX(' + pan.toFixed(1) + 'px)"' : '') + '>';
// K
const kw = textW('K' + rx.kSub, 20), kl = fitLeft(xK, 'middle', kw, w);
h += '<g class="lcl-kmove"' + tr(fromK, xK) + '><rect class="kline" x="' + (xK - 1.5) + '" y="' + (AY - 30) + '" width="3" height="56"/>' +
'<text class="klab" x="' + kl.toFixed(1) + '" y="' + (AY - 37) + '" text-anchor="start">K' + sub(rx.kSub, 13) + '</text></g>';
if (!stuck) {
let taken = null;
// the hollow Q and the arrow: where the change put Q, and the way the reaction took it
if (arrowOn) {
const sg = xQf > xQa ? 1 : -1, a = xQa + sg * (QR + 3), b = xQf - sg * (QR + 3);
if (sg * (b - a) > 14) {
const head = Math.min(12, sg * (b - a) - 2), base = b - sg * head;
h += '<polygon class="lcl-arrow' + fade + '" points="' + [a + ',' + (AY - 3), base + ',' + (AY - 3), base + ',' + (AY - 8), b + ',' + AY, base + ',' + (AY + 8), base + ',' + (AY + 3), a + ',' + (AY + 3)].join(' ') + '"/>';
}
// its label hangs away from K (so it does not run into the K mark or the solid Q), and is
// kept inside the line; a Q at an end gets a second line saying why
const anchor = sg > 0 ? 'end' : 'start', ax = xQa + (sg > 0 ? QR : -QR);
const l1 = label(ax, AY + 42, anchor, start ? 'starting mixture' : 'right after the change');
const l2 = isFinite(lg.qAfter) ? null : label(ax, AY + 58, anchor, endWords(lg.qAfter));
taken = { l: Math.min(l1.l, l2 ? l2.l : Infinity), r: Math.max(l1.r, l2 ? l2.r : -Infinity), rows: l2 ? 2 : 1 };
h += '<g class="lcl-ghost' + fade + '"><circle class="qghost" cx="' + xQa + '" cy="' + AY + '" r="' + QR + '"/><text class="qgtxt" x="' + xQa + '" y="' + (AY + 5) + '" text-anchor="middle">Q</text>' +
put(l1) + (l2 ? put(l2) : '') + '</g>';
}
h += '<g class="lcl-qmove"' + tr(fromQ, xQ) + '><circle class="qdot" cx="' + xQ + '" cy="' + AY + '" r="' + QR + '"/><text class="qtxt" x="' + xQ + '" y="' + (AY + 5) + '" text-anchor="middle">Q</text>';
if (phase === 'final' && !v.final.eq) {
// a mixture that is not at equilibrium: where the reaction stopped, or that it could not move
let s = label(xQ, AY + 42, 'middle', still ? 'no equilibrium' : 'stops here');
if (taken && s.l < taken.r + 6 && s.r > taken.l - 6) s = label(xQ, AY + 42 + 16 * taken.rows, 'middle', s.html);
h += put(s);
}
h += '</g>';
}
return h + '</g></svg>';
};
// ---------------------------------------------------------------- bars
// Three charts on one scale (Eric, 2026-10-05): the mixture before the change, right after it, and
// the new equilibrium. Read across, they show the change and how much of it the reaction undoes.
// The charts only display; the [+][-] buttons are in the Conditions card (Eric, 2026-10-02).
const CHARTS = ['b', 'i', 'e'];
const buildColumns = () => {
const rx = RX();
CHARTS.forEach(c => {
$('#lcl-bars-' + c).innerHTML = rx.species.map(s => {
const side = s.nu < 0 ? 'r' : 'p';
const nameId = 'lcl-n-' + c + '-' + s.id;
const sideWord = s.nu < 0 ? 'reactant' : 'product';
let body;
if (s.solvent) body = '<div class="lcl-track lcl-pure" style="border:0;background:none"><span>Solvent, not in <i>K</i><sub>' + rx.kSub + '</sub></span></div>';
else if (!api.inQ(s)) body = '<div class="lcl-track lcl-pure" style="border:0;background:none"><span>Pure ' + (s.state === 's' ? 'solid' : 'liquid') + ', not in ' + api.qSym(rx.id) + '</span></div>';
else body = '<div class="lcl-track" aria-hidden="true">' + '<div class="lcl-fill"></div></div>';
return '<div class="lcl-col lcl-' + side + '" role="group" aria-labelledby="lcl-c' + c + '-h ' + nameId + '" data-sp="' + s.id + '">' +
'<div class="lcl-val"></div>' + body +
'<div class="lcl-name" id="' + nameId + '">' + spName(s) + '<span class="lcl-side">' + sideWord + '</span></div></div>';
}).join('');
});
// one row of [-][+] per species, in the Conditions card with the other changes
$('#lcl-amounts').innerHTML = rx.species.filter(s => !s.solvent).map(s =>
'<div class="lcl-arow" role="group" aria-labelledby="lcl-a-' + s.id + '"><span class="lcl-aname" id="lcl-a-' + s.id + '">' + spName(s) + '</span><span class="lcl-btns">' +
'<button type="button" class="lcl-btn" data-key="minus-' + s.id + '"></button>' +
'<button type="button" class="lcl-btn" data-key="plus-' + s.id + '"><span aria-hidden="true">+</span><span class="lcl-sr">Add </span>' + C.fmtSig(s.step, 3) + ' ' + unitHTML(s) + '<span class="lcl-sr"> ' + spName(s) + '</span></button></span></div>').join('');
};
const nice = (v) => {
if (!(v > 0)) return 1;
const e = Math.floor(Math.log10(v)), m = v / Math.pow(10, e);
const step = [1, 2, 2.5, 5, 10].find(x => x >= m - 1e-12);
return step * Math.pow(10, e);
};
const H = 120;
const setBars = (c, st, anim) => {
const rx = RX(), box = $('#lcl-bars-' + c);
box.classList.toggle('lcl-anim', !!anim && !reduceMotion());
rx.sp.forEach(s => {
const col = box.querySelector('[data-sp="' + s.id + '"]');
const v = api.value(rx, st, s.id);
col.querySelector('.lcl-val').innerHTML = '<span>' + C.fmtSig(v, 3) + ' ' + unitHTML(s) + '</span>';
if (!api.inQ(s)) return;
const hpx = (x) => x > 0 ? Math.max(2, Math.min(1, x / S.scale) * H) : 0;
col.querySelector('.lcl-fill').style.height = hpx(v).toFixed(1) + 'px';
});
};
// from one state to another: the bars start at `from` (no transition) and ease to `to`
const easeBars = (c, from, to) => {
setBars(c, from, false);
void $('#lcl-bars-' + c).offsetHeight;
setBars(c, to, true);
};
// the scale fits the three mixtures on show, so it shrinks again after a large change is undone
const scaleFor = (v) => {
const rx = RX();
let m = 0;
[v.before, v.after, v.final].forEach(st => st && rx.sp.forEach(s => { if (api.inQ(s)) m = Math.max(m, api.value(rx, st, s.id)); }));
return nice(m * 1.05);
};
// ---------------------------------------------------------------- controls
const updateControls = () => {
const rx = RX(), list = api.controls(S.id, S.st);
root.querySelectorAll('[data-key]').forEach(b => {
const c = list.find(x => x.key === b.dataset.key);
const present = !!c;
b.hidden = !present;
if (!present) return;
b.setAttribute('aria-disabled', c.enabled ? 'false' : 'true');
b.title = c.enabled ? '' : strip(c.reason);
if (b.dataset.key.startsWith('minus-')) {
const s = rx.byId[b.dataset.key.slice(6)];
const all = api.inQ(s) && S.st.n[s.id] > 0 && api.value(rx, S.st, s.id) < s.step * (1 - 1e-9);
b.innerHTML = all ? '<span aria-hidden="true">−</span><span class="lcl-sr">Remove </span>all<span class="lcl-sr"> of the ' + spName(s) + '</span>'
: '<span aria-hidden="true">−</span><span class="lcl-sr">Remove </span>' + C.fmtSig(s.step, 3) + ' ' + unitHTML(s) + '<span class="lcl-sr"> ' + spName(s) + '</span>';
}
});
// the Other group hides argon for solutions; the volume group shows Dilute or Compress/Expand
$('#lcl-p-wrap').hidden = rx.kind !== 'gas';
$('#lcl-t-note').innerHTML = rx.k.method === 'fixed' ? api.tempNote : 'Data from ' + C.fmtT(rx.k.Tmin) + ' K to ' + C.fmtT(rx.k.Tmax) + ' K.';
const u = $('#lcl-undo');
u.setAttribute('aria-disabled', S.undo.length ? 'false' : 'true');
u.title = S.undo.length ? '' : 'Nothing to undo';
};
// ---------------------------------------------------------------- render
// mode: 'move' (Q and K slide to where the change put them; the charts ease to the changed
// mixture, the new-equilibrium chart veiled until the reaction responds), 'reveal'
// (Q slides back to K and the new-equilibrium chart eases there), 'final' (everything still).
// The readout keeps one height, measured for its longest wording at the current width, so the
// line below it never moves. Re-measured only when the reaction or the width changes.
const kvalHTML = (T) => api.kSym(S.id) + ' = ' + api.kFmt(S.id, api.Kst(RX(), T)) + ' at ' + C.fmtT(T) + ' K';
const reserveReadout = () => {
const row = $('#lcl-readout');
const w = row.clientWidth, key = S.id + '|' + w;
if (!w || key === S.rowKey) return;
S.rowKey = key;
const rx = RX(), q = api.qSym(S.id), k = api.kSym(S.id);
const kv = k + ' = ' + api.kFmt(S.id, 1.23456e-10) + ' at 298.15 K';
const pure = rx.sp.find(s => !api.inQ(s));
const tails = [', so the reaction shifts right', ', but nothing is left that can react'];
if (pure && rx.lost) tails.push(', but with no ' + pure.word + ' left nothing can ' + rx.lost.verb);
const probe = document.createElement('p');
probe.className = 'lcl-readout';
probe.setAttribute('aria-hidden', 'true');
probe.style.cssText = 'position:absolute;visibility:hidden;left:0;top:0;width:' + w + 'px;min-height:0;';
row.parentNode.appendChild(probe);
let h = 0;
tails.forEach(t => { probe.innerHTML = '<span class="lcl-rel">' + q + ' > ' + k + t + '</span><span class="lcl-kval">' + kv + '</span>'; h = Math.max(h, probe.getBoundingClientRect().height); });
probe.remove();
row.style.minHeight = Math.ceil(h) + 'px';
};
const drawReadout = (mode) => {
const v = S.view;
$('#lcl-kval').innerHTML = kvalHTML(v.after.T);
const rel = $('#lcl-rel');
rel.innerHTML = api.readRel(S.id, v);
rel.style.visibility = mode === 'move' ? 'hidden' : 'visible';
};
const drawConditions = (st) => {
const rx = RX();
$('.lcl-flask').innerHTML = flaskSVG(rx, st);
$('#lcl-T').textContent = C.fmtT(st.T) + ' K';
$('#lcl-t-sets').innerHTML = '(sets ' + api.kSym(S.id) + ')';
$('#lcl-V').innerHTML = C.fmtSig(st.V, 3) + ' L';
if (rx.kind === 'gas') $('#lcl-P').innerHTML = C.fmtSig(api.totalP(S.id, st), 3) + ' atm';
// one line of notes under the buttons, its space always kept (on a phone this card sits above
// the Q-against-K line, so a line that came and went, or wrapped, would move it); hidden from
// screen readers when there is nothing to say
const ar = st.nAr > 0, cat = st.cat > 0;
const catEl = $('#lcl-cat-read');
catEl.innerHTML = ar && cat ? 'Argon and a catalyst added.' : (ar ? 'Argon added (in the total pressure).' : 'Catalyst added.');
catEl.hidden = false;
catEl.style.visibility = ar || cat ? 'visible' : 'hidden';
catEl.setAttribute('aria-hidden', ar || cat ? 'false' : 'true');
};
const drawLine = (mode, pan) => {
const rx = RX(), line = $('#lcl-line');
const w = Math.max(200, Math.round(line.clientWidth || 700));
S.lineW = line.clientWidth;
const phase = mode === 'move' ? 'after' : 'final';
const ease = mode === 'move' ? 'move' : (mode === 'reveal' ? 'relax' : null);
line.innerHTML = lineSVG(rx, S.view, phase, ease, w, pan);
const svg = line.querySelector('svg');
if (svg && svg.classList.contains('lcl-anim')) requestAnimationFrame(() => requestAnimationFrame(() => svg.classList.add('lcl-go')));
};
const drawCharts = (mode) => {
const v = S.view, start = !v.before;
const hideE = mode === 'move';
setBars('b', v.before || v.after, false);
if (mode === 'move' && !start) { easeBars('i', v.before, v.after); easeBars('e', v.before, v.after); }
else {
setBars('i', v.after, false);
if (mode === 'reveal') easeBars('e', v.after, v.final);
else setBars('e', v.final, false);
}
$('#lcl-chart-b').classList.toggle('lcl-veiled', start);
$('#lcl-veil-b').hidden = !start;
$('#lcl-chart-e').classList.toggle('lcl-veiled', hideE);
$('#lcl-ci-h').textContent = start ? 'Starting mixture' : 'Right after the change';
$('#lcl-ce-h').textContent = mode === 'move' || v.final.eq ? (start ? 'Equilibrium' : 'New equilibrium') : 'Final state (no equilibrium)';
const rx = RX(), qs = rx.sp.filter(api.inQ);
$('#lcl-scale').innerHTML = 'The three charts share one scale. Full height is ' + C.fmtSig(S.scale, 3) + ' ' + unitHTML(qs[0]) + (qs[0].state === 'g' ? ' (partial pressure)' : ' (concentration)') + '. The numbers above the bars are rounded to the figures shown.';
};
const render = (mode) => {
const rx = RX(), v = S.view;
S.scale = scaleFor(v);
root.style.setProperty('--lcl-ms', ((mode === 'reveal' ? RELAX_MS : MOVE_MS) / 1000) + 's');
$('#lcl-eqn').innerHTML = eqnHTML(rx);
$('#lcl-rxnote').innerHTML = rx.note + (rx.dH ? '<span class="lcl-real">' + rx.dH + '</span>' : '') + (rx.realNote ? '<span class="lcl-real">' + rx.realNote + '</span>' : '');
$('#lcl-bars-h').textContent = barsHeading(rx);
drawConditions(mode === 'move' ? v.after : v.final);
reserveReadout();
drawReadout(mode);
drawLine(mode);
drawCharts(mode);
updateControls();
};
// the heading over the bars says what they measure
const barsHeading = (rx) => {
const q = rx.sp.filter(api.inQ), pure = rx.sp.some(s => !api.inQ(s));
if (!pure && q.every(s => s.state === 'g')) return 'Partial pressures';
if (!pure && q.every(s => s.state === 'aq')) return 'Concentrations';
return 'Composition';
};
const eqnHTML = (rx) => {
const side = (sign) => rx.species.filter(s => Math.sign(s.nu) === sign).map(s => (Math.abs(s.nu) > 1 ? Math.abs(s.nu) + ' ' : '') + s.html + '(' + s.state + ')').join(' + ');
return side(-1) + ' ⇌ ' + side(1);
};
// ---------------------------------------------------------------- actions
// One click, two beats: Q (and K, on a temperature change) slide to where the change put them and
// the charts show the changed mixture (0.6 s); then Q slides back to K, the hollow Q and the arrow
// fade in, and the new-equilibrium chart eases there (0.8 s). A click during either beat jumps to
// the end of the last change. (Predict first was removed, Eric 2026-10-06: whatever the widget
// shows before a guess, the Q-against-K line or the new K, gives the answer away.)
const MOVE_MS = 600, RELAX_MS = 800;
const clearTimers = () => { S.timers.forEach(t => clearTimeout(t)); S.timers = []; };
const finish = () => {
if (!S.timers.length) return;
clearTimers();
render('final');
say(S.msg);
};
// a width change during a beat is not drawn then (it would cut the motion short), so it is drawn
// when the beat ends
const catchUp = () => { const w = $('#lcl-line').clientWidth; if (w && w !== S.lineW) drawLine('final'); };
// the camera pan after a temperature change (see the line's notes): every mark slides by the same
// amount, so nothing changes relative to anything else
const PAN_MS = 500;
const panLine = () => {
const lg = api.qkLogs(S.id, S.view), to = panTarget(lg, S.win);
if (!to || reduceMotion()) return;
const w = Math.max(200, Math.round($('#lcl-line').clientWidth || 700));
const shift = lineFrame(S.win, w).x(lg.k) - lineFrame(to, w).x(lg.k);
S.win = to;
root.style.setProperty('--lcl-ms', (PAN_MS / 1000) + 's');
drawLine('final', shift);
S.timers.push(setTimeout(() => { S.timers = []; }, PAN_MS));
};
const reveal = () => {
render('reveal');
say(S.msg);
if (!reduceMotion()) S.timers.push(setTimeout(() => { S.timers = []; catchUp(); panLine(); }, RELAX_MS));
};
const act = (key) => {
finish();
const c = api.controls(S.id, S.st).find(x => x.key === key);
if (!c) return;
if (!c.enabled) { say(c.reason); return; }
const r = api.step(S.id, S.st, c.action);
if (!r.ok) { say(r.reason); return; }
S.undo.push({ st: S.st, view: S.view, win: S.win });
S.view = r; S.st = r.final; S.msg = api.describe(S.id, r);
S.prevWin = S.win;
S.win = chooseWin(api.qkLogs(S.id, r), S.win, Math.max(200, Math.round($('#lcl-line').clientWidth || 700)));
if (reduceMotion()) {
render('final'); say(S.msg);
return;
}
render('move');
S.timers.push(setTimeout(() => {
S.timers = [];
reveal();
}, MOVE_MS));
};
const reset = (text) => {
clearTimers();
S.view = api.startView(S.id); S.st = S.view.final; S.undo = []; S.msg = '';
S.win = chooseWin(api.qkLogs(S.id, S.view), null); S.prevWin = null;
render('final');
say(text || api.startText(S.id));
};
root.addEventListener('click', (e) => {
const b = e.target.closest('button');
if (!b || !root.contains(b)) return;
if (b.dataset.key) { act(b.dataset.key); return; }
if (b.id === 'lcl-reset') { reset(); return; }
if (b.id === 'lcl-undo') {
if (!S.undo.length) { say('There is nothing to undo.'); return; }
clearTimers();
const u = S.undo.pop();
S.st = u.st; S.view = u.view; S.win = u.win; S.prevWin = null;
render('final');
say('Undid the last change.');
}
});
$('#lcl-rx').addEventListener('change', (e) => { S.id = e.target.value; buildColumns(); reset(); });
// the line is drawn at the panel's pixel width, so it is redrawn when the width changes
const ro = new ResizeObserver(() => {
reserveReadout();
const w = $('#lcl-line').clientWidth;
if (!w || w === S.lineW || S.timers.length) return;
drawLine('final');
});
ro.observe($('#lcl-line'));
invalidation.then(() => { clearTimers(); ro.disconnect(); });
buildColumns();
reset();
return root;
}Le Chatelier’s Principle
How a system at equilibrium responds to changes in concentration, temperature, and volume or pressure, and why adding a catalyst does not shift the equilibrium.
Begin with a reaction at equilibrium. Now do something to it.
- Add/remove some reactant
- Add/remove some product
- Change the temperature
- Change the volume/pressure (for gaseous reactions)
In most cases it is no longer at equilibrium. What happens? Which way will the reaction shift?
Le Chatelier’s principle says that when a reaction at equilibrium is disturbed, it shifts in the direction that partly offsets the disturbance and then settles at a new equilibrium. For example, if we add more of a reactant that appears in the equilibrium expression, the reaction consumes part of the added amount, and the new equilibrium mixture still contains more of that reactant than the old one did.
The changes on this list work in one of two ways. Adding or removing a substance, or changing the volume of a gas mixture, can pull Q away from K. A temperature change alters K itself. Either way Q and K no longer match, and the reaction shifts in whichever direction brings Q back to K. Adding a catalyst changes neither Q nor K.
The same lab has its own full-width page.
Le Chatelier’s principle is named after French chemist Henry Louis Le Chatelier.
Henry Louis Le Chatelier: French chemist (1850–1936) (Source: Wikipedia)
Changing Concentrations
Consider the following reaction at equilibrium
\[\mathrm{CaCO_3}(\mathrm{s}) + \mathrm{CO_2}(\mathrm{aq}) + \mathrm{H_2O}(\mathrm{l}) \rightleftharpoons \mathrm{Ca^{2+}}(\mathrm{aq}) + 2~\mathrm{HCO_3{}^{-}}(\mathrm{aq})\]
and its equilibrium expression
\[K_{\mathrm{c}} = \dfrac{[\mathrm{Ca^{2+}}][\mathrm{HCO_3{}^{-}}]\,\!^2}{[\mathrm{CO_2}]}\]
Neither the solid CaCO3 nor the solvent water appears in the expression. This reaction carves limestone caves and makes water hard. Rainwater picks up CO2, dissolves the limestone it flows through, and deposits the carbonate again as stalactites where the CO2 escapes.
Let us add, for example, some CO2 to the mixture. The mixture is no longer at equilibrium, and the reaction shifts until it gets back there. Which way will it shift?
Compare the reaction quotient, Qc, with Kc.
\[Q_{\mathrm{c}} = \dfrac{[\mathrm{Ca^{2+}}][\mathrm{HCO_3{}^{-}}]\,\!^2}{[\mathrm{CO_2}]}\]
Upon the addition of CO2, the denominator in the expression increases, so Qc < Kc. The reaction shifts right (consuming reactants and producing products) to reach equilibrium. Kc itself has not changed, because the temperature has not changed.
Let us now add some product to this reaction that is at equilibrium. Perhaps we add a bit of Ca2+ as a soluble calcium salt. We notice that the numerator in the reaction quotient is now larger and Qc > Kc. The reaction therefore shifts left (consuming products and producing reactants) to reach equilibrium once again.
Practice
Predict the direction of the given reaction (currently at equilibrium) for each of the following scenarios:
\[\mathrm{CaCO_3}(\mathrm{s}) + \mathrm{CO_2}(\mathrm{aq}) + \mathrm{H_2O}(\mathrm{l}) \rightleftharpoons \mathrm{Ca^{2+}}(\mathrm{aq}) + 2~\mathrm{HCO_3{}^{-}}(\mathrm{aq})\]
- Add some CO2
- Add some CaCO3
- Remove some CO2
- Remove some CaCO3
- Add some Ca2+
- Add some HCO3−
- Remove some Ca2+
- Remove some HCO3−
- Add water (dilute the solution)
Solution
\[\mathrm{CaCO_3}(\mathrm{s}) + \mathrm{CO_2}(\mathrm{aq}) + \mathrm{H_2O}(\mathrm{l}) \rightleftharpoons \mathrm{Ca^{2+}}(\mathrm{aq}) + 2~\mathrm{HCO_3{}^{-}}(\mathrm{aq})\]
- Add some CO2 → right
- Add some CaCO3 → no shift (a solid does not appear in Qc)
- Remove some CO2 → left
- Remove some CaCO3 → no shift (as long as some solid remains)
- Add some Ca2+ → left
- Add some HCO3− → left
- Remove some Ca2+ → right
- Remove some HCO3− → right
- Add water (dilute the solution) → right. Water itself does not appear in Qc. Dilution lowers every concentration, and Qc has three concentration factors in the numerator against one in the denominator. Diluting to twice the volume, for example, multiplies Qc by ¼ and leaves Qc < Kc.
Changing Temperature
Exothermic Reaction
Consider the following reaction at equilibrium.
\[\mathrm{SO_2}(\mathrm{g}) + \tfrac{1}{2}\mathrm{O_2}(\mathrm{g}) \rightleftharpoons \mathrm{SO_3}(\mathrm{g}) \qquad \Delta_{\mathrm{r}}H^{\circ} = -98.9~\mathrm{kJ~mol^{-1}}\]
The reaction is exothermic (ΔrH° < 0), meaning heat is released. If we treat heat as a product of reaction, the reaction could be written as
\[\mathrm{SO_2}(\mathrm{g}) + \tfrac{1}{2}\mathrm{O_2}(\mathrm{g}) \rightleftharpoons \mathrm{SO_3}(\mathrm{g}) + \text{heat}\]
Now we apply the same principles as we did with changing concentrations!
If the temperature of the reaction mixture is raised (heat is added), the reaction shifts left to consume the heat and reach equilibrium.
If the temperature of the reaction mixture is lowered (heat is removed), the reaction shifts right to produce heat and reach equilibrium.
Heat is not a species in Qc, so the shortcut works for another reason. A temperature change alters Kc. Warm the mixture in a closed, rigid vessel and every concentration stays where it was, so Qc does not change. For an exothermic reaction the higher temperature lowers Kc. That leaves Qc > Kc, and the reaction shifts left. Cooling raises Kc above Qc, and the reaction shifts right.
Endothermic Reaction
Consider the following endothermic reaction at equilibrium.
\[\mathrm{H_2O}(\mathrm{g}) \rightleftharpoons \mathrm{H_2}(\mathrm{g}) + \tfrac{1}{2}\mathrm{O_2}(\mathrm{g}) \qquad \Delta_{\mathrm{r}}H^{\circ} = +241.8~\mathrm{kJ~mol^{-1}}\]
We can write the reaction as follows (indicating heat as a reactant)
\[\text{heat} + \mathrm{H_2O}(\mathrm{g}) \rightleftharpoons \mathrm{H_2}(\mathrm{g}) + \tfrac{1}{2}\mathrm{O_2}(\mathrm{g})\]
If the temperature is raised, the reaction shifts right. If the temperature is lowered, it shifts left.
For an endothermic reaction, Kc rises with temperature. Heating raises Kc above Qc, and the reaction shifts right. Cooling lowers Kc below Qc, and the reaction shifts left.
How far K moves for a given change in temperature depends on the size of ΔrH°. The van ’t Hoff equation in Chapter 18 makes that quantitative.
Changing Volume/Pressure
Recall from Boyle’s law that pressure and volume are inversely proportional.
Consider the synthesis of ammonia, the reaction behind the industrial Haber process at the end of this page:
\[\mathrm{N_2}(\mathrm{g}) + 3~\mathrm{H_2}(\mathrm{g}) \rightleftharpoons 2~\mathrm{NH_3}(\mathrm{g})\]
If the vessel is compressed to a smaller volume, raising the pressure of the mixture, which way will the reaction shift to reach equilibrium?
NotePressure and Moles of Gas
At the same temperature and volume, which exerts more pressure: 4 mol of gas or 2 mol of gas? The 4 mol sample, because it has more particles striking the walls!
The gas coefficients add to 4 on the reactant side and only 2 on the product side. Converting 4 mol of gas into 2 mol lowers the pressure and partly offsets the compression, so the reaction shifts right, toward fewer moles of gas!
Increasing the volume lowers the pressure, and the reaction shifts left, toward the side with more moles of gas!
The same prediction comes out of Qp. In Qp, the partial pressures in the denominator carry exponents that add to 4 (1 + 3), and the one in the numerator carries an exponent of 2. Squeezing the gas into half the volume doubles every partial pressure. That multiplies Qp by 22/24 = ¼. Kp stays the same, so Qp < Kp and the reaction shifts right.
When the gas coefficients on the two sides add to the same total, the doublings cancel, Qp is unchanged, and nothing shifts.
Partial pressures also settle what happens when an unreactive gas such as argon is pumped into the vessel at fixed volume. The total pressure rises, but every partial pressure in Qp stays the same, so Qp still equals Kp and the reaction does not shift. If the argon is added at constant total pressure instead, the vessel must expand and every partial pressure falls. The effect is the same as increasing the volume, and the reaction shifts toward the side with more moles of gas.
Adding a Catalyst
A catalyst does not cause a shift. It lowers the activation energy by the same amount in both directions, so the forward and reverse rate constants rise by the same factor and K is unchanged. A mixture that is not yet at equilibrium gets there sooner, but it ends up with the same composition. A mixture already at equilibrium stays as it is.
Because a catalyst leaves the reactants and products themselves unchanged, ΔrH° and ΔrG° stay the same as well. The route a catalyst opens is described in Catalysis.
The Haber Process
Ammonia is one of the most heavily produced industrial chemicals, and about 80 % of its total production is used in agricultural fertilizers. The Haber–Bosch process (or Haber process) makes it from atmospheric nitrogen and hydrogen over an iron catalyst at 150 to 300 bar and 350 to 500 °C.
\[\species{nitrogen}{\mathrm{N_2}}(\mathrm{g}) + 3~\species{hydrogen}{\mathrm{H_2}}(\mathrm{g}) \rightleftharpoons 2~\species{ammonia}{\mathrm{NH_3}}(\mathrm{g}) \qquad \Delta_{\mathrm{r}}H^{\circ} = -91.8~\mathrm{kJ~mol^{-1}}\]
Le Chatelier’s principle explains these conditions. Four moles of gas become two, so high pressure shifts the reaction toward ammonia. The reaction is exothermic, so a lower temperature would raise K and the yield, but at low temperature the reaction is far too slow, even with the catalyst. Plants settle on a moderate temperature for a workable rate and make up the yield with pressure. The ammonia is also condensed out of the gas stream, and removing that product keeps the reaction shifting right. The unreacted nitrogen and hydrogen are sent back through the reactor. The iron catalyst speeds the approach to equilibrium without changing where it lies.
About 176 million metric tons of ammonia were produced in 2018, and fertilizers made from it support food production for roughly half of the world’s population. The Haber–Bosch process is one of the most important synthesis reactions in modern times. Most of its energy goes into making the hydrogen, mainly from natural gas, and altogether ammonia production uses about 1.8 % of the world’s yearly energy output.
The fertilizer-fed share of the world’s population first appears in the 1910s, when the first industrial ammonia plant opened, and it has grown to about half.
Le Chatelier and Ammonia Synthesis
Le Chatelier was on the cusp of realizing a process for the synthesis of ammonia but was beaten to the punch by two German chemists: Fritz Haber, who demonstrated the synthesis in 1909, and Carl Bosch, who spent the following years scaling it up for industry.
Le Chatelier lamented not having fully realized the synthesis of ammonia. Published correspondence to the editor of the Journal of Chemical Education demonstrates this1.
LE CHATELIER AND THE SYNTHESIS OF AMMONIA
To the Editor
Dear Sir:
In the excellent article by Professor Silverman on Henry Le Chatelier in the December issue of this journal, there is one statement to which I must take exception. On page 556 we read, “It is not strange that he [Le Chatelier] should have accomplished the synthesis of ammonia from the elements in 1901, anticipating Fritz Haber, who is usually the only one mentioned in connection with the process.” Now Le Chatelier himself in his last book “De la Methode dans les Sciences Experimentales,” published in 1936, devotes three pages (pp. 73–6) to this synthesis in which he says that he tried to accomplish the direct union of hydrogen and nitrogen under a pressure of 200 atm. at a temperature of 600 ° in the presence of metallic iron. A terrific explosion occurred which nearly killed an assistant. Some time later Le Chatelier found that the explosion was due to the presence of air in the apparatus used. And thus it was left for Haber to succeed where a number of noted French chemists, including Thénard, Sainte Claire Deville and even Berthelot had failed. At the end of his career Le Chatelier, with a disarming frankness, tells us, “I let the discovery of the ammonia synthesis slip through my hands. It was the greatest blunder of my scientific career. I should have realized this synthesis five years before Haber…..”
In calling attention to this statement I may say that those of your readers who are familiar with French will find a great many interesting observations and reflections in this scientific testament of a great Frenchman.
H. S. van Klooster
References
(1)
Klooster, H. S. van. Le Chatelier and the Synthesis of Ammonia. J. Chem. Educ. 1938, 15 (6), 289. https://doi.org/10.1021/ed015p289.3.