Real Time Modeling and Control of Smart Grid Systems