Optimal Battery Energy Storage Dispatch for the Day-Ahead Electricity Market

: This work presents an innovative application of optimal control theory to the strategic scheduling of battery storage in the day-ahead electricity market, focusing on enhancing profitability while factoring in battery degradation. This study incorporates the effects of battery degradation on the dynamics in the optimisation framework. Considering this cost in economic analysis and operational strategies is essential to optimise long-term performance and economic viability. Ne-glecting degradation costs can lead to suboptimal operation and dispatch strategies. We employ a continuous-time representation of the dynamics, in contrast with many other studies that use a discrete-time approximation with rather coarse intervals. We adopt an equivalent circuit model coupled with empirical degradation parameters to simulate a battery cell’s behaviour and degradation mechanisms with good support from experimental data. Utilising direct collocation methods with mesh refinement allows for precise numerical solutions to the complex, nonlinear dynamics involved. Through a detailed case study of Belgium’s day-ahead electricity market, we determine the optimal charging and discharging schedules under varying objectives: maximising net revenues, maximising profits considering capacity degradation, and maximising profits considering both capacity degradation and internal resistance increase due to degradation. The results demonstrate the viability of our approach and underscore the significance of integrating degradation costs into the market strategy for battery operators, alongside its effects on the battery’s dynamic behaviour. Our methodology extends previous work by offering a more comprehensive model that empirically captures the intricacies of battery degradation, including a fine and adaptive time domain representation, focusing on the day-ahead market, and utilising accurate direct methods for optimal control. This paper concludes with insights into the potential of optimal control applications in energy markets and suggestions for future research avenues.


Introduction
According to the latest prediction from the European Commission, the percentage of electricity generated from renewable sources such as solar and wind will increase from 37% in 2020 to over 60% by 2030 [1].In March 2023, the European Commission proposed a reform of the electricity market in the EU as part of its ambitious goal [2].This reform aims at providing more resilience to the market.It enhances the protection of the consumers by using more long-term contracts, such as power purchase agreements, improving the energy pricing policies and support of investment and encouraging economic growth.The reform clarifies the main principles for trading in the day-ahead and intraday markets.It introduces new rules for procuring transmission systems for peak-shaving products, which reduces short-term demand spikes.It also introduces new provisions for forward electricity markets to improve liquidity and incentivises the role and use of longer-term contracts in power purchase agreements and two-way contracts for difference.Moreover, it provides new rules for assessing flexibility and the possibility to introduce flexibility support schemes.
Electricity prices in a deregulated power system, such as the European system, are determined by market players who consider the supply and demand of electricity.The most common market type is the day-ahead market, where electricity trading involves buying and selling electricity the day before the actual production and delivery [3].The price structure of all market transactions is established through the analysis of all supply and demand bids.A power producer looking to enter the day-ahead electricity market aims to maximise their profits while ensuring reliable delivery of electricity, something they strive to achieve by optimising their production schedule and pricing strategy to sell electricity at the highest possible price while managing their operational costs and adhering to regulatory requirements and grid reliability standards.Various models and algorithms have been proposed to analyse bidding strategies in the literature.
Battery storage plays an increasingly important role in the day-ahead electricity market by leveraging its unique attributes-such as flexibility, fast response, and the ability to capitalise on price differentials-to enhance the operator's market position, support grid stability, and contribute to the transition towards a more sustainable energy system.Their profitability lies in strategically purchasing energy during periods of low prices and storing it in the battery, subsequently capitalising on higher market prices by selling the stored energy and discharging the battery.The battery degradation cost in each charge/discharge cycle is often overlooked or not adequately addressed while designing the control policy for the battery's participation in the market.Since this degradation cost is hard to assess and varies greatly depending on operational conditions, battery models usually rely on an empirical approach based on fitting measured degradation curves.These models have the advantages of being relatively simple and computationally inexpensive.
Optimal control is a mathematical theory that seeks to optimise a performance index associated with a dynamical system by choosing the time-domain profiles of independent variables called the control inputs.The theory and methods of optimal control have found application in a variety of areas ranging from aerospace, robotics, and process control to the management of commodity markets.By leveraging optimal control, battery systems can be operated to maximise revenue generation in electricity markets.The controller can rely on models and market forecasts to determine the best charging and discharging strategies that exploit price fluctuations and market opportunities.This approach enables the system to buy electricity at low prices and sell it back to the grid when prices are high, increasing profitability.Optimal control theory also allows the integration of multiple objectives into the decision-making process.For example, the controller can optimise revenue generation, battery longevity, and grid support services simultaneously.By considering multiple objectives and their trade-off, the controller can strike a balance that satisfies various system requirements and stakeholder preferences.Generally speaking, a generic optimal control formulation with battery degradation constraints can be utilised to mathematically describe the battery's profitable participation in the day-ahead electricity market.Despite its potential usefulness, this approach has been relatively underutilised in existing studies.One such study is presented in reference [4], which formulated the optimal control problem with an unconventional definition of battery degradation to examine energy dispatch in a wind farm.In contrast, the author of reference [5] formulated three optimal control problems to investigate the optimisation of profits in the day-ahead market.The author factored in the effect of battery degradation in the objective functional, which is considered in the optimisation process.Another approach is presented in reference [6], where the authors accounted for battery degradation by defining the state of health as an additional state variable and then considering it in the objective function.
Formulating the optimal energy dispatch accurately considering battery degradation is challenging and requires a well-designed modelling framework with a deep understanding of the battery's chemistry.A vast amount of the literature discusses the different types of battery models and their associated degradation phenomena.However, the majority of battery degradation studies are based on holistic approaches and involve results derived from laboratory experiments.
Numerical methods are indispensable to obtain a solution for models characterised by complex, nonlinear differential equations, such as the one proposed in this work.These methods can be divided into two main techniques, namely, direct and indirect methods, which are further discussed below.
Indirect methods depend on necessary conditions and can be helpful for specific issues.However, they have limitations, such as difficulty adding new constraints, constructing necessary and sufficient conditions in closed form, and determining the number of switches in the control variable.Direct methods involve converting the problem into a constrained optimisation problem that can be solved using efficient optimisation algorithms.Direct methods are more convenient than indirect methods because they do not apply optimality conditions directly.The are able to provide very good numerical accuracy with reasonable computational expense by using mesh refinement algorithms, sparse nonlinear programming solvers, and a variety of collocation methods to approximate the differential equations over a discrete mesh.
There are two main factors that influence trading patterns in the energy market.On the one hand, suppliers and generators prefer to secure trades early to reduce the risk of price fluctuations.On the other hand, more accurate information about supply and demand becomes available closer to delivery time.This is especially true for renewable energy sources, as well as updates on power plant outages.By taking these factors into account, traders can make well-informed decisions about when to buy or sell energy in the day-ahead market.Moreover, the price determination takes into account marginal surplus, which is the change in total surplus when one unit of costless supply is added [3].Several authors [7][8][9][10][11] optimise the dispatch strategy of battery energy storage systems in day-ahead electricity markets using highly simplified discrete-time models of the battery storage systems and relatively coarse time intervals between 15 min to one hour.
Our study assumes that the auction process has already taken place and the price has been settled.We use this information to determine the optimal energy scheduling for the battery charging and discharging strategy employing an optimal control methodology, taking into account the effects on degradation on cost and battery dynamics We focus on a case study aimed at maximising the profit from a battery's participation in Belgium's dayahead electricity market.We use an equivalent circuit model to represent a battery cell along with an empirical degradation model to consider the reduction of capacity and the increase in internal resistance resulting from degradation mechanisms.The work presented here extends the model, methods, and results given in [5] through the use of direct collocation methods with mesh refinement.We also incorporated the effects of degradation of the internal resistance, and capacity degradation in the model state equations.
This work is divided into six sections.Section 2 reviews the literature on battery models and numerical techniques to solve optimal control problems.Section 3 explains the day-ahead electricity price and defines the degradation model.Section 4 presents the problem formulation using an optimal control approach.Section 5 presents the problems' results using direct collocation techniques.Finally, Section 6 concludes this paper by offering final remarks and discussing future work.

