Planning the deployment of energy storage systems to integrate high shares of renewables The Spain case study

The intermittent nature of the renewable energy sources with the greater potential, wind and solar, requires dealing with temporary mismatches between demand and supply. The object of this study is to assess the Spanish energy plan from a system perspective regarding the energy storage requirements to meet electricity demand with high penetrations of renewable energy generation. We use a model that builds on existing literature and commercial software and integrates features such as demand response modelling, the correlation between reserve requirements and the technology mix, and hydrogen as an energy vector. This representation is applied to the Spanish electricity system to assess the consistency of the targets of the national energy strategy. Several scenarios of costs, demand and variation of other parameters are simulated to analyse their relative influence on the solution of minimum cost, especially assessing the sensitivity of energy storage capacity. The simulation results show that the Spanish goals for decarbonising the electricity system are based on optimistic assumptions. Also, energy storage will play a more important role than expected, and the use of hydrogen for energy storage is only needed for a 100% penetration of renewable energies.


Introduction
Mitigation measures are mandatory to achieve the Paris agreement scenario [1], and the decarbonisation of the power sector is a crucial element to stay under the 2 • C objective scenario [2].Power systems will be based on variable Renewable Energy Sources (RES), especially wind and solar technologies [3].However, due to their stochastic nature, these technologies face a major problem, the unavailability to constantly supply electricity [4].Thus, future power systems will require storage technologies to balance and compensate RES generation [5][6][7].Moreover, emissions-free power systems will have to cope with current demand and the electrification of transport, building energy needs, etc. [8], increasing the requirements of RES capacity, energy storage and other balancing resources.
Countries are releasing strategic plans with RES and energy storage objectives to achieve decarbonised power systems.However, these tend to lack precision, for example, calculation of capacities required of energy storage, compatible strategies such as demand response or specificities about storage technologies and sector coupling.As mentioned above, there is a need for energy storage to achieve full decarbonisation of electricity systems, but storage technologies are still capital intensive, not mature, and have a high level of uncertainty concerning their technical and cost development.This has led to strategic plans with lack of precision regarding the needed investment and optimal operations of energy storage technologies [9].However, correctly planning the storage needs and their deployment is crucial to benefit from the least-cost path to reach the decarbonisation targets with a reliable power system.
Modelling studies have long served as a basis for planning and decision-making.In that regard, there is a line of research regarding 100% RES energy modelling to help decision makers to address the needs of fully decarbonised energy systems [9].Early studies date back to the start of the century [10], but it is only in recent years that the attention to them has increased exponentially [9].Several authors have provided world-scale studies to evaluate country by country the main features of systems with high integration of RES [11,12].Other researchers have studied regional pathways [13,14] or country scale models [15,16].Nevertheless, there is a need to continue studying the impact of the evolution of the technology mix and the flexibility requirements that the energy transition entails [9].
Energy storage is critical to reducing the system's need for backup and curtailment [17].[7] analyse how different types of storage are considered in energy system modelling.They  technologies and the total CO2 emission allowed in the system [18].study the value of storage at different time scales and decarbonisation requirements, concluding that it is essential in energy mixes based on wind and solar.In their study [19], assess the role of different storage and flexibility options in the Swiss system.They conclude that these options complement each other, and their success depends on their interaction.Finally [20], assesses the value of long-term energy storage to figure that cost-effective decarbonised systems need energy storage technologies with duration ranges over 100 h.Mainly, when focusing in the specificities of the Spanish power system, the Spanish "Plan Nacional Integrado de Energía y Clima" (PNIEC) aims at almost doubling the RES contribution to its mix by achieving 74% RES generation by 2030 and then a fully decarbonised economy for 2050.The plan includes the estimated needs for wind, solar PV and solar thermal and an estimate of energy storage needs.Nevertheless, there is no analysis of the deployment path, specific typologies of storage or future scenarios to achieve a fully renewable energy system by 2050.In this regard, different studies have analysed with a system perspective options and specific points to achieve the decarbonisation of the electricity sector in Spain and the Iberian peninsula, mainly focusing on generation technologies.Zubi et al. started to model the Spanish system with larger shares of RES in 2009 [21].The study complemented other reports by Greenpeace on the feasibility of a 100% RES system [22].[23] study the surplus of RES that can be used to produce hydrogen to power gas technology.Victoria and Gallego analyse pathways to increase the RES capacity while phasing out nuclear and coal generation in Spain, which are suited to reduce fossil contribution to almost 10% [24].[25] study the penetration of RES technologies in mainland Portugal, pointing out the essential role of energy storage in achieving a decarbonised electricity system with some backup.Gomez Exposito et al. model the Spanish system to consider the amount of decentralised Solar PV it can admit.They conclude that rooftop solar could get up to almost 50% of the final installed capacity, but they do not model its storage needs [26].In Ref. [27], the authors study storage strategies in the Spanish power system.They conclude that higher wind energy is needed compared to Solar PV to achieve 100% RES power system as wind production accommodates better and requires less storage.However, no specifics on the type of energy storage technologies are considered.Finally [28], studies hydrogen production with the curtailed energy expected in the PNIEC.In that sense, while there is an increasing interest in the decarbonisation of the Spanish power system, studies have focused on particular elements of the system, generating technologies, or energy storage needs without specifying technologies.Moreover, these studies do not compare and revise the current national plan.To overcome this analysis gap, we study the energy storage deployment regarding the current Spanish strategic energy plans.This paper uses a system-wide investment and operation modelling approach and particularises it for studying the future power system development in Spain.We use a single node (copper plate as the Iberian Electricity market [29]) electricity investment and operation model to compare and analyse different scenarios and objectives of the Spanish mainland power system, as has been done by other authors [24,30].Investment decisions are analysed and varied through a set of costs and sensitivity analysis.Besides, the operation is detailed with a four-year long hourly resolution, data considering operation constraints included modeling the variability of the variable RES performance [9].Thus, we assess the needs for energy storage and RES capacity to achieve different objectives and assumptions.In particular, we inquire about when and how much capacity of each technology is required with the current technological context, providing a more granular analysis than the ones used in the plan.With them, we provide valuable policy insights on the timing required for policy and investment on energy storage deployment, RES capacity installation, and potential curtailment needs in the 2030 and 2040 Spanish targets up to 100% RES penetration.
The results are valuable to assess and plan policy making and the necessary instruments to deploy energy storage and RES and are in line with other studies of Spain.It also serves as a comparison and validation of the current plan, pointing out the possible different results related to variations in assumptions and the potential need for new regulatory structures to overcome issues that do not exist now, but they will.
The rest of the paper's structure is as follows.Section 2 presents the methodology and mathematical model.Section 3 provides information on the case study and the Spanish strategic plan (PNIEC).Section 4 discusses the results and section 5 presents the conclusions.

