Mapping demand flexibility: A spatio-temporal assessment of flexibility needs, opportunities and response potential

Demand flexibility is needed to manage the challenges of decarbonising the heating and transport sectors and integrating large shares of intermittent renewable generation. While existing literature has provided models for estimating the response potential of some flexible devices, they have not been applied to assess if the response in a location is sufficient to solve the grid issue. Grid issues such as constraint and congestions are geographical issues and hence can be studied through GIS analysis. This paper presents a methodology for the spatio-temporal assessment of demand flexibility opportunities, response potential and adequacy in solving various grid issues of a country. We provide a method that may be used to link the electrical network with socio-demographic spatial data when the low voltage network data is not available using the k-nearest neighbour classification algorithm. The proposed method was able to match neighbourhoods with their primary substation with an accuracy of 60–94%. By segmenting neighbourhoods based on various metrics, we perform a left-behind analysis to identify vulnerable consumer groups at risk of being left behind in the energy transition and propose a flexibility prioritisation model that ensures a fair distribution of flexibility opportunities across all locations. Finally, we present the Northern Ireland demand flexibility map, an interactive tool for use by system planners to help in developing an effective flexibility strategy as well as a flexibility implementation pathway for Northern Ireland.

• Flexibility opportunities and response potential is assessed across space and time.
• A demand flexibility adequacy assessment framework is proposed for various services.
• A method for coupling an electrical network with socio-demographic data is proposed.
• A framework to identify and prioritise potentially left-behind groups is proposed.
• Northern Ireland Demand Flexibility Map: A tool for energy system planning.

Keywords:
Flexibility response potential Flexibility adequacy assessment Left-behind analysis Flexibility prioritisation Whole energy system Geographic Information System (GIS)

A B S T R A C T
Demand flexibility is needed to manage the challenges of decarbonising the heating and transport sectors and integrating large shares of intermittent renewable generation. While existing literature has provided models for estimating the response potential of some flexible devices, they have not been applied to assess if the response in a location is sufficient to solve the grid issue. Grid issues such as constraint and congestions are geographical issues and hence can be studied through GIS analysis. This paper presents a methodology for the spatio-temporal assessment of demand flexibility opportunities, response potential and adequacy in solving various grid issues of a country. We provide a method that may be used to link the electrical network with socio-demographic spatial data when the low voltage network data is not available using the k-nearest neighbour classification algorithm. The proposed method was able to match neighbourhoods with their primary substation with an accuracy of 60-94%. By segmenting neighbourhoods based on various metrics, we perform a left-behind analysis to identify vulnerable consumer groups at risk of being left behind in the energy transition and propose a flexibility prioritisation model that ensures a fair distribution of flexibility opportunities across all locations. Finally, we present the Northern Ireland demand flexibility map, an interactive tool for use by system planners to help in developing an effective flexibility strategy as well as a flexibility implementation pathway for Northern Ireland.

Introduction
Buildings are a major source of greenhouse gas (GHG) emissions. They accounted for 38% of global emissions in 2019 [1]. 17% of the global emissions were from residential buildings: 6% from direct emissions and 11% from indirect emissions (i.e. electricity) [1]. Electricity consumption from building operations accounted for almost 55% of global electricity consumption [1]. The energy system is changing due to the decarbonisation of heat and transport. The UK has legislated for a net-zero energy system by 2050 [2], has banned new homes from fossil fuel heating by 2025 [3] and new fossil fuel vehicles by 2030 [4]. The expected increase in electricity demand due to the electrification of heat and transport could lead to congestions in distribution networks. It could also affect energy affordability due to increased investments in network infrastructure.
Demand flexibility is the capacity to shift the time when energy is drawn from or exported to the grid by behind-the-meter resources in response to an external signal (such as electricity price) [5]. This is achieved either by using storage or changing the activity time. In the past, the focus has been to vary supply to match demand. However, the move to clean energy from renewable sources and the challenges posed by the decarbonisation of heat and transport have increased interest in managing demand [6]. These challenges include managing system frequency variation caused by the variable and intermittent nature of wind generation, voltage variation, overloading of network equipment due to the uptake of heat pump and electric vehicles (EV) [7], the risk of excess generation at times of low demand or additional network infrastructure needed to transport wind generation from remote locations [8].
Demand-side flexibility is seen as a low regret option to improve the overall system efficiency, reduce emissions while maintaining system security [9]. Furthermore, activation of demand flexibility is integral to the business case for the uptake of some low carbon technologies [10]. For example, the cost of heat pumps is higher than the current cost of fossil oil or gas heating, hence in literature, the activation of flexibility from heat pump and thermal storage is seen as a major factor when considering their economic viability [11]. Other demand-side resources include solar panels, batteries, electric vehicles, refrigerators and other consumer loads [12].
Article 32 of the Clean Energy Package sets a new requirement on the use of flexibility in distribution networks and its procurement by the system operator [13]. It requires system operators to consider flexibility in grid planning as an alternative to system expansion. It also requires the effective and non-discriminatory participation of all market participants, including allowing market access for domestic consumers. However, without adequate planning, these opportunities might create more unfairness and leave behind vulnerable consumer groups which are not homeowners or have limited access to capital or participatory expertise and allow more affluent groups to reap the benefits of the system.
For policymakers to effectively plan decarbonisation at the national level, they must understand the geospatial relationship of various energy assets and consumer groups [14]. For example, what locations or consumers have the option of gas heating? What areas have excess wind energy? How do flexibility needs and opportunities differ from location to location? How can we estimate the amount of flexibility or response obtainable in a given location? Is the estimated flexibility enough to solve the congestion problem? Where would activating demand flexibility matter most in the system? How do we prioritise flexibility activation in the event of competing resources? Only with a model interaction that takes into account all of the above problems, would they have a chance of developing an energy system that is both fair and efficient.

