Skip to main content

A direct and analytical method for inverse problems under uncertainty in energy system design: combining inverse simulation and Polynomial Chaos theory

Abstract

This article introduces and formalizes a novel stochastic method that combines inverse simulation with the theory of generalized Polynomial Chaos (gPC) to solve and study inverse problems under uncertainty in energy system design applications. The method is particularly relevant to design tasks where only a deterministic forward model of a physical system is available, in which a target design quantity is an input to the model that cannot be obtained directly, but can be quantified reversely via the outputs of the model. In this scenario, the proposed method offers an analytical and direct approach to invert such system models. The method puts emphasis on user-friendliness, as it enables its users to conduct the inverse simulation under uncertainty directly in the gPC domain by redefining basic algebra operations for computations. Moreover, the method incorporates an optimization-based approach to integrate supplementary constraints on stochastic quantities. This feature enables the solution of inverse problems bounding the statistical moments of stochastic system variables. The authors exemplify the application of the proposed method with proof-of-concept tests in energy system design, specifically performing uncertainty quantification and sensitivity analysis for a Multi-Energy System (MES). The findings demonstrate the high accuracy of the method as well as clear advantages over conventional sampling-based methods when dealing with a small number of stochastic variables in a system or model. However, the case studies also highlight the current limitations of the proposed method such as slow execution speed due to the optimization-based approach and the challenges associated with, for example, the curse of dimensionality in gPC.

Introduction

In energy system design, the consideration of uncertainty is instrumental for an informed decision-making process. Uncertainty refers to quantities for which knowledge is limited, introduced by stochastic processes that are usually too complex to model deterministically (Milton et al. 2022). Multi-Energy System (MES) design, from initial planning and implementation to future operation and monitoring, is a prominent example in this regard. MES define integrated energy networks that holistically manage multiple energy sources and carriers such as electricity, heat, cooling, gas, and renewable generation (Mancarella 2014). Effective MES design, in particular in its early stages, requires identifying which sources of uncertainty most significantly impact MES operation. The numerous uncertainties, i.e., component parameters that must be tuned during the design process, further necessitate sensitivity analysis (Ginocchi et al. 2021) to focus the attention on MES components with the greatest system influence. This analysis helps to identify significant interactions between MES components and overall system design metrics, enabling prioritization in defining system parameters that significantly impact the system behavior.

Moreover, inverse problems are frequently encountered in energy system design endeavors, in which the direct quantification of a physical design quantity is impractical or not feasible. In such cases, an indirect evaluation of the design quantity can be synthesized through models using computer-based simulation (Chakrabarti et al. 2011). We refer the term ‘model’ to as a virtual replica of a real-world system, i.e., numerical procedures or algorithms that aim at reproducing the behavior of the real-world system. Specifically, when the design quantity of interest serves as a dynamic input to a model, the challenge shifts toward determining this input from the model’s outputs, a scenario referred to as an inverse problem in mathematical terms (Murray-Smith 2014).

One tangible example of an inverse problem under uncertainty in energy system design involves quantifying the energy demand of heating units in buildings within an MES, when the buildings’ thermal space heating demands are not fully known and/or the buildings’ thermal dynamics exhibit stochastic behavior. In such cases, the starting point for assessment is often an established physical thermal model of one particular building, typically available from the building thermal modeling and simulation domain (for example, cf. works (Crawley et al. 2008; Harish and Kumar 2016; Rastegar-Moghadam et al. 2024; Crawley et al. 2001; Maier et al. 2024)). Using such an established model, the building’s total thermal heating power demand—commonly a dynamic input to the thermal model—must be determined reversely from the model’s uncertain and dynamic outputs, such as the building’s indoor air set temperature profile or the occupants’ thermal comfort specifications.

Solution methods to such inverse problems under uncertainty conventionally involve repeated applications of the given forward simulation model to observe how the outputs react to different inputs (Hiskens 2004). Referred to as sampling-based methods such as Monte Carlo (MC) simulation, Random sampling, Latin hypercube sampling or Importance sampling (Helton et al. 2006), the objective is to calculate the outputs for a known system model given a set of varying inputs. Sampling-based methods treat the model as a black-box, performing uncertainty quantification by repeatedly running the model with different sets of input parameters sampled from their probability distributions. Despite their intuitive nature, sampling-based methods are often cumbersome and computationally demanding. The widely-applied MC simulation, for instance, can become a time-consuming process due to its rather slow convergence rate of \(\sqrt{N}\), where N denotes the total number of simulation runs (Xiu 2008). In this context, depending on the spread of the Probability Density Function (PDF) of the uncertain inputs under consideration, a ‘sufficient’ number of samples N can quickly scale to a range of hundreds to thousands to obtain evidence about the real behavior of the considered system under uncertainty (Togawa 2015). With respect to early MES design stages when many system configurations require evaluation, this aspect makes uncertainty qunatification and sensitivity analysis challenging; thus demanding a more flexible analytical approach for design decision-making under uncertainty.

In this light, the purpose of this article is to formulate and formalize a novel method for solving inverse problems under uncertainty in energy system design in a direct and analytical way. The method is suitable for both uncertainty analysis and sensitivity analysis. According to the definition in Ginocchi et al. (2021), uncertainty analysis is the characterization of uncertainty in the outputs of a model due to the different sources of uncertainty in the model inputs, whereas sensitivity analysis is the study of how the uncertainty in the outputs of a model can be apportioned to the different sources of uncertainty in the model inputs.

The proposed method builds on i) the theory of generalized Polynomial Chaos (gPC) expansion using orthogonal polynomial sets from the Askey scheme (Xiu and Em Karniadakis 2002; Askey and Wilson 1985) and ii) the concept of inverse simulation for the inversion of generic, possibly nonlinear systems or simulation models (Murray-Smith 2014), and comprises three consecutive steps. First, it employs inverse simulation on a known forward model to obtain the model of the inverse problem. In conventional forward simulation, the objective is to calculate the outputs of a system given a set of inputs. In inverse simulation, the problem is reversed and the objective is to calculate a set of inputs that satisfy a predefined output trajectory. Second, the method transforms the inverse model into a stochastic problem by substituting deterministic variables with stochastic gPC expansion variables. In gPC, each stochastic variable in a system with uncertainty is expressed as a series of orthogonal polynomials, with each polynomial scaled by a coefficient. The polynomials in the series approximate the shape of the PDF of the stochastic variable, while the coefficients capture the magnitudes of the variable’s statistical moments (Milton et al. 2022). Third, the method enables the imposition of additional boundary conditions on the variables in the stochastic inverse problem through a least-squares optimization problem formulation. This feature involves the adjustment of user-defined gPC expansion coefficients during the evaluation process of the inverse model, thereby explicitly solving the stochastic inverse problem under numerical limitation of the bounds of statistical moments of target gPC system variables.

The rationale behind the proposed method and its key advantages over current state-of-the-art approaches (cf. Section Research to date) are as follows:

  1. 1)

    Unlike sampling-based methods, the gPC approach enables the analytical determination of the full PDF and statistical moments of stochastic system quantities through explicit integration of stochastic variables represented as gPC expansion. This enables the rigorous analytical analysis of how stochastic quantities propagate through an (inverse) simulation model towards the target design variables of interest. Moreover, the analytical representation enables the formulation of design, optimization, and control solutions directly in the stochastic domain.

  2. 2)

    Assuming that the number of independent stochastic variables in a system is limited, the use of gPC is extremely efficient from a computational point of view compared to sampling-based methods. In particular, gPC allows solving a system of differential equations affected by uncertainty in time domain simulation for a single execution of the model only (Xiu and Em Karniadakis 2002).

  3. 3)

    Although gPC is an intrusive method, which by definition requires reformulation of the equations within a given model, the proposed method aims at mitigating this drawback. By redefining basic arithmetic operators for gPC quantities, such as summation and multiplication, the proposed method allows for analytical stochastic analysis of a model as if it were deterministic, i.e., without the user’s need for explicit modification of equations within the model. In practice, this is made possible through object-oriented implementation (Milton et al. 2020), which enables the reuse of an existing model and seamless alternation between deterministic and stochastic analysis. In this scenario, a change of the type and source of uncertainty, i.e., the underlying PDF, also does not require adaptation to the model under study.

  4. 4)

    The optimization-based adjustment of single expansion coefficients of gPC variables allows for the imposition of additional soft constraints on stochastic system quantities. This means that statistical moments such as expected value and variance can be explicitly bounded by the user during model execution, leading to the possibility to solve an inverse problem bounding its stochastic variables but without imposing a precise matching to a specific PDF.

  5. 5)

    The concept of inverse simulation is simple but effective. In comparison to direct inversion methods, where the system poles and zeros are simply interchanged if feasible, inverse simulation methods can avoid analytical complexity in the inversion of models that cannot be directly inverted, especially in the case of non-linear, multiple-input-multiple-output (MIMO) systems (Murray-Smith 2014). In this context, literature demonstrates that inverse simulation is an acceptable approach for handling system inversion complexity with reasonable computation efforts (Hess et al. 1991).

The following sections will review related work and the theoretical foundations of the proposed method. This will be followed by proof-of-concept MES design applications related to uncertainty quantification and sensitivity analysis, demonstrating the method’s potential in energy system design decision-making under uncertainty.

Research to date

Review of inverse simulation methods and their applications

Inverse simulation involves reversing a forward problem by identifying the inputs to a known forward model that produce a predefined output trajectory. Remember that, except for a small subset of cases, such as first-order single-input-single-output (SISO) systems, an inverse problem cannot be calculated directly by inverting the system equations (Murray-Smith 2014). In this context, inverse simulation complements conventional model inversion techniques and overcomes limitations that may be present, for example, because of non-linearities or unstable zero dynamics in a given forward system model or simulation (Lu 2007).

Significant research on mathematical solutions for inverse simulation and its applications has been conducted, notably by the author in Murray-Smith (2014), Murray-Smith (2014a), Murray-Smith (2000), Murray-Smith (2018). The review article in Murray-Smith (2014) presents and categorizes multiple inverse simulation solution methods. For discretized system models, there are three primary methods: differentiation-based, integration-based, and optimization-based methods (Murray-Smith 2014). For continuous system models, differential algebraic equations, feedback methods, and approximate differentiation methods can be used to derive the inverse model (Murray-Smith 2014).

Historically, inverse simulation has been successfully applied in several mechanical engineering fields where the focus is primarily on the control actions needed to achieve a particular form of output response. Deterministic applications that have made significant use of inverse simulation are avionic flight control (Lu 2007; Thomson and Bradley 2006), water vehicle manoeuvres (Lu 2007; Murray-Smith 2014a), and robotics (Worrall et al. 2015).

Although energy system analysis could benefit from inverse simulation in many ways, as it can be used, e.g., for planning and scheduling, control design, model validation, parameter estimation or post-disaster/contingency analysis, rarely it has been applied in this context. One of the few deterministic examples is found in Borutzky (2017), where inverse simulation, combined with a bond graph-based fault accommodation approach, is used to detect, isolate, and resolve from faults in power electronic systems and circuits. Moreover, our previous work (Diekerhof et al. 2019) investigates a deterministic demand response algorithm that integrates an inverse simulation approach. This inverse simulation approach maps prosumer thermal comfort specifications in a building to the side of electrical consumption based on a building’s thermal dynamics model. We will reuse this model in the proof-of-concept application presented in Section Test Case 1: Quantification of the Uncertainty in the Thermal Space Heating Demand of Buildings for Heat Pump Sizing of this work.

