*2.5. Normalisation and Initialisation*

The normalisation and initialisation are crucial for the training of the GB model with NODEs. It is recommended to scale the inputs of neural networks [43]: The average of the input variables over the training set should be close to zero (note that this condition is fulfilled for a rechargeable battery, as negative currents for charge and positive currents for discharge integrate to zero). Additionally, their covariances should be about the same.

As the SOC is in the range of 0 to 1, we decided to scale all inputs to values between −1 and 1. Additionally, we normalised the output values of the neural networks to the same value range. We did not use different learning rates for different parameters. Therefore, we also scaled the learnable parameters according to the respective value range and the expected deviation from the chosen initial value.

According to the manufacturer, the cell has a nominal capacity *C*<sup>N</sup> = 180 Ah. However, integration of the measured current over time for a whole charging or discharging process leads to an approximate charge throughput of *Q* ≈ 191.5 Ah. As the manufacturers usually give lower values for the nominal capacity to be on the safe side, we decided to set the initial value to *ω*<sup>0</sup> = 191.5 Ah. In the model, we used SI units. Therefore, we had to include a conversion factor.

To get more information about the ohmic resistances and the capacitance in Equations (5) and (6), or rather their learnable representation in Equations (8) to (10), we examined the measurement data from the pulse tests more closely. Figure 3 shows a detailed view of the current versus time and voltage versus time plot for the charging process with a pulsed current. At *t* = 7264 s, there is a current step of Δ*i*bat = −25 A during charging. The battery follows this current step with an ohmic voltage drop Δ*v*bat,serial ≈ 7 mV. The ohmic voltage drop is modelled through the serial resistance in Equation (6), or rather the learnable parameter *ω*<sup>3</sup> in Equation (10). For discharging we found similar absolute values. Therefore, *ω*<sup>3</sup> = <sup>|</sup>Δ*v*bat,serial<sup>|</sup> /|Δ*i*bat<sup>|</sup> = 0.28 mΩ should be a good starting point for the learnable parameter. We introduced the normalised parameter *ω*∗ <sup>3</sup> = 1000 · *ω*<sup>3</sup> instead and initialised it as *ω*∗ <sup>3</sup> = 0.28 Ω. The value for *ω*3, which is the approximation of *R*S, is then calculated according to *ω*<sup>3</sup> = 1/1000 · *ω*<sup>∗</sup> <sup>3</sup> . The further course of the battery voltage following the ohmic voltage drop is modelled through the RC circuit in the ECM. We estimated the time constant *τ* of the RC circuit by applying a tangent to the voltage