Literature review
Geographic Information System (GIS) analysis has proved useful in energy system resource assessment [15] and planning [16]. It has been used in demand consumption modelling, building demand estimation [17], district heating planning [18], energy infrastructure planning [19], visual impact assessment [20], linking spatial model of hydrogen supply, demand and infrastructure to energy system model [21] and investigating the effect of solar photovoltaic (PV) siting on grid flexibility needs [22]. GIS tools such as Street View allow developers to zoom into an area to get a brief picture of the kind of houses located there and the possible energy-efficiency measures needed for them to target such customers [23]. This is particularly useful for energy service companies rolling out business models such as heat as a service or energy efficiency as a service [24].
A GIS model for targeting energy efficiency schemes using areabased multidimensional fuel poverty risk indicators was developed in [25]. Using data on the location and scale of household retrofit, the paper explored the limitations of current approaches to targeting and recommended a proactive area-based approach. This targeting algorithm has been particularly useful in calculating the eligibility of neighbourhoods for fuel poverty schemes [25]. While energy efficiency is a vital part of reducing fuel poverty, the role of demand-side flexibility to make use of excess wind energy has been identified in [26].
GIS models, together with models that describe resource availability, could be used to identify areas where distributed generation becomes attractive [27]. Topological characteristics such as proximity, adjacency and connectivity help to find the optimal location and size of flexibility resource [28]. It also helps to locate hotspots on the system where activating flexible demand would yield the most return. For example, certain locations might be able to deliver multiple system services.
Locating flexible demand at strategic points on the network can reduce the amount of flexibility that needs to be transported [29]. GIS is also used by system operators and flexibility markets to signpost locations where flexibility is needed in the system. Examples of such platforms are PicloFlex, Enera, GOPACS and NODES [30]. By geospatial analysis, energy system planners, market designers and policymakers can get an overview of the system, which would allow them to make strategic decisions and develop the right assets at the right location. Such early signposts are required for demand owners or aggregators to develop sufficient demand before it is needed and to ensure the security of flexibility supply [31]. Furthermore, since these flexible resources are consumer-owned, it usually takes longer to acquire, activate, aggregate and test them. This is necessary because the system and network operators would usually not have the same level of control of highly distributed demand assets as they would with traditional generators.
Demand flexibility has been studied both technically (power flow models) and socially in great details. However, there is very little geospatial understanding. The few studies which have attempted to address the geospatial flexibility analysis includes FlexiGIS, which is an opensource platform for optimisation of flexibility options cost and operation in urban areas [32]. However, it is limited to urban system planning and specific to microgeneration and battery storage [33]. It does not consider the flexibility needs of each location, such as the network constraint but assumes flexibility is needed everywhere. Furthermore, it is not easy to use (especially for policy developers without a good background in python programming).
A combined GIS-archetype model was developed in [34] to estimate the space heating requirements at city scale and post-code level. The study in [35] discusses a method to assess the demand-side potentials from Heating, Ventilation, and Air Conditioning (HVAC) for whole cities by analysing its building stock without consideration of the time or locational aspect of flexibility. In [36], GIS was used to map buildings energy performance at multiple scales. The authors in [37] used GIS to assess the effect of deep retrofit on the energy flexibility of building clusters. And finally, in [38], a GIS model was used to assess the impact of controlled electric vehicle charging in a 100% renewable electricity grid.
A review of energy flexibility quantification methodologies for buildings was provided in [39]. The review identified two general approaches, first, by using past data (usually from trials) and assuming specific energy system or market context. In particular, [40] provided typical response values for wet appliances, hot water tanks, EVs, refrigeration, and phantom loads [41]. These values are derived from specific kinds of buildings and technologies under specific control strategies and hence cannot be generalised. In the second approach, some authors have provided generalised models such as the available storage capacity and storage efficiency [42], power shifting capability [43], hourly energy cost (cost curves) [44], the ratio of the maximum change in power to the additional energy used to achieve the change (efficiency curves) [45], the power demand and priority to be supplied (priority curves) [46]. The spatio-temporal implication of such aggregated response potential assessment is not addressed.
Flexibility adequacy assessment models such as in [47] and [48] are all limited to flexibility from centralised supply-side assets (conventional coal, gas and hydro plants). Constraint and congestions are geographical issues and hence can effectively be studied through GIS analysis. To understand how flexibility opportunities are distributed, such spatial approaches are needed to understand the distribution of flexibility needs in order to target the development of demand flexibility resources [49]. While the needs and availability of flexibility is location-specific, there is hardly any literature that establishes a methodology for matching this relationship using geographical techniques. Importantly, to the best of the authors' knowledge, there is no methodology for investigating whether the response potential in a location is sufficient to solve a given grid problem. For example, the response potential of a local network would inform the system operators decision to implement flexibility or utilise other network solutions for relieving congestions.
This limitation is partly due to modelling and computational complexities, the large dataset needed, and the heterogeneous data structures [50], data availability and data privacy issues [51]. Furthermore, a major part of this analysis would involve sector integration and coupling, for example, linking electrical, gas, demographic, heating, and transport data. Existing GIS models are usually fragmented, which reduces the level of intelligence and use. This issue is also specifically mentioned in [52] as a gap in literature that needs to be addressed.
This work fills these two gaps by first providing a methodology for linking social-demographic, housing, heating and transport data with the electrical transmission, distribution and gas network models and hence provides a whole system model to flexibility planning. Secondly, this work provides a methodology for the spatio-temporal assessment of flexibility needs, opportunities, response potentials and adequacy assessment. Furthermore, it provides a framework for the identification of potentially left-behind groups and prioritisation of flexibility to ensure a just energy transition. Finally, we present the Northern Ireland (NI) demand flexibility map, an interactive tool for use by system planners to help in developing an effective flexibility strategy as well as a flexibility implementation pathway for NI.