Literature Review
The field of research that focuses on maximising profits when energy storage providers participate in the day-ahead electricity market is rapidly expanding.A recent study [12] solved a self-scheduling and redispatching optimisation problem.The problem formulation considers battery degradation and combines stochastic and mixed-integer linear programming.However, this technique is computationally expensive.Furthermore, other researchers have explored the same problem using simplified methods for mixed-integer linear programming, such as [13,14].However, these methods often overlook or oversimplify the expenses associated with battery degradation.
Only a few researchers have viewed energy dispatch as an optimal control problem.For instance, ref. [15] utilised model predictive control to optimise the operation of a leadacid battery and minimise the output power deviations from the predefined agreement.Additionally, the control method examined by the author proposed a heuristic technique to prolong the battery's lifespan rather than relying on degradation models.The technique reduces degradation by adding inequality constraints to the state of charge.In that manner, deep discharge and high values of the state of charge are avoided, increasing the battery life but limiting the use of the battery's full capacity.While the technique heuristically reduces degradation, the dynamics of the charge/discharge cycle are not considered.

Battery Models
Mathematical modelling is very useful for the study of a battery's behaviour and the optimisation of its operation when participating in the electricity market.While experimental testing is beneficial, it can be expensive and time consuming.The mathematical model of a real-world battery is often dynamic, complex, distributed, and nonlinear, although some simplifications are possible.
In ref. [5], the author delved into modelling and formulating an optimal control of lithium-ion batteries for the day-ahead energy market.Different profiles were suggested for optimising the battery energy storage system operation considering the price of electricity in Belgium's day-ahead electricity market.The proposed algorithm performs the necessary calculations to decide when to charge or discharge the battery and at what rate.Three different battery models were used to assess the effect of degradation: the bucket model, an empirical battery model, and a capacity reduction model.
An effective technique for simulating batteries is the holistic approach, which views the battery as a single entity rather than a collection of separated parts.The equivalent circuit model is an example of an empirical holistic model, where the model's parameters and components, such as battery capacity, capacitance, and resistance, along with the open circuit voltage function, are usually estimated by fitting the model predictions to experimental data.The simplicity of the model structure makes the equivalent circuit model easily accessible and widely used in various applications.With minimal computational complexity, this type of model provides valuable insights and predictions.Additionally, these models rely on historical data and empirical observations to validate and improve their predictions.By comparing the model output with real-world data, they can be fine-tuned and recalibrated for increased accuracy and reliability.
The empirical holistic battery model has been successfully used in battery simulation frameworks, as demonstrated in the work described in ref. [16], which does not consider battery degradation.In ref. [17], the authors also took a holistic approach to finding the best automotive battery; while acknowledging that previous studies have shown the effects of electrothermal load and time on battery ageing, their study did not address degradation in the problem formulation.In contrast, ref. [18] created a comprehensive model for a specific battery that considers both cycling degradation and calendar ageing.While the model is limited to a specific chemistry, its application can be extended to numerous other applications.

