calculating surplus energy