Public repository of the math behind Lambda — a fuel-mixture calculator for Brazilian performance engine builders (preparadores).
src/formulas.ts— Pearson/Turner 2015 (mass-weighted AFR), Anderson 2011 (molar octane), stoichiometric balance, 4 mixing modes (volume → AFR, target AFR → composition, injector calibration)src/formulas.test.ts— 61 unit tests (mathematical invariants + reference values from the ICE literature)src/fuels.ts— fuel library: Brazilian gasolines (E30 Comum/Premium/Podium), ethanols (hydrous/anhydrous), race fuels (VP C16, VP MS109, Sunoco Standard 110) and methanolsrc/types.ts— TypeScript types (Fuel,Recipe,MixtureResult,CorrectionResult)
- App code (UI, auth, billing, persistence) — closed, in a private repo
- Stripe/Cognito/mail integrations
- Customer custom fuels — the public library is the stock set only
The app is proprietary, but the math is auditable. If a builder wants to check how we compute the AFR of E30 or an E70 blend, it's right here. Pull requests with formula fixes or extra references are welcome.
npm install lambda-formulas
# or
pnpm add lambda-formulasimport { calculateModeA, DEFAULT_FUELS_BY_ID } from "lambda-formulas";
const result = calculateModeA({
components: [
{ fuelId: "gasoline-c-e30", volumeFraction: 0.7 },
{ fuelId: "ethanol-hydrous", volumeFraction: 0.3 },
],
fuelsById: DEFAULT_FUELS_BY_ID,
});
console.log(result.afrStoich); // 11.83
console.log(result.density); // 0.758 kg/L
console.log(result.ron); // 100.4pnpm install
pnpm test61 tests covering mathematical invariants and reference values from the literature (Heywood, Pulkrabek, Pearson, Anderson).
MIT — use, modify, fork. Attribution appreciated.
- ANP Resolution 988/2025 — Brazilian E30 gasoline (30% anhydrous ethanol by volume)
- ANP Resolution 907/2022 — fuel ethanol (EAC and EHC)
- ASTM D86 — density
- ASTM D2699 / D2700 — RON / MON octane
- Heywood, J.B. (2018) Internal Combustion Engine Fundamentals, 2nd ed. — ch. 3 (stoichiometric combustion)
- Pulkrabek, W.W. (2003) Engineering Fundamentals of the Internal Combustion Engine
- Pearson, R.J., Turner, J.W.G. et al. (2015) "Iso-stoichiometric fuel blends: Characterization of physicochemical properties for mixtures of gasoline, ethanol, methanol and water" — Proc. IMechE, Part D
- Anderson, J.E. et al. (2010) "Octane Numbers of Ethanol−Gasoline Blends: Measurements and Predictions" — Energy & Fuels
- Anderson, J.E. et al. (2011) "Octane Numbers of Ethanol- and Methanol-Gasoline Blends Estimated from Molar Concentrations" — Energy & Fuels
Found a bug or a discrepancy with the literature? Open an issue or send a PR. Email: roberto@microforge.app
Lambda uses these formulas plus UI, persistence, PDF and cloud sync. Free and no signup; Pro is R$ 348/year, with a 14-day money-back guarantee.