Degradation Models
Degradation of lithium-ion batteries is typically caused by the formation of a passive film on the negative electrode, known as the solid electrolyte interphase.When a battery operates, especially in the initial cycles, reactions occur at the interface between the electrodes and the electrolyte.These reactions involve the decomposition of the electrolyte and the subsequent creation of a thin layer.This layer acts as a barrier, preventing further electrolyte decomposition and reducing undesirable side reactions like dendrite formation or the dissolution of active electrode materials.However, this thin film leads to capacity fade and reduces lithium inventory.The internal reactions in the battery usually result in the deposition of solid products that depend on the electrolyte's composition.
High temperature is a crucial factor that significantly affects the growth of the solid electrolyte interphase.However, the relationship between temperature and solid electrolyte interphase growth is complex and depends on several factors, including battery chemistry, electrode materials, electrolyte composition, and operating conditions [19].
Although a simple equivalent circuit model can explain the internal electrochemical reaction in a lithium-ion battery, modelling the degradation process presents some challenges.Thus far, several studies have investigated the degradation process using first electrochemical principles.The equations for degradation considering solvent reduction were developed by the work presented in reference [20].Moreover, a recent study [21] presented the equations for modelling degradation due to solid electrolyte interphase layer growth, lithium plating, stress, and loss of active materials using the pseudo two-dimensional model.
Detailed electrochemical processes cannot be predicted in any equivalent circuit model, and therefore, degradation can only be modelled empirically.The work by [22] is an attempt to use equivalent circuit techniques to model degradation.The formulation uses AI to predict degradation through a 2-RC model in a CC-CV charging profile.Although satisfactory results have been obtained, the approach for formulating an optimal control problem is challenging.In contrast, ref. [18] provides sufficient details to capture battery degradation using experimental data.

Cycling Ageing
Several studies predict a linear dependency between the reduction in battery capacity and the number of charge/discharge cycles to which it is subjected [23].However, in [24][25][26], the data showed that for all the charging/discharging current used during the cycle ageing testing, the model equations favoured a power law relationship pivoting very close to an exponent of value 0.5.The author of [25] argued that the dependency of time on the square root is a better representation of ageing mechanisms that involve diffusion and parasitic reactions than a linear dependency.Thus, it is generally accepted that Equation (1) establishes the relation between the capacity reduction during battery cycling, C cyl , and the charge passing through the battery: where β cap is the cycling ageing factor for capacity reduction and Q is the charge.On the other hand, it is widely accepted that the increase in the internal battery resistance is the primary factor contributing to the capacity loss of lithium-ion batteries [27].In line with previous studies, the authors of [28] reported that all the cells tested demonstrated a robust linear degradation behaviour independent of the testing conditions, with slightly more rapid fade at the beginning of the cycling.Moreover, in reference [29], the authors used a simple and relatively intuitive model to analyse the coupled effect of resistance growth and cycling ageing.They concluded that a linear model fitted the curve satisfactorily.Hence, it is generally accepted that Equation (2) represents the relation between the resistance increase during battery cycling, R cyl , and the charge passing through the battery: where β res is the cycling ageing factor for resistance increase.