Besides inverse simulation, related system inversion methods exist. For instance, work (Hiskens 2004) presents a systematic system inversion approach for power system dynamics analysis using Petri nets and hybrid automata. This approach employs a differential-algebraic impulsive-switched model to solve inverse problems by unifying the description of hybrid discrete-time event-driven and continuous-time systems. However, the approach is rather complex and demands substantial modeling efforts. Modern machine learning approaches are also notable for solving inverse problems. Work (Raissi et al. 2019), for example, introduces physics-informed neural networks to solve both forward and inverse problems governed by partial differential equations, integrating physical laws directly into the learning process. Such data-driven approaches can solve high-dimensional inverse problems effectively, but require large data sets and significant computational resources for training. Furthermore, optimization-based approaches for system inversion, such as inverse optimization (Chan et al. 2023), aim at determining the underlying input parameters or objective functions of an optimization problem based on observed optimal solutions. This approach, however, necessitates that a given forward model can be formulated as an optimization problem, which is challenging if non-linear system equations are present.

Review of stochastic methods for energy system design and analysis

Recent research on stochastic methods for energy system design and analysis has significantly advanced the understanding of how sources of uncertainty impact the planning and operation of energy systems. Comprehensive reviews on state-of-the-art uncertainty modeling approaches and stochastic methods can be found in works (Fodstad et al. 2022; Aien et al. 2016; Hasan et al. 2019). In particular, work (Hasan et al. 2019) introduces a conceptual probabilistic analysis framework that integrates i) probabilistic input variable modeling, ii) stochastic computational methods, and iii) the definition of output and result indices. Our research contributes to this field by proposing a novel method to solving inverse energy system design problems under uncertainty, focusing on the second stage within this framework.

On a high level, stochastic analysis can be classified into intrusive and non-intrusive computational methods. Non-intrusive methods, such as sampling-based methods like MC simulation, come with the advantage of simplicity and do not require modifications to the original deterministic model formulations. However, they are computationally intensive and provide less information compared to more flexible analytical approaches. Although improved non-intrusive methods such as Quasi-Monte Carlo and Stochastic Collocation have been defined and proved to offer better convergence than classical MC simulation (dos Santos Azevedo and Pomponet Oliveira 2012), they still require multiple samplings of the random space described by the stochastic variables. In contrast, intrusive methods like Polynomial Chaos (Wiener 1938) enable the analytical computation of the full PDF and all statistical moments of system variables by explicitly integrating system variables represented as expansions of orthogonal polynomials. Polynomial Chaos theory was generalized as generalized Polynomial Chaos (gPC) by the authors in (Xiu and Em Karniadakis 2002, 2002a), which approximates different types of PDF using orthogonal polynomial sets from the so-called Askey scheme (Askey and Wilson 1985).

For a small number of stochastic variables in a simulation model or system, the number of required gPC expansion coefficients per stochastic variable is low, which allows for computational reductions in comparison to sampling-based approaches, where numerous samples may need to be computed for each stochastic variable of a system to achieve similar simulation solution accuracy and convergence as with gPC expansion (Milton et al. 2022). However, it is important to stress that this advantage over sampling-based approaches is lost as soon as the number of stochastic variables grows and the number of gPC expansion coefficients increases, because of the exponential-like growth of the complexity of the arithmetic with gPC expansion. This drawback is known as the so-called curse of dimensionality (Zhou et al. 2018). Sparse Polynomial Chaos expansion (Zhou et al. 2018; Lüthen et al. 2021; Ni et al. 2017) is a possibility to mitigate the effects of high dimensional uncertainty, but is not in the focus of this paper.

Moreover, since gPC is an intrusive method, one of its main drawbacks is the requirement of transforming model equations into the Polynomial Chaos domain. A number of tools already exist to simplify this process, e.g., such as Togawa et al. (2012), Feinberg and Langtangen (2015), Mühlpfordt et al. (2020) to mention a few. Non-intrusive approaches based on Polynomial Chaos have been also proposed in the past, for example in work (Eldred 2009), with limitations similar to sampling-based methods.

Traditionally, non-intrusive methods have been predominantly applied to power and energy system design and analysis. Among these, the MC simulation method is the most widely used due to its easy implementation, robustness, and strong adaptability. For example, work (Arens et al. 2022) explores the use of MC simulation to evaluate miscellaneous energy system component configurations within residential energy systems, focusing on device-agnostic energy management to optimize the integration and operational efficiency of different multi-energy devices. Similarly, the authors in Dubey and Santoso (2017) present a stochastic analysis framework for the hourly quantification of the maximum Photovoltaic (PV) hosting capacity in distribution grid feeders, using a MC-based steady-state AC probabilistic power flow analysis to evaluate the impacts of PV generation on bus voltages within the grid.

Nevertheless, the use of gPC has gained increasing attention in recent years. For instance, work (Mühlpfordt et al. 2019) presents an analytical method for performing AC probabilistic power flow by formulating moment-based versions of the AC power flow equations under uncertainty using gPC theory. This approach, similar to ours, explicitly considers all stochastic quantities directly in the model and ensures voltage magnitude and line current limits through a chance-constrained optimal AC power flow optimization problem formulation, demonstrating high accuracy at manageable computation efforts. Using a similar modeling approach for the AC probabilistic power flow, work (Ni et al. 2017) discusses a basis-adaptive sparse gPC method, showing that the proposed gPC approach achieves up to 99% accuracy compared to a MC-like method while reducing computational times substantially.

Besides pure uncertainty analysis, sensitivity analysis has also a long tradition in the power and energy domain, not only to support early-stage design of energy systems but also to evaluate robustness of optimization and control schemes. For a comprehensive review of sensitivity analysis in power and energy systems, we refer to work (Ginocchi et al. 2021). Works (Liu et al. 2021; De Mel et al. 2023), for example, use sampling-based methods for sensitivity analysis to study the design and operational efficiency of district energy systems. While non-intrusive approaches have been predominantly used for sensitivity analysis in the past, gPC has also been recently employed for this purpose, for instance, in power system analysis (Ni et al. 2018) and in assessing building energy performance (Tian et al. 2020). Against this background, we will showcase in Section Test Case 2: sensitivity analysis for MES design of this paper how the proposed method facilitates straightforward sensitivity analysis for energy system design tasks.

Contributions

The key contributions of this research are as follows:

  1. 1)

    With the exception of an application in the field of traffic accident reconstruction in Zhang et al. (2013), inverse simulation has so far been applied to deterministic problems only. The present work introduces a novel stochastic method that combines inverse simulation with the theory of gPC to study inverse energy system design problems under uncertainty. While both inverse simulation and gPC have been extensively studied independently, our literature review indicates that this is the first instance of their combined use.

  2. 2)

    The proposed method facilitates uncertainty and sensitivity analysis without requiring explicit modifications to the original forward or inverse model formulations. Unlike previous approaches that relied on non-intrusive methods, our solution leverages gPC arithmetic and operator overloading. The validity and effectiveness of this direct and analytical approach is demonstrated through uncertainty and sensitivity analysis for exemplary test cases in MES design.

  3. 3)

    The proposed method incorporates a novel optimization-based approach to integrate additional constraints on stochastic quantities. This feature increases the flexibility in uncertainty modeling and allows solving (inverse) problems by bounding the statistical moments of stochastic system variables represented as gPC expansion. Consequence is the advantage of easily evaluating how predefined probabilistic tolerance ranges on stochastic system variables propagate through a model and ultimately impact the system quantities of interest. This can be of relevance to stochastic analysis for a variety of real-world applications.

The proposed method

The three consecutive steps of the proposed method, as illustrated in Fig. 1, are briefly reviewed and formalized in the following Sections Step 1 of the method: inverse simulation-Step 3 of the method: imposition of supplementary constraints on gPC variables. While the first two steps of the method are essential, the third step is optional. Moreover, Section Sensitivity analysis outlines the approach for using gPC theory in sensitivity analysis.

Fig. 1
figure 1

Workflow schematic of the three consecutive steps of the proposed method. The notation and definition of variables is specified in the following Sections Step 1 of the method: inverse simulation-Step 3 of the method: imposition of supplementary constraints on gPC variables

Step 1 of the method: inverse simulation

Inspired by research works (Murray-Smith 2014, 2014a, 2000, 2018), cf. Section Review of inverse simulation methods and their applications, we focus in this work on the differentiation-based inverse simulation method for discrete-time systems from Murray-Smith (2000), because it is a straightforward and computationally lightweight method that has been used with considerable success in the past. It makes use of the Newton-Raphson algorithm for system inversion. This algorithm, also known as Newton’s method, is a powerful method for solving equations numerically (Schilling and Harris 2000). However, it is crucial to emphasize that our proposed method is not limited to this specific inverse simulation approach. Other solution methods presented by the author in Murray-Smith (2014), Murray-Smith (2014a), Murray-Smith (2000), Murray-Smith (2018) would seamlessly integrate with our proposed stochastic method, too.

We now proceed reviewing the differentiation-based inverse simulation method from Murray-Smith (2000). For this purpose, let us consider the generic non-linear, continuous-time system in (1), where function \(\textbf{f}\) involves a set of ordinary differential equations describing the system dynamics with a given state vector \(\textbf{x}(t)\) as well as input vector \(\textbf{u}(t)\), and where function \(\textbf{g}\) is a set of algebraic equations that yield the output vector \(\textbf{y}(t)\).Footnote 1

$$\begin{aligned} \dot{\textbf{x}}(t) = \textbf{f}\big (\textbf{x}(t), \textbf{u}(t)\big ), \quad \textbf{y}(t) = \textbf{g}\big (\textbf{x}(t), \textbf{u}(t)\big ) \end{aligned}$$
(1)

This system model, discretized via, e.g., the Backward Euler method, is expressed by the discretized state and output equations in (2), where index \(k \ge 0\) denotes the kth discretization point and \(\Delta t\) is the discretization time step.

$$\begin{aligned} \frac{\textbf{x}_k-\textbf{x}_{k{-}1}}{\Delta t} = \textbf{f}\left( \textbf{x}_k, \textbf{u}_k\right) , \quad \textbf{y}_k = \textbf{g}\left( \textbf{x}_k, \textbf{u}_k\right) \end{aligned}$$
(2)

For a dynamic discrete-time system as in (2), the output response sequence \(\textbf{y}_k\) can be calculated from the system initial conditions \(\textbf{x}_{k{=}0}\) and a sequence of inputs \(\textbf{u}_k\). The inverse problem, in turn, involves finding the system states \(\textbf{x}_k\) and input sequence \(\textbf{u}_k\) given a known output sequence \(\textbf{y}_k\) as well as the system initial conditions \(\textbf{x}_{k{=}0}\). Accordingly, the formulation in (3) seeks the input sequence \(\textbf{u}_k\) that, when combined with the dynamic system states \(\textbf{x}_k\), produce the known output sequence \(\textbf{y}_k\). In this context, \(\tilde{\textbf{g}}\) defines the inverse system function that, given the output sequence \(\textbf{y}_k\) and the system states \(\textbf{x}_k\), determines the input sequence \(\textbf{u}_k\). In the general case, however, finding \(\tilde{\textbf{g}}\) analytically might be difficult or impossible, depending on the complexity of the algebraic equation defined by function \(\textbf{g}\) in (2).

$$\begin{aligned} \textbf{u}_k = \tilde{\textbf{g}}\left( \textbf{x}_k, \textbf{y}_k\right) \end{aligned}$$
(3)