Geospatial integrated energy systems model
Spatial analysis was conducted using Google Map API V3 as the visualisation engine. The Google Map API uses GeoJSON (An open standard format for encoding geographic features and their non-spatial attributes) [53] as the data format. Spatial data needs a common reference or scope for comparison, filtering, and analysis purposes. Unfortunately, most data are available in different formats and scope, making comparative analysis difficult and inaccurate. Hence it is important to define a common scope and to convert the needed layers to the chosen scope. This further allows the use of mathematical equations and optimisations to solve energy system planning problems. We have chosen the 'small area' (neighbourhood) geography as the reference scope. The small area is the lowest geographic classification in a country. For example, in NI, the average size of each small area is 400 people or 155 households. There are a total of 4537 small areas in NI [54]. Fig. 1 shows an overview of the various geographic layers.

Data collection and processing
Data from various sources were collected, processed, and integrated into various layers within the map. Table 1 presents a summary of the various data sources and their use cases. Census data is one of the primary sources for getting data for various locations. These data are made available at a variety of geographic levels (including the small area). This could be used to formulate the demography, housing and accommodation, heating and transport layers. In addition to census data, countries such as the UK maintain a multiple deprivation rank of neighbourhoods [55], which could be used to formulate the socialeconomic layer. We used the Northern Ireland Multiple Deprivation Measure (NIMDM) [56] for this work. Data for the gas and electrical network can be sourced from the network operators. Grid operators are  increasingly becoming obliged to increase the transparency of energy data and publish information relating to new renewable generation installations [57]. Constraint groups are used to group wind and solar farms with similar effectiveness in reducing the level of a transmission constraint [58]. In cases where data cannot be sourced from the grid operators, an opensource alternative is the OpenStreetMap (OSM) database [59]. OSM data and maps can be obtained and used freely under the Open Database License (ODbL) [32]. OSM data has been used as the main input for modelling electrical networks in open source models such as open_eGO and SciGRID [60]. In [61], the authors provide a comprehensive framework for assessing the quality of OSM dataset and in [32], it was used to model an urban energy system with a high level of accuracy.

