3.5.2. Model Formulation

MPCPy utilizes models defined in the Modelica language [74], an equation-based multi-domain language to model complex physical systems including mechanical, electrical and deterministic control systems. These models can be used to predict the future system behavior and to support linked simulation-optimization problems. For use in optimization, MPCPy focuses on the use of simplified physical models, often known as "grey-box" models. These grey-box models include sufficient detail about the building systems to simulate overall responses but not the specific details of typical expert-defined building energy models. The goal is to balance model specificity with computational efficiency for use with optimization solvers. MPCPy utilizes JModelica.org [75] to generate and solve a control optimization problem based on the user-provided Modelica model, objective and constraint information and input data (e.g., weather or electricity prices). JModelica.org uses CasADi [76] to compute function derivatives and the optimization algorithm IPOPT [77] to solve the resulting nonlinear problem. IPOPT, short for interior point optimizer, is a state-of-the-art nonlinear optimization library to solve large-scale continuous system optimization problems.

#### 3.5.3. Optimization Configuration for Grid Interactions

Using the MPCPy framework, the SPO optimization engine is designed to minimize the cost of building operations subject to various DR scenarios or grid price signals. SPO can optimize for different types of peak-load reduction DR events (e.g., through utility programs such as Peak Day Pricing [78] or Critical Peak Pricing [79]), as well as dynamic prices [80,81]. At its most basic level, SPO minimizes electricity bills of buildings that are subject to Time-Of-Use (TOU) tariffs that contain both energy and demand charges. Other modes of operation for responding to signals from the grid are shown in Table 1, including real-time pricing, demand limiting, load shedding, load shifting and load tracking.

The optimization engine is structured in a flexible way so that the various responses to grid signals can be easily configured and swapped. This is achieved by formulating the objective function in a generic way, translating the grid signals into components of this parameterized function and into constraints of the optimization problem. The various options are stored in variables of a configuration file to easily switch between modes. Table 1 summarizes the five grid signals and

the corresponding configuration in the optimization engine. The constraints presented here only relate to the grid-responsive modes, excluding other constraints related to system operation (e.g., indoor temperature boundaries).


