**2. Background**

#### *2.1. Cost Estimation for EES Systems*

The estimation of the total cost (and the possible resulting economic benefit) of an EES should consider a number of cost items; namely, the initial investment, the runtime operation expenditures (i.e., maintenance and obsolescence), and the cost of energy consumption, which depends on the overall architecture and the load profiles. Once a comprehensive model is available, it will allow one to compare different solutions (mainly the allocation of the energy flow, and the choice and sizing of the components), so as to choose the most profitable one, by taking into account a number of constraints and of optimization goals.

Given its relevance in many domains (industry, residential, large-scale energy generation installations), the literature on the topic is quite rich. The most recent solutions proposed at state of the art are summarized in Table A1 (moved to the Appendix A not to interrupt the natural flow of the paper). The Table highlights the goal of each work, how EES components are modeled, the considered costs, and most importantly, the solution proposed by each work, which mostly fall under two categories: optimization-based approaches and simulation-based approaches.

*Optimization-based solutions* use analytical or empirical equation-based models of the power characteristics of EES components and the corresponding costs, and formulate the problem into the constrained optimization of a given target; e.g., maximization of power production, or minimization of a cost function [13–31]. Unfortunately such approaches suffer from many limitations. Given that the focus is optimization of some economic parameter, the evolution of EES components is considered only as a byproduct: either as a constraint or an optimization goal [29–31], or as a dimension of the problem that can be reproduced with simplified models or even simple input traces [13–18,24,25,28,32], thereby sacrificing accuracy to simplify computation. When accurate models are adopted, they are restricted to a subset of the components considered of interest (e.g., only batteries or PV modules), while the other EES components are either ignored or modeled with simplistic equations [20–23,26,27]. Few works take into account the power managemen<sup>t</sup> strategy used to activate power sources and energy storage devices. When this happens, the goal is determining the optimal day-ahead scheduling of energy storage devices, thereby preventing the comparison of different power managemen<sup>t</sup> strategies [26–31]. As a result, power dynamics are always considered as a minor dimension of the problem (i.e., a constraint, an optimization goal, or an input), and the mutual impact of power and cost is completely lost. Finally, these approaches provide one solution (or a few) and do not easily allow a comparative analysis of various solutions, nor the sensitivity of a solution with respect to some of the parameters.

*Simulation-based approaches* optimize EES design from an economic perspective based on dynamic simulations of alternative configurations [33–35]. The goal is the evaluation of the impact of electricity pricing, the feasibility of the constructed EES, or the evaluation of the most economical alternative. However, once again the focus is on the economic dimension, thereby adopting gross grain temporal scales (e.g., 1 h time steps) and restricting accurate modeling only to specific classes of EES components of interest (e.g., PV modules [33,34]). Finally, the focus is restricted to only one direction of the mutual impact between the cost dimension and power dynamics of the EES under analysis, which are evaluated strictly sequentially, depending on the causality of interest.

The main limitations of the aforementioned approaches are thus the adoption of abstract and simplistic models of EES components and the gross grain temporal scale: the energy dimension is thus modeled with a very low level of detail, thereby missing important intrinsic dynamics of the EES components, together with the modeling of inefficiencies and of realistic operating conditions. Additionally, cost and power evolution are never considered as mutually interacting dimensions, thereby missing important dimensions of the analysis.

The work proposed in this paper can be viewed as a different perspective; while it is a simulation-based approach, it *leverages results of an independent simulation of power traces*, which can use models with variable accuracy and possibly with different time scales; these power traces are then fed into the various models of different cost items (where they are power-dependent), which can vice versa influence and impact the power dimension. This kind of modular approach is not, however, the result of two distinct simulation environments, but both power and cost information can be derived by concurrently simulating them: this allows one to expose all mutual dependencies between power and cost, and thus to improve the design of EES with a more informed view of all the variables. There is one study [36] that focused on the modeling the different components in the EES by using a different model of computation (MoC) in one simulation framework by using SystemC-AMS. Cost is indeed mentioned in that study, but there is no indication of how the cost models of that work are linked to the power simulation. These are simply obtained by a post-processing of the power traces, as done in most related works. Our proposed simulation framework speeds up the design-time optimization process and has different methods to evaluate the power flow and economic benefit of EES by concurrently simulating the two quantities. The key for such a modular and concurrent simulation approach is described in the following section.

#### *2.2. A Multi-Layered Approach for Functional and Extra-Functional Simulation*