Linking small areas with the electrical network
One major limitation in performing geospatial analysis in electrical systems is that visibility usually ends at the primary substation. There is a missing link between the primary substation and the geography of the low voltage network. This is due to the cost and workload of low voltage mapping and modelling. We apply the k-nearest neighbour classification algorithm [69] to solve this problem. We assume that each small area is connected to the closest primary substation. Primary substations are usually located at central locations to the distribution area they serve; this is done to reduce the investments and losses of the lines [70]. Hence the assumption should be valid for most cases. To allocate each small area to a substation, we first determine the centre of each small area (C x , C y ) using the shoelace formula (any other suitable formula may be used) [71] as shown in Eqs. (1)-(3).
where n is the number of vertices of the small area polygon., and A is the area of the polygon. Then we calculate the distance from each small area (x s y s ) to all primary substations (x p y p ), and finally, we select the substation with the closest distance as expressed in Eq. (4).
where n is the number of primary substations and D sp is the distance between the small area and chosen primary substation. The assumption was validated against four primary substations for which we had more detailed information on the low voltage mapping. The accuracy in matching the small areas to their primary substation is presented in Table 2. The accuracy ranges from 60 to 94%. The more central the location of the substation, the higher the accuracy. The accuracy reduces where multiple substations located close together are serving the same town. Furthermore, some small areas may cut across two substations and hence are partly matched. Fig. 2 shows the interaction between the small areas and the electrical, gas network, renewable generation and constraint group layers. An interactive map/tool has been developed for this work. The map provides more visualisation options than could be presented in this paper. Hence, we recommend reading this paper along with the map. The map is publicly available for use at [72].

Dimensions of demand flexibility
Flexibility in energy systems presents itself in three dimensions: Direction, Time and Location [73], as shown in Fig. 3. This can also be described as the What, When and Where of Flexibility.
Direction: There could be a need to turn up demand (TUD). In this case, flexibility is in the positive direction (Upward Flexibility). When there is a need to turn down demand (TDD), flexibility is in the negative direction (Downward Flexibility). Furthermore, certain devices are only able to provide flexibility in one direction (for example, solar panels can provide flexibility in the downward direction). Some may be able to provide better and faster flexibility in one direction over the other.
Time: Flexibility is also analysed at different time scales since both the need for flexibility and its availability experiences both seasonal and diurnal changes [74]. For example, there could be a demand for flexibility in the evenings (4 pm − 7 pm) to manage peak demand. Furthermore, this peak demand may only occur during the winter season.
Location: Flexibility needs and availability also depend on location. Flexibility has both temporal and locational dimensions. The locational need for flexibility is determined by the presence of transmission and distribution constraints [29]. There are areas in the network with low headroom which may need flexibility to delay network investments. There are also certain areas that are experiencing lots of wind energy dispatch-down and need demand increase at certain times. There are other locations where neither of these two issues arises, and hence the provision of flexibility at those locations may not be needed.

Flexibility requirements
The system operator usually sets out their flexibility requirements which usually includes the duration, capacity and ramp, as shown in Fig. 4.
Duration: This refers to the duration for which flexibility is needed or how long the resource can maintain a certain output. In some flexibility market or use cases, the duration of flexibility is often standardised as products. For example, when providing tertiary operating reserves, the duration could be for 15 min. Some technologies may not fit these standardised products with fixed durations.
Capacity: The amount of flexibility a resource can provide. Ramp: How fast can the flexible resource respond to the grid need. For example, heat pumps can be turned down remotely under ten seconds; however, it takes up to ten minutes to turn them up completely [75].

Flexibility availability/response potential
Certain spatial and temporal parameters can be used to estimate the flexibility response potential of a neighbourhood. This information is useful for system operators to investigate the potential, risk, lead time and time frame for demand response solutions. It is also useful for aggregators looking for the best locations to develop their portfolios. In the case of baseload and heat loads, flexibility can be provided by curtailing or increasing load at a given time. This may result in a loss of comfort for consumers. Energy storage can be used to avoid discomfort by maintaining the consumer's demand profile. Our analysis is limited to flexibility from energy storage devices. In Fig. 5, we present a methodology to estimate the response potential of a neighbourhood at any given time of the day and month of the year for both flexibility directions. The process begins by initialising parameters for the selected devices to be investigated. Depending on the selected devices, this would include the charge and discharge rate of the battery (C BAT ), thermal storage (C TES ) and electric vehicle (C EV ); the capacity of the heat pump (C HP ) (in kWh of electricity); the storage capacity of the battery (S BAT ), thermal storage (S TES ) and electric vehicle (S EV ); parking times (PK) of the electric vehicle and the after-diversity average hourly demand profile of the baseload (P B ), heat pump (P HP ), solar PV (P PV ) and electric vehicle (P EV ). The average hourly demand profiles should be computed monthly to account for seasonality. The flexibility in month j and hour t can now be represented as F(j,t). For simplicity, we simply represent it as F(t) in the subsequent mathematical formulations (assuming the row or month has been selected).
If data for the number of each building type (detached, terraced, flat etc.) in a neighbourhood exists, the average hourly demand profile could then be prepared for each building archetype and matched with the number of that building type during computation. The response potential for each device type in any given direction is detailed below.

