Socio-technical modeling of smart energy systems: a co-simulation design for domestic energy demand

To tackle the climate crisis, the European energy strategy relies on consumers taking ownership of the energy transition, accelerating decarbonisation through investments in low-carbon technologies and ensuring system stability and reliability by actively participating in the market. Therefore, tools are needed to better understand an increasingly complex and actor-dense energy system, tracking socio-technical dynamics that occur at its margins and then predicting the effects on larger scales. Yet, existing domestic energy demand models are not flexible enough to incorporate a wide range of socio-technical factors, and to be incorporated into larger energy system simulation environments. Here, a co-simulation design for domestic energy demand modeling is presented and motivated on the basis of four design principles: granularity, scalability, modularity and transparency. Microsimulation of domestic energy demand, through the Python open source library demod, shows that it is possible to achieve high detail and high temporal resolution without compromising scalability. Furthermore, mosaik, an open source co-simulation framework, makes it possible to generate, integrate and orchestrate a multitude of demod-based instances with other independent models, which for the illustrative purposes of this study are represented by a heat pump model. The authors hope that the detailed documentation of the proposed solution will encourage interdisciplinary and collaborative efforts to develop a simulation ecosystem capable of investigating alternative energy transition pathways and evaluating policy interventions through the socio-technical lens.


Introduction
Since the energy crisis of the early 1970s, energy demand models have received great interest because of their relevance in predicting, quantifying and planning electricity generation needs and designing related policy interventions (Swan and Ugursal 2009). In recent years, however, traditional methods to model energy demand are being challenged by several emerging issues: (i) the profound change in nature, timing, ownership and dispatchability of electricity supply requires higher spatial and temporal resolution of energy demand (Camargo and Stoeglehner 2018), (ii) electrification is branching the interactions of a traditionally vertical system across different scales and sectors (e.g., heating and mobility) (?Brundlinger2018) and (iii) new policy interventions and grid management paradigms (e.g., multi-modal demand response programs and local energy systems) are unveiling the limitations of purely techno-economic modeling approaches (Pfenninger et al. 2014).
The common thread running through these changes is the new consumer-centric energy system paradigm, " [...] where citizens take ownership of the energy transition, benefit from new technologies to reduce their bills, participate actively in the market, and where vulnerable consumers are protected. " (European Commission 2015) [p.2]. Indeed, energy consumers can become prosumers by choosing to install photovoltaics on their roofs, act as a coupling node between the electricity and transport sectors by plugging-in their electric vehicles, or participate actively in the management of the electricity grid by enrolling in Demand Side Management (DSM) programs.
Nevertheless, current energy system models take a centralized perspective, neglecting social stakeholders and their decision-making (Fattahi et al. 2020). Indeed, the idea of modeling the consumer as a sink (Hilpert et al. 2018) prevails, and thus the use of empirical or synthetic load profiles to be fed into other models, e.g., to optimize the design of distributed energy systems (Dorer et al. 2016) or evaluate the performance of new management strategies (Mammoli et al. 2019).
To stimulate a socio-technical modeling perspective, this paper first presents and motivates four core design principles (i.e., granularity, scalability, modularity and transparency), then a domestic energy demand co-simulation design is presented and the fulfillment of the four design principles evaluated and discussed. The proposed solution employs mosaik 1 (Steinbrink 2017), an open source co-simulation framework, to integrate and orchestrate an occupancy-based energy demand model, developed using the Python library demod (Barsanti and Constantin 2021b), with an heat pump model ) (see Fig. 1).
It is worth emphasising that the selected case study (i.e., heat pump integration) aims to exemplify the assessment of mosaik's functionalities and challenges in generating, integrating and managing a multitude of demod-based model instances with other independent models in large simulation scenarios. The insights from this research and the fully documented and open access models can be used by other researchers with the aim of coupling energy demand with complementary behavioural models (e.g. investment in low carbon technologies, participation in DSM programs) to better account for the human component in current policy assessment tools.

