Modeling the Water-Energy Nexus in Households

One third of the global carbon emissions are emitted by the building sector. Over the last decades, space heating loads have decreased in modern buildings, and domestic hot water (DHW) is now oftentimes the largest energy consumer in the household. We developed the WaterHub modeling framework to assess the potential of technologies or measures targeting DHW energy demand. The framework combines process-based technological models and stochastic water demand modeling in a modular way to allow for holistic simulations of complex DHW systems. In two rigorous tests of the modeling framework, we demonstrated the importance of water consumption dynamics in the modeling of DHW systems, showing that static modeling leads to underestimated heat losses and wrong energy consumption predictions. In an exemplary case study, we identified and quantified the synergistic interactions between water boiler temperatures and a drain water heat recovery device, demonstrating the strength of this methodology for optimizing strategies targeting DHW systems. With its modular structure, this open-source modeling framework can be extended to include any DHWrelated technology, providing a useful common platform for collaboration between technology developers and water experts.


Introduction
Buildings are the largest energy consumers in the world, resulting in approximately one third of the global carbon emissions (IEA 2017). Remarkable efforts towards sustainable buildings has led to major improvements to reduce the primary energy consumption for space heating. Modern single family buildings consume 65% less energy for heating than constructions from the 1970s (Streicher et al. 2019). However, no similar shift was observed for domestic hot water (DHW). As a consequence, recent buildings oftentimes consume more energy for DHW than for space heating (up to 2-fold in Minergie-P buildings) (Frijns et al. 2013, Meggers andLeibundgut 2011).
Various strategies aim at increasing the sustainability of DHW systems. At household level, one can (i) reduce the primary energy consumption using energy-efficient or heat recovery systems.
Complementarily, one can (ii) decarbonize the DHW system through a change of technology/fuel, for instance solar technologies. At district or regional level, one can (iii) recover heat from sewers or wastewater treatment plant effluents, reducing the net energy consumption of the urban water cycle (Lazarova et al. 2012).
In particular, reducing the DHW primary energy consumption (point (i) above) may be achieved by multiple means, targeting either hot water production (e.g., using a geothermal heat pump), hot water distribution (e.g., using temperature-controlled valves to reduce system losses (Cholewa et al. 2019)), hot water demand (e.g., low-flow shower faucets or change of showering habits) or heat recovery from domestic wastewater streams (e.g., drain water heat recovery (Tomlinson 2005)).
The adoption of such improvements -or any combination thereof -in households leads to complex dynamics within DHW systems, most notably competing or synergistic patterns that may influence their performance. For instance, Sitzenfrei et al. (2017) identified competition between drain water heat recovery devices (within the household) and sewer-level heat recovery systems, leading to a performance drop of up to 40% when both systems were used simultaneously. In order to assess the potential of existing or upcoming improvements, an understanding of the water-energy nexus at household level is thus critical.
In the field of whole building simulation, bottom-up, process-based modeling approaches were developed for the investigation of energy systems. Software engines like EnergyPlus (Crawley et al. 2000) simulate thermal processes with outstanding detail. However, simulated and real thermal performances of buildings often show a mismatch. User behavior -with respect to hot water demand, lighting, other equipment and appliances -is admittedly a strong factor of this discrepancy (Hoes et al. 2009). In whole building simulation tools, user behavior is often modeled with insufficient detail, most importantly with respect to its inherent stochastic and dynamic nature (Corgnati et al. 2017).
Specifically, simulations of DHW systems using whole building simulation tools tend to use scheduled and averaged -i.e. deterministic -water demand, and their time resolutions are insufficient to grasp realistic dynamics of water consumption (Marini et al. 2015). Some models developed for technical investigations of DHW systems include state-of-the-art simulation of thermal processes in hot water pipes (Maguire et al. 2011, Springer et al. 2008. To our knowledge, though, water demand is modeled with insufficient realism. Unrealistic water demand modeling is not the result of a knowledge gap: the inherent variability of water consumption is well documented (Blokker et al. 2010, Penn et al. 2017, Scheepers and Jacobs 2014, and a wide range of models exist to simulate DHW consumption in households, based either on stochastic, time series, or machine learning methodologies (Fuentes et al. 2018). The problem is the lack of integration.
Hence we postulate that the key to understand the water-energy nexus in households is a holistic modeling framework that combines process-based modeling and detailed dynamics of water consumption. In environmental sciences, holistic methods such as life-cycle assessments (LCA) or material flow analysis (MFA) are regarded as valuable assessment methods, and can also be used for the analysis of DHW systems. Kenway et al. (2012) were the first to prove the value of MFA in their static analysis of an Australian household. The static approach did not, however, allow for an understanding of dynamic processes at the core of the water-nexus. The same authors later added dynamics to the shower processes, quantifying how much energy is lost to the sewer system (87% of total showering energy) (Kenway et al. 2019). Their modeling methodology, however, was not sufficiently versatile to allow for extended and straightforward scenario analyses at household level, e.g. to assess the systemic implications of implementing a drain heat recovery device. This paper therefore introduces the WaterHub modeling framework, designed to gain understanding of the household water-energy nexus. The novelty of our framework lies in its combination of processbased, object-oriented modeling with a stochastic water demand model allowing for holistic investigations of DHW systems. Our framework is designed specifically for straightforward scenario analyses to assess the potential of innovative technologies against realistic water consumption patterns and their interactions with other components in the system. The WaterHub framework is presented in Section 2. We also provide insights into the framework's abilities through three exemplary studies: a comparison -i.e. a sanity check -with an existing model, an exploratory investigation of water demand models and a showcase demonstrating the implications of implementing a drain water heat recovery system at shower-level.

Modeling Approach
The novelty of our framework lies in its approach: a process-based library of models and a stochastic demand model are combined for the generation of material and energy flow analyses (MEFA). We detail the advantages of this approach in the next paragraphs.
Our bottom-up, process-based technological approach provides an unequalled versatility for the dynamic modeling of DHW systems. Technologies, i.e. subsystems such as boilers, water pipes or appliances, among others, are modeled individually and dynamically, at second time resolution. Typical water consumption events durations range from a few seconds to a few minutes: a time resolution of one second is a good compromise between accuracy and computational time, especially with regard to Monte-Carlo processes. Time differential equations describing the demand-triggered water and energy flows through single technologies are solved numerically in the Modelica environment . Individual technology models are packaged into a library of models -called the WaterHub library. Depending on the modeling requirements (e.g, simulation speed, accuracy, focus of interest, number of Monte-Carlo iterations), models of various levels of complexity can be selected: a shower may for instance be modeled as an ideal shower without losses (most computationally effective), a shower with linear heat losses, or a shower with a detailed description of evaporation processes (most computationally demanding). Moreover, existing libraries can be interfaced, for example the Modelica Buildings library (Wetter et al. 2014).
In addition to the process-based library of models, the WaterHub framework includes a stochastic water demand model -called HydroGen -to simulate user behavior, i.e. water consumption and associated energy expenses in the system. Decoupling the modeling of thermal-hydraulic processes within the DHW system and water demand increases versatility: any water demand model -not only HydroGen -may generate inputs for the appliance models in the Modelica library described above.
Compared to (i) whole building simulation software tools like EnergyPlus or TRNSYS or (ii) existing Modelica libraries, the novely of the WaterHub framework lies in the seamless integration of DHW system modeling and a stochastic water demand model. This combination generates an intuitive demand-driven modeling workflow: simulation inputs are, simply, appliance-specific hydrographs, i.e. what water consumers request from appliances at a given time. The rest of the system "adapts" to provide the water consumer the required water flow at the right temperature.
The framework's overarching terminology and structure follows definitions from material and energy flow analyses (Brunner and Rechberger 2004). Results from MEFAs can be used in other integrated assessment methodologies such as life-cycle assessments (LCA) or multiple criteria decision analysis (MCDA) (Laner and Rechberger 2016). In the context of DHW systems, MEFA provides the opportunity to track individual water or energy flows, allowing to assess the systemic influence of alterations made to the system (e.g., new technologies, variable user behaviors, or modified layout).
The structure of the WaterHub framework described above provides a screening tool, in the design or experimental phase of construction, for the straightforward assessment of technology potentials and the identification of possible interactions with other system components. Figure 1 shows the workflow of a typical analysis: A) the DHW system is built graphically using the WaterHub Library (Section 3.1.1), B) A water-demand pattern for each appliance in the system is generated using HydroGen (Section 3.1.2), and C) all water and energy flows in the system are simulated dynamically using software tools from the Modelica environment. Steps B) and C) are oftentimes repeated as a Monte-Carlo process, as water demand from step B) may be generated stochastically.

