Initial code to close the mass and energy budgets.  Should work in theory, no effort yet to compile.