Nevertheless, for known ‘historical’ system states, \(\textbf{x}_{k{-}1}\), and desired output values, \(\textbf{y}_{d,k}\), the numerical values for \(\textbf{u}_k\) and \(\textbf{x}_k\) in (2)/(3) can be calculated numerically for \(k \ge 1\) by introducing the following two functions \(\mathbf {F_1}\) and \(\mathbf {F_2}\) as follows:

$$\begin{aligned} \mathbf {F_1}\left( \textbf{x}_k, \textbf{u}_k\right)= & {} \textbf{f}\left( \textbf{x}_k, \textbf{u}_k\right) - \frac{\textbf{x}_k-\textbf{x}_{k{-}1}}{\Delta t}, \nonumber \\ \mathbf {F_2}\left( \textbf{x}_k, \textbf{u}_k\right)= & {} \textbf{g}\left( \textbf{x}_k, \textbf{u}_k\right) - \textbf{y}_{d,k}. \end{aligned}$$
(4)

The fulfillment of (2) requires the functions \(\mathbf {F_1}\) and \(\mathbf {F_2}\) in (4) to take zero values. One possibility to solve this root-finding problem is to apply the Newton–Raphson algorithm. In matrix form, the iterative solution process according to the Newton–Raphson algorithm is

$$\begin{aligned} \begin{bmatrix}\textbf{x}_k^{(m)} \\ \textbf{u}_k^ {(m)}\end{bmatrix} = \begin{bmatrix}\textbf{x}_k^{(m{-}1)} \\ \textbf{u}_k^{(m{-}1)}\end{bmatrix} - {\underbrace{\begin{bmatrix}\frac{\partial \mathbf {F_1}}{\partial \textbf{x}_k} &{} \frac{\partial \mathbf {F_1}}{\partial \textbf{u}_k} \\ \frac{\partial \mathbf {F_2}}{\partial \textbf{x}_k} &{} \frac{\partial \mathbf {F_2}}{\partial \textbf{u}_k}\end{bmatrix}}_{=\,\textbf{J}}}^{{-}1} \begin{bmatrix}\mathbf {F_1}\left( \textbf{x}_k, \textbf{u}_k\right) \\ \mathbf {F_2}\left( \textbf{x}_k, \textbf{u}_k\right) \end{bmatrix}, \end{aligned}$$
(5)

where superscript m denotes the mth iteration step and \(\textbf{J}\) is the Jacobian matrix. The iterative process terminates if numerical values \(\textbf{x}_k^{(m)}\) and \(\textbf{u}_k^{(m)}\) are found that ensure that the functions \(\mathbf {F_1}\) and \(\mathbf {F_2}\) satisfy predefined numerical tolerances \(\varepsilon\) close to zero. In that case, the process moves on to the next discrete time step \(k{+}1\) until the numerical values for all variables \(\textbf{x}_k\) and \(\textbf{u}_k\) are successfully determined for all k, i.e., for the system’s entire time horizon, which completes the inverse simulation process (Murray-Smith 2014, 2000).

Step 2 of the method: gPC expansion

Polynomial Chaos theory, first introduced in Wiener (1938) and generalized in Xiu and Em Karniadakis (2002), Xiu and Em Karniadakis (2002a), offers a framework for modeling and simulating systems under uncertain conditions.

Mathematically, gPC is a spectral expansion of random variables that approximates a random process by a complete and orthogonal polynomial basis as a function of random variables with known PDF. Let X be a continuous random variable with a finite second moment. According to Xiu and Em Karniadakis (2002), X can then be represented as the spectral expansion

$$\begin{aligned} X = \sum \limits _{i{=}0}^{\infty } a_i \Phi _i(\xi ), \end{aligned}$$
(6)

where \(\{\Phi _i\}\) is a set of orthogonal polynomials from the Askey scheme (Xiu and Em Karniadakis 2002), \(a_i\) are the gPC expansion coefficients representing the spectral projection of X on \(\Phi _i\), and \(\xi\) is an artificial random variable whose PDF corresponds to one of the orthogonal polynomials listed in Table 1 (Milton et al. 2022).

Table 1 Correspondence of Common Distributions/PDF and Orthogonal Polynomials Based on Eldred (2009)

The choice of specific orthogonal polynomials \(\Phi _i\left( \xi \right)\) from Table 1 to represent a random variable X as gPC expansion builds on the property of orthogonality of polynomials, which ensures efficient and accurate representations of random variables as spectral expansion with the fewest number of terms. Orthogonality means that the inner product \(\langle \Phi _i, \Phi _j \rangle\) of any two different polynomials \(\Phi _i\left( \xi \right)\) and \(\Phi _j\left( \xi \right)\) is zero, which can be mathematically expressed as

$$\begin{aligned} \langle \Phi _i, \Phi _j \rangle = \int \limits _{\xi _a}^{\xi _b} w\left( \xi \right) \Phi _i\left( \xi \right) \Phi _j\left( \xi \right) \,d\xi = 0, \quad i \ne j, \end{aligned}$$
(7)

where \(w\left( \xi \right)\) is a weight function associated with a specific polynomial base, and \(\left[ \xi _a,\, \xi _b\right]\) is the interval region of integration, see Table 1. Moreover, orthogonality implies that the expected value \(E\left[ \Phi _i\left( \xi \right) \right]\) is zero for all \(i \ge 1\), because the polynomial \(\Phi _i\left( \xi \right)\) will have zero mean for \(i \ge 1\) with respect to the orthogonality property. Vice versa, for \(i = 0\), it applies \(E\left[ \Phi _0\left( \xi \right) \right] = 1\), because \(\Phi _0\left( \xi \right) = 1\) by definition. Thus, the orthogonality of basis \(\Phi\) with respect to a probability measure can be written as

$$\begin{aligned} \!\!\!\!E\left[ \Phi _i\left( \xi \right) \Phi _j\left( \xi \right) \right] = \int \limits _{\xi _a}^{\xi _b} p\left( \xi \right) \Phi _i\left( \xi \right) \Phi _j\left( \xi \right) \,d\xi = \int \limits _{\xi _a}^{\xi _b} w\left( \xi \right) \Phi _i\left( \xi \right) \Phi _j\left( \xi \right) \,d\xi = \langle \Phi _i, \Phi _j \rangle , \end{aligned}$$
(8)

assuming that the PDF \(p\left( \xi \right)\) of random variable \(\xi\) is equal to the weight function \(w\left( \xi \right)\), which is typically the case in the context of gPC.

With reference to Table 1, the Hermite polynomials, for instance, are particularly suited for Gaussian random variables, because they form a complete set of orthogonal polynomials over the integration interval \(\left( -\infty , \infty \right)\). The corresponding weight function is \(w(\xi ) = e^{-\frac{\xi ^2}{2}}\), which optimally matches the Gaussian PDF. Consequently, a Gaussian distribution can be described accurately by only a very few gPC expansion terms with the Hermite polynomials. In contrast, using, e.g., the Legendre polynomials, which are orthogonal over a finite interval \(\left[ -1, 1\right]\) with the constant weight function \(w(\xi ) = 1\), would require more terms to achieve the same level of accuracy for a Gaussian random variable due to the different orthogonal base and weight function definitions. Nevertheless, it is legitimate to represent any continuous random process with, for example, the Legendre polynomials for simplicity and practicality in the application of the gPC approach.

The inner product calculation in (7) and (8) is a key operation in gPC and, with reference to definition (6), it applies the following to the calculation of the gPC expansion coefficients \(a_i\) (Mühlpfordt et al. 2019):

$$\begin{aligned} X = \sum \limits _{i{=}0}^{\infty } a_i \Phi _i(\xi ),\qquad a_i = \frac{\langle X, \Phi _i \rangle }{\langle \Phi _i, \Phi _i \rangle } = \frac{1}{\langle \Phi _i, \Phi _i \rangle } \int \limits _{\xi _a}^{\xi _b} w\left( \xi \right) X \Phi _i\left( \xi \right) \,d\xi \end{aligned}$$
(9)

From a computational point of view, the integral in (9) can be effectively computed using Gaussian quadrature. Gaussian quadrature is a numerical integration method that approximates the integral of a function as a finite sum (Schilling and Harris 2000). The standard Gaussian quadrature rule for the integration of a function in the interval \(\left[ -1,\, 1\right]\) states that the integral value can be approximated by the summation of a finite number of function evaluations at optimally chosen evaluation points. Each evaluation is thereby weighted by a coefficient \(\omega _i\) as follows:

$$\begin{aligned} \int \limits _{-1}^{1} f\left( x\right) \,dx = \sum \limits _{i{=}1}^n \omega _i f\left( x_i\right) . \end{aligned}$$
(10)

In (10), the set of points \(\{x_i\}\) for the function evaluation, as well as the set of weights \(\{\omega _i\}\), depend on the interval in which the integral is calculated. For the standard interval \(\left[ -1,\, 1\right]\), the Gauss-Legendre quadrature points and weights are used, whereas, for example, the interval \(\left( -\infty , \infty \right)\) requires Gauss-Hermite quadrature points and weights. These quadrature points and weights can be calculated analytically and offline, and can be also found in standard literature, e.g., such as in textbook (Schilling and Harris 2000).

For any practical application of gPC, the spectral expansion in (6) must be truncated to a series with a finite number of terms (Milton et al. 2022). Accordingly, the truncated expansion of X can be represented with the truncated spectral expansion

$$\begin{aligned} X_{P} = \sum \limits _{i{=}0}^{P{-}1} a_i \Phi _i(\xi ), \end{aligned}$$
(11)

where \(P \ge 1\) defines the total number of expansion terms in the truncated series (Milton et al. 2022), which is reflected by the additional index P for the representation of random variable X, i.e., \(X_{P}\). Because of the truncation, the representation of \(X_P\) is naturally an approximation compared to the exact solution of X, with accuracy and convergence depending on the number of expansion terms P. The standard deviation error \(\sigma _{err}\) between X and \(X_P\) can be calculated as:

$$\begin{aligned} \sigma _{err} = \sqrt{E\left[ \left( X-X_P\right) ^2\right] }, \end{aligned}$$
(12)

where \(E\left[ \cdot \right]\) again denotes the expected value, and with \(\sigma _{err}\) converging to zero when P approaches infinity (Milton et al. 2022). This implies that the accuracy of the approximation is high as long as the number of gPC expansion terms is sufficiently high. According to Milton et al. (2022), an adequate choice for the truncation order of \(X_P\) is

$$\begin{aligned} P = \frac{\left( n+r\right) !}{n! \, r!}, \end{aligned}$$
(13)

where n is the number of independent stochastic variables in a system, and r is the maximum degree/order of the orthogonal polynomials \(\Phi _i\).

gPC arithmetic

The fundamental idea of introducing gPC theory is the possibility to readily substitute standard deterministic variables with gPC expansion variables in a system or simulation model by redefining the basic arithmetic operators such as summation and multiplication for gPC type of variables. This approach enables the user to smoothly alternate deterministic and stochastic analysis for a given model: changing the type of the model’s variables varies the nature of the model, i.e., deterministic vs. stochastic, whereas all internal calculation steps remain the same (Milton et al. 2020).

We now proceed defining the basic algebra operations for gPC. For this purpose, it is important to recall the calculation of single gPC expansion coefficients in (9) together with the following mathematical definitions on the inner product calculation for orthogonal polynomials (Jain et al. 1997):

  • symmetry: \(\langle \Phi _i, \Phi _j \rangle = \langle \Phi _j, \Phi _i \rangle\)

  • linearity: \(\langle \Phi _i, \Phi _j \pm \Phi _k \rangle = \langle \Phi _i, \Phi _j \rangle \pm \langle \Phi _i, \Phi _k \rangle\)

  • positive definiteness: \(\langle \Phi _i, \Phi _i \rangle > 0,~\text {if}~\Phi _i(\xi ) \ne 0\)