Model Implementation
The technical details of the framework implementation were introduced in a previous publication (Hadengue et al. 2019). We summarize and complement here implementation details necessary for the practical use of the framework. This framework is open-source and source code can be accessed through the GitLab repositories 1 .

WaterHub Library
The WaterHub Library is a collection of models acting as building blocks of DHW systems. The modeler selects models from the library and builds a graphical representation of the DHW system. Models are grouped into Modelica packages, according to their function:  The Import/Export package groups models simulating imports and exports through the system boundaries. The package contains for instance infinite water/energy sources and sinks.
 The Appliances package groups technologies interfacing with the water consumer. For instance taps, showers, dishwashers, kettles, and WCs. Appliances take as input hydrographs from the HydroGen module (Section 3.1.2).
 The Conveyance package groups models simulating water and energy transport, for instance water pipes or electric wires. Required inputs relate to the conveyance system layout, e.g., pipe lengths, diameters, material, insulation layer, etc.
 The DHW technologies package groups remaining building blocks of a DHW system: e.g., boilers or reservoirs. The package also includes resource-recovering technologies, for instance drain water heat exchangers, wastewater-connected heat pumps or decentralized greywater treatment units. Inputs are technology-specific: e.g., nominal heat transfer for heat exchangers, nominal coefficient of performance for boilers or heat pumps, etc.
 The Blocks package contains utility models: models to interface with the stochastic water demand model as well as compatibility models to allow for the integration of technical models outside of the WaterHub Library, for instance models from the Fluid package in the Modelica Buildings Library (Wetter et al. 2014).
