Added functions to calculate phasor magnitude