Scalar-Lyapunov-function method for single- and multimachine problems in power systems