Fix output of energy density
Description
Only compute it where needed, so right before the output. It is not needed anywhere else in the code, so there is also no need to always compute and store it.
Checklist
-
I have checked that my code follows the Octopus coding standards -
I have added tests for all the new features added in this request.