*4.1. Day-Ahead Market Offering*

The inputs for the day-ahead market offering include the price and power generation forecasts for the next day generated at 12:00 PM and the plant assets' parameters. The optimization problem is subject to the following constraints:

1. The charge power cannot be higher than the nominal value:

$$P\_{ch}(h) \le P\_{nom,BESS} \cdot \phi\_d(h),\tag{11}$$

where the following apply:


2. The discharge power cannot be higher than the nominal value:

$$P\_{dis}(h) \le P\_{nom,ESS} \cdot \Phi\_{\mathbb{C}}(h),\tag{12}$$

where the following apply:


$$P\_{\rm ch}(h) \ge 0.\tag{13}$$

4. For optimization algorithm simplicity, the discharge power is also always positive:

$$P\_{dis}(h) \ge 0.\tag{14}$$

5. The simultaneous charge and discharge is not possible:

$$
\phi\_{\mathcal{C}}(h) + \phi\_d(h) \le 1. \tag{15}
$$

6. The energy stored at the end of each period is calculated as follows:

$$E(h) = E(h-1) + \left(P\_{ch}(h) \cdot \mathfrak{f} - \frac{P\_{dis}(h)}{\mathfrak{f}}\right),\tag{16}$$

where the following apply:


$$E(h) \ge 0.\tag{17}$$

8. The BESS cannot discharge if its participation in the day-ahead market is disabled; this constraint is activated depending on the case of study:

$$P\_{\rm dis}(h) = 0.\tag{18}$$

9. The power flow of the plant is defined as follows:

$$P\_{\mathcal{S}^{\rm ren}}(h) = P\_{\mathcal{s}}(h) + P\_{\rm cl}(h), \tag{19}$$

where the following apply:


The following objective function seeks to maximize the income:

$$\max \left\{ \sum\_{h=1}^{24} \Pi\_{DM}(h) \cdot \left( P\_{\mathbf{s}}(h) + P\_{\text{dis}}(h) \right) \right\}. \tag{20}$$

The objective of this function is to maximize profits through the generation of the optimal schedule based on forecasted energy and prices. Deviations are not accounted for in this optimization problem and are addressed in the intraday market optimization. The output of this offering strategy is the hourly schedules for the following day, which serve as input for the next optimization problems.

As it can be seen, the BESS does not purchase energy from the market. As per the regulations of the Renewable Energy Economic Regime [21], a BESS is not allowed to purchase energy from electricity markets when operating in hybrid plants.

#### *4.2. Intraday Market Participation*

The intraday market participation aims to adjust the hourly schedule in the case of expected deviations. It does so through two means: selling expected excess energy if enabled and purchasing energy in case of expected downward deviation. The optimization function takes the following inputs: committed hourly schedules, generated power prediction, deviation costs, intraday market prices, and the expected state of charge at the beginning of delivery.

Each intraday market session occurs three hours before delivery, as shown in Table 1. The expected SOC at the start of delivery is communicated by the tertiary control level. The constraints for this optimization are the same as those for the day-ahead market scheduling problem, with the addition of the following constraints:

1. The upward deviations are

$$
\lambda\_\uparrow(h) = P\_{\text{PCC}}(h) - P\_{\text{sch}}(h) \, \tag{21}
$$

where the following apply:


$$
\lambda\_\downarrow(h) = P\_{\rm sch}(h) - P\_{\rm P,C}(h)\_\prime \tag{22}
$$

where the following applies:


$$
\lambda\_\downarrow(h) \ge 0.\tag{23}
$$

4. The same happens with upward deviations:

$$
\lambda\_\uparrow(h) \ge 0.\tag{24}
$$

As can be seen, when one type of deviation takes place, the other is equal to zero. 5. The hourly deviation costs are

$$
\lambda\_{\text{cost}}(h) = \lambda\_\downarrow(h) \cdot \rho(h) - \lambda\_\uparrow(h) \cdot \beta(h), \tag{25}
$$

The deviation penalty and bonuses are calculated from expressions (3) to (5). The intraday optimization uses real day-ahead market prices, available at the time of the intraday market. The deviation coefficient is set at 21% and the average is from 2017, and it is used only as an assumption at this stage, while historical deviation coefficients are used later to calculate real benefits.

6. The internal power flow constraint depicted in (19) is modified:

$$P\_{\mathcal{S}^{\rm ren}}(h) = P\_{\mathcal{S}}(h) + P\_{\mathcal{ch}}(h) + P\_{\text{del}}(h) + P\_{\text{curt}}(h),\tag{26}$$

where the following apply:


The generated power is allocated to either cover expected deviations or to maximize profits in the intraday market.

7. The constraint regulating stored energy is a modification of (16) as follows:

$$E(h) = E(t - 1) + \left(P\_{cl}(h) \cdot \xi - \frac{P\_{dis}(h) + P\_{dis,s}(h)}{\xi}\right),\tag{27}$$

where the following applies:

• *Pdis*,*s*(*h*): BESS power sold during hour h (MW).

This division of discharged power into two parts—one used to cover deviations and one used for arbitrage—is similar to the division of generated power.

8. If arbitrage in the intraday market is disabled, the following constraints are applied:

$$P\_{dis,s}(h) = 0.\tag{28}$$

$$P\_s(h) = 0.\tag{29}$$

9. The PCC output power is computed as follows:

$$P\_{\rm PCC}(h) = P\_{\rm dcl}(h) + P\_{\rm dis}(h) + P\_{\rm \mathcal{P}}(h),\tag{30}$$

