now have a working energy/magnetization function