Design principles
Before presenting and motivating the choice of the four design principles, it is important to emphasize two points: first, the four reported design principles do not represent an exhaustive list of criteria for the development of "good" models, and the authors refer the readers to other studies for a more detailed discussion about the models' ability to explain past observation (Grandjean et al. 2012;Salisu and Ayinde 2016), ability to predict future observations (Grandjean et al. 2012;Lopion et al. 2018), uncertainty quantification (Pfenninger et al. 2014;Sovacool et al. 2018), flexibility (Lopion et al. 2018), capturing the human dimension (Pfenninger et al. 2014;Sovacool et al. 2018;McKenna et al. 2017), observability and adjustability (Richter et al. 2006), and licensing and programming / modeling language (Lopion et al. 2018;Morrison 2018); second, there are models that, despite not having a scalable, modular or transparent framework, allow to provide scientifically relevant results. In summary, these principles should be intended as the basis for the development of an effective model backbone, which can give centrality to the consumer and facilitates the subsequent improvement and integration of more advanced features and methods for the study of socio-technical energy system. In the authors' opinion, the design of socio-technical energy demand models should be based on the core principles presented in Table 1.
In terms of granularity, the increasingly fluctuating and distributed nature of electricity generation, together with new management paradigms (e.g., DSM) requires that the level of detail goes down to individual consumers and devices (Grandjean et al. 2012) and time-steps of the order of minutes (Ayala-Gilardón et al. 2018). These considerations refer to energy demand models, while technology diffusion (Moglia et al. 2018) or DSM participation (Krebs 2017) models may require different spatio-temporal resolutions.
This heterogeneity of detail, however, is not a limitation if model outputs can be integrated at different scales in order to bridge the information gap between dynamics that occur locally and/or in the short term but may impact on medium/large and/or long-term scales, such as DSM programs (Yamaguchi et al. 2020). However, increasing granularity of models can significantly affect the computation time. Thus, the trade-off between It consists of both the quality of being granular, i.e., in the modeling field as the ability of "resolving details in time and space" (Pfenninger et al. 2014), but also the state of being composed of many individual parts or elements. In other words, to obtain results relevant to the purpose of the analysis, the model must ensure that the output meets the required granularity of detail (Lopion et al. 2018), and must be "technically explicit i.e. the different specificities of the simulated elements (equipments, buildings, etc.) must specifically impact the load curve calculations and results" (Grandjean et al. 2012)[p.6541].

Scalability
It explicits and extends the term "aggregative", proposed by Grandjean et al. (2012) to describe model's ability to generate results at different levels (household, city, region, etc.), emphasising on two implicit aspects: computational cost and data availability for parametrization. Indeed, as discussed in the field of computer science, a scalable model must have "the ability to handle increased workload by repeatedly applying a cost-effective strategy for extending a system's capacity" (Weinstock and Goodenough 2006)[p.1]. In addition, to ensure consistency across levels, the model must use observable values, e.g., consumer socio-demographics and appliance penetration rates, allowing the model to be sensitive to micro-level factors that are available at macro-level (Xu et al. 2020).

Modularity
It goes beyond the modeling domain and as described in Baldwin et al. (2014)[p.1383], consists of the decomposition of a framework (e.g., a model) into modules characterized by "the interdependence of decisions within modules; the independence of decisions between modules; and the hierarchical dependence of modules on components embodying standards and design rules". In this case, "module" is intended according to the definition of McClelland et al. (1987) adopted by Baldwin and Clark (2000)[p.63]: "[...] a unit whose structural elements are powerfully connected among themselves and relatively weakly connected to elements in other units".