curve. We found *τ* ≈ 15 s. The final battery voltage drop caused by the RC circuit is Δ*v*bat,RC ≈ 8 mV. In the ECM the ohmic resistance *R*<sup>1</sup> models this voltage drop. It can be approximated as *R*<sup>1</sup> = <sup>|</sup>Δ*v*bat,RC|/|Δ*i*bat<sup>|</sup> = 0.32 mΩ. The capacitance *C*<sup>1</sup> was estimated according to *C*<sup>1</sup> = *<sup>τ</sup>*/*R*<sup>1</sup> = 15 s/320 μ<sup>Ω</sup> = 47 kF. One has to take into account that the ohmic resistance *R*<sup>1</sup> in Equation (5) or (8) depends on SOC and battery current. Therefore, this is only a rough reference point. We expected it to be much higher than the estimated value for low and high values of SOC. Again, we introduced normalisation factors to simplify the later training process. The current input to the neural networks *f* ∗ and *g*∗ was normalised in relation to the maximum absolute current. The outputs of the neural networks *f* and *g* were generated as follows: *f* SOC, *<sup>i</sup>*bat,*θ f* = 1/100 · *f* <sup>∗</sup> SOC, *<sup>i</sup>*bat/180,*θ <sup>f</sup>* <sup>∗</sup> , and *g* SOC, *<sup>i</sup>*bat,*θg* = 1/100 · *g*<sup>∗</sup> SOC, *<sup>i</sup>*bat/180,*θg*<sup>∗</sup> . We initialised the weights and biases of *f* ∗ and *g*<sup>∗</sup> from the uniform distribution U − √*k*, √*k* , where *k* = <sup>1</sup> *<sup>l</sup>* with *<sup>l</sup>* <sup>∈</sup> <sup>N</sup> the number of inputs to the respective layer (cf. Ref. [43]). The learnable parameter *ω*<sup>1</sup> was represented by *<sup>ω</sup>*<sup>1</sup> <sup>=</sup> 105 · *<sup>ω</sup>*<sup>∗</sup> <sup>1</sup> , where the normalised parameter *ω*<sup>∗</sup> <sup>1</sup> was initialised as *ω*<sup>∗</sup> <sup>1</sup> = 0.5 F. We implemented the non-linear *v*OC(SOC) curve according to the measurements of Ref. [18] as look-up table. The *v*OC(SOC) relationship needed in Equation (10) was obtained from the look-up table via linear interpolation. Due to inaccuracies of the current measurement and the choice of the initial SOC value it could be possible that the calculated SOC was sometimes slightly larger than 1 or slightly lower than 0. In these cases we provided the OCV values for SOC = 1 or SOC = 0, respectively. We approximated the hysteresis voltage drop to find a good initial value as follows. We subtracted the voltage drops over the resistances *R*<sup>S</sup> and *R*<sup>1</sup> from the difference between the OCV and the measured battery voltage at a medium SOC for *i*bat = −50 A, yielding *v*hys ≈ 15 mV. We introduced the respective normalised learnable parameter *ω*∗ <sup>2</sup> = 10 · *ω*2. We initialised it to *ω*<sup>∗</sup> <sup>2</sup> = 0.15 V.

**Figure 3.** Simulation results using NODEs for grey-box modelling of a lithium-ion battery in comparison to experimental data at *T* = 25 °C. The focus is on charging with a pulsed current at a medium SOC; (**left**): battery current versus time; (**right**): battery voltage versus time.

Applying these modifications, the following equations describe the final GB model:

$$\frac{\text{dSOC}}{\text{d}t} = -\frac{1}{3600 \,\text{s/h}\,\omega\_0} i\_{\text{bat}} \tag{11}$$

$$\frac{\mathrm{d}v\_{\mathrm{RC1}}}{\mathrm{d}t} = \frac{1}{10^5 \cdot \omega\_1^\*} \cdot \left(\mathrm{i} - \frac{1}{R\_1(\mathrm{SOC}, i\_{\mathrm{bat}})} \cdot v\_{\mathrm{RC1}}\right) \tag{12}$$

$$R\_1(\text{SOC}, i\_{\text{bat}}) = \begin{cases} \frac{1}{100} \cdot f^\* \left( \text{SOC}\_r \cdot i\_{\text{bat}} / 180, \vec{\theta}\_{f^\*} \right) & \forall \, i\_{\text{bat}} < 0 \\\frac{1}{100} \cdot g^\* \left( \text{SOC}\_r \cdot i\_{\text{bat}} / 180, \vec{\theta}\_{\mathcal{S}^\*} \right) & \forall \, i\_{\text{bat}} > 0 \\\frac{1}{200} \left( f^\* \left( \text{SOC}\_r \cdot i\_{\text{bat}} / 180, \vec{\theta}\_{f^\*} \right) + g^\* \left( \text{SOC}\_r \cdot i\_{\text{bat}} / 180, \vec{\theta}\_{\mathcal{S}^\*} \right) \right) & \text{else} \end{cases} \tag{13}$$

$$
\omega\_{\rm bat} = v\_{\rm OC}(\rm SOC) - \frac{1}{10} \cdot \omega\_2^\* \cdot \text{sgn}(i\_{\rm bat}) - \frac{1}{1000} \cdot \omega\_3^\* \cdot i\_{\rm bat} - v\_{\rm RC1} \tag{14}
$$

where *ω*0, *ω*∗ <sup>1</sup> , *ω*<sup>∗</sup> <sup>2</sup> , and *ω*<sup>∗</sup> <sup>3</sup> are learnable parameters and the functions *f* <sup>∗</sup> and *g*<sup>∗</sup> represent neural networks. They were built in analogy to the neural networks *f* and *g* in Equation (9). We used feedforward networks with one hidden layer and ReLU activation. The number of hidden neurons was varied.

#### *2.6. Simulation and Optimisation Methodology*

We implemented our model in Python (version 3.7.6). We used the open-source machine learning framework PyTorch (version 1.9.0) [44]. PyTorch provides two main features: Tensor computing and automatic differentiation for deep neural networks. Furthermore, we used the torchdiffeq library (version 0.2.1) [45] which builds on PyTorch. It allows solving ODEs and backpropagation through the solutions of the ODEs.

The differential Equations (11) and (12) were solved with the Dopri8 method. Backpropagation was performed with the standard odeint method from torchdiffeq. Finally, an Adam optimiser minimised the loss function.
