Evaluation of the energy autonomy of urban areas as an instrument to promote the energy transition

ABSTRACT The management of energy systems with a high share of renewables is a challenge for grid planners and operators, as weather and energy demand do not always coincide. Investigating the energy autonomy of cities and their local energy resources can help to overcome this challenge. To this end, real energy demand data from the city of Loja, Ecuador, and wind energy generation from a nearby wind farm were compared. This showed that wind energy provides 53% of the city’s demand. It is exposed that despite the excess energy, the wind farm’s ability to supply the city with electricity is limited to about 74% when the wind farm is expanded to twice its rated capacity. The results show that in order to improve the autonomy, other energy sources, such as photovoltaic, as well as useful size energy storage are needed.


Introduction
The global economic crisis triggered by the pandemic has shown the fragility of global supply chains (Ivanov 2021), especially when it comes to basic food or energy. To build resilience to future supply chain disruptions and ensure basic services to populations everywhere, local food and energy production must be improved and strengthened, including in urban areas . This scenario will increase the global demand for electricity in the coming decades . Therefore, the integration of renewable energy will be a crucial feature of urban energy systems (Bareiß 2020), which entails a good understanding of the multivector energy networks within a context of an energy transition (P. C. Taylor et al. 2022).
Urban energy systems are essential for any city because they need a reliable and abundant source of electrical energy as well as other services such as drinking water, fuels for transportation or food (Montealegre et al. 2022). On the other hand, the double crisis of fossil fuels (availability and pollution) forces an urgent and inevitable energy transition toward renewable sources (Eicker 2019). In this sense, governments and institutions are making great efforts to reduce dependence on fossil fuels before the fuel shortage becomes apparent (Spyridaki et al. 2020). A detailed analysis of electricity use and its relationship with local energy resources, economic activity and the environment provides very valuable information that can be used as a basis for planning the energy transition in urban areas (Droege 2018;Johnstone and McLeish 2022). The current energy system must therefore transform to integrate Distributed Energy Resources (DERs) and Demand Response programs (DR) (Kubli, Loock, and Wüstenhagen 2018). This paradigm shift brings new challenges for power system management (Darby 2020). On the one hand, utilities and distributors need to implement systems to monitor and control the power system in order to integrate distributed generation (Karad and Thakur 2021), especially in medium and low voltage

Overview on urban energy autonomy
Wind and solar PV capacity within an urban context is increasing rapidly. However, their integration depends on the characteristics of each city, its location, climate and landscape (Delponte and Schenone 2020). It also depends on the city size, population density, electricity grid robustness and energy demand profile. This section takes on the state of the art regarding these arguments, focusing specifically on the renewable energy integration in urban areas' networks to improve their energy autonomy (Juntunen and Martiskainen 2021).
There is currently a growing debate concerning the role of decentralized and distributed solution, since energy regulations are not a responsibility of local governments (Lazaro et al. 2022). It is therefore required to generate evaluation methods that allow the cooperation between the different actors to promote local energy transition projects and solutions, and assist the local governments in their investment decisions (Ha and Kumar 2021).
There are some studies that address the integration of renewable energy in urban areas, but they mostly rely on simulations of implausible scenarios based on little to none measured data (Minin and Furtaev 2018). Kühnbach et al., propose a model to optimize the expansion of solar PV capacity and storage in 166 regions of southern Germany, and assesses the autonomy level of a decentralized electric grid, which gives a great excess installed capacity (Kühnbach et al. 2020).
Icaza et al. simulate the renewable energy sources in order to ensure a 100% renewable electricity generation in mid-sized cities in Ecuador (Icaza, Borge-Diez, and Galindo 2021), and assesses the state of a 100% renewable electricity system in Ecuador (Icaza, Borge-Diez, and Galindo 2022). However, finding the link between uncertainties in wind generation and local demand side management can help in the integration of wind energy in power grids (Ahmed et al. 2020).
In order to create self-sufficient urban electricity grids it is necessary to lay down the infrastructure (power lines, storage facilities) required to continuously manage energy. This is both a technical and a financial challenge (Arroyo and Miguel, 2020). This paper introduces a system which we believe will allow the quantification and comparison of both generation and consumption data in real time. These results can be used to manage the power grid as well as to assist decision makers in their investment plans. The study of the city of Loja, Ecuador, and its neighboring wind farm fills this knowledge gap (Maldonado-Correa et al. 2020).