Model overview
The model consists of a linear deterministic optimisation and is based on existing energy infrastructure modelling techniques [31][32][33].As such, it is structured to find, from a system perspective, the cost-minimal technology combination to reach an energy mix with high RES penetration.First, it determines efficient energy generation, energy storage and demand response capacities to fulfil the electricity balance at each time step.Second, it delivers the optimal dispatch strategy to trade-off between energy curtailment and storage, at what time step and how much [31].The model's ability to perform resources coordination in economic dispatch allows minimising global costs through optimised management of pumping, battery storage, demand response options and conventional power plants.
The model has been developed to include new technological features, such as the combination of different energy storage technologies and demand response schemes to take advantage of each specific characteristic; and the correlation between rotational inertia and balancing reserve for Ancillary Services (AS), needed to maintain the grid's stability and avoid imposing a minimum of conventional generation.Some simplifications have been made to obtain a computationally viable modelling environment.The main assumptions can be summarised as follows: • The model assumes complete information to predict hourly parameters, as electricity demand and RES generation profiles, which are impacted by hourly prices, climate conditions, and societal changes.• The development of grid infrastructure and an adequate spatial deployment of RES and flexibility technologies allow for avoiding grid constraints, as assumed in Ref. [30].The electricity system is modelled as a single node system, including Baleares Islands, although account is taken for the losses inherent in the network by considering the gross load.• Regarding interconnections, these were stylised and seen as an ultimate resource for imports (the most expensive solution to satisfy demand) and a low profitable activity in the case of exports.These assumptions derive from the necessity of avoiding modelling the infrastructure planned in neighbouring countries and their future demand.• Imperfect competition and market dynamics are not considered.The problem is optimised within a holistic system perspective without considering agent behaviour.• The existing capacity of wind, solar photovoltaic, hydroelectric, solar thermoelectric, biomass, biogas and urban solid waste technologies that reach the end of useful life will be repowered to an equal degree.The costs of dismantling generating units currently in service, possible costs of extending the useful life of generating units and other factors (tariffs, taxes) that may form part of the generation's supply strategy are not considered.Concerning the new capacity to be installed, it has been assumed that it will be solely renewable energy systems, energy storage facilities, demand response and combined cycle gas turbine (CCGT) power plants.[35].
These assumptions prevent making the model more complex and subject to even more variables and hypotheses, not necessarily improving the quality of the overall results.The study aims to elaborate on an effective decision-making instrument when planning electricity systems expansion and to assess the system's sensitivity to the variation of endogenous and exogenous variables.The study does not aim at forecasting future energy system behaviour but aims at being a tool for elaborating regulatory frameworks, incentive schemes and alternative markets, showing the most cost-efficient infrastructure to reach the goals of emissions' reduction in the power sector.

Mathematical formulation
Fig. 1 illustrates the conceptual structure of the model.In each simulation, a complete assessment of the generation dispatch during each hour of the timeframe considered is carried out.Only when the optimal solution is reached the model exits the simulation process and prints the results.

