## 2 Buck Converter Modeling
When the load requires less current (modeled with \(R=30\;\Omega\)), the zero-crossing events take place during a significant number of the simulated cycles. In 50 switching cycles, there are 39 where the current crosses zero during a deadtime, 78 percent of the total. This means that the \"if-then\" block of Algorithm 2 is entered 78 percent of the simulation cycles. Figure 3 shows the simulated values of the capacitor voltage and inductor current in this case. An intermediate situation was also modeled using \(R=15\;\Omega\). In this case, only one switching cycle has a zero-crossing event. The reference for the comparison was the simulation with a \(dt\) as low as \(10\;\mathrm{ns}\). As explained above, the smaller the \(dt\), the smaller inherent error and the lower errors caused by mis-detection of the duty cycle or zero-crossing events. The \(dt\) of \(10\;\mathrm{ns}\) is three orders of magnitude lower than the deadtimes, which are \(10\;\mathrm{\SIUnitSymbolMicro s}\) long. This ensures that any inaccuracy in the modeling of deadtimes or any other event is very small in the reference. Then, simulations with larger \(dt\) are performed, and they are compared with the reference. The values chosen for \(dt\) were \(100\;\mathrm{ns}\), \(1\;\mathrm{\SIUnitSymbolMicro s}\), and \(10\;\mathrm{\SIUnitSymbolMicro s}\). These values were chosen as many commercial systems achieve a maximum simulation step between \(500\;\mathrm{ns}\) and \(1\;\mathrm{\SIUnitSymbolMicro s}\). The case with the largest \(dt\) matches the length of the deadtime. In this particular case, it means that the state variables are calculated only once during one complete deadtime. If the main contributor to the error is the inaccuracy caused by the value of \(dt\), then with any of the three resistance values, the difference between a reference with \(dt=10\;\mathrm{ns}\) and the calculation with \(dt=1\;\mathrm{\SIUnitSymbolMicro s}\) should be of the same order of magnitude. The result for the simulation with no zero crossing events is that the calculation with \(dt=1\;\mathrm{\SIUnitSymbolMicro s}\) compared with the reference obtained with \(dt=10\;\mathrm{ns}\) has an error of \(4.57\times 10^{-12}\;\mathrm{A}\) for \(i_{L}\) and \(2.42\times 10^{-11}\;\mathrm{V}\) for \(v_{C}\). However, in both cases with zero-crossing events, the simulation error grows six orders of magnitude larger at \(dt=1\;\mathrm{\SIUnitSymbolMicro s}\), even in the case with only one event in fifty cycles. The conclusion is that this difference in error values is caused by the miscalculation of \(i_{L}\) and \(v_{C}\) at the zero-crossing events, because other contributors to the error do not differ between these three calculations: fourth-order Runge-Kutta was used, with 64-bit floating-point representation and no modeling of first-order losses in all of them. Table 2 summarizes these results. Figure 3: Numerical simulation of the capacitor voltage and inductor current with \(R=30\;\Omega\)—the case when inductor current crosses zero during 78% of the deadtimes

It can be seen that the model with \(R=7.5\,\Omega\) approximates the ideal behavior. The error in calculation of both the capacitor voltage \(v_{\text{C}}\) and the inductor current \(i_{L}\) resembles a line with slope 4. Values of \(dt\) smaller than 10 ns are not used because the resolution limits of the 64-bit floating point are reached and the smallest representable number (machine epsilon) cannot represent properly the very small values needed for an accurate calculation. Values larger than 10 us were also not used because the deadtime of 10 us would not be detected by the model. The error curves of the other values of \(R\) do not resemble a line with a slope of 4. This points to the fact that the miscalculation of \(i_{L}\) during deadtimes offsets the high accuracy provided by the fourth-order Runge-Kutta method. As the variables \(i_{L}\) and \(v_{\text{C}}\) are interdependent, the error caused by the miscalculation of \(i_{L}\) propagates to \(v_{\text{C}}\) and the curves are very similar.