Linearized and distributed methods for power flow analysis and control in smart grids and microgrids