Objective function
The objective is the minimization of the cost function Ct, see equation (1), consisting in the sum of operational and replacement (calculated as CAPEX divided by the lifetime) costs of the energy systems to be deployed to satisfy demand with a specified minimum share of RES.
For all energy sources, the capacity installed P is multiplied by the operational C opex and replacement C Replace costs.These are defined as a costs per year, so they are divided by 8760 (# of hours in a year) and multiplied by the length of the simulation period T.
Besides CAPEX and OPEX for maintenance, renewable energies do not incur any variable costs.In fact, since the objective function comprises the total costs of RES, irrespective whether it eventually satisfies demand or is curtailed, no additional costs are imposed for curtailment.
As far as conventional generation is regarded, the cost function also accounts for fuel consumption -multiplying fuel cost for the generation in both wholesale and ancillary services -and start-up costs RC ff , modelled by imposing a cost on ramping up generation.
In the case of storage technologies, there are two terms for OPEX, one depending on the capacity installed and a second one associated with the energy flow through the storage system.Only the energy flow out of the storage system is accounted for to avoid charging twice for the utilization of the system.The same applies for load curtailment, or rather the reduction of demand in one period without any recovery of the energy not consumed; and load shifting, or rather the delay of demand at moments with more capacity of generation resources.As far as imports and exports, these are parametrised by setting a cost for the energy imported and a compensation for the energy exported.

Constraints
At each timestep, the market clearing conditions make sure that demand is satisfied by either RES, energy storage, fossil fuels or imports, or load is reduced through demand response schemes.
The previous equation illustrates the balance that we refer to as wholesale, or the demand on which the analysis is based.However, in the model, we have included reserve for AS in both directions (reserve upwards and downwards).The frequency reserve demanded at each time step is obtained by multiplying the demand DE t for the factor Y t , that depends on the rotational inertia in that timestep.This is imposed to be equal to the sum of the contribution of each technology considered effective for this scope, multiplied by 2 for reserve upwards by 2.5 for reserve downwards; see equations ( 3) and ( 4).These factors are applied to consider that not all the capacity requested as a reserve is activated.In particular, analysing data from Ref. [36] corresponding to secondary and tertiary regulation during the years from 2016 to 2019, these two factors were obtained, with 50% of the capacity activated for the reserve downward and 40% for the reserve upward. ) At each timestep, the hourly renewable energy generation from the additional installations G Ren,a t is the result of the power installed P Ren of each technology multiplied by the hourly capacity factor CF Ren t of the corresponding technology.
Existing RES generation is calculated as the new generation but provided as input to the model.The energy content of the energy storage system at each time step S content t considers the previous hour's content S content t− 1 , the inflows S input and φ Storage,i , and the outflows S output t and φ Storage,o   of energy and the corresponding efficiencies η Sto,i and η Sto,o .It must be noticed that the energy content S content t at each timestep corresponds to the energy stored at the end of the hour considered, see equations ( 6) and (7).Moreover, the energy flows correspond to the actual flows for the energy balance since the losses are parametrised as internal to the energy storage systems.At the beginning of the simulation, energy storage technologies are discharged at their specific depth of discharge rate.(by means of the factors for the energy activated for balancing) does not exceed the installed power capacity of the energy storage system S p , and that the energy storage content level S content t never exceeds the installed energy storage capacity S e , see equations ( 8)-( 12).