Notice that there is also a prototype implementation of gPC theory and gPC arithmetic, which is available as an open-source MATLAB tool (2023), also featuring more advanced algebra operations such as powers, exponential or logarithm.

Summation and subtraction

Let’s assume that A and B are two gPC variables of the same polynomial base and expansion order, with gPC expansion coefficients \(a_i\) and \(b_j\), respectively. Summation or subtraction of A and B then yields gPC variable C with respective expansion coefficients \(c_k\). Using gPC theory, variable C can be written as

$$\begin{aligned} C = \sum \limits _{k{=}0}^{\infty } c_k \Phi _k(\xi ) = \underbrace{\sum \limits _{i{=}0}^{\infty } a_i \Phi _i(\xi )}_{=\,A} \pm \underbrace{\sum \limits _{j{=}0}^{\infty } b_j \Phi _j(\xi )}_{=\,B} = A \pm B. \end{aligned}$$
(14)

Because of the orthogonality of the polynomial base, the gPC expansion coefficients of variable C can thus be calculated as follows (Milton et al. 2022):

$$\begin{aligned} c_k= \frac{\langle C, \Phi _k \rangle }{\langle \Phi _k, \Phi _k \rangle } = \frac{\langle \Phi _k, C \rangle }{\langle \Phi _k, \Phi _k \rangle } = \frac{\langle \Phi _k, A \pm B \rangle }{\langle \Phi _k, \Phi _k \rangle } = \frac{\langle \Phi _i, A \rangle \pm \langle \Phi _j, B \rangle }{\langle \Phi _k, \Phi _k \rangle } \nonumber = \frac{\langle \Phi _k, A \rangle \pm \langle \Phi _k, B \rangle }{\langle \Phi _k, \Phi _k \rangle } = \frac{\langle A, \Phi _k \rangle \pm \langle B, \Phi _k \rangle }{\langle \Phi _k, \Phi _k \rangle } = \frac{\langle A, \Phi _k \rangle }{\langle \Phi _k, \Phi _k \rangle } + \frac{\langle B, \Phi _k \rangle }{\langle \Phi _k, \Phi _k \rangle } \nonumber \\=\, & {} a_k \pm b_k. \end{aligned}$$
(15)
Multiplication and division

Let’s assume that A and B are two gPC variables of the same polynomial base and expansion order, with gPC expansion coefficients \(a_i\) and \(b_j\), respectively. Multiplication of A and B then yields gPC variable C with respective expansion coefficients \(c_k\). Using gPC theory, variable C can be written as

$$\begin{aligned} C= \sum \limits _{k{=}0}^{\infty } c_k \Phi _k(\xi ) = \underbrace{\left( \sum \limits _{i{=}0}^{\infty } a_i \Phi _i(\xi )\right) }_{=\,A} \underbrace{\left( \sum \limits _{j{=}0}^{\infty } b_j \Phi _j(\xi )\right) }_{=\,B} = \sum \limits _{i{=}0}^{\infty }\sum \limits _{j{=}0}^{\infty } a_i a_j \Phi _i(\xi ) \Phi _j(\xi ) = A \cdot B. \end{aligned}$$
(16)

Therefore, it applies the following (Milton et al. 2022):

$$\begin{aligned} c_k= \frac{\langle C, \Phi _k \rangle }{\langle \Phi _k, \Phi _k \rangle } = \frac{\langle A \cdot B, \Phi _k \rangle }{\langle \Phi _k, \Phi _k \rangle } = \frac{\langle \sum \limits _{i{=}0}^{\infty } \sum \limits _{j{=}0}^{\infty } a_i b_j \Phi _i \Phi _j, \Phi _k \rangle }{\langle \Phi _k, \Phi _k \rangle } = \frac{1}{\langle \Phi _k, \Phi _k \rangle } \sum \limits _{i{=}0}^{\infty } \sum \limits _{j{=}0}^{\infty } a_i b_j \langle \Phi _i \Phi _j, \Phi _k \rangle . \end{aligned}$$
(17)

Considering equation (17) for each element k, the multiplication of gPC variables A and B can also be written in vector form as a multiplication between a square matrix \(\varvec{M}\) and the vector \(\varvec{a}\) as follows:

$$\begin{aligned} \underbrace{\begin{bmatrix}c_0 \\ c_1 \\ c_2 \\ \vdots \\ \end{bmatrix}}_{=\,\varvec{c}} = \varvec{M} \underbrace{\begin{bmatrix}a_0 \\ a_1 \\ a_2 \\ \vdots \end{bmatrix}}_{=\,\varvec{a}},~\text {where}~M(k,i) = \frac{1}{\langle \Phi _k, \Phi _k \rangle } \sum \limits _{j{=}0}^{\infty } b_j \langle \Phi _i \Phi _j, \Phi _k \rangle . \end{aligned}$$
(18)

Consequently, by defining the division of gPC variables A and B as a multiplication \(C = A \cdot B^{{-}1}\), the following applies (Milton et al. 2022):

$$\begin{aligned} \varvec{c} = \varvec{M}^{{-}1} \varvec{a}. \end{aligned}$$
(19)

Step 3 of the method: imposition of supplementary constraints on gPC variables

A change in the expansion coefficients of a gPC variable corresponds to a change in the magnitudes of the gPC variable’s statistical moments. Because statistical moments can be expressed in closed form with gPC (Ni et al. 2017), it becomes hence possible to explicitly constrain the statistical moments of stochastic gPC variables, but without presupposing the matching to a predefined PDF. Supplementary information that may exist during model execution therefore makes it possible to impose numerical limits on the lower and/or upper bounds of user-defined statistical moments of gPC variables. Important quantities are typically the expected value \(\mu\) and variance \(\sigma ^2\), which have the following relations to the expansion coefficients \(a_i\) of their underlying gPC variable \(X_{P}\) (Eldred 2009; Ni et al. 2017):

$$\begin{aligned} \mu (X_{P})= E\left[ X_P\right] = E\left[ \sum \limits _{i{=}0}^{P{-}1} a_i \Phi _i(\xi )\right] = \sum \limits _{i{=}0}^{P{-}1} a_i E\left[ \Phi _i(\xi )\right] = a_0 \underbrace{E\left[ \Phi _0(\xi )\right] }_{=1} + \sum \limits _{i{=}1}^{P{-}1} a_i \underbrace{E\left[ \Phi _i(\xi )\right] }_{=0} = a_0, \end{aligned}$$
(20)

and

$$\begin{aligned} Var\left( X_{P}\right)= \sigma ^2(X_{P}) = E\left[ X_{P}^2\right] -E\left[ X_{P}\right] ^2 = E\left[ \sum \limits _{i{=}0}^{P{-}1} a_i \Phi _i(\xi )\right] ^2 - a_0^2 = E\left[ \sum \limits _{i{=}0}^{P{-}1}\sum \limits _{j{=}0}^{P{-}1} a_i a_j \Phi _i(\xi ) \Phi _j(\xi )\right] - a_0^2 = \left( \sum \limits _{i{=}0}^{P{-}1}\sum \limits _{j{=}0}^{P{-}1} a_i a_j E\left[ \Phi _i(\xi ) \Phi _j(\xi )\right] \right) - a_0^2 \overset{\text {(8)}}{=} \left( \sum \limits _{i{=}0}^{P{-}1}\sum \limits _{j{=}0}^{P{-}1} a_i a_j \langle \Phi _i, \Phi _j \rangle \right) - a_0^2 \overset{\text {(7)}}{=} \left( \sum \limits _{i{=}0}^{P{-}1} a_i a_i \langle \Phi _i, \Phi _i \rangle \right) - a_0^2 \sum \limits _{i{=}1}^{P{-}1} a_i^2 \langle \Phi _i, \Phi _i \rangle . \end{aligned}$$
(21)

Consequently, a quadratic least-squares optimization problem can be formulated, which substitutes in a model or simulation a given gPC variable \(X_{P}\) with a surrogate gPC variable \(\hat{X}_{P}\). This surrogate variable shares the same orthogonal polynomial base of \(X_P\), and its expansion coefficients \(\hat{a}_i\) are adjusted to closely match those of \(X_P\), but it also considers any supplementary equality or inequality constraints that may be present during model execution. The least-squares problem can be written as follows:

$$\begin{aligned}{} & {} min\ \sum _{i{=}0}^{P{-}1} \left( \hat{a}_i-a_i\right) ^2\nonumber \\{} & {} \quad s.t.\ X_{P} = \sum \limits _{i{=}0}^{P{-}1} a_i \Phi _i(\xi ),\quad \quad \hat{X}_{P} = \sum \limits _{i{=}0}^{P{-}1} \hat{a}_i \Phi _i(\xi ),\nonumber \\{} & {} g_j(\hat{a}_i) \le 0,\quad \quad h_k(\hat{a}_i) = 0, \end{aligned}$$
(22)

where function \(g_j\) denotes the jth additional inequality constraint and function \(h_k\) denotes the kth additional equality constraint on the expansion coefficients of surrogate gPC variable \(\hat{X}_{P}\).

Sensitivity analysis

Sensitivity analysis is a crucial tool in understanding how the uncertainty in the input parameters of a model affects its outputs. Among various methods for sensitivity analysis, cf. work (Ginocchi et al. 2021), variance-based global sensitivity approaches and in particular so-called Sobol indices, are widely recognized for their ability to decompose the output variance of a model into contributions from individual model inputs and their interactions. In this context, gPC offers a straightforward way to perform sensitivity analysis by representing the model outputs as a series of orthogonal polynomials of the input random variables. In the following, we shortly review the approach for using gPC for variance-based global sensitivity analysis, focusing on the computation of the first-order and total-order sensitivity indices directly from gPC expansion coefficients without any need of sampling. For a more detailed review of sensitivity analysis and gPC-based sensitivity calculations, we refer the interested reader directly to Ginocchi et al. (2021), Haro Sandoval et al. (2012).

First-order sensitivity index

With reference to (1), consider a generic stochastic model \(Y = g(X_1, X_2, \ldots , X_n)\) (or the corresponding stochastic inverse model), where the inputs \(X_1, X_2, \ldots , X_n\) and the output Y are random variables with known PDF. Based on (11), this implies that Y can be represented as a gPC expansion as

$$\begin{aligned} Y = \sum \limits _{i{=}0}^{\infty } a_i \Phi _i(X_1, X_2, \ldots , X_n). \end{aligned}$$
(23)

The first-order sensitivity index \(S_j\) for an input variable \(X_j\) quantifies the portion of the total variance in the output Y that can be attributed solely to input \(X_j\), where \(j=1,\ldots ,n\). It is a measure of how much the uncertainty in \(X_j\) affects the uncertainty in Y, independently of the other input variables. Mathematically, the first-order Sobol index \(S_j\) is defined as Ginocchi et al. (2021):

$$\begin{aligned} S_j = \frac{Var\left( E\left[ Y|X_j\right] \right) }{Var\left( Y\right) }, \end{aligned}$$
(24)

where \(E\left[ Y|X_j\right]\) is the conditional expectation of Y given \(X_j\), and \(Var\left( Y\right)\) is the total variance of Y.