The intraday market purchased power is not physically received by the plant and serves to fulfill commitments in the day-ahead market in case of deviations. It is therefore not included in the PCC output power constraint, which measures expected deviations. The exchanged power is part of the scheduled power vector input for the subsequent intraday market optimization, as shown in the constraints represented by expressions (21) and (22).

The objective function is defined in (31) with two goals: minimizing expected deviations and maximizing profits through energy trading.

$$\text{Max}\left\{\sum\_{h=1}^{ID\_{len}} \Pi\_{ID}(h) \cdot \left(P\_s(h) + P\_{dis,s}(h) - P\_\varphi(h)\right) - \lambda\_{\text{cost}}(h)\right\},\tag{31}$$

where the following applies:

• *IDlen*: Intraday market length.

The hourly commitment vector is updated using the outputs of the intraday market optimization problem:

$$P\_{Sch,new}(h) = P\_{Sch,prev}(h) - P\_{\mathcal{P}}(h) + \left(P\_{\mathcal{S}}(h) + P\_{dis,\mathcal{S}}(h)\right) \tag{32}$$

where the following apply:


#### *4.3. State of Charge Emptying*

As previously discussed, the secondary control level sends generated energy to the grid when the BESS is full and hourly commitments are fulfilled, leading to an upward deviation. The market operator only pays for excess energy at the day-ahead market price when the deviation is in favor of the system, as described in Equations (2) and (3). This can result in a missed opportunity to sell energy at higher prices when the deviation is against the system.

Moreover, the highest calendar degradation occurs when the BESS is full, as shown in Table 2. A new operating mode is proposed that involves selling part of the stored energy on the nearest intraday market when the BESS SOC exceeds a set threshold. This service differs from intraday market arbitrage in the following ways:


In Figure 7, the operating hours of the proposed service are shown, marked in blue, over the delivery hours of the intraday market, which are represented as white bars.

**Figure 7.** SE service operating hours.

This service splits the BESS into two virtual energy storage systems (VESS), one for profit generation and the other for deviation reduction. The stored energy is divided with a threshold of 75% set for the SE service. This value was determined through testing various values in the study and was found to be the optimal balance between profits and deviation reduction.

$$SOC\_i = SOC\_{SE} - SOC\_{thr\_{thr}} \tag{33}$$

where the following apply:


The SE service is managed as an optimization problem identical to the one for intraday market participation but limited to the first hours of the next intraday market. The variables used for deviation coverage are disabled as the objective of this service is solely profit generation. The objective function is as follows:

$$\max \left\{ \sum\_{h=1}^{SE\_{len}} \Pi\_{ID} \cdot P\_{SE}(h) \right\}\_{\prime} \tag{34}$$

where the following apply:


The goal is to sell available energy at the most expensive hours. The scheduled power vector is updated as in (32).

$$P\_{\rm Sch,new}(h) = P\_{\rm Sch,prev}(h) + P\_{\rm SE}(h) \tag{35}$$

#### **5. Simulations and Results**

In this section, the simulation scenarios are presented, each showcasing a different approach to using the BESS on the HF. Each scenario involves simulating the HF with the respective approach operating during 2018 in the Iberian electricity markets. The aim is to compare and assess whether revenue-stacking is more efficient than focusing on individual services, and the performance of the proposed service.

At the end of each day, the accumulated degradation and SOC serve as initial values for the following day's operation. The average daily profits and degradation under each scenario are used in a full project extrapolation for a comprehensive view of the different cases.

#### *5.1. Simulation Cases*

The simulation cases used are the following:


#### *5.2. Simulation Results*

The simulation was conducted using the same input data in each case. Expected profits were calculated by summing the earnings from day-ahead and intraday market commitments and real prices. Real profits were calculated as the difference between daily earnings (Equation (9)) and daily losses (Equation (10)) using historical data of electricity prices and deviation coefficients. Figure 8 displays the accumulated profits and costs for each scenario, and Table 3 shows the numerical results.

**Figure 8.** Simulations results.

**Table 3.** Numerical results.


The results indicate that expected profits increase with intraday market arbitrage, as anticipated. These profits are calculated based on the delivery of all committed energy to the market, resulting in higher profits in scenarios with intraday market participation as all expected energy excess can be sold. The worst expected outcomes occur in scenarios without intraday market participation, and similar results are observed when the BESS performs capacity firming.

The deviation costs are negative in almost all scenarios, indicating when upward deviations are more frequent. Purchasing energy in the intraday market effectively avoids downward deviations. The fewer services the BESS provides, the greater the negative deviation costs, suggesting that the BESS tends to be fully charged most of the time, leading to upward deviations.

Purchases in the intraday market are the primary cause of profitability losses. These costs are significantly higher with intraday market participation. The fact that intraday market purchases occur when the BESS cannot cover expected deviations highlights that increased BESS involvement in markets can have negative effects.

Committing more energy to various markets increases the risk of having to make corrections by purchasing energy in the intraday market. The best results seem to be achieved by letting the BESS operate solely in the day-ahead market or providing capacity firming services. As shown in Figure 9, intraday market participation has resulted in the need to cover up to 40% of committed energy through intraday market purchases.

**Figure 9.** Committed energy covered with purchases in intraday markets.

Figure 10 displays the accumulated degradation. In scenarios where the BESS provides the most services, it tends to be emptier, which reduces calendar degradation and results in lower overall aging of the BESS.

**Figure 10.** Degradation in each case.

Figure 11 shows the comparison between real profits and degradation. It reveals that reserving the BESS for SOC emptying and capacity firming yields the best outcome when profits are compared to capacity loss, which indicates a more efficient usage of the BESS.