S content
Most of the chemicals in batteries degrade as they are charged and discharged, gradually reducing their ability to store energy.This affects the length of the battery's operational life, and the total number of kilowatt-hours it will be able to store over that lifetime.A specific maximum depth of discharge DOD for each energy storage technology is applied by imposing a minimum energy content S content t equal to the energy capacity S e multiplied by the factor representing the share of the total capacity that is not exploited to avoid faster degradation, or rather (1 − DOD s ).Additionally, the ratio between the energy and the power capacity of each energy storage technology is defined by means of the factor PE.
Energy storage investment costs are considered on an exogenously imposed lifetime.A limit on the storage charge-discharge cycles has been imposed to avoid excessive usage of specific technologies, which would imply a faster degradation, thus affecting CAPEX assumptions, see equation (13).
Generation from renewable energies needs to satisfy a minimum share of demand α ∈ [0, 1].For convenience, the constraint is imposed as a maximum share of fossil fuel generation, defined as the sum of fossil fuels power output in the wholesale segment G ff t and AS φ ff ,u t , nuclear generation G N t , and the fraction of imports that does not come from RES during the entire duration of the simulated timeframe.This must be less or equal to the DE t minus the load curtailed and not recovered LC t during the same time frame, multiplied by (1 − α), that represents the maximum share of generation from non-renewable energy sources (equation ( 14)).
Even though there is already a significant installed capacity of efficient CCGT power plants in the current Spanish electricity system, the model considers that, for these to be available, investments or capacity payments should be made.This is done to evaluate the real requirements of fossil fuel power plants, to avoid subsidising unnecessary capacity as a reserve.Thus, hourly generation from fossil fuels in the wholesale Another constraint is the ramping of fossil fuel power plants [37].To take into consideration ramping limitations both upwards and downwards, two constraints are defined (equations ( 16) and ( 17)): The power output in each timestep t cannot imply an increment or a decrease in respect to the previous timestep t − 1 of more than the power installed P ff multiplied by the ramp rate R that the technology allows.In these equations both the wholesale G ff t and G ff t− 1 balancing provision 1 0,4 • φ ff,u t and 2 * φ ff ,d t− 1 of fossil-fuelled power plants are considered to guarantee that the ramp rate does not represent a limitation even in case of requiring the entire output set as provision,.
Additionally, for fossil fuel balancing reserve down, we impose it to be lower than half of the generation in the wholesale segment, thus considering that conventional generation can provide flexibility with up to 50% of its output during that specific hour.Again, this assumption is considered since we do not account for unit commitment to keep the optimisation linear.
The relative share of start-up costs in overall variable costs of thermal power plants represents around 0.9% for shares of 30% of RES [38].Even with these relatively low shares, the operators of these plants take start-up costs seriously into account when defining the bidding strategy.Considering the high penetration of RES that is expected in the coming years, the impact of start-ups on the final costs will consistently increase.Increasing the cycle frequency of conventional fossil fuel power plants to provide flexibility will have both short-and long-term repercussions on plant costs, ultimately increasing the costs of generation technologies [39].While modelling, ramping up and down costs were considered jointly since, from a mathematical standpoint, the differentiation would not affect the results.A shutdown cost is considered to acknowledge the cost of losing inertia in the system.At each time step, ramping costs RC ff t are greater than or equal to the difference between the power output (G ff t +φ ff,u t ) during the hour considered minus the one corresponding to the previous hour G ff t− 1 , multiplied by the specific costs of ramping C Ramping,ff .RC ff t is defined as a positive value, so that when the power output decreases, it assumes a value of 0, see equations (19) and (20).
As already anticipated, demand response (DR) can also provide system flexibility.In this model, two types of DR were considered, load curtailment and load shifting.Load curtailment implies the reduction of demand without recovery at a later time.The first constraint for this type of DR is the limitation of the actual curtailment LC t at each timestep to the capacity deployed for this purpose LC Capacity (equation ( 21)).
The second constraint for load curtailment is its limitation in terms of duration.It is imposed that at each timestep t, the sum of actual curtailment LC i during the time period that goes from i = [t − LC Rec p +1] to i = [t +LC Rec p − 1] must be equal or less to the maximum duration LC Max multiplied by the capacity LC Capacity .This constraint guarantees that the load is not curtailed beyond its maximum duration and respects the recovery time LC Rec p (equation ( 22)).
The second DR modelled is load shifting, which functions as an energy storage system.The analogy is that load shifting up is equivalent to energy storage input, whereas load shifting down equals energy storage output.The first constraints in this sense are the capacity limit, for which the sum of load shifting down in wholesale LSD t and balancing 1 0,4 * φ LSD e,t , and the sum of load shifting up LSU t and balancing 2 * φ LSU e,t , must be equal to or less of the capacity deployed LS Capacity at each timestep, see equations (23) and (24).Since there are technologies that require specific geological or territorial characteristics (such as pumped hydro energy storage) to be M. Auguadra et al. deployed or technologies that present only a marginal fraction of future demand (such as electric vehicles), we introduce a limit to their potential expansion.This is done for energy storage, load shifting and load curtailment; see equations ( 28)-(30).
Future electric grids might be more vulnerable to frequency contingencies due to higher penetrations of renewable energy generation along with retirements of synchronously connected generators.Insufficient rotational system inertia -defined as the amount of stored kinetic energy from direct (synchronously) connected machines that offer resistance to any change in frequency -can lead to high Rates Of Change Of Frequency (ROCOF) in the event of an imbalance between generation and demand [40].A high ROCOF event that exceeds the tolerances could lead to involuntary shedding of customer load and generation.
For this reason, a technical constraint was imposed to correlate the rotational inertia of the system with the balancing provision requirements in order to guarantee system stability.By means of the inertia constant, we calculate the inertia of the system I t [40,41].This is set to be equal to the sum of the inertia provided by each power-generating unit, obtained as the product of the power output by the respective inertia constant RI.The inertia of the system is then used to calculate the frequency reserve requirements Y t , defined as a percentage of demand.The equation was deterministically established starting from the values of balancing reserve in current energy systems (elaborated from Ref. [36]) and expectations of requirements in future energy systems [42].Accordingly, we impose a minimum of 6% of frequency reserve upward and 4% downward to avoid distortions for values of rotational inertia higher than 90.000MWs (equations ( 31)-( 35)).
For the security of supply reasons, each country is likely to subsidise some generation power plants that would otherwise shut down for the lack of economic availability.Recently this has been done in other countries through capacity remuneration mechanisms, where a bidding process determines the remuneration for this extra capacity that is used to guarantee the security of supply.Even though the evaluation of a capacity market is out of the scope of the project, it was set that the national installed capacity should always be sufficient to satisfy demand to guarantee the security of supply.In this sense, the lost load is partially considered by considering load curtailment, see equation (36).
The last constraints refer to interconnections exchange limitation, for which energy exchanges at borders need to be lower than the capacity limits of the interconnections.
All the elements of the equations are described in the section "Nomenclature".Their input parameters are given in the Annexes.The model has been built in Python®, utilising an open-source library called "Pyomo"®, that allows to write linear optimisation problems in an algebraic manner and to solve them by means of external solvers, such as GUROBI® [43], used in this study under the academic license.Gurobi is a state-of-the-art solver widely used in power modelling, as in Refs.[44,45].The laptop used for the simulations is equipped with an Intel Core i7 4500U @ 1.80 GHz and 3 DDR3 of 2 GBytes each.The running time, with a 4-year timeframe, ranges between 25 min and 4 h, depending on how much additional capacity needs to be installed to reach the optimal solution.

Spanish system
The current Spanish framework for energy and climate is based on the 2030 targets defined in the National Energy Strategy (PNIEC), which aims at ensuring a smooth transition, especially as Spain plans to phase out both coal and nuclear power plants.However, Spain's total energy mix has an important fossil fuel share.In addition, seeing the relatively small capacity of international interconnections, the fluctuations of an increasingly renewable energy mix must be dealt with within the Iberian region, which is below the EU standards.This means that accurate planning of the national energy system is required to ensure a reliable electricity supply in the future.
So far, the national system has presented high reliability and has successfully allowed the integration of a large share of RES with little generation curtailment [46].Fig. 2 presents the peninsular installed capacity in 2020.During 2019, the installed power from RES has experienced a growth of 13.4%, with the entry into operation of more than 6500 MW of new RES.In this way, RES now represent 50% of the installed generation capacity in Spain.Electricity generation and consumption peaked in 2008.After booming for years, 311 TWh were consumed that year.The 2008 financial crisis meant the start of a decreasing trend in electricity consumption.In 2019 the electricity demand in Spain accounted for 264.55 TWh [47], 37.5% of which came from RES (20.9% from wind, 5.5% from PV and solar thermal, 10.3% from hydro).