For the calculation of this first-order Sobol index using gPC, the objective is to identify the set of indices \(I_j\) for the orthogonal polynomials \(\Phi _i\) in (23) that depend solely on \(X_j\). This set of indices excludes any terms that involve interactions with other input variables. Using an object-oriented implementation approach of the gPC theory, such as in tool (2023), the identification of the set \(I_j\) is a simple process by iterating over all gPC variables and checking for their dependency on \(X_j\). Once the set \(I_j\) has been successfully identified, the first-order Sobol index can be calculated as follows (Haro Sandoval et al. 2012):

$$\begin{aligned} \tilde{S}_j = \frac{\sum \limits _{i \in I_j} a_i^2 \langle \Phi _i(X_j), \Phi _i(X_j) \rangle }{\sum \limits _{i{=}1}^{P{-}1} a_i^2 \langle \Phi _i, \Phi _i \rangle }. \end{aligned}$$
(25)

This ratio provides the fraction of the total variance in output Y that is attributable to input \(X_j\) alone.

It should be remarked that, very similar to the mapping of (24) to (25), it is also possible to define sensitivity indices of order greater than one using gPC. The calculation in (25) remains similar and basically only the set \(I_j\) must be redefined.

Total-order sensitivity index

With reference to (1), again consider a generic stochastic model \(Y = g(X_1, X_2, \ldots , X_n)\) (or the corresponding stochastic inverse model), where the inputs \(X_1, X_2, \ldots , X_n\) and the output Y are random variables with known PDF. Based on (11), this implies that Y can be represented as a gPC expansion as

$$\begin{aligned} Y = \sum \limits _{i{=}0}^{\infty } a_i \Phi _i(X_1, X_2, \ldots , X_n). \end{aligned}$$
(26)

Unlike the first-order sensitivity index, the total-order sensitivity index \(S_{T_j}\) quantifies the total contribution of input variable \(X_j\) to the variance of the output Y, including all interaction effects with other input variables. The total-order sensitivity index is defined as follows (Ginocchi et al. 2021):

$$\begin{aligned} S_{T_j} = 1 - \frac{Var_{X_j}\left( E\left[ Y|X_j\right] \right) }{Var\left( Y\right) }, \end{aligned}$$
(27)

where \(Var_{X_j}\left( E\left[ Y|X_j\right] \right)\) denotes the variance reduction that would be obtained, on average, if all inputs but \(X_j\) could be determined and fixed at their ‘true’ values.

For the calculation of this total-order Sobol index using gPC, the objective is thus to identify the set of indices \(I_{T_j}\) for the orthogonal polynomials \(\Phi _i\) in (26) that involve \(X_j\), either alone or in interaction with other inputs. In other words, \(I_{T_j}\) includes all terms that have \(X_j\) as part of their argument. Again, the identification of the set of indices \(I_{T_j}\) is a simple process using an object-oriented implementation approach for gPC theory. Once the set \(I_{T_j}\) has been successfully identified, the total-order Sobol index can be calculated as follows (Haro Sandoval et al. 2012):

$$\begin{aligned} \tilde{S}_{T_j} = \frac{\sum \limits _{i \in I_{T_j}} a_i^2 \langle \Phi _i(X_j), \Phi _i(X_j) \rangle }{\sum \limits _{i{=}1}^{P{-}1} a_i^2 \langle \Phi _i, \Phi _i \rangle }. \end{aligned}$$
(28)

This ratio provides the fraction of the total variance in output Y that is attributable to input \(X_j\) as well as all its interaction effects with inputs \(X_i\), \(i \ne j\).

Results and discussion – proof-of-concept tests

In this section, we present two exemplary proof-of-concept tests in energy system design to demonstrate the validity and effectiveness of the proposed method. Drawing inspiration from current research projects on the improved planning and operation of MES, such as from TransUrban.NRW,Footnote 2 (2024), our objectives are i) to perform uncertainty quantification for components of MES and ii) to conduct sensitivity analysis to understand how such sources of uncertainty impact the overall MES behavior. It is important to note that the purpose of these test cases is to showcase the capability of the proposed method rather than to provide specific guidelines or considerations for the optimal design of a real MES. This is beyond the scope of the present paper but is linked to future work that aims at applying the proposed method to real MES application scenarios.

As a reference MES model for the two test cases, we consider a section of an urban district. The MES consists of three office buildings B1, B2, and B3 supplied by a Low-Temperature District Heating (LTDH) network and a Low-Voltage (LV) electrical grid, as shown in Fig. 2. For the sake of simplicity, we assume that all three office buildings are identical in construction type, physical behavior, and energy needs and that the distance L between the office buildings and the substations is constant. Each office building is equipped with an electro-thermal water-to-water heat pump unit connected to the LTDH network, operating at a constant coefficient of performance (COP) of 5, a PV unit installation with a peak power of 15 kW, and a stationary battery storage unit with an energy capacity of 10 kWh and rated charging/discharging powers of 10 kW. Additionally, we assume that all office buildings possess an inflexible electrical load demand and a flexible thermal space heating demand. The latter depends on the thermal comfort specifications of the buildings’ occupants on the indoor air temperature.

Fig. 2
figure 2

Models of a the MES reference and b the considered office buildings. The MES reference comprises a LV grid, a LTDH network as well as three office buildings B1, B2, and B3. The three office buildings are identical and all are equipped with a heat pump unit, PV unit, stationary battery storage unit, inflexible electrical load demand, and flexible space heating load demand. The distance between the office buildings and the substations is equal to L

In the first test case in Section Test Case 1: Quantification of the Uncertainty in the Thermal Space Heating Demand of Buildings for Heat Pump Sizing, the goal is to estimate the optimal size of the heat pump units of the office buildings, considering the thermal comfort specifications of the occupants and the outdoor ambient air temperature conditions of a cold winter day, both of which can be uncertain. This design problem is formulated as an inverse problem under uncertainty employing an existing building thermal RC forward model.

In the second test case in Section Test Case 2: sensitivity analysis for MES design, we perform a sensitivity analysis on the reference MES model to assess how the previously determined sizing of the buildings’ heat pump units, along with other uncertain design parameters for the MES, affects the overall operation of the LTDH network and electrical LV grid of the MES. For this purpose, we integrate the buildings’ uncertain space heating demands, which have been determined in the context of the first test case, directly into the second test case.

In the following, the modeling and simulation is performed in MATLAB R2023b (2023) using sequential codeFootnote 3 on a desktop computer equipped with an Intel® XeonTM E3-1275 v2 3.50 Ghz processor (2019) and 32 GB main memory. Moreover, the Gurobi 9.5 optimization solver (2021) is used for solving constrained optimization problems.

Test case 1: quantification of the uncertainty in the thermal space heating demand of buildings for heat pump sizing

The first test case is an extension of previous work (Diekerhof et al. 2019), in which inverse simulation was employed on building thermal RC models to inversely compute space heating power demand profiles for an office building, but without considering uncertainty. Again, the goal is here to reversely determine the thermal space heating power demand for an office building, i.e., in our case for building B1, B2, and B3, using a deterministic RC forward model, but it is now assumed that both the desired output for the building’s indoor air temperature and the outdoor ambient air temperature are subject to uncertainty. The former is attributed to uncertainty in the thermal comfort specifications of the building’s occupants, whereas the latter is attributed to uncertainty in weather forecast. The specific design goal is to determine the building’s maximum thermal peak power demand for sizing the nominal thermal generation of the office building’s heat pump unit, but, in principle, there are versatile engineering applications that could make use of this indirect quantification of the building’s thermal space heating power demand under uncertainty. Examples are the identification of the portion of electrical power consumption attributed to the building’s thermal demand or assessing the building’s overall thermal performance, including the detection of anomalies such as open windows.

Building thermal RC forward model

The considered building thermal RC forward model is a white-box model that describes the transient thermal dynamics of an office building over time. The input to this model is the thermal heating power generation by a heating unit to calculate, under consideration of the building’s thermal properties and the outdoor ambient air temperature conditions, the building’s indoor air temperature. Assumed is that the office building consists of n rooms, where each room represents one single thermal zone according to the second-order prototype model provided by the German guideline VDI 6007 (2015). Similar to Diekerhof et al. (2019), Ni (2015), we add a third capacitance to also capture the indoor air mass and further consider the outdoor ambient air temperature as an additional input to the zone model, see Fig. 3. For the sake of exemplification, it is further assumed that all n rooms of the building behave in accordance with a thermal zone model of identical parameterization according to the component values specified in Table 2.

Table 2 Parameter Values and Parameter Units for the Thermal Zone Model Based on Ni (2015)
Fig. 3
figure 3

Third-order thermal zone model based on Diekerhof et al. (2019), 2015, Ni (2015). \(C_o\), \(C_i\), and \(C_{air}\) denote the capacitance of outer wall, inner wall, and air mass, respectively. \(R_a\), \(R_o\), and \(R_i\) denote the thermal resistance of the outdoor ambient air mass, the outer wall, and the inner wall, respectively. \(R_{co}\) and \(R_{ci}\) denote the thermal convection of the outer and inner wall, respectively. \(T_a\), \(T_{air}\), \(T_o\), and \(T_i\) denote the outdoor ambient air temperature, the indoor air temperature, the outer wall temperature, and the inner wall temperature, respectively. \(\dot{Q}_a\), \(\dot{Q}_{air}\), \(\dot{Q}_o\), and \(\dot{Q}_i\) denote the heat flow rate, i.e., the thermal heating power, for the outdoor ambient air segment, the indoor air segment, the outer wall segment, and the inner wall segment, respectively. Moreover, the third-order thermal zone model’s primary input is the thermal heating power \(\dot{Q}_{h,n}\) per thermal zone, yielding the total thermal power \(\dot{Q}_{h}\) for all n thermal zones, i.e., for all n rooms of the office building

The physical dynamics within thermal RC models are the same compared to electrical RC circuits. Thus, by applying Kirchhoff’s laws, we obtain the following three first-order differential equations:

$$\begin{aligned} \!\frac{\partial T_o}{\partial t} =&\frac{T_a}{R_a \cdot C_o} + \frac{T_{air}}{(R_o{+}R_{co}) \cdot C_o} - \frac{T_o \cdot (R_o{+}R_{co}{+}R_a)}{R_a \cdot (R_o{+}R_{co}) \cdot C_o}, \end{aligned}$$
(29)
$$\begin{aligned} \frac{\partial T_{air}}{\partial t} =&\frac{T_o}{(R_o{+} R_{co}) \cdot C_{air}} + \frac{T_i}{(R_i{+}R_{ci}) \cdot C_{air}}\nonumber \\&- \frac{T_{air} \cdot (R_o{+}R_{co}{+}R_i{+}R_{ci})}{(R_o{+} R_{co}) \cdot (R_i{+}R_{ci}) \cdot C_{air}} + \frac{\dot{Q}_{h,n}}{C_{air}}, \end{aligned}$$
(30)

and

$$\begin{aligned} \frac{\partial T_{i}}{\partial t} = \frac{T_{air}}{(R_i{+}R_{ci}) \cdot C_{air}} - \frac{T_i}{(R_i{+}R_{ci}) \cdot C_{air}}. \end{aligned}$$
(31)

These relations enable the calculation of the indoor air temperature \(T_{air}\), given the thermal heating power \(\dot{Q}_{h} = n \cdot \dot{Q}_{h,n}\) as well as the outdoor temperature \(T_a\) as the inputs to the model.

For the sake of practicality, the set of differential equations in (29)–(31) can be written as the following multiple-input-single-output continuous-time state-space model by defining \(\textbf{x}(t)=[T_o, T_{air}, T_i]^{T}\) as the state vector, \(\textbf{u}(t)=[T_a, \dot{Q}_{h}]^{T}\) as the input vector, and \(y(t)=T_{air}\) as the system output:

$$\begin{aligned} \dot{\textbf{x}}(t)= & {} \textbf{A}\,\textbf{x}(t) + \textbf{B}\,\textbf{u}(t) \nonumber \\ \textbf{y}(t)= & {} \textbf{C}\,\textbf{x}(t) + \textbf{D}\,\textbf{u}(t), \end{aligned}$$
(32)

where the specific entries for the matrices \(\textbf{A}\), \(\textbf{B}\), \(\textbf{C}\) and \(\textbf{D}\) are as follows:

$$\begin{aligned} \textbf{A}&=\begin{bmatrix} \frac{-R_o - R_{co} - R_a}{R_a \, (R_o + R_{co}) \, C_o} &{} \frac{1}{(R_o + R_{co}) \, C_o} &{} 0 \\ \frac{1}{(R_o + R_{co}) \, C_{air}} &{} \frac{-R_o - R_{co} - R_i - R_{ci}}{(R_o + R_{co}) \, (R_i + R_{ci}) \, C_{air}} &{} \frac{1}{(R_i + R_{ci}) \, C_{air}} \\ 0 &{} \frac{1}{(R_i + R_{ci}) \, C_i} &{} \frac{-1}{(R_i + R_{ci}) \, C_i} \end{bmatrix}, \end{aligned}$$
(33)
$$\begin{aligned} \textbf{B}&=\begin{bmatrix} \frac{1}{R_a \, C_o \, n} &{} 0 \\ 0 &{} \frac{1}{C_{air} \, n} \\ 0 &{} 0 \end{bmatrix}, \end{aligned}$$
(34)
$$\begin{aligned} \textbf{C}&=\begin{bmatrix} 0&1&0 \end{bmatrix}, \end{aligned}$$
(35)
$$\begin{aligned} \textbf{D}&=\begin{bmatrix} 0&0 \end{bmatrix}. \end{aligned}$$
(36)

Derivation of the building thermal RC inverse model using inverse simulation

The building thermal RC forward model represented by (32)–(36) dynamically calculates the building’s indoor air temperature \(T_{air}\) for thermal heating power inputs \(\dot{Q}_{h}\) and outdoor ambient air temperature inputs \(T_a\). Using the theory provided in Section Step 1 of the method: inverse simulation, the differentiation-based inverse simulation method is applied to invert this system model. The inverse system model, in turn, enables the calculation of the required thermal heating power input \(\dot{Q}_{h}\) to achieve a desired, i.e., known, indoor air temperature \(T_{air}\) subject to the outdoor ambient air temperature \(T_a\).

Based on (1)–(4), with discretized state vector \(\textbf{x}_k=[T_{o,k}, T_{air,k}, T_{i,k}]^{T}\) and input vector \(\textbf{u}_k=[T_{a,k}, \dot{Q}_{h,k}]^{T}\), the functions \(\mathbf {F_1}\) and \(\mathbf {F_2}\) in the differentiation-based inverse simulation method calculate for the considered thermal RC forward model as follows:

$$\begin{aligned}&\mathbf {F_1}\left( \textbf{x}_k, \textbf{u}_k\right) = \textbf{A}\,\textbf{x}_k + \textbf{B}\,\textbf{u}_k - \frac{1}{\Delta t} \left( \textbf{x}_k - \textbf{x}_{k{-}1} \right) , \end{aligned}$$
(37)
$$\begin{aligned}&\mathbf {F_2}\left( \textbf{x}_k, \textbf{u}_k\right) = \textbf{C}\,\textbf{x}_k - \textbf{y}_{d,k}. \end{aligned}$$
(38)

Moreover, the Jacobian matrix required by the Newthon-Raphson algorithm in (5) calculates as follows:

$$\begin{aligned} {\mathbf{J}} = & \left[ {\begin{array}{*{20}c} {\frac{{\partial {\mathbf{F}}_{{\mathbf{1}}} }}{{\partial T_{{o,k}} }}} & {\frac{{\partial {\mathbf{F}}_{{\mathbf{1}}} }}{{\partial T_{{air,k}} }}} & {\frac{{\partial {\mathbf{F}}_{{\mathbf{1}}} }}{{\partial T_{{i,k}} }}} & {\frac{{\partial {\mathbf{F}}_{{\mathbf{1}}} }}{{\partial T_{{a,k}} }}} & {\frac{{\partial {\mathbf{F}}_{{\mathbf{1}}} }}{{\partial \dot{Q}_{{h,k}} }}} \\ {\frac{{\partial {\mathbf{F}}_{{\mathbf{2}}} }}{{\partial T_{{o,k}} }}} & {\frac{{\partial {\mathbf{F}}_{{\mathbf{2}}} }}{{\partial T_{{air,k}} }}} & {\frac{{\partial {\mathbf{F}}_{{\mathbf{2}}} }}{{\partial T_{{i,k}} }}} & {\frac{{\partial {\mathbf{F}}_{{\mathbf{2}}} }}{{\partial T_{{a,k}} }}} & {\frac{{\partial {\mathbf{F}}_{{\mathbf{2}}} }}{{\partial \dot{Q}_{{h,k}} }}} \\ \end{array} } \right] \\ = & \,\left[ {\begin{array}{*{20}c} {\frac{{ - R_{o} - R_{{co}} - R_{a} }}{{R_{a} {\mkern 1mu} (R_{o} + R_{{co}} ){\mkern 1mu} C_{o} }} - \frac{1}{{\Delta t}}} & {\frac{1}{{(R_{o} + R_{{co}} ){\mkern 1mu} C_{o} }}} & 0 & {\frac{1}{{R_{a} {\mkern 1mu} C_{o} {\mkern 1mu} n}}} & 0 \\ {\frac{1}{{(R_{o} + R_{{co}} ){\mkern 1mu} C_{{air}} }}} & {\frac{{ - R_{o} - R_{{co}} - R_{i} - R_{{ci}} }}{{(R_{o} + R_{{co}} ){\mkern 1mu} (R_{i} + R_{{ci}} ){\mkern 1mu} C_{{air}} }} - \frac{1}{{\Delta t}}} & {\frac{1}{{(R_{i} + R_{{ci}} ){\mkern 1mu} C_{{air}} }}} & 0 & {\frac{1}{{C_{{air}} }}} \\ 0 & {\frac{1}{{(R_{i} + R_{{ci}} ){\mkern 1mu} C_{i} }}} & {\frac{{ - 1}}{{(R_{i} + R_{{ci}} ){\mkern 1mu} C_{i} }} - \frac{1}{{\Delta t}}} & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ \end{array} } \right]. \\ \end{aligned}$$
(39)

Accordingly, the numerical values for \(\textbf{x}_k\) and \(\textbf{u}_k\) can be calculated iteratively via (5) as follows:

$$\begin{aligned} \begin{bmatrix} T_{o,k}^{(m)} \\ T_{air,k}^{(m)} \\ T_{i,k}^{(m)} \\ T_{a,k}^{(m)} \\ \dot{Q}_{h,k}^{(m)}\end{bmatrix} = \begin{bmatrix} T_{o,k}^{(m{-}1)} \\ T_{air,k}^{(m{-}1)} \\ T_{i,k}^{(m{-}1)} \\ T_{a,k}^{(m{-}1)} \\ \dot{Q}_{h,k}^{(m{-}1)}\end{bmatrix} - \textbf{J}^{{-}1} \begin{bmatrix}\mathbf {F_1}\left( \textbf{x}_k, \textbf{u}_k\right) \\ \mathbf {F_2}\left( \textbf{x}_k, \textbf{u}_k\right) \end{bmatrix}, \end{aligned}$$
(40)

until both

$$\begin{aligned} \mathbf {F_1}\left( \textbf{x}_k, \textbf{u}_k\right)< \varepsilon \qquad \text {and} \qquad \mathbf {F_2}\left( \textbf{x}_k, \textbf{u}_k\right) < \varepsilon \end{aligned}$$
(41)

are satisfied for all k. Notice that, because the Jacobian matrix \(\textbf{J}\) in (39) is not square, it becomes necessary to consider its generalized inverse, i.e., the so-called Moore-Penrose pseudoinverse (Penrose 1955). Once the numerical values for all variables \(\textbf{x}_k\) and \(\textbf{u}_k\) are successfully determined, the last component of vector \(\textbf{x}_k\), i.e., the required thermal heating power \(\dot{Q}_{h,k}\), is the solution to the inverse problem.

Deterministic case – test of inverse simulation

In a first purely deterministic test case, we assess the accuracy and performance of the inverse simulation method. The experimental setting involves one of the identical office buildings B1, B2 or B3 comprising \(n{=}20\) rooms, with thermal zone models parameterized with the component values specified in Table 2. For the purpose of system design, i.e., sizing the nominal power of the office building’s heat pump unit, simulated is one cold winter day of 24 h with one-second resolution, i.e., \(\Delta t{=}1\,{\textrm{sec}}\), using weather data for the region of North Rhine-Westphalia, Germany, from (2022). It is assumed that both the building’s thermal RC forward and inverse model, as described in the previous two subsections, are initially in steady state. Moreover, for the Newton–Raphson algorithm in the differentiation-based inverse simulation method, we set \(\varepsilon = 10^{-4}\).

The top plot in Fig. 4 shows the target time series values for the indoor air set temperature \(T_{air,k}\) that we demand in this test case. Furthermore, the bottom plot in Fig. 4 shows the assumed time series values for the outdoor ambient air temperature \(T_{a,k}\). Through the inverse simulation, we obtain the required thermal heating power \(\dot{Q}_{h,k}\), as shown in Fig. 5. This quantity represents the thermal heating power generation that must be provided by the building’s heat pump unit over time to match the desired indoor air temperature specification from Fig. 4. It can be observed that, in correspondence with the desired indoor air set temperature specification and particularly relevant for sizing purposes, the deterministic peak power occurs at 6.30 am with a required thermal heating power generation of approx. 20.9 kW.

Fig. 4
figure 4

Time series values for the indoor air set temperature \(T_{air,k}\) (top plot) and the outdoor ambient air temperature \(T_{a,k}\) (bottom plot). The discrete-time values for both \(T_{air,k}\) and \(T_{a,k}\) have one-second resolution, i.e., \(\Delta t{=}1{\textrm{sec}}\)

Fig. 5
figure 5

Time series values for the required thermal heating power \(\dot{Q}_{h,k}\) obtained by the inverse simulation. The discrete-time values for \(\dot{Q}_{h,k}\) have one-second resolution, i.e., \(\Delta t{=}1\,{\textrm{sec}}\)

Fig. 6
figure 6

Time series values for the indoor air set temperature \(T_{air,k}\) re-obtained by the forward simulation. The discrete-time values for \(T_{air,k}\) have one-second resolution, i.e., \(\Delta t{=}1\,{\textrm{sec}}\)

Moreover, Fig. 6 shows that, when using the calculated thermal heating power \(\dot{Q}_{h,k}\) as an input to the original forward model again, along with the same time series values for the outdoor ambient air temperature, the desired indoor air temperature from Fig. 4 is perfectly reconstructed. This validates the accuracy of the inverse simulation method.

Running the inverse simulation for the entire 24 h time horizon, i.e., for all 86 400 discrete time slots, requires our computational setup a wall clock runtime below 1 sec. This reflects the high computational performance of the differentiation-based inverse simulation method for system inversion.

Building thermal inverse model – substitution of deterministic with gPC variables

To investigate the impact of uncertainty on the given design problem, we now substitute the deterministic inputs \(T_{air,k}\) and \(T_{a,k}\) in the building thermal inverse model with stochastic gPC variables leveraging gPC arithmetic.

