added assertions to ensure thermal energy remains non-negative, see #141
Merge remote-tracking branch 'origin/master'