The simultaneous simulation of the various aspects of a system requires the construction of frameworks that integrate different views of a system in a single run. The work in [9], which targeted smart electronic systems, proposed an effective methodology that allows the simulation of system functionality together with its power, thermal, and reliability evolution.

The approach proposed in [9] envisions a multi-layer, bus-centric framework (depicted on the left-hand side of Figure 1, adapted from the original paper): *multi-layer* because it has a stacked layers structure; each layer is associated with one simulated characteristic of the system (called *property*). *Bus-centric* means each property is simulated with a virtual bus in each layer, used to update the property-specific status of the system. All simulated properties are thus reduced to this common structure, thereby easing synchronization and information exchange. The goal is indeed to avoid the construction of co-simulation frameworks, and to rather simulate all layers in a single run by falling on the same implementation language; namely, SystemC-AMS.

Each layer is fixed to a single generic underlying *architecture*, of which the layer-specific bus is the central element, used to carry information between components (*layer-specific signals*). Such information is specific of the property under analysis in the layer (e.g., voltage and current for the power layer). Each component in the system corresponds to a model in each layer, to capture the property-specific evolution over time of the component. The *layer-specific bus* aggregates the property-specific information of each component to control the information flow and update the overall property-specific information. Layers can additionally share information (*inter-layer signals*) to mutually influence each other. Notice that signals can go in both directions; i.e., they can be forwarded to upper layers, as signals that are needed to carry out the simulation at that layer (solid lines); but signals can also be fed back to lower layers as information that can make the lower-level simulation more accurate (dotted lines). In the context of [9], for example, the former type of signals could be power consumption signals forwarded upwards to compute the temperature map of the system; the latter type could be the same temperature maps, which could impact the power consumption of some of the components. Most importantly, when the layers run at different time scales, *time converters* can be introduced to convert the signals towards coarser or finer time scales. For instance, while it makes sense to measure the functionality of an electronic system at the nanosecond scale, this is not a required granularity for power simulation, and can be even more relaxed for the analysis of the thermal flow.

Not shown in the figure, there are also *layer-specific description data* that are strictly referring to that layer and are needed as a sort of "context" of the simulation. In the temperature layer of [9], these data could refer either to the physical locations of the components, which affect the thermal flow, or to the characteristics of the materials (type, thickness, etc.) constituting the system itself.

**Figure 1.** The multiple layered framework for the non-functional properties simulation proposed in [9] (**left**) and application to the simulation of power and cost proposed in this paper (**right**).

This paradigm proved to work very well for the simulation of the different views of a smart system, thanks to its scalability and to the simultaneous evolution of the different system properties, which thus can react simultaneously the one to changes of the other.

For this reason, in this work we tried to fit the above-described paradigm to the *co-simulation of power and cost of an EES*, with the objective of exploiting its two main benefits; namely, modularity and generality. Notice that the contribution of this work is showing that the layered, modular framework of [9] is not a customized architecture, but its paradigm can be extended to other quantities: in this specific case the operational costs of an EES. The work of [9] was applied to small-scale electronic systems, where the non-functional properties were (from bottom to top; see Figure 1 in the manuscript) power, temperature, and reliability. Our work aims at demonstrating the general applicability of the modeling and simulation paradigm of [9] to the context of large-scale EES, and can add different non-functional properties that the properties in this work are power and cost. The right-hand side of Figure 1 shows how the generic bus-based layered architecture maps to our specific context. Since we focus on EES, the first layer of the simulation stack coincides with the power layer. In some sense, this represents the equivalent of "functionality" in the original version; that is, the lowest abstraction level of the semantics. On top of the power layer sits the cost layer, which receives power flow information (used to update the power-dependent cost items, such as electricity cost) and returns cost information to the power layer, which can be used to implement policies in the power bus to decide the optimal power flow among the various components.

Time converters are also expected, since some updates of some of the cost items might generally have different time granularity with respect to power updates, which in the finest granularity are updated every 15 min (as in the most accurate meters).

In the conceptual architecture of Figure 1, the power layer is fundamentally working just as described in [9]; even if components are different in their power scale (100 s of Watts vs. milliwatts), their interfaces and interaction are the same. The cost layer, conversely, is an original layer and its implementation within the constraints of the layered structure demonstrates the claim of modularity of the architecture. In the next section, we will describe the cost models and the technical details to incorporate the cost layer within the template of Figure 1.