Transparency
It requires that the documentation and communication of a model provide all the necessary information to allow the recipients to understand, reproduce and possibly validate its results (Morrison 2018;Grunwald et al. 2016;Huebner et al. 2021). As the concept of transparency relates to the requirements of the recipients, it is important to note that here the authors are referring to an expert-to-expert exchange.
granularity at different scales and the need for computation time is crucial for planning a simulation and guaranteeing model scalability.
Since running scalable models for an increasingly complex and interconnected system is computationally and design challenging, a modular design seems to be the most appropriate (Pfenninger et al. 2014). This approach allows decoupling of processes that happen at different scales more easily by specifying multiple instances of modules and letting them interact (Bompard et al. 2014). Moreover, modularity provides the ability to incorporate the adoption of new devices in a detailed manner (e.g., heat pumps or electric vehicles) and facilitate model use and modification (Stavrakas and Flamos 2020). Thus, scalable models allow the parameterisation of models to be adapted and modularity allows modules to be replaced according to the requirements of a simulation (Steinbrink et al. 2018).
Finally, as interdisciplinarity is now essential to overcome the traditionally technologyoriented modeling approaches and adequately capture the complexity arising from the multiplicity of actors and their interactions (McKenna et al. 2017), a modular design is not sufficient. Indeed, given the increasing complexity of developing, provisioning, running, and analyzing energy system models, (Morrison 2018), transparency facilitates the integration of new theories and factors (e.g., human behavior and indirect costs) into existing ones. Moreover, transparent models contribute towards enhancing research quality by promoting a deeper consideration of the choices made throughout the research process, as these will have to be described and justified (Sovacool et al. 2018;Huebner et al. 2021).

State of the art
At the local/regional scale the attempt to simulate many aspects of the energy system simultaneously is recent but nevertheless relevant (Allegrini et al. 2015). One of the possible approaches is to develop broader tools, such as 'CitySim' (Robinson et al. 2009) or 'IDEAS' (Baetens et al. 2012), which allows the integration of multiple technical components (e.g., building thermal behavior, and heating and electrical systems) with (sub-)hourly temporal resolution. However, this integrative approach may not be practical when more detailed modelling is required, as the complexity of the tool may become unmanageable (Allegrini et al. 2015).
Alternatively, a co-simulation approach can be implemented, allowing independently developed models to exchange data bidirectionally and to be executed automatically separately or in conjunction. However, aspects such as lack of transparency and accessibility (e.g., 'MESCOS' (Molitor et al. 2014) and NEDS project (Blaufuß et al. 2019)) or limited scalability (e.g., 'HEUS' (Bollinger and Evins 2015)), hinder any attempt to improve and extend such models to better address the human dimension.
To motivate the co-simulation design proposed in this study, an overview of the state of the art of its three components (i.e., co-simulation framework, domestic energy demand model and heat pump model) is presented in the following sections.

Co-simulation frameworks
Co-simulation frameworks provide functionality to combine heterogeneous simulation components from different domains in an integrated simulation. Due to the increasing complexity in the power system, co-simulation is often used for interdisciplinary studies and a number of frameworks exists, which are compared in Vogt et al. (2018).
In this work, mosaik (Steinbrink 2017) is used, which is focusing on usability and flexibility for interdisciplinary simulation. Most of mosaik's use cases are related to the smart grid, but its flexibility allows to integrate also models from other domains. Transparency is emphasized by mosaik with the open-source available Python code (mosaik 2021a) and a detailed documentation (mosaik 2021b).