Response potential of a battery
The upward flexibility capacity of a battery R BAT U (t) at a time t is given by the battery charge rate C BAT and is subject to the SOC (in kWh) of the battery, as presented in Eq. (5). The maximum response duration d BAT U (t) (in hours) for upward flexibility, starting at time t is given by Eq. (6).
The downward flexibility capacity of a battery R BAT D (t) at a time t is given by the minimum between the battery discharge rate C BAT and the baseload demand at that time P B [t] and is subject to the SOC of the battery, as presented in Eq. (7). The maximum response duration d BAT D (t) (in hours) for downward flexibility, starting at time t is given by Eq. (8).

Response potential of a heat pump and thermal storage
The upward flexibility capacity of a heat pump and thermal storage R HP U (t) at a time t is given by the capacity of the heat pump C HP and is subject to the SOC of the thermal storage, as presented in Eq. (9). The maximum response duration d HP U (t) (in hours) for upward flexibility, starting at time t is given by Eq. (10).
The downward flexibility capacity R HP D (t) at a time t, is given by the minimum between the discharge rate of the thermal energy storage C TES and the heat pump demand P hp (in kW) at that time and is subject to the SOC of the thermal storage as presented in Eq. (11). The maximum response duration d HP D (t) (in hours) for downward flexibility, starting at time t is given by Eq. (12).

Response potential of a solar PV
Solar PV can only provide flexibility in the downward direction by exporting excess energy to the grid instead of charging a battery. The downward flexibility capacity R PV D (t) at a time t is given by Eq. (13), where P PV [t] is the power generated by the solar PV at time t and P B[t] is the baseload demand at time t. The maximum response duration d PV D (t) (in hours) for downward flexibility, starting at time t is given by Eq. (14).

Response potential of an Electric Vehicle
The timing of EV charging can be shifted. Furthermore, an EV could be used to provide downward flexibility by powering some baseloads or heat loads using vehicle-to-grid (V2G) technology.
The upward flexibility capacity of an electric vehicle R EV U (t) at a time t is given by the power of the charger C EV and is subject to the SOC of the vehicle battery and the parking times (PK) of the vehicle as presented in Eq. (15). The maximum response duration d EV U (t) (in hours) for upward flexibility, starting at time t is given by Eq. (16).
For V2G applications, the downward flexibility capacity R EV D (t) at a time t, is given by the minimum between the discharge rate of the electric vehicle battery C EV and the house load (baseload and heat load) at that time and is subject to the SOC of the battery as seen in Eq. (17). For EV demand shifting applications, the downward flexibility is the EV demand P EV [t] at that time, as also presented in Eq. (17). The maximum response duration d EV D (t) (in hours) for downward flexibility, starting at a time t, for both V2G and shifting applications, is given by Eq. (18).
The number (N) of each device in the small area will depend on the scenario that is to be investigated. Geospatial data can help in formulating such scenarios. For example, census data gives a good picture of the number of households and building types in a neighbourhood, the distribution of heating and the types of transport available in each neighbourhood. This could be used to understand current flexibility potentials and future prospects (based on future adoption of heat pumps and electric vehicles). The gas network could be used to identify areas with potential uptake of heat pumps, if the strategy is focused on off-gas areas. Depending on the data available, other factors that could be used to formulate the uptake scenarios include the number of rooms, the classification of the neighbourhood (urban/rural) and the number or percentage of south-facing roofs. The total response potential of each small area, R(t), and the net response duration for flexibility starting at a time t, d(t), can then be calculated using Eq. (19) and Eq. (20), respectively. R(t) and d(t) should be computed for both upward and downward direction.
The flexibility density (kW/km 2 ) can be estimated using the area (A) of the small area, as given in Eq. (21). This can be used to compare the response potential of each small area to indicate hotspots irrespective of the size of the small area.

