energy code with loopupdate included

energy code wit
fixed bug in e0total

fixed but in e0total that appears only for L>1