Calendar Ageing
Calendar ageing is the natural deterioration of a lithium battery that occurs over time, regardless of usage.When the battery remains inactive, parasitic reactions in the anode material occur between the electrolyte and the electrode, resulting in lithium-ion loss and the creation of a solid electrolyte interphase layer [30].This thin film layer can raise the battery's internal resistance and decrease the battery capacity.Moreover, repeated charge and discharge cycles can intensify calendar ageing even at low levels.
In reference [18], the authors normalised the battery capacity, C, to apply a degradation factor based on calendar ageing.Moreover, it is indicated that the capacity varies with time, particularly with t 0.75 , according to the following relationship: where α cap corresponds to the ageing factor for the capacity to be determined using curvefitting techniques and t is the simulation time in days.
Similarly, as per the references cited in the literature [26,31], it is widely accepted that the primary reason behind the ageing of carbon-based anode materials is the formation of a solid electrolyte interphase.This thin film is created when the electrolyte breaks down and consumes lithium, leading to an increase in resistance.Following the model presented in reference [18], the increase in the resistance is also a function of t 0.75 according to the following relationship: where α res corresponds to the ageing factor for the resistance to be determined using curve-fitting techniques and t is the simulation time in days.The total degradation factor in the capacity and in the internal resistance due to calendar ageing and cycling is given in Equation ( 5): Furthermore α res and α cap are functions of the mean voltage V mean and ambient temperature T a , and β res and β cap are functions of the the root-mean square voltage V rms and the depth of discharge D od .These degradation measures quantify the amount of wear and tear that occurs on the battery's components as time passes and the battery goes through charge and discharge cycles, and are often used to assess the level of degradation and estimate the remaining lifespan or degradation tolerance of the battery [32,33].

Problem Statement
Electricity buyers and sellers in the real world are keenly interested in maximising their profits in the day-ahead electricity market, which spans 24 h and publishes prices a day before actual buying and selling.In order to comply with the energy trading market rules, the operator who sells energy should commit to selling a certain amount of electricity.These rules greatly depend on the country or the region where they apply, but essentially, the core rules that regulate market participants are remarkably alike.
This study uses an optimal control methodology to determine the most effective charge/discharge energy dispatch strategy for a lithium-ion battery energy storage system in the day-ahead electricity market.Direct collocation with automatic mesh refinement methods is employed to compare the optimal solutions of two battery models.This approach differs from the previous study reported in [34], which compared the optimal control trajectories resulting from the use of three different battery models without describing how the optimal control problems were solved.Our goal is to identify the battery's operational profile that maximises profit, measured as the difference between net revenue (considering the sale and purchase of electricity while discharging and charging the battery, respectively) and the cost of battery degradation.

Price Time Series
The European power market has two different pricing systems for buying and selling electricity.This policy states that electricity can be purchased more expensively in the balancing market compared to the day-ahead market.Conversely, electricity can be sold at a lower price in the balancing market compared with the day-ahead market [35].
The key is to maintain the grid balance at all times.Since imbalance costs are unavoidable, the operator must plan the price submissions carefully as they can incur higher prices due to imbalances.This market approach facilitates transactions for electrical energy by allowing generating company agents to submit bids for buying and selling energy for the following day.The market session occurs daily at noon Central European Time, where prices and energy volumes are determined for the next twenty-four hours.The intersection of supply and demand defines the price and energy volume for a particular hour.Therefore, price information for the day-ahead market is essential to plan market transactions that will occur the next day.
Our study chose a simpler approach than the one described in reference [34].In that reference, the problem was formulated using a combination of optimal control and model predictive control methodologies that extended the analysis beyond the day-ahead window, making the solution more complex.Instead, we only formulated the problem using an optimal control approach, focusing exclusively on the 24-hour period.For simulation simplicity, we assumed that the initial state of charge (S oC ) of the battery was 42%.
The price time series for this study is presented in Figure 1.The figure shows the day-ahead electricity prices in EUR/MWh from 00:00 to 23:59 on 6 June 2023 at precisely 1 h intervals, which were the most recent data at the time when this modelling work was carried out.The day-ahead electricity price for 2023 is available for download from the official European Network of Transmission System Operators website [36].

Formulation of Dynamic Models
As shown in Figure 2, an equivalent circuit model was postulated to formulate the empirical model with degradation.The equivalent circuit model does not rely on any thermal model to incorporate temperature effects.Its holistic approach considers these effects embedded in the experimental data.The holistic approach aims to comprehensively analyse experimental data and understand how various factors interact to shape observed outcomes then uses a parameter identification procedure to estimate the best fitting curve.This model achieves enough accuracy to estimate the output voltage, load current, and power flow.It also maintains a manageable computational complexity to predict internal degradation.
The state vector used to describe the equivalent circuit model is where x 1 is the state of charge, x 2 is the current through the resistance R p (A), and x 3 , x 4 , and x 5 are extra states used to determine quantities of interest, as described below.The control variable u is the current from the battery (A).The convention used in the model implies that u is positive when the battery is discharging and negative when it is charging.The model was partially extracted from [5] and augmented with three new state variables, namely, x 3 , x 4 , and x 5 , as shown in Equation ( 6): where C is the nominal battery capacity in Ah, C deg is the capacity degradation factor of Equation ( 5), and V(t) is the voltage across the battery terminals, given in Equation ( 7): where V OC is the function used to estimate the internal voltage, R deg is the degradation factor given in Equation ( 5), and R bat s is the internal battery resistance.The time dependency of the degradation factors C deg and R deg is shown, as both of them depend of the electric charge Q passing through the battery, which varies with time.
The state of charge versus V OC data points for a lithium-ion battery 18650 Li(NiMnCo)O 2 were digitalised from the reference [37] and a seventh-order polynomial was used to fit the curve.
Typical values for R bat p , R bat s , and C bat p are R bat p = 15.80 × 10 −3 Ω, R bat s = 8.2 × 10 −3 Ω, and C bat p = 38 kF [38].The transient behaviour of the lithium-ion cell is characterised by the product of R bat p and C bat p [39].States x 3 , x 4 , and x 5 are state variables required to estimate the RMS value of the terminal voltage V rms , the mean value of the terminal voltage V mean , and the total charge going through the battery Q(t), which is calculated as the integral of |u(t)| as follows:

Empirical Degradation Parameters
The research object of this work is the Sanyo UR18650E lithium-ion battery cell (Sanyo Electric Co., Ltd., Osaka, Japan), which has a cylindrical shape.According to the manufacturer, this cell is rated at C = 2.1 ± 0.05 Ah, and its nominal voltage is 3.6 V.The cathode active material consists of Li(NiMnCo)O 2 , and the anode material is made of graphite.The grid-connected battery energy storage system modelled in this work is assumed to be composed of 750 UR18650E battery cells, with a total nominal energy storage capacity of 5.67 kWh.The battery cells were assumed to be arranged in a series/parallel configuration.It is important to note that although the cells are assumed to behave identically to simplify the analysis, slight differences in behaviour have been observed even among cells from the same production batch [40].
The empirical degradation model considers two crucial factors: battery cycling and calendar ageing.The model was extracted from [34], also using information from [18].The model is based on the approach from Liaw et al. [41] in which a relatively simple equivalent circuit model simulates the battery performance and life cycling using a coupled thermal ageing model.However, all nonlinear parameters in the model were determined through empirical means.In the tests presented in [18], the authors found two different dependencies during cycling ageing analysis, one related to capacity reduction, or C deg , and one to internal resistance increase, R deg .
All the experimental data regarding battery capacity fading and resistance degradation used in this work were digitally obtained from reference [18].However, all the curve-fitting procedures were revisited, and improvements in the fitting quality were implemented, as explained below.
To begin with, we examined the reduction in battery capacity due to battery cycling.The relationship between the capacity reduction during battery cycling and the charge that passes through the battery is determined by Equation (1).On the other hand, the increase in resistance during battery cycling and the charge passing through the battery is determined by Equation (3).The experimental data set to estimate the parameter β cap were digitally extracted from reference [18].The data points are shown in Table 1.The data showed that β cap is strongly dependent on both the average battery voltage (V mean ) and the depth of cycle D oc .
In reference [18], the authors proposed a method for effectively linking the parameters β cap and β res with the voltage and depth-of-discharge cycle.They suggested a linear function combined with a quadratic function, and while this approach is reasonably accurate, we chose to use a different methodology.We opted for the bilinear interpolation function, a feature provided by PSOPT, the optimal control solver used in this work [42].We sampled the data based on voltage and depth of cycle, and the data points are presented in Table 1.
Table 1.Data points for the ageing factor β cap for different average voltages (V) and depth of cycle (D oc ).The data in the table were created using the WebToolDigitizer, release v5.The data were sourced from reference [18].Second, we considered degradation in the capacity via calendar ageing.Here, the battery capacity varies with time, particularly with t 0.75 , according to Equation (3).The calendar ageing data showed that α cap and α res strongly depend on the average battery voltage and the cell temperature T. Therefore, they can be approximated using a single two-variable interpolation function to fit both dependencies simultaneously.