Assumed here is that both quantities \(T_{air,k}\) and \(T_{a,k}\) from Fig. 4 are superimposed with uncorrelated additive white Gaussian noise of variance \(\sigma ^2(T_{air,k}) = 1\,{\textrm{K}}\) and \(\sigma ^2(T_{a,k}) = 2\,{\textrm{K}}\), respectively. Employing (11), we express \(T_{air,k}\) and \(T_{a,k}\) as gPC variables for Gaussian distributions on the basis of the Hermite polynomials, cf. Table 1. Based on (13), we further set \(P=3\) as the gPC truncation order for all stochastic variables, and perform the inverse simulation directly in the gPC domain using the tool from (2023).

Consequently, as \(T_{air,k}\) and \(T_{a,k}\) follow Gaussian distributions, this also causes all other dynamic system variables within the inverse building thermal model to become Gaussian. This includes the target quantity \(\dot{Q}_{h,k}\).

Stochastic case – test of the proposed method

In this test case, we evaluate the accuracy and performance of our proposed method by comparing it with traditional MC simulation. The overall workflow process for both approaches is illustrated in Fig. 7. For MC simulation, we evaluate the inverse building thermal model for \(N = 10\,000\) samples of variables \(T_{air,k}\) and \(T_{a,k}\), which proves sufficient for this test case.

Fig. 7
figure 7

Comparison of the workflow process for a MC simulation and b gPC expansion. For the notation and definition of variables, refer to the specifications from Section The proposed method

Fig. 8 shows the thermal heating power \(\dot{Q}_{h,k}\) of the office building obtained through MC simulation. The black curve represents the expected value, while the grey curves indicate the minimum and maximum deviations from the expected value due to the propagation of the uncertainty in the inverse model’s inputs toward the model outputs. Similarly, Fig. 9 visualizes the thermal heating power \(\dot{Q}_{h,k}\) of the building obtained by the proposed method based on gPC expansion. The curves in Fig. 9 result from analytically computing the expected value as well as the minimum and maximum deviations from the expected value for gPC variable \(\dot{Q}_{h,k}\). Since \(\dot{Q}_{h,k}\) represents a Gaussian PDF, we thereby define the minimum and maximum deviations from the expected value from an engineering standpoint as three times the standard deviation, i.e., according to the ‘three-sigma rule’ (Smith et al. 2009).

A comparison between Fig. 8 and 9 reveals very consistent results, showing the accuracy of the gPC approach. This is further validated through a numerical assessment of the Root Mean Square Error (RMSE) between MC simulation and gPC expansion for the time series of expected value \(E[\dot{Q}_{h,k}]\) and standard deviation \(\sigma (\dot{Q}_{h,k})\) of the stochastic thermal heating power quantity. The RMSE value yields a small difference of \(11.46\,{\textrm{W}}\) for the expected value and the difference in standard deviation is only \(71.97\,{\textrm{W}}\).

Moreover, in comparison to the deterministic case, it can be found that the peak heating power demand still occurs at 6.30 am, but with a worst-case thermal heating power demand of approx. 24.0 kW. This additional worst-case power peak of almost 3.1 kW is a direct consequence of the stochastic nature of the problem, demanding for consideration in the heat pump unit’s sizing process.

Fig. 8
figure 8

MC simulation – expected value and minimum/maximum deviations from the expected value for the required thermal heating power \(\dot{Q}_{h,k}\) over time due to propagation of uncertainty in the model inputs. The discrete-time values for \(\dot{Q}_{h,k}\) have one-second resolution, i.e., \(\Delta t{=}1\,{\textrm{sec}}\)

Fig. 9
figure 9

gPC expansion – expected value and minimum/maximum deviations from the expected value for the required thermal heating power \(\dot{Q}_{h,k}\) over time due to propagation of uncertainty in the model inputs. The discrete-time values for \(\dot{Q}_{h,k}\) have one-second resolution, i.e., \(\Delta t{=}1\,{\textrm{sec}}\)

Furthermore, from a computational performance point of view, the gPC approach demonstrates superior efficiency compared to MC simulation. In gPC domain, the execution of the inverse model requires a runtime of approx. 1 169 sec, while MC simulation takes 6 724 sec. Considering that the MC simulation’s runtime per iteration is 0.67 sec on average, the gPC approach proves more efficient in this particular test case. The break-even point is located at around \(N = 1 \, 750\) samples for MC simulation. It should be recalled, however, that this computational advantage is lost due to the curse of dimensionality as soon as the number of independent stochastic inputs would increase here. Still, a general drawback of sampling lies in the increased need for storing large simulation/results data sets, further underscoring the computational advantage offered by the gPC approach in uncertainty analysis applications necessitating a substantial number of samples.

Stochastic inverse model – imposition of constraints on gPC variables

Employing the gPC approach, we finally examine the impact of imposing additional, user-defined boundary conditions on the stochastic inverse model. We again consider the test case described in Section Building thermal inverse model – substitution of deterministic with gPC variables, but additionally enforce a constraint on the maximum variance of the building’s outer wall temperature \(T_{o,k}\). Specifically, we define a numerical limit of \(\sigma ^2(T_{o,k}) = 0.25\,{\textrm{K}}\) for all discrete time slots k, reflecting a predetermined threshold. This threshold is motivated, for example, by a-priori knowledge about the office building’s geometry and external influences/disturbances (e.g., such as solar irradiation) during the system design phase.

Building on the least-squares optimization problem formulation in (22) as well as on the closed form variance definition in (21), we hence substitute gPC variable \(T_{o,k}\) with surrogate gPC variable \(\hat{T}_{o,k}\), and introduce a supplementary inequality condition on \(\hat{T}_{o,k}\) during the execution of the stochastic inverse model as follows:

$$\begin{aligned}{} & {} 0 \le g(\hat{a}_i) = \sigma ^2(\hat{T}_{o,k}) = \underbrace{\sqrt{2\pi }}_{=\langle \Phi _1, \Phi _1 \rangle }\left( \hat{a}_1\right) ^2 + \underbrace{2\sqrt{2\pi }}_{=\langle \Phi _2, \Phi _2 \rangle } \left( \hat{a}_2\right) ^2 \le 0.25\,{\textrm{K}},\nonumber \\{} & {} \quad \text {where}~\hat{T}_{o,k} = \sum \limits _{i{=}0}^{P{-}1} \hat{a}_i \Phi _i(\xi ). \end{aligned}$$
(42)

It is important to emphasize that the imposition of constraints on statistical moments of an internal stochastic model variable poses challenges when applying purely sampling-based methods such as MC simulation. This challenge arises from the necessity to rigorously modify the model to adhere to the supplementary constraint. Thus, the limitations of MC simulation become apparent when explicitly considering constraints such as in (42), making analytical methods such as the gPC approach favored for addressing such nuanced modeling requirements. Nevertheless, it is worth noting that this advantage comes at the expense of an increased runtime for conducting the gPC domain simulation, because of the rather expensive computational cost of solving a least-squares optimization problem for all time steps k. In our case, the overall runtime for the execution of the stochastic inverse model increases by a severe factor of almost twelve compared to the previous scenario without the integration of the additional constraint.

Stochastic case with imposed constraints – test of the proposed method

In the following, we denote the required thermal heating power that integrates the effect of the additional constraint according to (42) as \(\dot{Q}_{h,k}^{'}\). The time series values for \(\dot{Q}_{h,k}^{'}\), as shown in Fig. 10, thereby illustrate the impact of the supplementary constraint \(g(\hat{a}_i)\) on the overall behavior of the inverse system.

In this context, a qualitative comparison with Fig. 9 reveals the following: the expected value for \(\dot{Q}_{h,k}^{'}\) remains the same compared to \(\dot{Q}_{h,k}\), while the minimum and maximum deviations from the expected value of \(\dot{Q}_{h,k}^{'}\) increase compared to the scenario without the supplementary constraint. The latter also implies that, at 6.30 am, the worst-case thermal heating power peak increases to \(27.0\,{\textrm{kW}}\), demanding for further consideration in the heat pump unit’s design process. This growth in the deviations from the expected value can be explained on the basis of differential equation (30), in which the uncertainty on \(T_{air,k}\) can be understood as a function/summation of system variables \(T_{o,k}\), \(T_{i,k}\), and \(\dot{Q}_{h,k}\). Since \(\sigma _{}^2(T_{o,k})\) has been explicitly bounded, this inherently leads to an increase in both \(\sigma _{}^2(T_{i,k})\) and \(\sigma _{}^2(\dot{Q}_{h,k})\).