Domestic energy demand models
The growing need for spatial and temporal detail, their inherent modularity and the ability to integrate socio-technical factors, make bottom-up models preferable to top-down models for studying domestic energy demand dynamics within the smart energy system paradigm (Mammoli et al. 2019). As pointed out by Grandjean et al. 2012, bottom-up models can be disentangled into three categories: statistical random models, probabilistic empirical models and Time-of-Use (TOU) models.
Statistical random models and probabilistic empirical models (Mammoli et al. 2019;Yilmaz et al. 2017) use probability distributions to simulate appliance usage. In this case, therefore, household occupancy/activity behavior is not simulated, limiting the possibility to integrate these models within broader modeling ecosystems (e.g., mobility or commercial building energy demand) in a coherent way.
TOU models differ from statistical random models and probabilistic empirical models because they explicitly consider human behavior to reconstruct the load curves of a given household. As discussed by Yamaguchi et al. 2019, TOU statistics can be used to (i) derive directly domestic appliance usage statistics (Fischer et al. 2015), (ii) simulate occupancy profiles (McKenna and Thomson 2016), or (iii) simulate household daily activities (Bottaccioli et al. 2019;Ziegler et al. 2020;Müller et al. 2020).
As in the case of the statistical random models and probabilistic empirical models, the first category of TOU-based models does not allow the simulation of building occupancy or activity profiles. In contrast, CREST (McKenna and Thomson 2016), an occupancybased model made available open source, allows to generate occupancy profiles with 10min resolution from which the probability of an activity occurrence is then estimated, and thus also the corresponding appliance usage profile with 1-min time resolution.
More recently, however, greater interest has been given to models that explicitly simulate consumer activities (Bottaccioli et al. 2019;Ziegler et al. 2020;Müller et al. 2020). In this way, it is possible to simulate the behaviour of individuals (usually with a time resolution of 10-min) and consistently simulate the use of household appliances, heating and electric vehicles. However, these models are often developed within research projects and not made available open source.

Heat pump modeling
In the future, heat pumps might get a highly increasing impact on the energy demand at residential level and can play a significant role in providing flexibility. For the detailed modeling of generic thermal systems commercial software exists, which might significantly increase the complexity and runtime of simulation and are problematic to achieve the goal of transparency and reproducibility. In contrary, the ThermoPower library, an open source software for Modelica simulation environment, is available (Casella and Leva 2003). Another modeling framework is the Thermal Engineering Systems in Python (TESPy), which is also open source (Witte and Tuschy 2020), and provides a framework for modeling thermal systems. It was used as base to integrate a heat pump model into the co-simulation because of the direct Python-based integration into mosaik.

Simulation design
This section provides an overview of the co-simulation framework and the models employed in the proposed design. It is worth noting that, since the main contribution of this work is the design of the co-simulation according to the four aforementioned design principles, the technical details are briefly described and readers are referred to the models' and scenarios dedicated documentation for further details (Kasturi and Schwarz 2021; Barsanti and Constantin 2021a; . For the integration of the models the co-simulation framework mosaik is used (Steinbrink 2017). It provides a component-API, which has to be implemented by each model to connect it to mosaik. Based on the connected models, the scenario-API allows to initialize the models and to define their connections within a simulation. With this scenario definition, mosaik executes the simulation and handles the scheduling and data exchange between the models even with different time granularity ).  Occupancy Simulator: Occupancy profiles are generated with temporal resolution of 10-min through demod module 'Transit occupancy simulator' . This module uses German TOU statistics (Statistisches Bundesamt 2013) to parametrize first-order Markov-chain. Inspired by (Yamaguchi et al. 2020), each resident occupancy status is defined by activity status (i.e., 'active' or 'asleep') and three location (i.e., 'home' , 'away for work' and 'away for other').