Average
It can intuitively be observed from the graphs that α is linearly dependent on the voltage and follows the Arrhenius formula for temperature dependency according to the following equations: where the variables E a , T, and R are the activation energy, temperature in Kelvin, and universal gas constant, respectively.The parameter α cap is a combination of both results, as shown in Equation ( 13): Equation ( 12) can be transformed into a linear function using the natural logarithm function, as shown in Equation ( 14): The experimental data set to estimate the parameters α cap and α res was digitally sourced from [18] using WebToolDigitiser.Employing linear regression yielded the subsequent linear approximation: and exponential approximation: and finally, the parameter α T (T) is given in Equation ( 17): Equations ( 15) and ( 17) cannot be combined into a single equation, as suggested in Equation ( 13), because the two fitting functions, α T (T) and α V (V), do not match precisely for all the experimental data.Therefore, we use the technique proposed in reference [18].The approach is to average α T (T) and α V (V) at 323.15 K, where the two experimental curves intersect.The resulting value is named α ϕ , and it is used for scaling both fitting functions to a single one.Then, apply this scale factor to the final α cap equation.
From [18], α V (3.699V) at T = 323.15K is 0.0016368, and α T (323.15K) is 0.0001746702.Hence, the scale factor applied to α cap is given in Equation ( 18): Applying the scale factor to α T (T) and α V (V), the resulting scale factor that needs to be applied to the fitting function α cap is given in Equation ( 21): = 591.7278766 and Equations ( 15) and ( 17) with ( 22), provide the final expression for α cap (V, T) is given in Equation ( 23): The estimation of the total capacity lost considering cycling ageing and calendar ageing is the superposition of the C age as shown in Equation ( 1) and C cyl as shown in Equation (3).
A similar procedure was applied to find the values for degradation in the resistance, R deg .The experimental data set to estimate the parameter β res was digitally extracted from Figure 12b of reference [18].We used a bilinear interpolation function, which is provided in the optimal control solver, PSOPT.The data were sampled for different values of voltage and depth of cycle.The data points are shown in Table 2.
Table 2. Data points for the ageing factor β res for different average voltages and depth of cycle (D oc ).The data in the table were created using the WebToolDigitizer, release v5.The data were sourced from reference [18].

Depth of Cycle (D oc )
Voltage (V) 5% 10% 20% The data showed that β res is strongly dependent on both the average battery voltage (V mean ) and the depth of cycle D oc .
To obtain α res , we followed the same steps as before, with α ϕ being defined in Equation (18).Equation (24) provides the expression for α res : The estimation of the total resistance increase considering battery cycling and calendar ageing is the superposition of the R cyl as shown in Equation ( 2) and R age as shown in Equation (4).

Objective Functional Derivation
The objective functional, J for the empirical model, is shown in Equation ( 25): where u is the control variable, which is the current from the battery, x is the state vector, t f is the final time, and R ev is the revenue (or cost of energy purchase) per unit of time, given by Equation ( 26): where V(t) is the voltage defined in Equation ( 7), π(t) is a known price function that represents the actual price of energy in EUR/MWh at time t, N is the number of cells, and the 10 −6 factor converts the electricity price from EUR/MWh to EUR/Wh.Similarly, C deg is the degradation cost defined by Equation ( 27): where E lost,Wh is defined in Equation ( 28): where T a = 298.5K is the ambient temperature.As our mathematical model does not include a coupled thermal model, we approximated the average temperature during the charging cycle in the empirical equations as the ambient temperature.Substituting Equation (28) into Equation ( 27), then J is given in Equation ( 29): where the meaning of the variables and parameters in Equation ( 29) is given in Table 3.

Optimal Control Problem Formulation
An optimal control problem is typically expressed as follows: the goal is to find the optimal state trajectory x(•) ∈ R n and the open-loop control function u(•) ∈ R m in order to optimise the objective functional J over the interval t ∈ [t 0 , t f ].The initial and final time are denoted by t 0 ∈ R and t f ∈ (0, T f ] ⊆ R, respectively, and m, n ∈ N. The variable t ∈ R is the independent variable.The objective functional is given in (30): where Φ : R n × R × R n × R → R is the end cost, the integral term is known as the running cost, and the scalar function L : R n × R m × R → R is the integrand.The system is subject to the system state equations (i.e., dynamic constraints): A set of inequality constraints can be used to express the initial and terminal conditions.These constraints are also known as event constraints: The problem might also have time-dependent inequality constraints, often called path constraints: where L and U refer to lower and upper bounds, respectively.The functions f, e, and h are defined as per Equation ( 34): and r, s ∈ N.There are, in addition, bound constraints on the decision variables as given in Equations ( 35)-( 38): The day-ahead problem is formulated as a single-phase optimal control problem, with the phase contained in the time interval t ∈ [t 0 , t f ], where t 0 and t f are fixed.The aim is to find the control trajectory u(t), t ∈ [t 0 , t f ], and the state trajectory, x(t), t ∈ [t 0 , t f ], that minimises the objective functional, J, expressed in Equation (39), given the dynamics of the battery described in Equation (6).
where V(t) is defined in Equation (7), and ∆D = S max oC − S min oC within the relevant time window, where S oC is the state of charge of the battery.In this research, the definition of ∆D is based on the methodology described in [5].
The bounds for the states and the control are given in Equation (40): (40) where I max is the maximum current from the cell in one hour.
A path constraint is included to prevent under/overvoltage damage, given in Equation ( 41): The initial condition for the state vector is given in Equation ( 42): x(0) = [0.42,0.0, 0.0, 0.0, 0.0] T and t f = 24 h is fixed.