Flexibility opportunity assessment
This section provides a methodology for the spatio-temporal assessment of flexibility opportunities (summarised in Fig. 6). The flexibility opportunities in a small area depend mainly on two factors: the demand headroom of the substation it is connected to and its closeness to renewable generation sources.
Since flexible technologies are often yet to receive widespread adoption, these analyses are usually performed for future scenarios. The number of heat pumps and EVs forecasted for the scenario investigated is represented by N HP and N EV, respectively. The additional demand from these devices can be estimated using the after-diversity maximum demand (ADMD) for the time investigated. The ADMD profile is computed by aggregating N profiles, determining the maximum demand for each hour and dividing it by N to get the average (or diversified) maximum demand profile per device. Example of such profiles derived from field trials can be found in [76], which also presents uptake scenarios of heat pump and EVs for the UK. The ADMD profile can then be scaled by the number of devices estimated for the scenario investigated.
Flexibility opportunities change seasonally and diurnally. For example, congestions may occur between 4 pm and 8 pm and only during the winter months. Hence computations should be performed for individual hours of the day (t) and month of the year (j). Hence the ADMD matrix of j rows (representing the 12 months of the year) and t columns (representing the 24 h of the day) should be computed for both the heat pump and electric vehicle. The additional future demand D F (j,t) can now be computed using Eq. (22). If the investigation is for the current scenario, then D F = 0.
We provide a detailed assessment of three flexibility opportunities.
• Congestion management • Ancillary services • Managing dispatch-down of wind energy

Congestion management
Congestion occurs in MV/LV transformers whenever the transformer loading exceeds its thermal rating. Substations with low demand headroom are prone to congestion, particularly with the uptake of low carbon technologies like heat pumps and EVs [77]. The congestion management opportunities F CM (j, t) occurring in each small area (s) at time (j,t) is given by Eq. (23).
where H r is the demand headroom of the substation small area s is connected to, n is the number of small areas (4,537 for NI). Fig. 7 shows the locations where the demand headroom is less than 2 MW (assumed D F ) in NI. Demand flexibility is needed to avoid or delay upgrading network infrastructure by reducing demand at peak times 4 pm-8 pm. In this case, flexibility is in the downward direction, as indicated in the figure.

Ancillary services
The variable nature of renewable generation such as wind and solar energy necessitates the use of ancillary services to ensure that the security of the grid and its power quality is maintained [78]. In a previous study [79], we showed how consumer-owned flexible demand such as heat pumps, thermal storage, solar panels and batteries could provide operating reserve. The timing of ancillary services and the direction of flexibility depends on the system imbalance, which changes with time. This can be represented by the resultant or average hourly system imbalance profile (the difference between total system generation and demand).
For each hour, two types of ancillary services could be bought: • Turn Up Demand (TUD): In this case, the system imbalance is positive (generation exceeds demand). Hence, to bring the system back to balance, the excess generation is used to meet the heat demand of houses or charge up their thermal storage. • Turn Down Demand (TDD): In this case, the system imbalance is negative (demand exceeds generation). Hence, to bring the system back to balance, heat loads are turned down or disconnected from the electricity grid. The previously charged storage is used to meet the houses heat demand during the turn-down time.
For homes in a given location to be able to provide TUD services, the substation they are connected to must have sufficient demand headroom; otherwise, there is a huge risk of exacerbating congestion (loading and voltage issues) in the substation caused by an increase in demand [80]. This is because of the loss of diversity as a result of multiple loads coming up at the same time to respond to system imbalance [81]. However, in substations with low headroom, provision of operating reserves in the turn-down direction should not cause loading issues. But for such a portfolio, it can be argued that the limitation of just providing TDD services would have a negative impact on their profitability. Furthermore, it would remove the free charging that comes from providing TUD services. However, with the modernisation of the grid to become smarter, substations without sufficient headroom could also participate in TUD events using smart control to turn up devices only when the substation is underloaded. Hence, a filter can be applied to remove all locations or substations at hours when their headroom is less than D F since it would be risky to turn-up loads in these areas at those times [80]. The ancillary services opportunities F AS (j, t) for each small area at time j, t is given by Eq. (24). Fig. 8 shows the locations, resultant direction and time where ancillary services (operating reserves) may be provided in NI.