PNIEC
The measures described in the Spanish "Plan Nacional Integrado de Energìa y Clima" (PNIEC) are supposed to lead to the achievement in 2030 of a series of decarbonisation targets within the whole energy value chain.Since the focus of the study is on the power sector, the target set in terms of integration of RES is 74% of the electricity generated (starting from 37.5% in 2019), as in the PNIEC.Table 1 illustrates the national generation system in the upcoming years, specifying all the technologies and distinguishing between Target Scenario and Baseline Scenario, as in the PNIEC [34].
With regards to the 2030 Target Scenario, and compared to 2015, the evolution of the RES is evident.An increment of +32 GW (653% relative growth) of solar photovoltaic followed by +27 GW of wind (120% relative growth), complemented by an additional capacity of 3.5 GW pure pumped-hydro energy storage (PHES), 5 GW of Concentrated Solar Power technologies (CSP) and 2.5 GW of batteries with a maximum of 2 h' storage at full charge.Nevertheless, the precise composition and operation of storage systems is not detailed.
Between 2021 and 2030, the planned closing of electricity generation from all coal-fired power plants will continue, phasing out a total capacity of 11 GW.Nuclear will undergo the same phasing out process, whose reactors' closure is foreseen to start in 2025 and to be completed by 2035.

Renewable energy sources hourly capacity factors
For the elaboration of the plan, the energy generated from RES is calculated by considering specific hourly capacity factors (CF) for each technology.Table 2 illustrates the annual operating hours of the main technologies, as shown in the PNIEC.
To verify the robustness and reliability of the planned infrastructure, the model has been simulated also assuming different capacity factors.Specifically, the planned infrastructure for 2030 has been tested, assuming that the specific output of the installed capacity resembled the output historically registered and elaborated from data downloaded from Refs.[36,47].
Analysing data representing the renewable energy generated from January 01, 2016, 00:00 to December 31, 2019, 23:50 in Spain, in parallel with the capacity installed, the hourly capacity factors of each technology have been obtained for a total duration of 35,040 h, or rather 4 years, by means of the following formula: However, since data corresponding to the capacity installed is available only for the last day of the year, a linear correlation was adopted between the capacity installed year to year.In 2016, 2017 and 2018 reasonable values for the capacity factors of each technology were found.In 2019, due to the deadline for the project delivery of the installations that won the previous auctions, several plants were put in place in the last few weeks of the year.This is particularly relevant for PV installations that in 2019 increased their total capacity by 89%.Again, a linear correlation was used to find reasonable capacity factors for the year, but the year was split into three time periods to account for the faster deployment during the last part of the year.
Looking at Fig. 3, the annual operating hours indicated in the PNIEC [34] seem quite optimistic.Even though technology may advance, and capacity factors may increase, they would have to improve significantly to outperform current power plants, which have already occupied the best spots, and to compensate for the loss of performance of existing plants.

Simulations
The time frame for the simulations is four years, with a resolution of 1 h.Smaller time frames were tested but seemed to distort the results, mainly due to the sensitivity to RES output.Instead, simulations based on longer time frames (i.e., ten years) present results only slightly different -supposedly more precise -but computationally far more complex to be obtained.For the scope of the study, a 4-year time frame was selected as a good trade-off between the accuracy of results and the time required for the script to find the optimal solution.
The expected electricity demand used in this analysis comes from the Fig. 2. Spanish capacity installed and generation per source in 2020.Own elaboration based on [48,49].Hydro includes pumped hydro, with a total installed capacity of 3331 MW.European Network of Transmission System Operators of electricity (ENTSOE-e), which published different scenarios for each country in which its members operate [51,52].The ENTSO-e scenario selected is the DG scenario, as the Spanish PNIEC is built around this case, too, allowing a clear comparison.The three different climatic variations presented by ETNSO-e are considered by queuing them up, repeating the first year to obtain a 4-year time frame.This is done to assess a different demand profile over the years, considering more extreme weather events combined with different demand curves.Since the simulations are focused on the peninsula energy system, under the assumption of the single node, the demand from ENTSO-e is reduced by the electricity consumption in the Canarias Islands, hypothesising a Compound annual growth rate (CAGR) of 1% from the current consumption.
A series of simulations are run to assess whether the Spanish energy strategy's objectives can be reached using the planned infrastructure.This is done by comparing the generation capacity planned according to  the PNIEC and the historical one to evaluate if energy storage and conventional generation sizing is correctly planned.The model the maximum amount of required RES generation in the system according to Eq. ( 14).Varying from 50% to 100%.Another series of simulations is based on the generation capacity existing at the end of the year 2020, evaluating the best combination of new generation and energy storage capacity required to reach the objective of the PNIEC, to evaluate whether the optimum implied a different combination of technologies.Regarding the assessment of storage technologies, the model considers Lithium Ion batteries, PHES, and hydrogen storage.These technologies are selected due to their degree of maturity, the attention grabbed in the Spanish plans [34,53], and their position at a global scale to play a critical role [7].DR schemes are divided in Load Shifting, which include EVs, Heat Pumps, and Climatization, and Load Shedding, modelled in two ways as expensive and cheap industries.Table 6, Table 8, and Table 9 in the Annex detail the parameters for Storage, Load shifting, and load curtailment, respectively, used to model them.
In particular, since the exogenous and endogenous variables that can potentially impact future energy systems are countless, the simulations are performed under several scenarios of costs, demand and variation of other parameters to analyse their relative influence on the optimal solution.The sensitivity analysis, which focuses on the impacts on energy storage optimal capacity, is performed according to the following scenarios described in Table 3: Because of the discrepancies regarding the annual equivalent operating hours of RES illustrated above, all simulations run twice, once with the hourly capacity factor registered between 2016 and 2019 and once using the same historical series but adapted to reach the annual equivalent hours set in the national energy strategy.
Lastly, we run the model varying the RES integration target, moving from 50 to 100%, to assess how the capacity, and consequently the costs of the system's components increase while increasingly decarbonising the energy mix.For these simulations, we run the model with the RES hourly capacity factor registered between 2016 and 2019 and exclude nuclear energy.Fig. 4 summarises de model and all elements and parameters considered in the simulations and analysis.

