**1. Introduction**

In the design of large-scale electrical energy systems (EESs), cost is a dimension at least as important as the energy efficiency of the system: given the initial investment, in fact, users do want an effective solution that can provide a return on the investment in the shortest possible time.

Designing an EES encompasses a number of options, such as the choice of components (which power sources and which storage devices), their sizing, and particularly, their managemen<sup>t</sup> (how the energy flow is controlled among all the actors), possibly in a way that is aware of the load profiles. The problem of optimizing the cost under an initial investment cost constraint is therefore a complex problem, as it involves both "physical" aspects (i.e., the dynamics of the various

devices, their non-idealities, the electrical characteristics of the loads, etc.) as well as "cyber" issues (the algorithms that manage the flow of energy among these devices and the loads).

It is quite evident that accounting for (i) such a set of heterogeneous variables, (ii) numerous significant non-idealities, and (iii) complex inter-dependencies between components can only be handled effectively by the simulation of the EES as a cyber-physical system (CPS). This would allow one to describe accurate (power and cost) models for the components, fed by accurate traces of environmental data for the power sources, and exercised under realistic power demand traces [1,2]; on top of that, managemen<sup>t</sup> policies modeled in software can evaluate a number of alternative scenarios. Although throwing all these aspects into an optimization problem would be possible [3], this could be done only using average quantities as representative values for the variables of the problem.

The literature presents many solutions for the simulation of these cyber-physical electrical energy systems (CPEES), with different levels of accuracy, complexity, generality, and flexibility [4–8]. Most of these approaches lack one fundamental feature which could be regarded as *modularity*. With this term we mean the possibility of separating the different layers of information to be tracked in the CPEES simulation. For instance, the analysis of the power flow (an "power layer") could be carried out to extract information that could be used for different purposes by another "layer" of simulation that sits on top of that power layer. Such information could be used, for example, to track the reliability (e.g., the mean time to failure, MTTF, or the mean time between failures, MTBF) of the CPEES, using appropriate reliability models that depend on how energy is used and are fed by the power traces obtained by the simulation at the power layer. Alternatively, as done in this work, one could use the power traces to feed *cost* models to assess the overall economic balance of the system. In some cases, a user might want to have both layers (reliability and cost), while in others, one might be interested in only one of them. This degree of modularity requires a specific architecture of the overall simulation framework.

An interesting solution that follows this modular approach was proposed in [9], where the authors design a framework for the concurrent simulation of both functionality and extra-functional properties, ye<sup>t</sup> in a different context. The work refers to smart electronic systems [10–12], which can be seen as small scale CPSs; here, the bottom layer of the simulation is the *functionality*; i.e., what the overall system does and its timing evolution in terms of digital signals. Layers built on top of this baseline layers (called "non-functional") track other quantities (called properties), such as power consumption, temperature, and reliability, stacked in this order. The key for modularity in this work was the definition of a multilayer, bus-centric framework where each layer has a similar structure: each simulated quantity corresponds to a simulation layer, and the bus-centric organization in each layer implies the definition of a virtual bus, which conveys and elaborates quantity-specific information (i.e., power-bus, temperature bus, etc.) to ease synchronization and information exchange.

In this work we adopt the paradigm of [9] to use it to add support for a new "property"; i.e., *cost*. Cost is modeled as a new layer of the framework of the bus-centric approach: component-specific costs are estimated locally to each component, while the bus merges them and keeps track of the power balance and of any operation of the grid; i.e., to buy or sell power. We additionally extend the framework to focus on the simultaneous simulation of cost with the power layer, to reproduce the mutual interactions of the two properties, and to investigate such mutual inter-dependency.

Finally, we apply the extended framework to the design of a custom EES, that is used to highlight and investigate the characteristics of the proposed modeling and simulation approach.

The paper is organized as follows: Section 2 discusses the background, including related work and a brief introduction of the multi-layered framework of [9]. Section 3 illustrates how to build the cost-layer and the information exchanges with the other layers. The implementation of proposed simulation framework is introduced in Section 4. Section 5 exemplifies the overall approach on a reference EES case study to prove the effectiveness of the proposed solution, and Section 6 draws our conclusions.