Managing wind energy dispatch-down
Windfarms are dispatched down due to curtailment or constraint. On windy nights where there is low system demand in the whole network, and the SNSP limit is exceeded, system operators curtail wind farms to manage the security of the system. The solution, in this case, would be a system-wide increase in load to reduce curtailment. Constraint, on the other hand, refers to situations when wind energy is dispatched down because of localised network issues such as backflows, voltage issues, thermal ratings or network maintenance outages [82]. In this case, the constraint can only be alleviated by turning down controllable wind or Fig. 8. Locations were ancillary services may be provided at times of local congestion. solar generation in a particular location (constraint group). The flexibility solution is local load-on-demand to reduce the amount of wind or solar energy constrained.
Hence, the opportunity for managing curtailment at time j,t is given by Eq. (25), and the opportunity for managing constraint in a constraint group G is given by Eq. (26). C u(j,t) and C G(j,t) is the average amount of curtailed and constrained wind energy at time j, t. The increase in load is subject to the demand headroom H r(j,t) .
∀s ∈ {1, ⋯, n}, There are four constraint groups in Northern Ireland. Wind Dispatchdown profile (curtailment and constraint) for the year 2019 was used to model the time domain. Curtailment and constraint range for each transmission node (bulk supply points) was derived using both the aggregate values from the 2019 report [82] and the forecasted nodal values in the 2016 curtailment and constraint report [83]. As explained earlier, increasing load at any point in the system would reduce systemwide curtailment; however, only loads in a constraint group can reduce the constraint. Hence, we have calculated the total constrained wind energy for 2019 in each constraint group. Fig. 9 shows the locations and time of dispatch-down. Constraint group 3 is a subset of constraint group 2, as shown in Fig. 2. Hence, the total constraint wind energy for constraint group 2 is 89 GWh/Yr. (53 GWh/Yr. +36 GWh/Yr.). The opportunities for constraint group 4 are mostly curtailments, which has a higher occurrence in the night periods.

Aggregate flexibility potential
The overall flexibility requirement of the system changes with time. For example, Fig. 10 shows the net flexibility needs of the system at 4 am and 6 pm. We have multiplied the flexibility potential of each location (based on the substation headroom and excess renewable generation) by each flexibility profile (time-domain) to give a visual representation of the aggregate flexibility using the colour opacity. At 4 am, the main flexibility need is for reducing wind energy dispatch down and for providing ancillary services (mainly TUD). Both opportunities are available for some locations, as indicated in the figure. While at 6 pm, there is a lower frequency of excess wind energy occurring in the system and hence flexibility is needed most in the downward direction. Depending on the demand headroom of the substation, some locations may be able to provide congestion management while others would be providing mostly ancillary services (mainly TDD).

Flexibility adequacy assessment
An adequacy assessment needs to be performed to investigate if the response available is enough to solve the grid problem. For example, a system operator would need to assess if there are enough flexible loads that can be turned down in the small areas connected to a substation experiencing congestion problem. The system operator would also need to ensure that the flexibility could last for the duration of the grid issue.
The sufficiency of flexibility S CM to solve a congestion problem at substation P, at time t is given by Eq. (27). The equation assesses if the sum of the downward flexibility response R D (t) in all the small areas connected to primary substation P, at time t is up to the congestion F CM (t). And the duration of the response d D (t) is up to the required duration d CM (t). Where N is the number of small areas.
Similarly, the amount of reduction in wind energy constrained at a constraint group G, at time t is given by Eq. (28), the amount of reduction in curtailed wind energy is given by Eq. (29) and the amount of operating reserves that can be provided by demand flexibility in Eq. (30). Fig. 9. Opportunities for managing wind energy dispatch-down (annual constraint and curtailment).
When considering the opportunities for demand flexibility, it is necessary to consider the availability of alternative solutions. For example, there might be other suitable methods for relieving network congestions, and system planners must choose the most cost-effective and sustainable solutions. Furthermore, we must consider the availability of other low carbon devices. Flexible demand from heat devices and electric vehicles may compete for the same flexibility opportunity. In the case of managing wind energy dispatch-down, we must also consider if there are plans for utilising the excess wind for other uses, such as the production of green hydrogen for industrial use. For the provision of ancillary services, we must also consider if there are other low carbon grid balancing technologies. A whole-system approach must be considered when selecting or combining grid management strategies.

Flexibility needs/left behind analysis
The energy system is changing in a way it has not since it was invented. Without intervention, this change could lead to greater unfairness in distributing the system cost and the system benefits [84]. This unfairness could come from the inability of vulnerable consumer groups to participate in and reap the benefits of the new system due to the cost and complexity of participating or the location where they reside. It is important that these new innovations are inclusive by design and to ensure that there is increased justice in smart energy systems [85]. Hence a risk analysis must be done to identify and prioritise these vulnerable groups. We propose two main strategies for flexibility prioritisation, as shown in Fig. 11.