Results and discussion
This section presents the results of the model applied to the Spanish power system under different scenarios and assumptions.Firstly, we show an overview of the results and validation of the model with the data of the plan.Then, we present the sensitivity analysis and the results of the pathway up to 100% RES system.Finally, we discuss these results and the policy implications arising from them.

Overall model comparison with the PNIEC
When getting all the data in the model, we can observe that the results of the projected capacity in the PNIEC and the ones obtained with the model are similar, especially with regard to the installation of wind, solar PV, and PHES.The major differences can be found in the CSPthe model results indicate it does not represent an economic viable optionand the electrochemical energy storage, whose participation is projected to be much greater according to the model.Fig. 5 shows the differences between the model results and the plan's objectives increase if we use the historical CF.As the historical factors are lower than the ones indicated in the PNIEC, when using historical CF, wind and solar energy requirements substantially increase.Accordingly, energy storage requirements increase with the increasing levels of RES, and Lithium-Ion batteries cover the gap as PHES reach their maximum.Besides, demand response has a significant role too, overlooked in PNIEC.Finally, it is important to note that power to gas (H 2 ) does not appear in the mix at any of these points, hence its deployment before 2030 in the electricity sector does not seem to be needed.

Sensitivity analysis of the results
Analysing the sensitivity to the parameters considered for the study, Fig. 6 presents the renewable power capacity, on the left, and the energy storage power capacity, on the right, resulted from the 32 simulations run considering the generation target capacities set in the PNIEC.In view of the observations done regarding the annual equivalent operating hours, the charts present two boxes for each technology, corresponding to historical and PNIEC's capacity factors, for a total of 64 simulations.Looking to the left of the figure, we can see how renewable energy generation capacity results to be sufficient to reach a 74% of share in almost all cases, with just a modest increase suggested by the model in terms of wind turbines' total power installed.In contrast, variations in PV technology are lower due to their more predictable and stable generation during the mid hours of the year and with a clear seasonal pattern.
Regarding energy storage, in almost all simulations, PHES reaches its expansion limits, with batteries providing the additional capacity and with no room left for Power-2-Gas, that in order to reach the target does not seem to be an economic viable option to decarbonise the electricity mix with 74% objective.The only cases in which PHES does not reach the 9.5 GW, that are set in the national energy strategy, corresponds to the simulations run with a reduction of costs for Lithium-Ion and hydrogen of 50% and the reduction of the expansion limits from the baseline scenario.However, the most interesting evidence that can be seen from the simulations is the Lithium-Ion capacity, that appears to vary quite substantially depending on the scenarios, and that is well above the 2.5 GW planned in the PNIEC, with values around 6.5 GW on average.
In a second series of simulations, we run the model starting with the generation capacity installed at the end of 2020.The results, displayed in Fig. 7, indicates that the RES capacities set as a target in PNIEC seem to be reasonable.Regarding wind generation, the model suggests  installing more power in almost all simulations, especially when considering the historically registered capacity factors.This compensates for the fact that in these simulations we not considering an increase in other RES generation capacity, such as biomass, due its expansion limit, whose assessment is out of the scope of this project.Besides that, the increase in wind capacity compensates for the decrease in CSP capacity, since the model suggests that no additional capacity from the one existing at the end of 2020 would have to be installed.This is no surprise since CSP does not seem a viable economic option when compared with wind and PV.As photovoltaics, the capacity is in line with the one set as a target in the PNIEC, even though it indicates higher values when considering the hourly capacity factors historically registered.
Energy storage capacity, as in the first series of simulations, sees PHES reaching its expansion limits in all cases, with batteries providing the additional capacity.Again, Lithium-Ion capacity appears to vary quite substantially depending on the scenarios, with values around 7 GW on average.

