The optimal trade-off between reliability and cost of a microgrid, including vehicles as both loads and sources, can be a challenge. Prior approaches have modeled the microgrid using MATLAB, but did not include the detailed physics of loads and sources, and therefore missed the transient effects which are important in representing the real time behavior of a microgrid. This paper discusses the physics implementation of a detailed microgrid model including a diesel generator, wind turbine, photovoltaic array and utility as sources, in Simulink. Various loads are also implemented including an asynchronous motor. A vehicle is connected to the grid and is represented as a battery. A central control algorithm optimizes the microgrid by trying to maximize reliability while reducing operational cost.