Context of the case study
Ecuador is located in the west South America (see Figure 1). Ecuador is bordered by Pacific Ocean to the west, Colombia to the north, and Peru to the southeast, between 81.03° W-75.16° W, 1.48° N-5.04° S (Erazo et al. 2018).
The climate of Ecuador is tropical and varies according to altitude and region, due to the different altitudes and, to some extent, the proximity to the equator (Moreno, Bernal, and Espinosa 2018).
The coastal lowlands in the western part of Ecuador are typically warm, with temperatures around 25°C. The coastal areas are influenced by ocean currents and are hot and rainy between January and April. Figure 2 shows the location of Loja, Ecuador. The weather in Loja is that of a subtropical highland climate. The average daytime temperature is 21°C, which drops to a minimum of 10°C on average at night. The average annual temperature is 18°C, with daily averages ranging from 16°C to 30°C (Benítez, Armijos, and Calva 2021).
According to ARCONEL (Ecuador's electricity system regulator), 64% of electricity in the country is generated from hydropower, while 35% is of thermal origin. The remaining 1% is from other renewable sources (wind, photovoltaic, biogas, biomass) (Carvajal et al. 2019). See Table 1 for a detailed breakdown of electricity generation in Ecuador. Loja is located in the southern part of the country, on the border with Peru, at an altitude of 2057 m above sea level (a.s.l.) (Solano et al. 2021). The history of wind generation in mainland Ecuador began in 2012 with the construction of the first large-scale wind farm (16.5 MW) on the hills of Villonaco near the town of Loja (Hernandez, Maldonado-Correa, and Méndez 2016).
NIS has 133 power plants with a total capacity of 8073 MW, largely hydraulic because the government implemented policies and regulations to promote the development of renewable energy (Guimara˜es 2020) and the gross energy generation in April 2020 was 27062 GWh (Ayala-Chauvin et al. 2021). On the other hand, the interconnection with Loja is a radial branch of the NIS, as it is not meshed. Therefore, a single failure in the transmission line could isolate Loja from the NIS and leave it without power.
In this sense, the Villonaco wind farm is a strategic project to diversify the energy mix and improve Loja's resilience to power outages. It also represents an ideal scenario to study a new model of decentralized energy management.  This study compares the electricity demand of an urban area with the electricity supply based on the DERs generation of a nearby wind farm, Villonaco (16.5 MW). Electricity consumption in the urban area follows daily, weekly and annual patterns. Electricity generation depends on wind availability, which is determined by weather conditions, so it has a very high variability, although it also follows a seasonal pattern.
This analysis is based on the aggregated measurements of electricity consumption in the urban area of Loja, measured at the substations, and on the data from the SCADA of the Villonaco wind farm (Maldonado-Correa, Solano, and Rojas-Moncayo 2019). The study assumes that the electricity generated by the wind farm is consumed in the urban area and that the National Interconnected System (NIS) of Ecuador covers the rest of the demand, covers generation gaps and serves as a power sink when there is a generation surplus.
The main results from the reconciliation of electricity generation and use data are quantitative. The Villonaco wind farm does not provide a continuous supply in some time intervals, even considering an expansion by a factor of 2, since no electricity is generated when the wind speed is below the cut-in speed of the turbines.
The analysis of power generation shows some degree of seasonality, with January to March having more frequent and longer gaps in power generation, and overall lower power generation than the rest of the year. This knowledge will be useful to set up storage systems for both short term (seconds) and long term (days or weeks).
Finally, this paper presents a practical method that shows that it is possible to implement a low-cost and independent energy management system that allows local companies to manage their energy consumption in a decentralized and autonomous way. Furthermore, the knowledge obtained through this project is an input to local Ecuadorian governments that can be used to support investment decisions regarding energy infrastructure within urban areas.

Materials and methods
The method presented in this section is based on the confrontation of the data generation and consumption. The wind farm power generation values were obtained from the wind farm SCADA system. An algorithm was developed to time-synchronize the wind farm power generation and the town's power demand. This created time synchronous energy values were used to assess the daily, seasonal and annual comparisons between generation and demand.

Wind resource data
The Villonaco Wind Farm is located in the Loja region on the Villonaco Hill at 2700 meters above sea level in an area considered orographically complex. It was put into operation in 2013 (Perdomo, López-Presa, and Maldonado 2016).
The location of the wind farm has wind resources of exceptional quality, due to the temperature difference between the two sides of the Villonaco Mountains with Loja (2100 m a.s.l.) to the west and Catamayo (1000 m a.s.l.) to the east. This orographic peculiarity causes the Foehn effect, with an eastward air movement that generates steady winds in this direction. The result is a high density of wind resource in the area where the wind farm is located. The locals call this type of orographic phenomenon Huayrapungo (wind gate in Quechua language). Wind resources are measured with weather stations located 80 m above the ground, on the nacelle. Data are collected for mean wind speed, wind direction, temperature and air density at 15-minute intervals. Figure 3 shows the spatial distribution of the wind turbines which consists of 11 direct-drive wind turbines of model GW70/1500 Goldwind with a capacity of 1.5 MW each, corresponding to a total installed capacity of 16.5 MW with mean year production of 59.57 GWh (Sánchez et al. 2021).

Measurement of the power generation and use variables
The power variables were measured using DNP 3.0 (Distributed Network Protocol), which is based on the OSI (Open Systems Interconnections) model (Singh, Nivangune, and Patwardhan 2017). This is a secure communication protocol that is an industry standard (Richard and Appiah-Kubi 2017).
On the other hand, the data analysis processes were performed using the R language in RStudio, an open source tool for statistical analysis and real-time visualization of the data. Figure 4 shows the automation, monitoring and control systems. These systems mainly consist of the SCADA of the wind farm, a communication concentrator and the RTUs (Remote Terminal Units) (Medrano et al. 2018). This equipment is used to measure the data at both ends of the power grid: the generation side at the wind farm and the consumption side at the city substations. In the case of Loja, Ecuador, the measurements were made in 4 substations feeding the circuits of the urban area.

Integration of the data
The authors have developed code in the R language to integrate the generation and consumption of active power to give the active energy in real time. The integration of the power to give the energy for the superposition period was calculated using an interval integrator based on Riemann's theorem (Martínez-Cervantes 2016) and displayed using RStudio. The theorem states the following: for all a; b 2 R n , where P is active power of f and Where P g and P d are the electricity power generation and demand respectively, and epsilon are binary variables ε 1 ; . . . ; ε n ¼ 0; 1 f g that allow to generate all the 2 n vertices of the n rectangles dimensioned where they need to be evaluated. Therefore, the sum of the term with 2 n with n 2 1; 2; 3; etc:, can be read as follows: and is an alternating sum over values P g;d that takes place at the 2 n vertices of the integration domain, which we refer to simply as a rectangle (Taylor 2020). This theorem has been implemented in the RStudio tool for real-time data analysis, integration and visualization. It is an extension of the 1st theorem, known as Barrow Rule (Ponce-Campuzano and Maldonado-Aguilar 2014).

Analysis of the data
Once the information is integrated and the intervals are standardized, statistical analysis is performed to assist the system operator. The statistical analysis is essentially to create a database where you can visually observe the seasonal behavior of the wind.
The generated energy E g and the energy demand E d are the sum of all generated and demanded active power.
The difference in synchronized data for power sources and power loads at 15-minute intervals determines the net energy surplus or deficit in each interval: In periods when the energy generated E g is greater than the energy demand E d , there is an energy surplus. Otherwise, there is an energy deficit.
Both data sets, generation and usage, were synchronized and overlaid to produce a time series with 15-minute intervals. The time format used is a standard format (%d-%m-%Y %H:%M:% OS), so it is easy to compare data from different sources.
The data in the frequency column are fitted to the Weibull function using a nonlinear method, and the values of the parameters c and k are determined using the RStudio function "nlinfit" -nonlinear regression and "survreg" -regression for a parametric survival model function. Figure 5 is the flowchart of the proposed method. This method integrates active power variables and calculates the surplus or deficit for each interval. It also compares the measured data with the modelled production forecasts. Finally, the results are printed to provide insights into skewness, tail behavior, presence of multimodal behavior, and data outliers. The histograms can be compared to the basic shapes associated with standard analytical distributions.
A wind turbine operates when the wind speed is above a minimum value (cut-in) and below a maximum value (cutout). To calculate the number of hours that the wind turbine has generated electrical energy, the current data is fitted to the Weibull statistical model (Datsiou and Overend 2018;Jiang et al. 2015).
Therefore, this RStudio tool allows system operators to perform real-time analysis of power generation and usage within the system and use this information to plan ahead and develop energy management strategies. The tool is also open source, low cost and easy to implement (Campbell 2019;Tyralis et al. 2017).

Results
The results presented in this section are based on wind analysis and data comparison between electricity generation and consumption. Additionally, annual and per day generation and consumption curves are presented.

Wind data
The readings show an annual pattern characterized by strong winds between July and September and lower wind availability from January to April, resulting in frequent generation gaps during these months. This illustrates the natural shortcomings of renewable energy systems and how they affect the continuity of electricity generation, and highlights some of the challenges in managing renewable energy systems. This case is about managing a wind farm as the main source of energy with the support of National Interconnected System, to fill generation gaps. Figure 6 was created by applying the function "density ()" Kernel Density Estimation of the software RStudio. The generic density function computes kernel density estimates for wind and temperature at Villonaco. The default method does this with the given kernel and bandwidth for univariate observations. Graphs are created using plot(density(x)), where x is a numerical vector (Shi and Chen 2021). In addition, the wind rose and wind frequency distribution are shown. The mean annual wind speed and temperature in 2019 are 10.5 m/s and 13.5°C, respectively.
The weather data collected from the towers show the three-season climate of the Loja region with a warm rainy season (summer: 1 December to 28 February, autumn: 1 March to 31 May), a cool dry season (winter: 1 June to 31 August) and a warm dry season (spring: 1 September to 30 November). Figure 7 shows the boxplot of wind speed and temperature by season. Summer and autumn are characterized by rainfall, mean temperature is 15°C and mean wind speed is 10 m/s and 13 m/s, respectively. In spring, precipitation is lower, the mean temperature is 10°C and the mean wind speed is 8 m/s. Finally, winter is characterized by temperatures between 17 and 18°C and a mean wind speed of 15 m/s. Moreover, it can be seen that the kernel density estimate of the wind in winter is characterized by winds between 5 and 20 m/s with an average of 15 m/s, all within the power curve of the wind turbines.
By using the Compute Tukey Honest Significant Differences (TukeyHSD) function of RStudio, it was found that summer and autumn are quite similar seasons. Therefore, 3 periods can be considered in the study area: Summer and Autumn from December 1 to May 31, Winter from June 1 to August 31, and Spring from September 1 to November 30 (Alavipanah et al. 2015;Hui 2018).

Electricity generation
The study period was set from May 2018 to April 2019, as the quality of the data was good for a full year, with very few missing data (< 0.2%).    The generation corresponds to the three weather periods in the Loja region, with a warm rainy period (summer: December 1 to February 28, autumn: March 1 to May 31), a cool dry period (winter: June 1 to August 31) and a warm dry period (spring: September 1 to November 30).
The measured data from the wind turbine in Ecuador were used to simulate the kernel density curve, which allowed the comparison of the curves by season, as shown in Figure 9. From this comparison, it can be deduced that there is a higher power generation in winter.

Electricity use
Electricity use data for the urban area of Loja were provided by Empresa Eléctrica Regional del Sur (EERSSA), the local utility, and aggregated at the substation level for this study. These are high quality data that characterize the energy consumption of the urban area in 15-minute intervals over a 5-year period.
As with the generation data, the period selected for this study was May 2018 through April 2019, as shown in Figure 10.
The total electricity use for the study period was 156191 MWh, and the maximum active power was registered on Friday, March 4, 2019, at 19:30, with a peak demand of 29689 kW.   Figure 11 shows one of the main contributions of this section, a realistic load profile and urban electricity consumption data that can be used by researchers and utilities. The consumption curve shows a high peak demand from 19:00 to 22:00. According to the Ecuadorian Ministry of Energy, this is due to lighting and other electrical appliances, so it is necessary to promote energy efficiency plans to flatten the consumption curve.
On the other hand, these results illustrate the low performance of the system, since the system is designed for peak power, covering a period of 3 to 4 hours per day, and has a low capacity factor for the rest of the day. Therefore, it is necessary to promote demand management, renewable energy integration, energy conservation and optimization of energy flows to flatten the consumption curve and make better use of energy resources and infrastructure (López 2020).

Confronting urban electricity demand with wind energy supply
In this section, two sets of real data are contrasted, the electricity consumption of the urban area of Loja and the energy generated by Villonaco Wind Farm. Electricity consumption follows well-defined daily and weekly cycles, and wind energy has a seasonal behavior.  For the one-year period with 15-minute intervals, we have 35040 measurements ((8760x60)/15) instead of 35132 measurements. During the study period, the wind farm generated 87778 MWh and the urban area consumed 155987 MWh (see Figure 12). Figure 13 shows the generation of the wind power plant by station. In this section, the results of the measurements of electricity use in the urban area are discussed in detail considering the different seasons. It was found that the usage is uniform in all periods, with an average power of 15000 kW. Nevertheless, there is a small increase in usage in summer, especially in the month of December. On the other hand, the generation is characterized by a high density of power generation in winter with an average of 15000 kW. Figure 14 shows the synchronized data for May 2018. There is a generation gap from May 28 to 30. In normal operation, National Interconnected System covers the rest of Loja's electricity needs during peak demand and generation gaps.   Figure 15 shows the production surplus and deficit for the month of May. The deficit for the month of May was 5342.1 MWh and the surplus was 286.3 MWh. So, in the month of May, surplus availability for storage is low and therefore the national interconnected system supplies energy to meet the deficit.
The generation surplus occurs during off-peak hours and is delivered to National Interconnected System. To maximize the efficiency of the system, it is advisable to use the energy at the time it is generated. One of the ways to achieve this is by adopting demand response strategies that encourage the adjustment of industrial production schedules to the availability of electricity. Electricity can also be stored using storage systems such as batteries or hydrogen, and used either to control and balance the system or for other purposes such as electric mobility or industrial activities that require a lot of electricity.
Alternatively, excess generation can use the National Interconnected System current hydroelectric plants as equivalent storage capacity. In this case, National Interconnected System uses the excess generation from the wind turbines in exchange for energy bonds, through an equivalence between usable excess power and saved water from the dams.   Figure 16 shows generation and consumption per day. The variable nature of wind energy generation and the difficulty to synchronize them is obvious, but the variables can be discretized to optimize the system by determining the storage and discharge capacity per hour (X. Jiang et al. 2018;Oree, Sayed Hassen, and Fleming 2017). In the case of Loja, the annual charging capacity of a storage system is small. In the following section, several discussion scenarios are considered. One of them is the expansion of the wind farm to improve the storage capacity.
These results, based on measured data, are a good basis for discussing energy management strategies or agreements with the National Interconnected System, to avoid energy dumping and achieve a net zero balance for the city.

Discussion
Three scenarios are considered in the analysis of electricity generation and demand: Base scenario. The urban area of Loja and the Villonaco wind farm are connected to the grid National Interconnected System.
Isolated system scenario. The urban area of Loja and the Villonaco wind farm are not connected to the National Interconnected System.
Wind farm expansion scenario. The Villonaco wind farm is expanded to double its capacity (33 MW).

Base scenario
In the baseline scenario, the urban area of Loja prioritizes the electricity generated by the Villonaco wind farm and relies on National Interconnected System to meet the rest of its electricity needs, especially the peak demand that exceeds the capacity of the wind farm and the generation gaps of the wind farm. However, on the way to a 100% renewable energy system, and considering that Ecuador is facing the post-oil phase, this scenario could be feasible in the long term only during the rainy season, as the NIS generates most of its renewable electricity from hydropower. According to National Energy Center Corporation (CENACE), there are some periods during the dry season when NIS needs up to 40% electricity from thermal power plants to meet the total national electricity demand. Therefore, it is important to consider a scenario in which Loja does not rely on the NIS and has to operate as an isolated system.
In addition, Loja is located at the end of a radial branch of the NIS and is therefore connected to the system by only one power line. This creates an inherent vulnerability with a high risk of temporary isolation of the urban area. In this scenario, it makes sense to optimize grid management using electricity storage.
The third scenario examines the impact of doubling the rated capacity of the wind farm to 33 MW by extending it to the neighboring hills. The expansion consists of adding 11 new wind turbines of the same type as the existing ones, for a total capacity of 33 MW, on the Membrillo and Ducal hills, near Villonaco. In this study, it is assumed that the same wind conditions prevail in the expansion area as in the original site, which is a reasonable assumption given the proximity and the common geographical structure. Therefore, doubling the wind farm capacity in this study results in doubling the energy output. This scenario basically maintains the current conditions where the town receives power from both Villonaco and the NIS to compensate for the fluctuations of the wind farm.
In addition, there are two other scenarios that include Loja as an isolated system and the expansion of the current wind farm by a factor of 2.

Isolated system scenario
In this scenario, the Villonaco wind farm is considered as the only source of electricity for the urban area of Loja. This is a plausible situation since Loja's power grid is connected to the NIS through a single 138 kV power line, and thus only one outage away from being isolated.
To maintain a reliable power supply in an isolated environment, the electrical system must include energy storage and management systems. Comparing the energy supplied by the wind farm to the city's electricity needs gives an idea of the storage requirements and additional electricity generation that Loja would need to install as an isolated system.
Ecuador's electricity system, like most electricity systems in the world, matches electricity generation to the system's electricity demand at any given time. Large-scale integration of renewable energy sources requires to change the system with a completely different approach to energy management, matching energy demand to resource availability to maximize system efficiency. Figure 17 shows the generation surplus and generation deficit of the system Villonaco-Loja over a period of 1 years, from May 1, 2018 to April 30, 2019. The total energy consumption during this period was 155987 MWh, while the wind farm generated 87778 MWh, which corresponds to a total deficit of 71774 MWh, i.e. 46% of the total energy demand of Loja. The rest of the demand was met by the NIS.
Direct energy demand response was 84212 MWh, 53% of demand and 96% of generation, and there was a generation surplus totaling 3565 MWh that could not be absorbed by the City and was delivered to NIS. Table 2 summarizes the monthly values for wind farm energy generation, city energy use, deficit and surplus, direct supply and net balance of the Villonaco-Loja system. The net balance with NIS showed a deficit of 68209 MWh, which is 43.7% of Loja's electricity usage.
In November and from January to April, wind resources are scarcer and direct supply is low. The energy deficit exceeds 50% of demand during this period. In addition, the current system generates only a very small surplus (2.6% of total energy consumption), and it is neither practical nor economical to invest time, effort, and money in storage or DR systems under these conditions. In addition, the operation of the Villonaco-Loja isolated system also requires a highly automated control system for the medium and low voltage networks to ensure supply quality and stability. Therefore, energy policies to incentivize the use of efficient technologies at a household level are needed (Tsao, Vu, and Lu 2021).

Villonaco wind farm expansion scenario
According to the preliminary study by the Ecuadorian Ministry of Energy, the wind farm can be expanded to the neighboring Ducal and Membrillo hills, which have similar wind conditions to Villonaco hill. The resulting installed capacity of 33 MW exceeds the average peak demand by 25%, and the energy generated by the expanded wind farm is 175611 MWh, 13% higher than the yearly city energy use. Table 3 shows that the expanded wind farm directly supplies 115890 MWh (74% of the total demand) during the study period, while the total surplus is 59665 MWh and the total deficit is 40096 MWh. This means that the electricity generation is sufficient to theoretically meet 100% of the energy demand of the urban area. In practice, these values need to be adjusted taking into account the efficiency and limitations of the storage systems, such as energy and power limits and operating range.
Considering NIS as a perfect virtual storage system (infinite power and capacity, and 100% efficiency), the net balance is positive with NIS totaling 19568 MWh.
This scenario shows that the expansion of the wind farm could make the urban area of Loja a selfsufficient electricity producer, as long as a utility-sized energy storage system is installed in order to manage the generation surplus.  In a global context in which energy demand is increasing at an exponential rate due to population growth, it is necessary to optimize the exploitation of renewable resources to achieve energy sustainability (Bilgen and Sarıkaya 2018). In this sense, a challenge for energy system designers is to analyze the feasibility of combined wind and solar systems with storage systems (Ruiz et al. 2019). However, recent studies show that for an installed power of 9 MW, storage systems are not feasible, but for higher powers (Akyürek and Türkay 2017).
Ecuador is studying the integration of Storage Systems to improve the performance of hydropower plants, and their role in tackling demand variability, improving power quality and also to phase out more polluting power plants (Posso Rivera et al. 2022).
The region of Loja, Ecuador, presents an interesting solar potential that would allow the implementation of photovoltaic solar technology (Cevallos-Sierra and Ramos-Martin 2018), this combined with the extension of the Villonaco Wind Power Plant would increase the installed power and possibly improve energy autonomy, however, it is necessary to conduct a feasibility study.
In the social sphere, the positive influence of the Villonaco Wind Power Plant, the improvement of road infrastructure, educational equipment and public lighting has been verified (Vicuña and Pérez 2020), therefore, future research should consider the analysis of the impact of economic and social in the area of influence (Costa-Campi, Jové-Llopis, and Trujillo-Baute 2019).

Conclusions and policy implications
The current situation of climate change and resource scarcity encourages communities to rely as much as possible on local resources to increase resilience, especially in critical supply chains such as food or energy. Therefore, locating critical supplies should be a priority for urban planners in the coming decades. For energy supply, this means using distributed energy resources such as wind, solar or hydro power in different proportions depending on what is available in each area.
Managing a DERs based energy system presents a new set of challenges due to the limited control of energy resources and their real-time nature. Therefore, real-time data acquisition and processing systems are key to managing this type of network. The model presented in this paper manages this real-time data collection and processing for both generation and demand, providing easy-tounderstand information for urban planners and network managers that can be used to develop dayto-day and medium-term strategies and policies for sustainable management and development. These strategies include demand reduction programs for large consumers to manage the grid in real time, or measures to flatten and shape the demand curve to better match generation and thus improve the long-term stability of the system. Moreover, this model is implemented using an open source tool (RStudio), so it is flexible and inexpensive. The city of Loja in Ecuador is located in a geographical environment that generates constant easterly winds throughout the year, with little seasonal variation due to its proximity to the equator, being January to April being the months with the least amount of wind. This makes wind energy the best option as the main renewable local energy source for the city.
Villonaco Power Station is a 16.5 MW wind farm located on the nearby hills of Villonaco. Due to the excellent quality of wind resources in the area, it has a remarkable annual capacity factor of about 54%.
The comparison between the wind farm's electricity production and the city's electricity consumption shows that 53% of the real-time demand can be met by the wind farm in its current configuration, with very little excess production during off-peak hours.
A hypothetical expansion of the wind farm to 33 MW would result in 74% of the City's electricity demand being met directly, even though the total annual output of the wind farm exceeds the total annual demand. Further expansions of the wind farm do not result in a significant increase in direct coverage. This is because the periods not covered are due to lack of wind rather than lack of capacity.
However, the Electricity Plan of the Energy and Resources Ministry of Ecuador considers the development of unconventional renewable resources, including a 110 MW expansion of the Villonaco wind farm in Loja with Villonaco II and III. Another 50 MW wind project called Minas de Hascachaca, also in the Loja province, is projected for 2023. This project will be 100% funded with private capital thanks to the recent opening of the energy sector to private actors.
Therefore, if the system is to be self-sufficient, a power storage system with the capacity to supply the city with power for a few days would need to be established. Such a storage system is a technical and financial challenge, and currently the preferred option is to sell the excess energy to the national grid operator.
The main contribution of this study is the creation of a tool to analyze and compare consumption and generation data in real time, which can be used by grid operators, policy makers and researchers to improve energy use and efficiency and to educate the public. The tool is also flexible enough to be used in grids of different sizes and with any generation mix, helping grid operators in the Global South.

Disclosure statement
No potential conflict of interest was reported by the author(s).