(a) Prioritising Vulnerable Consumers
Flexibility opportunities are finite. For example, only a certain amount of demand is needed to solve a congestion issue or mitigate the dispatch-down of excess wind energy. Hence it is important to prioritise flexibility from potentially left-behind groups to avoid creating a more unfair energy system where flexibility is largely monetised by affluent privately-owned households, with better access to capital, automation technologies or that could be favoured by aggregators. Networks need to  support vulnerable consumers as part of their social obligations [86]. In [79], we argued that flexibility from vulnerable consumers should have priority-dispatch in the provision of system services as it is vital to ensuring a fair transition where no one is left behind. We termed this new policy -The Vulnerable Consumer Priority in Administering System Services (VCPASS). The socio-economic layer provides information on the vulnerability of each neighbourhood. Depending on the data available, various metrics could be used to identify vulnerable neighbourhoods: i. Deprived Areas: These groups risk suffering further detriment if left behind. ii. Low-Income Areas: Income is a primary determiner of being left behind. These groups have limited capital to switch to low carbon technologies such as heat pumps; they would also have financial limitation in accessing several markets and smart technologies. iii. Areas with a high percentage of households under benefits iv. Areas with a high percentage of older people. (b) Equalising Flexibility Opportunities Some consumers may be disadvantaged because of the location they reside in. There are two categories of location-based inequality.
i. Areas with no local flexibility opportunity: Some neighbourhoods may have location-specific flexibility opportunities such as congestion management and managing wind energy constraint. Other neighbourhoods may only have system-wide opportunities such as ancillary services provision or managing wind energy curtailments. Hence it makes sense to prioritise system-wide flexibility opportunities to those that do not have any local alternative. For example, in Fig. 9, wind energy curtailments could be prioritised for consumers in constraint group 4 since they have little constraint opportunity. ii. Off gas areas: Consumers without access to the gas network may have no other suitable and sufficient option for low carbon heat except installing heat pumps or other electric options. If the rate of electricity is high compared to the cost of oil-fired heating which may be currently used by these consumers, they would be unable to switch to low carbon heat without a higher risk of falling into fuel poverty. Provision of flexibility from off-gas areas could be prioritised to make the adoption of heat pumps as economical as possible to ensure these consumers do not suffer greater fuel poverty as a result of the energy transition.
We used the NIMDM data to identify the deprived and low-income areas. We classify a small area as deprived if its income ranking or its multiple deprivation measure rank is in the worst 20%. To develop a priority map, each small area is initially assigned a priority equal to the flexibility opportunity for the service investigated normalised to 1. Then if they belong to any of the left-behind groups, their priority is multiplied by 2. Fig. 12 shows the generated flexibility priority maps for NI (without consideration of time), which can be used to locate left behind or priority areas for the various grid services. For temporal assessment, please see the interactive map [72].

Discussion and conclusion
We have developed a methodology for the spatio-temporal assessment of demand flexibility needs and opportunities. The methodology uses simple spatial data that can be sourced privately or from public datasets (such as census and open street map), with average profiles of various energy assets and storage device characteristics. We provide equations to assess the demand response potential of various flexible devices at any given time and in any direction. This model could be used with a scenario forecast model that can be generated using the spatial properties (such as number of households, number of vehicles, building type, connection to gas) of each small area to determine the response potential for various uptake scenarios.
We provide a methodology for assessing the flexibility opportunities available to each small area across space and time. Three flexibility opportunities are investigated in detail: congestion management, ancillary services and managing wind energy dispatch-down. The major factor affecting the flexibility opportunities of a neighbourhood is the demand headroom of the substation that the neighbourhood is connected to and the closeness to renewable energy generation sources such as wind and solar farms. We present a flexibility adequacy assessment model that can help system operators assess whether the response available in a location is sufficient to solve the grid issue. We establish a methodology for identifying vulnerable neighbourhoods at risk of being left behind and developed a flexibility prioritisation framework that ensures a fair distribution of flexibility opportunities across all locations. The framework uses two main metrics: prioritising flexibility provision from vulnerable consumer groups and equalising flexibility opportunities by prioritising system-wide flexibility opportunities to areas with no local alternative and prioritising off-gas areas that may have no other suitable and sufficient option for low carbon heating. We highlight the role that such a strategy would have in ensuring a fair energy transition and assisting in the decarbonisation of vulnerable homes.
One major problem that has limited geospatial analysis of energy systems is the lack of visibility beyond the primary substation. The geography of the low voltage network is often not publicly available. To solve this problem, we developed a methodology for linking the small areas with the primary substation using the k-nearest neighbour classification algorithm. The methodology was able to match small areas with an accuracy of 60-94%. This methodology may be used only when no low voltage network data exist, since the precision of the matching will impact the accuracy of the other investigations.
Finally, we present the Northern Ireland Demand Flexibility map tool available in [72] as a resource that provides a whole system approach to guide energy system planners in developing a decarbonisation strategy for Northern Ireland. We would also recommend the reader consult the interactive map tool, which provides more information about the interplay between the various map layers discussed in this paper.

Declaration of Competing Interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.