The advantage of a package structure -and object-oriented modeling -is that single models contained in the package may be calibrated and validated individually. They are then trusted and reused as part of more complex systems without requiring additional calibration or validation steps. In the analyses presented in this publication, only the water pipe model required an active calibration process. Other WaterHub models were either modeled as ideal (no losses, e.g., appliances) or did not need calibration as their thermal characteristics were set to experimental values from literature (e.g. tank boiler). For the water pipe model, which follows a discretization scheme (Hanby et al. 2002), the convective heat transfer coefficients of water and air were manually calibrated to fit steady-state temperature drops and heat loss rates provided by Hiller (2006). More information of the calibration process of the water pipe model is presented in Section 1.1 of the supplementary information. We note that the continuous development, calibration and validation of additional models will extend the modeling possibilities and further increase the robustness to the framework.
The WaterHub Library is programmed in the Modelica language (Modelica Association 2017).
Individual models exhibits one or several water and energy ports, necessary to connect them with other models in the system. A connection indicates that a water or energy flow is expected between two models. System definition is facilitated through the use of graphical connection editors, such as the open-source OMEdit from the OpenModelica environment. These editors also allow to parametrize individual models according to geometrical (e.g., length of pipes, tank boiler volume), environmental (e.g., temperature of water imports), or performance (e.g., heater coefficient of performance, pipe insulation material) aspects.
Documentation is embedded in the library: a general user guide (under continuous development) helps modelers in their first steps, and individual model documentation give information on the modeling approach. The documentation is accessible through connection editors.

HydroGen -Demand Modeling
A stochastic Python model -HydroGen -was developed to simulate water demand for the demandtriggered appliances of the WaterHub Modelica Library. The output of HydroGen contains the water flow and the flow temperature resulting from the use of appliances in the WaterHub Library. When necessary, HydroGen also provides the operation energy required by the appliance (e.g., electricity required by a dishwasher).
HydroGen can generate stochastic or deterministic water demand patterns. Individual water consumption events may be triggered at fixed times, or two events may have fixed time interval between them. Events may also be produced with constant flows, temperatures or volumes, artificially neglecting the inherent variability of water consumption.
Water demand may be generated by other models based for instance on real data or agent-based methodologies. In this case, HydroGen provides methods to translate the model's output into an input compatible with the WaterHub Library. We stress, however, that HydroGen was designed to be used in conjunction with the WaterHub Library, resulting in a seamless integration of both modules when used as part of a Monte-Carlo process (see Figure 1).
HydroGen uses stochastic sampling methods to generate appliance hydrographs from distributions describing the number of events, event flow, event temperature, event total volume and event starting times. First, the number of events and their starting times are sampled. The modeler can select a Poisson process (per capita or per household), in which case both the number of events and their starting time are an output of the process. Alternatively, starting times are sampled using an inverse transform sampling scheme over a given distribution (e.g., a normalized frequency curve based on measured data) and sampled number of events. Second, individual events are then attributed a flow, temperature and total volume through the sampling of various distributions defined by the modeler (e.g. normal, lognormal, Weibull, Rayleigh, etc.), as described by Blokker et al. (2010).
Documentation for HydroGen can be accessed, with the source code, from the GitLab repository.

