Rubychem ( is a new Chemistry library for Ruby, supporting the calculation of moles, balancing chemical equations and valence orbital calculations. We wrote Rubychem with three goals:

  • Lightweight: Rubychem should be a light simple library, providing a chemistry API and returning simple Ruby.
  • Fast: Rubychem should, out of the box, be quick.
  • Accurate: Rubychem should have complete test coverage, so you can rely on it.

1.0.4 beta

Version 1.0.4 is currently in beta, filled with features you'll love. To download the beta:

gem install rubychem

Chemistry Calculations

Using rubychem is quite straightforward:

valence =
{"1s"=>2, "2s"=>2, "2p"=>6}
chemical_species ="H2O").chem_species
moles ="H2O",2).moles

You can use rubychem to parse chemical equations

equation ="NaCl = Na + Cl")
[#<RubyChem::Chemical:0x007f842313dae0 @chem_species=[["Na", "1"]], @mm=22.99, @moles=0.04349717268377556>, #<RubyChem::Chemical:0x007f842313d2e8 @chem_species=[["Cl", "1"]], @mm=35.45, @moles=0.028208744710860365>] 

You can enter an unbalanced chemical equation and have rubychem take care of the dirty work

 chemical ="C12H26+O2=CO2+H2O")
 "2C12H26 + 37O2 = 24C1O2 + 26H2O1"