added device function calculatePotential