Towards a 100% renewable energy system
The results presented in Fig. 8, indicates that, as RES, wind generation represents the most interesting source to decarbonise the energy mix, mainly thanks to its generation profiles, whereas, as energy storage is regarded, besides the considerations already presented in previous paragraphs, the usage of the hydrogen vector as a storage energy system does not represent a good option unless the target is the complete decarbonisation of the electricity mix, for which long-term energy storage is required.
Analysing the hourly energy balance to assess the macro results of the installation of such capacity, Fig. 9 shows the evolution of the energy stored and curtailed.We found that, while decarbonising the energy mix, the amount of energy stored on a yearly basis increases substantially, moving from 17 TWh with a 50% RES target to 80 TWh with zero emissions.The energy curtailed, instead, does not appear in relevant measure until an 80% RES integration, for which the model suggests that 5 TWh would need to be curtailed in the economic optimal configuration.Nevertheless, what deserves special attention in this figure is the increase of RES curtailment to make the last steps towards a complete decarbonisation, for which the model indicates that 225 TWh would need to be curtailed (100% RES).
Going more in depth in the economics implications of decarbonising the energy mix, the following Fig. 10 presents the evolution of the system costs for the additional capacity to be installed on top of the one existing at the end of 2020 in parallel with the CO2 emissions.These have been calculated considering an emission factor of 0,206 kg/kWh and a 50% efficiency of the power plants.Since Natural Gas technology is the only conventional technology considered, CO2 emissions decrease is linear, whereas the costs of the system increase assuming almost an exponential trajectory.This can be seen clearly when focusing on the cost per tons of CO2 avoided while moving to the next target, represented by the line in Fig. 10.This deserves special attention since, even though in the model we do not consider grid expansion/reinforcement costs, nor the costs of financing for the additional capacity, we found that moving from 90% to 100% the costs of decarbonisation would pass 800 €/tonsCO2.This increase is mainly attributable to the necessity of storing energy for long periods of time, thus requiring high investments in H2 and consequently in generation capacity to off-set the increased inefficiency.This correlates with already published research arguing for the need of firm generation technologies as a way to reduce costs in fully decarbonised systems [4].However, an interesting aspect that emerges is that 25 €/tonsCO2 represents the additional cost of reaching a 70% renewable integration, far below the price at which the allowances in the EU ETS were trading in 2021.Nevertheless, achieving a 100% decarbonised power system will have huge costs with the current technology costs, besides having to deal with RES curtailment.This non linearities of the system represent the economic burden to achieve 100% RES scenarios under the current technological development [9].Fig. 8 shows how wind capacity more than doubles to achieve a 100% RES scenarios, wind overinvestment and curtailment results cost competitive due to the large costs of seasonal storage.Again, this remark correlates with other studies as the extra need of wind over solar for a fully decarbonised system [27], or the potential role that firm technologies might have on the system [4,20].

Storage requirements sensitivity to demand response
Among the results presented in the previous paragraph, it was worth digging into the sensitivity of storage capacities to DR parameters variation.Since PHES requirements do not change in almost any  scenario, confirming to be the best technology to store energy, we focus on the required power capacity of Lithium-Ion technologies.Fig. 11 shows the differential vs the baseline scenario, according to which GW of Li-Ion power capacity would have to be installed to reach the objective of 74% of ren integration with an optimal energy system.
As DR costs are regarded, a decrease in excess of 25% seems to have only a marginal impact on Li-Ion requirements.Li-Ion capacity decreases by the same order of magnitude when increasing the expansion limits of DR, even though in this case the difference between 25% and 50% is greater.What is interesting to notice, is the asymmetry between increasing and decreasing the expansion limits of DR.The results indicate that a failure in implementing adequate demand response scheme could cause a notable increase in storage requirements.
Looking now at Fig. 12, the sum of the load shifted and curtailed on average on a yearly basis is displayed, showing the increasingly important role played by DR schemes while increasing the RES targets.According to the results, DR seems to be especially relevant with 90% of RES integration as a target.The explanation stays in the adoption of H 2 as an energy vector.Indeed, because of the high costs that Hydrogen entails, the model attempts to avoid adopting this technology, favouring any other alternative.Ultimately, moving towards a fully decarbonised power sector, H2 is required, as per Fig. 8, and the usage of DR drops, since the extra storage capacity, both Lithium-Ion and H 2 , would be required even if maximising load shifting/curtailing.
Finally, considering that an effective deployment of DR measures require the electrification of other sectors, e.g.heating and transportation, and that the electrification has as side effect the increase in efficiency, it is evident that DR deserves special attention to decarbonise the system in the most cost efficient way as it has a role as shown in other studies [54,55].In that sense, efforts should be made to increase the efficiency of DR and facilitate its wider adoption and competitiveness with other energy storage technologies that provide flexibility.

Discussion of the results
The impacts of the transformations of the electricity system from a fossil fuel based to one with a major share of RES will have vast economic and policy implications.First, transitioning from current levels to almost 80% penetration will have a far smoother way than going above these levels, specially, going above 90% penetration in the mix.Moreover, this transition is surrounded by uncertainties and parameter variations regarding technological advances, cost fluctuations, climate patterns change, and demand projections among others.All of them suggest a need to plan in more detail the strategic plans in order to deploy the necessary policy instruments and investments at the right time in order to profit from technological innovations and cost reductions without lagging from the overall objective.
Second, when planning the decarbonisation of electricity systems, policymakers ought to consider the role that demand flexibility and demand response can have in the system [56].We demonstrate that these actions and changes can have an important role that provides value to the system and is complementary to energy storage deployment, while preventing or alleviating rebound effects of the change of technology.Moreover, activating demand can also provide flexibility for energy storage and future grid investments, which can accommodate to   timely planned auctions and installation [57].Therefore, ensuring the reliability needs required by the system within a yearly perspective.Regarding energy storage technologies, our model does contradict the hydrogen Spanish plan that states that will have a role in providing flexibility to the system before 2030 [53].Our simulations show that hydrogen might play a critical role in providing season energy storage capacity to power systems, but this will only occur at the last mile of decarbonisation, as its costs and low efficiency make it not cost competitive otherwise.
Regarding energy and cost efficiency for the full decarbonisation of the system, curtailment of renewable energy generation appears as a critical element to discuss about.With increasing emission reduction objectives, curtailment starts to become increasingly useful under an economic optimisation perspective.In this context, two major concerns arise.First, if is efficient and the system should curtail RES based electricity, or we should target consumption to accommodate to those peaks and electrify new flexible sector.If so, we need to study what types of consumption are suitable for this strategy and if they are technically and economically viable to operate with such patterns.Second, if so much electricity is going to be curtailed, the system and the market need regulation and clear frameworks to cope with these situations sharing the burden among all the actors.
Finally, we raise awareness about some optimistic assumptions presented in the initial Spanish plan that might overestimate RES production on the long run, for example the capacity factors.Thus, extra capacity will be required to achieve the stated objectives.We suggest also to perform and provide these plans' results with a wider range of scenarios and potential outcomes, as single capacity installation objectives can be misleading and tight to manoeuvre with flexibility in an ongoing transition.