Model Comparison
In 2012, Kenway et al. (2012) released one of the first MFA investigation of a household DHW system located in Brisbane, Australia. We performed a sanity check of the WaterHub modeling framework by comparing our results to those obtained in their study.
First, a similar DHW system was modeled using building blocks from the WaterHub Library (see Section 3.1.1). The system is shown schematically in Figure 2 and more details are provided in the supplementary information (Table S1 and Figure S2). Differences were introduced in the plumbing layout for more realism: for appliances using hot water from the tank boiler, a water pipe model was added between the appliance and the boiler, simulating heat losses to the environment due to flowing and stagnating hot water in the pipe. The characteristics of the water pipes were indexed on the information provided by Kenway et al. (2012): 5m long, ½ inch (12.7 mm) outside diameter copper pipes. In addition, we disaggregated the "taps indoor" appliance into three separate taps. This difference was introduced due to a risk of overlap when numerous tap events were generated for a single appliance.
Second, alongside the technical system, water demand files were generated for all appliances in the system (see Section 3.1.2). Individual appliances simulate various usages, as for instance adults and children have different showering patterns. Because the original study is static, no consumption schedule was available. HydroGen thus triggered water events uniformly across the day.
Last, following the process described in Figure 1, we simulated 5000 days of the DHW system in a Monte-Carlo process. Results are expressed as daily averages for water and energy flows.
3.3 Figure 2. Model Diagram for the model comparison study. Cold or warm water flow are in blue, hot water in red, and energy (here electricity) in green.Water Demand Scenarios

WaterHub Simulations
Based on the model from the comparison study presented in Figure 2, we explored how water demand scenarios influence the energy dynamics in the system. The first step of the analysis evaluated three water demand scenarios: (i) a non-stochastic scenario, with identical events randomly scheduled according to a uniform distribution, (ii) a semi-stochastic scenario, with identical events but water is consumed according to realistic time schedules from literature (Butler et al. 1995, Friedler andButler 1996), and (iii) a fully-stochastic scenario, where events, in addition to being scheduled realistically, have varying flow, temperatures and volumes. A summary is shown in Table 1. The appliances' daily averages for water consumption and required temperatures were identical in all scenarios, with a daily cumulative water consumption around 470 L. We provide the detailed water consumption patterns in Table S2 of the supplementary information.
From the Monte-Carlo simulations (3000 Iterations), we retrieved and compared the respective system losses, i.e. the ratio between lost energy (from the pipes and boiler) and total energy (imported into the DHW system). In a second step, we analyzed how the system's energy dynamics were influenced by the frequency of events. For this purpose, six hypothetical scenarios were generated, ranging from identical events being very close in time (scenario 1) to events evenly spread out over the day (scenario 6). The time interval between subsequent water events (in the same appliance) for Scenario 1 are summarized in  (Table S3).

Static Model
A static pipe model for energy losses based on inter-event time intervals was used for comparison purposes. The heat transfer of a pipe to its environment is described by its overall thermal conductance . For a pipe of length L, inner surface area Ai and inner diameter ri, and outer surface area Ao and outer diameter ro, UA reads where hw,a are the convection heat transfer coefficient of water and air, respectively, and k the thermal conductivity of the pipe material. We set hw = 3000 W K -1 m -2 , ha = 15 W K -1 m -2 and k = 400 W K -1 m -1 .
These values were selected to represent a moderate flow of water in a pipe surrounded by still air at ambient temperature, and were set in compliance with the values used in the WaterHub modules. In the model under consideration, the overall conductance of a pipe was UA = 3.85039 W K -1 .
With UA known, the amount of heat lost to the environment during stagnation of hot water in the pipe (i.e. after a water event) can be described as a function of time: where V is the fixed volume of water in the pipe, cw the volume specific heat capacity of water (4179.6 J L -1 K -1 ) and Thot, env the temperature of hot water and the environment, respectively.
Using Equation (2), we computed the theoretical amount of energy lost within the distribution system based on the average number of events for each appliance and the time intervals from Table 2. In the static model, contrary to the WaterHub simulations, (i) the amount of energy lost during flowing conditions and (ii) the temperature variations in the pipes and in appliances were purposely disregarded in order to evaluate their relative importance as drivers for energy dynamics in the system.