Domestic energy demand model
Electricity Demand: Electricity demand is simulated through appliance and lighting modules 2 (see yellow blocks in Fig. 2). These modules take as input household occupancy profiles and technical characteristics and statistical data for different appliances to simulate the daily load profile at 1-min time resolution. At the beginning of a run, this module populates each household with a set of appliances considering sociodemographic dependent distributions (Dena 2020). To maintain compatibility with the occupancy simulator, the appliance usage module computes appliance turn-on events depending on the type of appliance (i.e., fixed or stochastic duration and level usage or activity dependent), as in McKenna and Thomson (2016). Moreover, a number of lighting bulbs is initialized based on normal distribution from Frondel et al. (2019). Their operation is simulated as switch on/off events and it considers irradiation and effective occupancy as inputs, which takes into account occupants sharing lights within the same room, as in McKenna and Thomson (2016).
Thermal Demand: The simulation of thermal demand requires multiple modules 3 (see light red blocks in Fig. 2). The modules are available in demod and they are based on CREST (McKenna and Thomson 2016) and its UK-based parameters. The authors decided to retain these parameters since the purpose of this article is primarily methodological and does not focus on the accuracy and validation of the results. The building thermal behaviour module consists of a simplified lumped-capacitance models to simulate heating system behavior. It uses the equivalent electric circuit with four resistances (i.e., air ventilation, outdoor air/walls, walls/indoor air and indoor air/emitters) and three capacitances (i.e., walls, indoor air and emitters) for estimating space heating demand and temperature profiles. The thermostat settings module simulates the behavior of residents in managing a programmable thermostat. In this work the comfort temperature is assigned stochastically for each household and kept constant throughout the day, although several modules exist in demod for stochastic simulation of switch on periods and indoor temperature set point based on occupancy profiles and consumer preferences. The thermal demand for domestic hot water is estimated in the same way as household appliances: first the number of water fixtures in the house is initialized; then based on the probability of associated activities the number of times each water fixture is used, the temperature of the hot water and the withdrawn volume are determined stochastically.

Heating system model
The heating system model consists of three individual components, which are connected via mosaik: a heat pump, a hot water tank and a controller that manages the integrated operation of the former two. The heat pump model is based on the TESPy library (Witte and Tuschy 2020) and contains parametrization taken from manufacturer's data sheets of two common heat pumps. The model provides two different modes. The "detailed mode" uses a map of operating points indicating the electrical demand of the compressor under different design conditions, to identify at each timestep the closest design point. Alternatively, the "fast mode" performs the calculations for a range of possible inputs beforehand, stores the results and uses them during the simulation. Thereby, the precision of the results decreases, but the simulation time can be reduced significantly. Second, a hot water tank, developed in Gerster et al. (2016), is used as buffer between the heat pump and the emitters. During the initialization, the size of the tank, the initial temperature profiles, and inlet and outlet water flows can be specified. During the simulation, temperatures and water flow rates are updated, considering stratification effects and heat losses. Finally, the controller model aims at matching heat supply and demand. On one hand, it estimates the heat that the hot water tank can supply. On the other hand, the controller computes the heat required from the heat pump, to maintain the hot water tank at its temperature set point, ensuring that the temperature operating limits are not exceeded.

Evaluation and discussion
In this section results for granularity and scalability are evaluated and discussed, while the design decisions to achieve modularity and transparency are reviewed.

Granularity
To achieve model granularity, an occupancy-based energy demand model has been developed. The use of the German TOU data (Statistisches Bundesamt 2013) allows to simulate occupancy profiles with a resolution of 10-min for individual households (see top of Fig. 3). Behavior simulation of individual households is known as microsimulation and it enables consistent and integrated simulation of different forms of energy demand as shown in this work. However, this approach takes the whole household as simulation unit, not allowing to track individual residents, the activities they conduct and, thus, their behavioural heterogeneity. Therefore, this limits the evaluation of policies that target individuals (e.g., specific lifestyle interventions or response to DSM incentives), which play a key role in determining energy demand and its flexibility.
Based on the simulated occupancy profiles, the operation of individual household devices and thus the electrical and thermal demand were estimated with a time resolution of 1-min (see bottom part of Fig. 3). Making the model technically explicit allows to assess the impact of individual device on the load curve and its potential for flexibility, which depends on their specific characteristics and operating conditions. Furthermore, being able to model the behaviour of the household and the operation of individual devices in a combined way opens up new scenarios for modeling household flexibility, combining purely technical characteristics with changing activity and service expectation.

Scalability
To evaluate the scalability of the proposed design, the execution time was estimated for varying number of instances and simulated time. This evaluation was done with a temporal resolution of 1-min for (i) only demod, (ii) demod integrated in mosaik, and (iii) with additional heating system models in "fast mode".
There is just a small overhead of demod executed inside of mosaik compared to starting demod stand-alone (see left side of Fig. 4). The addition of the heating system model significantly increases the execution time. But it can be seen, that the execution time with an enlarged number of instances increases linearly for all types of models. Especially for smaller numbers of instances, the rise of execution time is less steep, which might be a results of demod vectorizing of computations.
The measurement of the execution time for different simulation times shows that it is increasing linearly as well (see right side of Fig. 4). For a detailed simulation with a temporal resolution of 1-min, the simulation of a year with 32 household including the heating system model takes about 24 h.