Conclusions
The study hereby presented proposes a model to optimise the Spanish electricity system required to integrate cost-effectively high shares of RES using the national strategic plan as a baseline and comparison.A linear optimisation model is applied to evaluate the energy storage cost-effective requirements to different costs and development scenarios.Energy storage is a major contributor to the future reliability of the power grid, and identifying the correct requirements to balance the future decarbonised energy system is particularly important.Thus, the model has been developed to also assess the sensitivity of the results to variations in the uncertain parameters, so that scenarios can be designed and evaluated.
The Spanish case study differs from many European countries that are also engaged in the energy transition due to its low interconnection capacity.However, the trends and results obtained are similar to other country-specific studies.Based on the model results, we conclude that energy storage will become a fundamental player in electricity systems with high RES penetration.In fact, even though its network-related value -such as the contribution to congestion management -is not considered here, the optimal capacity to deal with the intermittency of RES exponentially increases while increasing the decarbonisation targets.Assessing the different scenarios, we find that PHES plays a central role in the future of the grid.In almost all simulations, the results recommend the installation of the maximum potential set as an upper limit.
For this reason, potential further expansions by looking to new sites should be considered.Regarding hydrogen, the application of this vector for decarbonising the electricity system is not competitive with the other options.Instead, the batteries' capacity set in the national strategy seems to be underestimated, with the model indicating higher requirements in almost all simulations, making of Li-Ion batteries a key element of the system.
Analysing the sensitivity of each system component, we found that Lithium-Ion is the technology whose optimal capacity is more uncertain, depending strongly on its own cost development, on the demand's profile, and on the cost and availability of other flexibility options.Additionally, we found that the national energy strategy to achieve the decarbonisation goals seems to be based on quite optimistic assumptions, especially regarding renewable energy output.According to our simulations, the energy mix could be improved, especially closely monitoring the evolution of RES and energy storage costs.Furthermore, using the hydrogen vector as a flexible tool for the electricity sector becomes necessary only to reach a penetration of RES of 100% but further efforts need to be done to include other flexibility options as DR.Finally, all these outcomes are based on the values given to the parameters and thresholds of the model (see Annexes).Therefore, as evidence of new technologies arise and parameter values change, the model can be easily adjusted and run again.
The analysis focuses on the electricity system because it is one of the main sources of GHGs.In addition, the European Union has committed to the electrification of cities, mobility, etc., for its decarbonisation objectives, so the electricity sector will increase its role in the energy mix and global emissions.Finally, the results should be considered with caution and used to help improve policy-making and energy planning in the long run with more temporal granularity.In this regard, the model raises questions regarding the regulatory framework of renewable energy curtailment, energy storage needs, and capital deployment on the system.Timely ordered rates of energy storage deployment would help to reduce the costs of this technology and avoid jeopardising the decarbonisation of the system.Regulatory frameworks need to be created in the sweet spot that allows fostering the deployment of energy storage systems without leading to neither over-incentivising nor causing technological lagging of the national power systems.Trade-offs and detailed analyses should focus on these topics.

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.

Table 7
CCGT parameters used for the simulations (base case values and sensitivity range) [38,39].

Table 8
Load curtailment parameters used for the simulations (base case values and sensitivity range) [15,62].

Fig. 4 .
Fig. 4. Model overview in the analysed case study.

Fig. 5 .
Fig. 5. Results of the installed capacity under the base scenarios with different capacity factors.

Fig. 6 .Fig. 7 .
Fig. 6.Sensitivity analysis of the installed RES and energy storage capacity considering the PNIEC's RES installed capacity as a minimum.

Fig. 8 .
Fig. 8. Evolution of the installed capacity under different decarbonisation objectives.
conclude that dispatching different storage technologies depends on the other available (15)limited by the power installed P ff multiplied by the factor (1 − U f ), which represents the reduction of available capacity due to maintenance, blackouts or any other problem in which these plants can incur.The problem and the code are formulated to consider different nonrenewable energy generation sources, which allows for either to simulate with different CAPEX and OPEX (such as open cycle gas turbines and CCGT) or the same technology but with different dispatch strategies that affect the ramp rate and the maintenance and operational costs (CCGT used with either slow or fast start-ups), see equation(15).
the equation, assuming that at the beginning of the simulation, no energy has been "cumulated" for the shifting of the load. is limited by the maximum capacity of each technology, as the product of output capacity LS Capacity and its maximum duration LS Max .

Table 2
[50]al operating hours assumed in the national energy plan[50].

Table 3
Considered Scenarios in the simulation.