Direct stability evalution and on line dynamic security assessment of power systems using structure preserving energy function