Direct Numerical Methods for Optimal Control
Typically, with a few exceptions, optimal control problems are solved using numerical methods.In this work, we chose to use direct methods for optimal control as they offer several advantages over other approaches, as discussed in [43].Direct methods for optimal control involve discretising the differential equations, constraints, and objective function associated with the problem and the numerical optimisation of the resulting nonlinear programming problem.Usually, nonlinear programming (NLP) methods are used for solving the resulting nonlinear programming problem.Different methods can be used to discretise the differential equations, constraints, and objective function, as discussed below.
Collocation methods consider the states and control variables as optimisation parameters, and the system of ODEs is regarded as nonlinear equality constraints in the discretised formulation.Then, a general NLP solver can produce a numerical solution to the discretised optimal control problem [44].There are various approaches to collocation, but primarily, they can be divided into two groups.The first one is grounded on an implicit k-state Runge-Kutta scheme, as described in [43,45].Euler, trapezoidal, and Hermite-Simpson are among the most widely used collocation methods, which use linear, quadratic, and cubic polynomial interpolation, respectively.
Suppose that the differential equations involved in the optimal control problem of interest consist of a set of state equations described as follows: where x : [t 0 , t f ] → R n defines the trajectory of the vector of state variables, u : [t 0 , t f ] → R m defines the trajectory of the vector of control variables, t represents time, [t 0 , t f ], t f > t 0 is a time interval, and f : R n × R m × [t 0 , t f ] → R n is a vector function that defines the state equations.Assume that a set of discretisation points is defined as follows: {t 0 , t 1 , t 2 , . . .t M }, where t M ≡ t f , and M is an integer number.For a given integer i ∈ [0, M − 1], the discretisation step h i is defined as and Euler's method, which is based on a linear interpolation polynomial, is the simplest collocation method and is given in Equation ( 44): The trapezoidal approach is based on a quadratic interpolant polynomial, and is shown in Equation ( 45): Hermite-Simpson scheme is based on a cubic interpolant polynomial and is described by Equation ( 46): Only a few authors have explored the use of collocation methods to solve optimal control problems associated with battery storage systems.A discussion paper [46] formulated a discretised optimal control problem to examine the influence that energy storage can have on energy generation and investment decisions.The problem was solved using Chebyshev collocation methods and dynamic programming.In [47], orthogonal polynomials were used to estimate the optimal control strategy for a hybrid storage configuration composed of batteries and ultracapacitors.Recent work [48] has addressed the optimal charging profile for a hybrid electric vehicle using an orthogonal collocation approach.

Results and Discussion
This study attempts to determine the battery operation over time that yields the optimal day-ahead energy dispatch by utilising market data from 6 June 2023.The measure to determine the solution quality used in this work is the maximum relative local error, which measures the accuracy of the approximation of the state variables and is described in detail in [49].As mentioned, the day-ahead electricity price data were sourced from [36].
The problem was solved using mesh refinement with trapezoidal/Hermite-Simpson collocation methods.The mesh refinement algorithm was configured to perform up to seven iterations.Mesh refinement involves adjusting the mesh defined by the discretisation points by efficiently subdividing the existing cells into smaller ones in sections of the time domain where accuracy needs to be improved, resulting in a higher number of cells and a finer representation of the problem domain.This process allows for a more precise approximation of the control and state variables over the time domain of the problem.By refining the mesh, finer details and variations in the control and state variables can be captured, leading to more accurate optimisation results.However, it is essential to strike a balance between the accuracy of the solution and computational cost.

Numerical Simulation
This section presents the outcomes of our in-depth refinement procedure to improve our computational simulations' accuracy and resolution.We studied three cases, which are summarised in Table 4.We aimed to improve the maximum local relative error of the solutions and provide the best solution for each particular case.The price of electricity was assumed to be constant within each hourly interval.Moreover, we assumed that the battery cells were not degraded at the beginning of the 24 h window.As in case 2 but including the effect of degradation of the internal resistance.

Solver Configuration
All computations were carried out using the optimal control software PSOPT version 5.0.PSOPT [50] is an open-source, optimal control solver written in C++.The key parameters that define the solver configuration are given in Table 5.

Simulation Results
Table 6 shows a summary of key results for the three cases, including the profit, net revenues, degradation cost, and maximum relative local error achieved.Details on the results obtained for each case, including the mesh refinements process, accuracy and resolution of the simulations, the state of charge profile, the optimal current profile, and the terminal voltage profile are also presented.In this scenario, the focus is on maximising net revenues without taking into account the cost of degradation.The state equations do not account for degradation, and it is assumed that the internal resistance value does not increase due to degradation effects.It is important to note that energy sales occur when the battery discharges (charging current is positive), meaning the system is selling energy to the grid, while energy purchases occur when the battery is being charged (charging current is negative), indicating the system is buying energy from the grid.Table 7 shows the mesh refinement results.The best maximum relative local error is 5.099 × 10 −3 , obtained for iteration seven, with a total number of discretisation points of 845.Table 6 shows the optimal profit obtained for this case, corresponding to EUR 7.82 × 10 −1 .Figure 3 shows the resulting state of charge over time in this case.Figure 4 displays the optimal current profile.The battery is charged at the beginning of the day and reaches 85% in about 1 h.Following that, for the next 10 h, the battery remains essentially unused.Between 11 h and 17 h, the battery goes through a charge/discharge cycle, then stays discharged until 22 h, when it starts charging again to about 85%.The voltage at the terminals is shown in Figure 5. Notice that the voltage increases/ decreases as the battery charges/discharges and that the voltage path constraint is respected.