Fig. 11 serves as an illustrative representation of this circumstance by offering a histogram for \(\dot{Q}_{h,k}^{'}\) at 6.30 am. In Fig. 11, the gray histogram visualizes the PDF of \(\dot{Q}_{h,k}^{'}\), accounting for the supplementary constraint. Vice versa, the black histogram illustrates the PDF of variable \(\dot{Q}_{h,k}\) when the supplementary constraint is not considered. A key observation from the two histograms is the approximate quadruplication of the variance \(\sigma ^2(\dot{Q}_{h,k}^{'})\) when incorporating the supplementary constraint. This leads to the ‘stretched’ spread of the underlying PDF, causing the increased minimum and maximum deviations from the expected value of \(\dot{Q}_{h,k}^{'}\) for all time steps k.

In conclusion, it can therefore be stated that the office building’s heat pump unit must be designed for a thermal space heating load of at least \(27.0\,{\textrm{kW}}\) in order to meet the thermal comfort specifications of the occupants even in the worst-case scenario. In contrast, a purely deterministic design process according to section Section Deterministic case – test of inverse simulation would have led to a thermal space heating load of only \(20.9\,{\textrm{kW}}\), which would possibly have resulted in an undersizing of the building’s heat pump unit.

Fig. 10
figure 10

gPC expansion with imposed constraints – expected value and minimum/maximum deviations from the expected value for the required thermal heating power \(\dot{Q}_{h,k}^{'}\) over time due to propagation of uncertainty in the model inputs. The discrete-time values for \(\dot{Q}_{h,k}^{'}\) have one-second resolution, i.e., \(\Delta t{=}1\,{\textrm{sec}}\)

Fig. 11
figure 11

Histograms for \(\dot{Q}_{h,k}\) and \(\dot{Q}_{h,k}^{'}\) at time 6.30 am. The gray histogram shows the PDF of \(\dot{Q}_{h,k}^{'}\) that accounts for the supplementary constraint. The black histogram shows the PDF of variable \(\dot{Q}_{h,k}\) that does not account for the supplementary constraint. Both histograms have been obtained by resampling gPC variables \(\dot{Q}_{h,k}\) and \(\dot{Q}_{h,k}^{'}\) from their analytical PDF representations in the gPC domain

Test case 2: sensitivity analysis for MES design

Leveraging the optimal sizing of the office buildings’ heat pump units determined in the previous test case through the application of the proposed method, the objective of this second test case is to conduct a sensitivity analysis for the reference MES introduced at the beginning of this section. The analysis aims at identifying how the uncertainty in the thermal space heating power demands of the office buildings, together with other uncertain design parameters, affects the physical operation of the LTDH network and the electrical LV grid of the reference MES during winter. For the sake of exemplification, we will focus the analysis on the sensitivity of the LTDH network’s pipe pressure and the electrical grid’s voltage at the connection points of office building B3.

The rationale behind this test case is the assumption that the sensitivity analysis is applied to prioritize investments during the early stages of MES design. We therefore consider an existing, preliminary MES design configuration, specified by the key parameters in Table 3. In this context, the parameters for both the LTDH network and the electrical LV grid have been slightly adjusted from a realistic scenario to reproduce the impact of a larger system setup on the electrical grid and heating network.

Table 3 Key Parameter Specifications for the Preliminary MES Design Configuration

To evaluate the physical quantities of interest for the LTDH network and the electrical LV grid, i.e., the pressure and voltage at the connection point of building B3, we perform state-of-the-art steady-state electrical power flow and thermal flow calculations as described in work (Liu and Mancarella 2016). Moreover, the electrical load demand of the office buildings is derived from time series data provided by (2017). For the space heating load demand of the office buildings, we integrate the uncertain thermal heating power demand \(\dot{Q}_{h,k}^{'}\) according to Fig. 10, which has been determined in the first test case using the proposed method. PV generation data is obtained from (2024). Consistent with the first test case, we again consider a cold winter day, using weather data for the region of North Rhine-Westphalia from (2022). Because PV generation is inherently low during winter days in Germany, we assess the operation conditions of the MES at noontime (12 pm) to capture the effect of maximum PV generation. However, in a real scenario, it would be essential to study the system’s behavior across various operating points throughout the year. Furthermore, for the office buildings’ stationary battery storage units, we assume a simple rule-based control approach designed to maximize the self-consumption of PV generation.

Sensitivity analysis – pipe pressure of the LTDH network

At first, we focus on the LTDH network and examine how the uncertain thermal heating demand \(\dot{Q}_{h,k}^{'}\) of office buildings B1, B2, and B3, as well as variations in the diameter and insulation thickness of the LTDH pipes, impact the pipe pressure at the connection point of building B3. These five uncertain parameters are considered the uncertain inputs to the LTDH network part of the MES reference model, while the grid pressure at the connection point of building B3 is the target quantity of interest within the set of model outputs. Based on the theory presented in Section Sensitivity analysis, we calculate the total-order sensitivity index \(\tilde{S}_{T_j}\), defined in (28), for all five inputs directly in the gPC domain.

For this purpose, we assume that both the diameter and insulation thickness of the LTDH network follow Gaussian distributions with a 5 % standard deviation of their expected values, i.e., of their nominal values of \(D=0.25\,{\textrm{m}}\) and \(\delta _{ins}=0.2\,{\textrm{m}}\), respectively, cf. Table 3. Accordingly, we define D and \(\delta _{ins}\) as gPC variables for Gaussian distributions on the basis of the Hermite polynomials. While this is a reasonable approach from a mathematical and analytical perspective, in a real-world scenario, other factors should be considered. A more practical approach would involve performing sensitivity analysis by defining the input variances based on equal investment. However, this is beyond the scope of this paper and would be very specific to the scenario considered.

The results of the sensitivity analysis are shown in Fig. 12. The cake diagram illustrates how the five different uncertain inputs contribute to the variability in the pipe pressure at the connection point of office building B3 at 12 pm. The percentage values thereby correspond to the obtained total-order sensitivity indices.

The sensitivity analysis confirms theoretical expectations (Liu and Mancarella 2016): the primary factor affecting pipe pressure is the diameter of the pipes, followed by the local mass flows. Mass flow is strongly connected to the space heating load of the individual buildings, which is mapped to the building’s thermal demand on the LTDH network through the heat pump units. The effect of the uncertainty in the office buildings’ desired indoor air temperature profiles on the operation of the LTDH network is thus reflected here. The insulation thickness, on the other hand, has almost no impact on the pipe pressure.

Fig. 12
figure 12

Sensitivity of the LTDH network’s pipe pressure at the connection point of building B3 at time 12 pm. The percentage values correspond to the obtained total-order sensitivity indices according to (28)

Fig. 13
figure 13

Histogram for the pipe pressure at the connection point of building B3 at time 12 pm. The histogram has been obtained by resampling the gPC variable of the pipe pressure from its analytical PDF representation in the gPC domain

Still, the histogram in Fig. 13 for the pipe pressure at the connection point of office building B3 indicates that the pressure fluctuates moderately between approx. 2.6 bar and 3 bar, suggesting that the preliminary design specification for the LTDH network may require further investigations.

Sensitivity analysis – voltage of the LV grid

We now focus on the electrical LV grid and examine how the uncertain thermal heating demand \(\dot{Q}_{h,k}^{'}\) of office buildings B1, B2, and B3, as well as the distance L (and therefore the line length) between buildings and the substation within the LV grid impact the voltage at the connection point of building B3. These four uncertain parameters are considered the uncertain inputs to the LV grid part of the MES reference model, while the voltage at the connection point of office building B3 is the target quantity of interest within the set of model outputs. Similar to Section Sensitivity analysis – pipe pressure of the LTDH network, we calculate the total-order sensitivity index \(\tilde{S}_{T_j}\), defined in (28), for all four inputs directly in the gPC domain.

For this purpose, we assume that the LV grid length follows a Gaussian distribution with a 5 % standard deviation of its expected value, i.e., of its nominal value of \(L=150\,{\textrm{m}}\), cf. Table 3. Accordingly, we define L as a gPC variable for Gaussian distributions on the basis of the Hermite polynomials.

The results of the sensitivity analysis are shown in Fig. 14. The cake diagram illustrates how the four different uncertain inputs contribute to the variability in the voltage of the LV grid at the connection point of building B3 at 12 pm. The percentage values thereby correspond to the obtained total-order sensitivity indices.

Also for this test case, the results of the sensitivity analysis confirm theoretical expectations. Since the line length substantially affects the impedance within LV grids, the line length parameter has the most significant impact on the voltage at the connection point of building B3. Additionally, the buildings’ electrical net loads affect the voltage in the LV grid. On a cold winter day, a large portion of this net load is attributed to the electrical demand of the buildings’ heat pump units, which, in turn, depends on the required thermal heating power demand for space heating and the uncertainty in the office buildings’ desired indoor air temperature profiles.

Nevertheless, the histogram in Fig. 15 for the voltage at the connection point of office building B3 indicates that the deviation from the reference voltage \(V_{ref}=400\,{\textrm{V}}\) of the LV grid is rather small, suggesting that the preliminary design specification for the LV grid is adequate.

Fig. 14
figure 14

Sensitivity of the LV grid’s voltage at the connection point of building B3 at time 12 pm. The percentage values correspond to the obtained total-order sensitivity indices according to (28)

Fig. 15
figure 15

Histogram for the voltage at the connection point of building B3 at time 12 pm. The histogram has been obtained by resampling the gPC variable of the voltage from its analytical PDF representation in the gPC domain

Conclusion

This work shows that the combination of inverse simulation and gPC theory results in an accurate and effective method for the direct and analytical solution of inverse problems under uncertainty, particularly in energy system design. The method’s application goes beyond the straightforward calculation of stochastic inverse problems, enabling i) direct solutions through inverse simulation and ii) the representation of stochastic variables in a model or system as gPC expansion variables. The latter provides the user with a complete analytical representation of a stochastic variable’s PDF, whose statistical moments can be explicitly bounded or constrained during the solution process to the stochastic inverse problem.

In essence, the method serves as a meaningful and user-friendly tool for analyzing complex systems in the presence of uncertainty that require computationally demanding simulations. When dealing with a low number of stochastic variables, this method offers significant computational advantages over traditional sampling-based methods, thereby facilitating rapid and effective design decision-making under uncertainty. Moreover, it streamlines the entire design process and ensures coherent modeling throughout.

This research exemplifies this capability through focused MES design applications. By quantifying the uncertainty in thermal space heating demand for office buildings in the context of heat pump sizing, the proposed method demonstrates how uncertainty in desired system outputs propagates through an inverse system to the target design parameters. Furthermore, this research showcases the method’s ability to facilitate sensitivity analysis, as exemplified by examining the sensitivity of design parameters for a reference MES.

However, it is important to recognize the proposed method as a first starting point for further exploration. The current gPC approach is limited by execution speed when dealing with systems involving numerous independent stochastic variables, because of the adverse effects of the so-called curse of dimensionality. Integrating sparse gPC approaches could mitigate this issue. Although the proposed method allows for imposing additional constraints on gPC variables, its underlying optimization-based approach is computationally intensive and can further hinder execution speed. Therefore, it should be used with care. In addition, both the gPC approach and the differentiation-based method of inverse simulation require users to have complete knowledge about the equations of the system or model under investigation. Future research should thus extend the method to include black-box approaches, such as feedback-based inverse simulation methods and non-intrusive gPC approaches.

Ultimately, future work should also apply the method to real-world inverse design problems across various engineering disciplines, thoroughly comparing its performance with conventional (sampling-based) methods to identify and study the method’s potential benefits, challenges, and limitations in greater detail. In this context, future work should in particular answer the question of how the proposed method might handle imposed constraints in more practical, real-world scenarios together with the potential modeling challenges involved.

Availability of data and materials

The datasets used and/or analysed during the current study are available from the corresponding author on reasonable request.

Notes

  1. Remark on the notation: the bold-type variables \(\textbf{x}(t)\), \(\textbf{u}(t)\), and \(\textbf{y}(t)\) represent vectors indicating multiple elements for the state, input, and output of the system respectively, with (t) denoting their dependence on continuous time, while the functions \(\textbf{f}\) and \(\textbf{g}\) describe the system dynamics and the relationship between the multiple state and output elements through differential and algebraic equations.

  2. Research project TransUrban.NRW publicly funded by the German Federal Ministry for Economic Affairs and Climate Action under promotional reference 03EWR020E, aims at demonstrating how traditional district heating systems can be transitioned into low-carbon energy supply systems through the implementation of modern low-temperature district heating and cooling networks. The project also explores new system planning and design approaches, business models as well as regulatory frameworks to enable a sustainable and economically viable transition to sector-coupled MES.

  3. In this research, we do not take advantage of code parallelization for reasons of fairness in the following analyses and evaluations. However, it should be remarked that both sampling-based methods and gPC can realize substantial computational benefits through code parallelization. In the case of sampling-based methods, parallelization can be applied to the model evaluation process itself. Similarly, for gPC, parallelization can significantly accelerate the arithmetic procedures described in Section gPC arithmetic.

Abbreviations

gPC:

Generalized Polynomial Chaos

LTDH:

Low-Temperature District Heating

LV:

Low-Voltage

MC:

Monte Carlo

MES:

Multi-Energy System

PV:

Photovoltaic

PDF:

Probability Density Function

RMSE:

Root Mean Square Error

References

Download references

Funding

Open Access funding enabled and organized by Projekt DEAL. Open access funding provided by the Open Access Publishing Fund of RWTH Aachen University.

Author information

Authors and Affiliations

Authors

Contributions

All authors were major contributors in formulating and formalizing the proposed method and jointly conducted the proof-of-concept study. Sebastian Schwarz and Daniele Carta were major contributors in processing the results and in writing the manuscript. Sebastian Schwarz prepared figures 1-15. Antonello Monti and Andrea Benigni edited and approved the final manuscript.

Corresponding author

Correspondence to Sebastian Schwarz.

Ethics declarations

Ethics approval and consent to participate

Not applicable.

Consent for publications

Not applicable.

Competing interests

The authors declare that they have no Competing interests.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Schwarz, S., Carta, D., Monti, A. et al. A direct and analytical method for inverse problems under uncertainty in energy system design: combining inverse simulation and Polynomial Chaos theory. Energy Inform 7, 55 (2024). https://doi.org/10.1186/s42162-024-00360-0

Download citation

  • Received:

  • Accepted:

  • Published:

  • DOI: https://doi.org/10.1186/s42162-024-00360-0

Keywords