Repository navigation
v0.3.0 — stoichiometry (limiting reagent, yield, leftovers)
New tool: stoichiometry. Give the equation and how much of each reactant you actually have
(mol or g) and get the extent of reaction, which reactant runs out first, how much of every product
forms, and what is left over. Add product + actualYieldG for theoretical and percent yield.
{ "equation": "C3H8 + O2 -> CO2 + H2O",
"reactants": [{ "formula": "C3H8", "moles": 0.5 }, { "formula": "O2", "moles": 2 }],
"product": "CO2", "actualYieldG": 44 }→ limiting: ["O2"], extent: 0.4, CO2 1.2 mol / 52.8108 g, propane leftover 0.1 mol / 4.4097 g,
percentYield: 83.3162913646.
Deterministic rules:
- Every reactant needs an amount — an unstated one would make the limiting reagent undefined, so it is
an error naming the missing species (never an assumption about “excess”). - Exactly stoichiometric amounts report both reactants as limiting and no leftovers.
- Coefficients come from the exact rational balancer (the equation may be written unbalanced); grams are
converted with the same IUPAC molar massesformula_massreports. - Errors instead of guesses: not-a-reactant, both/neither of
moles/grams, duplicates, non-positive
amounts, product not in the equation,actualYieldGwithoutproduct.
Also in this release
- Oracle self-check (
--check): the value oracle now verifies itself against outside rulers —
8 published molar masses, 2 textbook coefficient sets, R and the molar volume, the pH definition, and
mass-conservation / leftover bounds over every stoichiometry case. It caught a wrong product row while
being written. - Shared lossless-JSON helper: tests now use
assertLosslessfrom the canonical template, so-0,
NaN/±Infinityandundefinedlive keys are all rejected. - Numbers: 136 → 149 tests, coverage 88.89% → 90.35%.
v0.3.0 — 限量试剂计算(stoichiometry)
新工具 stoichiometry:给出方程式与每种反应物的实际量(mol 或 g),得到反应进度、哪种反应物先
耗尽、各产物生成量与剩余量;再给 product + actualYieldG 还能算理论产量与产率。
{ "equation": "C3H8 + O2 -> CO2 + H2O",
"reactants": [{ "formula": "C3H8", "moles": 0.5 }, { "formula": "O2", "moles": 2 }],
"product": "CO2", "actualYieldG": 44 }→ 限量试剂 O2、进度 0.4、CO2 1.2 mol / 52.8108 g、丙烷剩 0.1 mol / 4.4097 g、产率
83.3162913646 %。
确定性规则:
- 每个反应物都必须给量——漏给会让「限量试剂」无定义,所以直接报错并点名缺哪个,不假设“过量”;
- 恰好按配比投料时,两种反应物都算限量,且没有任何剩余;
- 系数由精确有理数配平器给出(方程式可以不平衡着写),克的换算与
formula_mass用同一套 IUPAC 摩尔质量; - 一律报错而不猜:不是该方程的反应物、同时/都没给 mol 与 g、重复条目、非正数、产物不存在、只给产率不给产物。
同版本附带
- oracle 自检(
--check):期望值脚本现在拿外部尺子自检——8 个公开摩尔质量、2 组教科书系数、
气体常数与摩尔体积、pH 定义,以及每个限量试剂用例的质量守恒与剩余边界。写自检时它当场抓出一处产物行取错。 - 共享无损 JSON 助手:测试改用标准模板的
assertLossless,-0、NaN/±Infinity、undefined活键一并拦截。 - 数字:测试 136 → 149,覆盖率 88.89% → 90.35%。