Made the potential ceiling an input parameter and moved the if statement to Vv instead of leaving it in the Alavi energy routine (for the purposes of generality)