Modularity
To ensure that the principle of modularity is satisfied, individual models were implemented in Python. These models are structured also internally in a modular way 4 , but here the focus is on the integration of these models in the proposed co-simulation design to exchange data bidirectionally.
For the presented simulation a directly integrated approach would probably have some advantages, because the overhead of the framework in between the models and the redundancy of a controller in demod and the heat pump model would be omitted. However, the advantage of co-simulation is that other already available models can be directly added to the simulation and additional models can be connected with reasonable effort. This flexibility can be used to integrate models from different domains to get a more holistic view on the energy system. Nevertheless, this interdisciplinarity and increasing number of models also introduces new complexity, which is addressed by new approaches for planning of co-simulation in this interdisciplinary context .

Transparency
In order to guarantee complete transparency, all the models employed in this work are documented in detail and made available open-source, as shown in Table 2.

Conclusion
In this study, first four design principles (i.e., granularity, scalability, modularity and transparency) were introduced with the aim of contributing to domestic energy demand simulation within socio-technical energy systems. Then in the light of these principles, the state of the art was reviewed, motivating the decision to (i) develop demod, a Python library for TOU-based domestic energy demand models, (ii) to build a heat pump model using the Python library TESPy and (iii) to integrate and orchestrate the former through the co-simulation framework mosaik.
As previously shown, microsimulation of household behaviour allows to generate high-resolution profiles of household occupancy, appliance usage and integrated thermalelectric demand. Moreover, given the low computational load of the models, the outputs can be aggregated at different scales to bridge the information gap between what occurs locally and the larger scale implications. Finally, in order to foster knowledge transferability and interdisciplinary collaboration, the proposed design is made fully transparent and accessible through the publication of model codes and their detailed documentation. At the same time, the evaluation of the four design principles showed challenges and limitations. First, simulating consumer behaviour using the entire household as a simulation unit limits the evaluation of policies that target individuals (e.g., lifestyle interventions) and their heterogeneity. Second, while the co-simulation design provides a high flexibility in replacing individual modules to achieve greater detail, this must be done considering the right trade-off with the computational load. In addition, while the case study (i.e., heat pump integration) allows to investigate some co-simulation challenges, still some relevant aspects are missing. For instance, an increasing number of different models and dynamics occurring on different time frames (e.g., short-term, such as energy demand, and long-term, such as the investment in low-carbon technologies) make it difficult to manage and track the complex and dense network of interactions when planning a simulation.
To conclude, the insights collected in this work will guide the extension of the proposed co-simulation design. Additional models of networks (e.g., eletric grid and mobility infrastructure), devices (e.g., electric vehicles and batteries), agents (e.g., industries and governance authorities) and platforms (e.g., spot market) may be integrated into the simulation ecosystem with the overarching target of developing a tool for investigating energy transition pathways and assess policy interventions.

About this supplement
This article has been published as part of Energy Informatics Volume 4 Supplement 3, 2021: Proceedings of the 10th DACH+ Conference on Energy Informatics. The full contents of the supplement are available online at https://energyinformatics. springeropen.com/articles/supplements/volume-4-supplement-3.

Funding
This work is part of the MoMeEnT project "Modellierung von Verbrauchs-und Erzeugungsdynamiken in sozio-technischen Energiesystemen", jointly funded by Swiss National Science Foundation (SNSF project number: 182878) and the "Deutsche Forschungsgemeinschaft" (DFG project number: LE 3131/8-1). Publication funding was provided by the German Federal Ministry for Economic Affairs and Energy.

Availability of data and materials
The integrated simulation described in this article, is made available at .