Case 2: Maximising Profits without Considering Degradation in the Internal Resistance
In this scenario, the aim is to maximise profits, which are calculated as the net revenue minus the cost of battery degradation.The state equations take into account the effect of degradation on the battery's capacity but do not consider any increase in the battery's internal resistance due to degradation.Similar to case 1, energy sales happens when discharging the battery (charging current is positive), while energy purchase occurs when charging the battery (charging current is negative).Table 8 shows the mesh refinement results for this case.The best maximum relative local error is 9.5225 × 10 −4 , obtained with a total number of discretisation points of 668.  Figure 6 shows the resulting state of charge over time.Figure 7 shows the optimal current profile for this case.Table 6 shows the optimal profit obtained for this case, which corresponds to EUR 4.769 × 10 −1 .The same table shows the net revenues and the cost of degradation for this case.
In this case, the battery is partially charged to about 80% after 1 h and then charges more slowly, reaching 85% at about 5 h, and then it stays inactive until about 10 h.Between 10 h and 13 h, the battery fully discharges, then charges again to about 85% at 15 h, then it starts discharging again until about 17 h.It remains discharged until about 21 h, when it starts to charge again to about 85% as the price of electricity starts reducing, making it cheaper to buy electricity from the grid.The terminal voltage profile for case 2 is shown in Figure 8.In this case, the primary objective is to optimise profits by maximising the difference between net revenue and the cost associated with battery degradation.The approach involves using mathematical equations to model the system, considering the effects of degradation on both battery capacity and internal resistance.Battery degradation is anticipated to lead to a decrease in capacity and an increase in internal resistance over time, impacting the battery's overall performance and efficiency.The results of the mesh refinement procedure are shown in Table 9.The best maximum relative local error is 2.372 × 10 −3 , obtained with a total number discretisation points of 671.Table 6 shows the optimal profit obtained for this case, which corresponds to EUR 4.768 × 10 −1 .The same table shows the net revenue and the cost of degradation associated with this case.Figure 9 shows the resulting state of charge over time.Figure 10 shows the optimal current profile.The results are very similar to those obtained in case 2; for instance, the profit values of cases 1 and 2 are only different in the third decimal digit, which indicates that introducing degradation to the internal resistance has a negligible effect on the profit value.The terminal voltage profile for case 3 is shown in Figure 11.

Conclusions
This work discussed the application of optimal control methods to optimise the participation of lithium-ion batteries in the day-ahead electricity market.Three cases were studied: maximising net revenues without consideration of degradation, maximising profits with consideration of capacity degradation, and maximising profits with consideration of degradation affecting both the battery's capacity and the internal resistance.This study aimed to determine the optimal charge and discharge schedules for each case considering a 24 h price profile from Belgium's day-ahead electricity market.
The results show that while the resulting charge/discharge profiles are similar in the three cases, consideration of capacity degradation in the dynamics and objective function reduces profits, while also including the increase in internal resistance due to degradation resulted in a reduction of EUR 0.001 in the profit value for the scenario considered in this work.On the other hand, considering only the maximisation of revenues, which translates into removing any degradation cost in the objective functional, profits were higher by EUR 0.31 compared with the case where degradation is considered.
Two areas for further research include the incorporation of a thermal model into the state equations so that temperature effects on degradation can be more accurately modelled and the validation of the optimal control methods presented here on a real battery energy storage system that participates in the day-ahead electricity market.Experimental

Figure 1 .
Figure 1.24 h day-ahead electricity price for Belgium's market.

Figure 3 .
Figure 3. State-of-charge profile for case 1, showing the charge/discharge schedule.

Figure 6 .
Figure 6.State-of-charge profile for case 2, showing the charge/discharge schedule.

Figure 9 .
Figure 9. State-of-charge profile for case 3, showing the charge/discharge schedule.

Table 3 .
Definitions of variables for the objective functional in the empirical battery model.

Table 4 .
Summary of the case studied to simulate the day-ahead problem.

Table 6 .
Summary profits, net revenues, degradation cost, and best maximum relative error for each case.Profits and costs are in EUR per day assuming a battery storage system consisting of 750 Sanyo UR18650E lithium-ion cells.

Table 7 .
Results from the mesh refinement for case 1: maximise revenues with no degradation in the internal resistance.

Table 8 .
Results from the mesh refinement for case 2: maximise profits.

Table 9 .
Results from the mesh refinement for case 3: maximise profits with degradation in the internal resistance.