Showcase
The last study presented in this paper is a demonstration showcase. The modeling of water demand was identical to the "fully-stochastic" model described in Section 3.3.1 above, and the DHW system described in Figure 2 was altered to implement a drain water heat recovery system. A heat exchanger was added in series with the shower, pre-heating the cold water stream with warm drain water. The heat exchanger model followed a discretization approach: the device is divided into nodes of parallel pipes in thermal contact, on the basis of a parallel counter-flow heat exchanger. The performance of the heat exchanger is controlled by its theoretical nominal heat transfer, expressed in Watts.
In parallel with the addition of the heat exchanger model, the shower model was modified to lose 5% of its carried heat flow to the environment during showering. Consequently, the drain water was about 2 K colder than at the faucet, slightly higher but close to the 0.5 -1.5 K temperature drop measures by Kenway et al. (2019). We also note that the temperature of the cold water import was set to 10 °C, reflecting a colder climate than used for the model comparison and water demand scenarios studies.
We performed Monte-Carlo processes for three nominal heat transfer values (3.0, 7.5 and 12.0 kW, representing medium-sized heat exchangers used in drain heat recovery systems on the market (Joulia AG 2017)). In addition, we evaluated variable boiler set point temperatures, ranging from 40 to 70 °C, with the objective to investigate the impact on the heat recovery performance.

Model Comparison
Results from the WaterHub simulation were compared to those obtained by Kenway et al. (2012). We observed a clear correspondence between the results. Complete Sankey diagrams of the daily water and energy flows are shown in the supplementary information ( Figure S3 and S4).
The two modeling approaches yielded similar total water consumption values, with less than 1% discrepancy (473.8 and 470 Liters per household per day [L d -1 ] for WaterHub and Kenway study, respectively). With the exception of the kettle and the boiler, all appliances showed less than 5% discrepancy with values obtained in the Kenway study (Figure 3 a)). Nevertheless, two exceptions appeared: (i) WaterHub calculations estimated the volume of water heated up by the boiler 17% larger than Kenway calculations (187.5 against 160 L d -1 ), (ii) WaterHub estimated the water consumption of the kettle appliance 24% lower than Kenway calculations (10.6 against 13.9 L d -1 ). We note, however, that the kettle only contributed to roughly 2% of the total water consumption.
From an energy perspective, results from the two modeling approaches matched similarly well (Figure   3 b)). The most energy intensive appliance -the shower, at 3.30 kWh hh -1 d -1 -showed a discrepancy of only 0.3%. Similarly to water consumption, calculations from the WaterHub also lie within 5% difference compared to the Kenway study. However, notable exceptions appeared: heat losses from pipes were evaluated by the WaterHub framework one order of magnitude higher, while energy use from the taps was estimated roughly 20% lower. The thermal losses from pipes reached on average 13% of the total daily energy use in the household.
Overall, discrepancies between the two modeling approaches can mostly be attributed to differences in the handling of water and energy dynamics. We discuss these differences in Section 5.1.1.

