|
Stoichiometry - Chemical Equation Balancer & Molar Mass Calculator for HP Prime +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (https://www.hpmuseum.org/forum/forum-10.html) +--- Forum: HP Prime Software Library (https://www.hpmuseum.org/forum/forum-15.html) +--- Thread: Stoichiometry - Chemical Equation Balancer & Molar Mass Calculator for HP Prime (/thread-24783.html) |
Stoichiometry - Chemical Equation Balancer & Molar Mass Calculator for HP Prime - andrea.baccin - 2026-03-06 11:12 After experience of writing a Markdown viewer for the Prime I uses the experience to create an app for the HP Prime that balances chemical equations, calculates molar masses, and includes a library of 270 pre-balanced reactions across 7 categories (combustion, synthesis, redox, neutralization, etc.). What it does:
The balancing algorithm uses a matrix nullspace approach: the equation is parsed into a stoichiometry matrix A (elements × compounds, LHS positive, RHS negated), then we find the nullspace vector x where Ax = 0 and scale to smallest positive integers via GCD. All done with the built-in linalg module. Everything is built from scratch on the 320×240 pixel display using only hpprime graphics primitives (fillrect, textout, line, blit). There are no UI frameworks, no widget libraries, nothing pre-built. That means: The scrollable equation browser with sortable columns, alternating row colors, touch scrollbar drag, and category badges are all manual pixel math
Here's a couple of screenshots, but you can see a demo video in my gh
I have been testing this in my new G2, as the emulator is good for development but the physical calculator turned out to be a bit more prone to crashes in the python environment. GitHub: https://github.com/abaccin/hpprime-stoichiometry Feedback and suggestions welcome! |