Repository navigation
v0.2.0 — balance_equation + gas_law
v0.2.0 — two new tools (6 total)
balance_equation — balances any equation with exact integer coefficients (BigInt-backed rationals, no floating-point artefacts):
- smallest integer solution, GCD-reduced and sign-normalized; per-element atom counts on both sides returned for verification
- ionic charges add a charge-conservation constraint (
MnO4- + Fe2+ + H+ -> Mn2+ + Fe3+ + H2O→ 1/5/8/1/5/4) - hydrate water participates (
CuSO4·5H2O -> CuSO4 + H2O→ 1/1/5) unique: falsewhen several independent balances exist (Fe + O2 -> Fe2O3 + Fe3O4→ 7/5/2/1, the smallest sum)- honest failures:
H2 + O2 -> H2O + N2reports “a species would need coefficient 0” instead of silently dropping N2
gas_law — ideal-gas arithmetic with fixed units (atm/L/mol/K, plus kPa, mmHg, mL, °C):
idealsolves PV = nRT for the one quantity you omit (exactly three of P/V/n/T required)molar_volume→ 22.413969545014133 L/mol at STP (textbook 22.414)densityρ = P·M/(R·T) from a formula or a given molar mass;molar_massback-calculates M = ρ·R·T/P- R = 8.31446261815324 / 101.325; missing operands and non-positive values are errors, never guesses
Tests: 102 → 136, coverage 86.34% → 88.89% (baseline ratcheted). Numeric anchors come from the independent Python oracle test/anchors-chem.py (own periodic table, own tokenizer, own Fraction-based balancer) and are cross-checked against published textbook values (propane 1/5/3/4, permanganate/HCl 2/16/2/2/5/8, 22.414 L/mol).
中文:新增两个零依赖工具。balance_equation 用 BigInt 有理数精确配平(最小整数系数、电荷守恒、结晶水、多解时给最小解、配不平就明说);gas_law 做理想气体四大运算(PV=nRT 解缺项、摩尔体积、气体密度、由密度反推摩尔质量),单位固定为 atm/L/mol/K 并附带 kPa、mmHg、mL、°C。测试 102 → 136,覆盖率 86.34% → 88.89%(基线棘轮上调),全部数值锚点由独立 Python oracle 生成并与教科书值交叉验证。
Install
dsh plugin --profile <profile> add github:TYEclipse/dsh-chem#v0.2.0