Water Demand Scenarios
We assessed the impact of three water demand scenarios (non-, semi-and fully-stochastic) on the DHW system. Figure 4 a) shows the results of the Monte-Carlo simulations. The distributions shown are essentially a measure of the dynamics of heat losses in the system. Only marginal differences were observed between the distributions of the semi-and fully-stochastic demand scenarios, with medians 12.6% and 12.4% and skewness coefficients 1.67 and 1.49, respectively. However, the non-stochastic scenario induced significant changes in the energy dynamics: its median reads 19.7% and its skewness coefficient is 0.86. The less-realistic non-stochastic water demand scenario thus led, in our case, to an overestimation of the system losses by 7%, as well as a misinterpretation of the dynamics of heat losses from the distribution shapes.
Because events from the semi-and fully-stochastic scenarios have lower inter-event time intervalsi.e. a higher frequency -, these results suggest that event frequency is the main driver for heat losses dynamics in the system. We confirmed the role of event frequency by confronting results from the WaterHub framework to the static model described in Section 3.3.2 (Figure 4 b), top). A significant dependency was observed: system losses grow from 3.1% in Scenario 1 (high frequency) to 14.6% (static) and 10.8% (WaterHub) in Scenario 6 (low frequency). Although similar in Scenarios 1, 2 and 3, the curves diverge as the event frequency is reduced. In absolute terms, system losses increase roughly 5-fold to 10 kWh hh -1 d -1 between Scenarios 1 and 6, mainly driven by additional losses from the taps (Figure 4 b), bottom).

Showcase
Simulations showed the impact of adding a drain water heat exchanger in the system ( Figure 5, 55 °C boiler). The amount of saved energy was in the same order of magnitude as the energy lost by the pipe network and the boiler (930 kWh y -1 ). As heat was recovered, the drain water temperature decreased significantly. With 3.0, 7.5 and 12.0 kW nominal heat transfer setups, the temperature of the shower drain stream was reduced by 7.0 ± 0.6, 10.9 ± 0.8 and 12.9 ± 0.8 K, respectively (daily averages).
Further, we analyzed the interaction of the heat exchanger with the tank boiler. The heat recovery performance increased with increasing boiler temperatures, as shown in Figure 5. Estimates of annual system losses are also shown. Part of the losses were compensated by the performance increase of drain water heat recovery systems. Between 45 and 55 °C, 34%, 54% and 69% of the additional system losses (290 kWh) were compensated by the increased performance of the drain water heat recovery system for the 3.0, 7.5 and 12.0 kW setups, respectively. Between 55 and 65 °C, annual losses increased by roughly 300 kWh, of which 12%, 22% and 24% were compensated by the simultaneous increase in performance of the 3.0, 7.5 and 12.0 kW setups, respectively.

Figure 5. Annual recovered energy (dashed lines) and system losses (bars) against boiler set point temperatures.
We note an improved performance of drain water heat recovery systems as the boiler temperature increases. This effect compensates part of the additional system losses. We note that neither 40 nor 70 °C are, in practice, realistic boiler temperatures. These temperatures are shown here for the sake of completeness.

Dynamics of Water Consumption
Results from the model comparison and water demand scenarios studies highlight the importance of water consumption dynamics in modeling the water-energy nexus at household level. We develop this statement in the sections below by discussing specific insights from the two studies.

Insights from Model Comparison
Although the WaterHub framework and the model from Kenway et al. (2012) yielded close results, significant discrepancies in water and energy consumption flows appeared. We attribute these discrepancies to the main difference between the approaches: dynamic versus static simulation of water and energy flows.
The WaterHub framework simulates flow and heat losses in water pipes for individual events, in static and flowing conditions. In taps, water is typically consumed as short (5 -15 seconds) but frequent events (around 30 per day). Hot water from the boiler must first flush the cold water contained in the pipes before reaching the tap, as water from the last event has cooled down to room temperature in the meantime. This effect reduces the cumulated heat transported (thus consumed) through the taps, as the water being flushed is still cold during the first seconds of the consumption event. As Kenway et al. (2012) do not consider the temperature dynamics in pipes, their estimation of tap energy consumption is higher than that of the WaterHub, leading to the observed 20% discrepancy.
This effect also increases the amount of hot water extracted from the boiler. In appliance models, the mixing of hot and cold water flows is thermo-regulated. If the hot water flow is not warm enough, no mixing takes place and water is drawn from the hot stream only. This explains the difference in boiler water consumption (27.5 L d -1 discrepancy) between the two models.
Finally, the amount of heat lost to the environment is larger in our model, as hot water stagnates in the pipes during subsequent water events. We note that the pipe thermal losses to the environment reached 13% of the total energy use in the household, close to the 20% commonly estimated for single family homes (Cholewa et al. 2019).
Our interpretation of the discrepancies -resulting from the dynamic modeling approach -is in line with results from Kenway et al. (2019), who recently presented a model for dynamic simulations of shower events (at minute resolution). They conclude, as we do, that heat losses from hot water pipes can only be accurately simulated with the help of a dynamic model. However, this statement can be generalized, as our results show that dynamic simulations of all water-related processes in households are critical for accurate assessments of the water-energy nexus.
We notice that the handling of water events in the present model can be made even more realistic, especially for short and frequent events -in taps, for instance. In reality, consumers often let water flow until it is hot enough for their use. Formally, the water event only starts when the water temperature reaches a threshold temperature, defined by the use. We may expect, for instance, a higher temperature threshold for shaving than for hand washing. The WaterHub library contains a tap model reproducing this behavior, and an interesting outlook would be to evaluate how these taps modify our understanding of system losses in DHW systems.
However, modeling water consumption with such realism requires additional information about water consumption behaviors: What do water events look like? How variable are their flow, temperature and duration? How important is it to know how events are spread out over the day? The required information depends heavily on the selected water demand models, as we discuss in the next section.

