Real time simulator for microgrids