Insights from Water Demand Scenarios
Results from Figure 4 a) indicate that the frequency of events is a major driver of the dynamics of heat losses in the system. Indeed, the non-stochastic water demand scenario produces wrong estimates of energy losses in the system, whereas results from the fully-stochastic and the semi-stochastic scenario are similar. Other factors, such as event-specific stochastic patterns (variable flow, temperature, volume), play a smaller role.
This assertion, however, was challenged by a second analysis (results of Figure 4 b)). Although the time interval between subsequent events clearly appears as a major driver of system losses, the story is not complete. Indeed, results from the static model (depending only on the frequency of events) diverge from those of the WaterHub framework. Two competing phenomena explain this divergence:  For appliances with longer events, e.g. shower and bath, the static model overlooks losses during flowing condition, thus underestimating losses from these appliances.
 For appliances with short events, i.e. taps, events tend to stop before the water in the water pipe has reached boiler water temperature. In these conditions, the static model overestimates system losses from taps, as water in the pipe starts the stagnation phase -once the event stops -with a lower temperature.
In Scenario 1 -high event frequency -, the two phenomena annihilate, providing a good match between the static and the WaterHub curves. In scenario 6 -low event frequency -, however, taps represent 90% of the total losses (Figure 4b), bottom), and the second phenomena prevails, leading to an overall overestimation of system losses in the static model.
These results strengthen preliminary conclusions from the model comparison study: dynamic modeling of DWH systems is critical for understanding processes at the core of the water-energy nexus in the household. A realistic scheduling of water consumption is crucial for trustworthy energy estimates. We add to this statement that simple models based on few characteristics of water consumption -for instance only event frequency as in our static model -may overlook important aspects of the energy dynamics. We extend with these claims conclusions from literature: according to Fuentes et al. (2018), who have reviewed the use of water demand models in energy simulations, the effect of more realistic models in the energy performance assessment of buildings remains unclear. We stress that these dynamic processes may be especially critical for the realistic simulation and dimensioning of systems containing one -or more -heat recovery technologies, as they involve highly non-linear phenomena.

Holistic Water-Energy Investigations
In addition to water consumption dynamics, as discussed above, the implementation of technologies or energy-saving measures in DHW systems benefits greatly from a holistic modeling approach, as systemic interactions may limit -or increase -the performance of the implemented device or measure. Results from the showcase study -implementation of a drain water heat recovery devicehighlight the importance of holistic approaches for investigations of the water-energy nexus.
Indeed, the most striking results of this showcase study (presented in Figure 5) relate to the dependency of the drain water heat exchanger on boiler temperatures. With higher boiler temperatures, more cold water is mixed at the faucet and thus flowing through the heat exchanger.
This increases the energy uptake potential, thus the performance of the device.
This interaction is of particular interest in the perspective of hygiene regulations for DHW systems.
With the aim to prevent Legionella growth in hot water systems, guidelines notably suggest to increase boiler set point temperatures (Van Kenhove et al. 2019). With higher boiler temperatures, system losses inevitably increase, as (i) the temperature difference between the boiler and ambient air increases, and (ii) hotter water stagnates in the pipes between consumption events. The interaction may mitigate up to 24% the additional heat losses when boiler temperature is increased from 55 to 65 °C, not only saving energy, but also improving the economic efficiency of the heat recovery device.
Although deviations may be expected due to a lack of calibration data for thermal inertia and fouling of the heat exchanger, we are confident that the simulations are close to reality. Indeed, the modeling methodology used for the drain water heat exchanger model used in the analysis is well established (discretized modeling of heat exchange) and based entirely on physical laws.
We highlight that significant energy savings are possible using the drain water heat recovery device.
The middle-sized heat exchanger, comparable to commercially available devices such as Joulia Inline (Joulia AG 2017), recovered 37% of the energy contained in the shower drain stream, close to the value calculated by Kenway et al. (2019) during the investigation of a similar scenario (44%). For the household, this translates -in Switzerland -to a 20% reduction of the 800 kWh p -1 y -1 lost as wastewater-contained heat to the sewer system downstream (Larsen 2015).

Modeling Framework
The WaterHub framework, as a tool to investigate the water-energy nexus at household level, showed its versatility, exemplified by the model comparison, water demand scenario analysis and showcase studies. Some of the framework's identified limitations are discussed in the next paragraphs.
First, the Modelica language, although well established in some disciplines -e.g. in the automotive sector -and recognized for system-wide analyses (Casella 2015), is not widely spread in environmental research. Some libraries were developed for environmental engineering applications, like the WasteWater Library (Reichl 2003), but to the best of our knowledge none in the field of LCA or MFA.
We hypothesize that expanding the community will be driven by lowering the barrier to adoption.
Many Modelica libraries are still demanding tools. The WaterHub framework is a step towards making DHW simulations available to water professionals who are not expert Modelica users.
In the attempt to lower the barrier to adoption, however, water flows were modeled -as a first step -in their simplest form, consequently lowering the potential to model some physical phenomenon, e.g. pressure drops. This may limit the integration of some technologies in the library. Pump models, for instance, require measuring pressure drops to evaluate their electrical energy consumption.
In this sense, future developments will aim at using the interface standard set by the International Building Performance Simulation Association (IBPSA) (Christoph et al. 2015) as basis for the simulation of water and energy flows. They will be adapted, however, to suit the requirements of a simplified, MFA-ready library targeting environmental researchers less acquainted with building modeling and simulation.

Conclusions
This paper presents a novel modeling framework to investigate the household water-energy nexus.
Based on straightforward graphical flow diagrams, this modular framework combines a stochastic demand model and a process-based library of models to create material and energy flows analyses (MEFA) of complex domestic hot water (DHW) systems.
We demonstrated the usefulness of the framework in three studies: a comparison against an existing model, an explorative study on water demand scenarios and an exemplary case study on the integration of a drain water heat recovery device into a DHW system. Two studies -model comparison and water demand modeling -highlighted the importance of dynamic modeling for the understanding of the water-energy nexus. Thanks to the dynamic approach of the WaterHub framework, we showed that a former -static -material flow analysis (MFA) of a DHW system had underestimated heat losses from the distribution system by one order of magnitude.
Furthermore, the inherent variability -i.e., dynamics -of water consumption also influenced energy dynamics. In this regard, non-stochastic water demand scenarios led to inaccurate heat loss predictions, overestimating heat losses from the system (19.6% versus 12.6% for stochastic water demand scenarios). Highly non-linear systems, comprising for instance one or more heat recovery devices, are suspected to be particularly sensitive to the choice of water demand model, and may thus require a fully stochastic water demand model. Future research will evaluate further how detailed water demand scenarios need to be for various modeling objectives.
The framework also demonstrated the value of its holistic approach: identifying systemic interactions is critical to avoid competition between technologies and promote synergies. Results from the exemplary case study suggested that a synergy between the drain water heat recovery device and the boiler set point temperature can be used to partially compensate -up to 24% for a 55 to 65 °C increase -the additional heat losses induced by higher boiler temperatures.
The WaterHub modeling framework provides a validated methodology for the assessment of optimization strategies of the water-energy nexus at household level. The framework is an intuitive screening tool to assess the potential of new technologies and identify systemic interactions which may influence their performance. Its modular structure allows to include any DHW-related technology, providing a useful common platform for collaboration between technology developers and water experts. We can now expand the boundaries (e.g. towards the household-district interface) or the complexity (e.g. towards heat-and water-recycling DHW systems) of our water-energy nexus investigations. We hope that this open-source and user-friendly framework will be adopted by other researchers with the aim of reducing the carbon footprint of our building stock.