Modeling Lyapunov Control-Based Selective Harmonic Compensated Single-Phase Inverter in the Dynamic Phasor Domain

Single-phase grid-forming inverters are commonly used in uninterruptible power supply (UPS) systems that feed single-phase critical loads in homes, data centers, and hospitals. With the increasing use of power electronics-interfaced loads, single-phase UPS inverters are being designed to exhibit characteristics such as low total harmonic distortion (THD) in output voltage, fast dynamic response, and strong robustness against large changes in load, to ensure a seamless operation of critical loads. The Lyapunov-function-based control strategy is a popular method to provide these characteristics in UPS inverters. However, most studies and designs related to Lyapunov-function-controlled single-phase UPS inverters are conducted by using detailed switching models. While detailed switching models accurately represent the true dynamics of power converters, simulating these models with nonlinear control schemes requires small time steps to produce accurate results. To address this limitation, we propose a new model of Lyapunov-function-based single-phase grid-forming inverter using the dynamic phasor (DP) method. The DP method transforms time-domain signals into slow-varying signals, enabling the use of larger time steps in simulations, which results in shorter simulation times. In the proposed DP model, the Lyapunov energy function is constructed in the DP domain using the dominant harmonics of the inverter output voltage and output current as state variables. The high accuracy and superior computational speed of the proposed DP model are validated through comparison with results obtained from a detailed model with natural-frame-based Lyapunov-function control. Experimental test results confirm the validity and high accuracy of the proposed DP-based method of modeling Lyapunov-function-controlled single-phase grid-forming inverter.


I. INTRODUCTION
Uninterruptible power supply (UPS) systems are usually deployed in applications where critical loads are present [1].Examples of these applications include data centers, hospitals, military installations, and communication facilities.Most critical loads need high-quality power to function reliably and efficiently.Due to the increasing adoption of power electronic converter interfaces in loads, most critical loads now behave like nonlinear loads.Accordingly, UPS systems need to have certain features to maintain the quality of power supplied to critical loads that exhibit nonlinear behavior.These features include low total harmonic distortion (THD) in output voltage, fast dynamic response, excellent tracking performance, and strong robustness against large changes in load consumption.The IEEE Std.1547 [2] places a 5% limit on the THD of output voltage in UPS systems.Low THD in the output voltage is usually achieved by embedding selective harmonic compensators (SHCs) in the control scheme of a UPS.
To incorporate the features mentioned earlier in UPS systems, a variety of control strategies have been proposed by researchers in the literature.These control strategies can be categorized into linear and nonlinear control strategies.Most of the linear control strategies are based on proportionalintegral (PI) controllers, proportional-resonant (PR) controllers, and feedforward control schemes.In [3], SHCs based on a single equivalent synchronous frame are included in the control scheme of a distributed energy resource (DER) in an islanded microgrid to reduce voltage harmonics caused by a nonlinear load.The resulting control scheme reduced the THD of the DER output voltage.However, the system parameters are omitted.Thus, it is challenging to replicate the results shown.Javadi et al. [4] proposed a multilevel transformer-less hybrid series filter for enhancing power quality in a singlephase residential microgrid.The proposed filter relies on PR controllers to improve the power factor and mitigate current harmonics caused by nonlinear loads from polluting the utility voltage.However, the proposed hybrid filter is a load-based compensation strategy.Thus, each nonlinear load in an islanded microgrid must be fitted with the proposed hybrid filter to keep the utility voltage free from harmonics.This strategy may not be economically feasible for single-customer-based residential microgrids.
Linear controllers, despite their attractive features such as simple control structure, ease of tuning, and ease of implementation, do not provide important features required in a modern UPS.For instance, as linear controllers are tuned based on small-signal models, they do not provide global asymptotic stability.In addition, linear controllers do not provide strong robustness against parameter variations and model mismatches.As a result of the limitation of linear controllers, researchers have devised and then reported in literature numerous nonlinea control strategies suitable for modern UPS systems.Examples include deadbeat control [5], [6], model predictive control [7], [8], [9], H-infinity control [10], feedback linearization [11], sliding mode control [12], [13], [14], and Lyapunov-function-based control [1], [15].Among the nonlinear control strategies mentioned, the Lyapunov-function-based control strategy offers the best performance in UPS in terms of robustness against parameter variations and disturbances, fast dynamic response under sudden load changes, and negligible steady-state error in the output voltage.The main goal of the Lyapunov-functionbased control approach is to find a control law that keeps the derivative of a Lyapunov energy function negative under all operating points [1].In [15], the Lyapunov-function-based control strategy is implemented in a single-phase UPS system.The Lyapunov function is constructed from the expressions for the energy stored in the inductor and the capacitor since the system will be stable if the total energy of the system is continuously dissipated [1].The authors added an output voltage feedback loop in the Lyapunov-function-based control strategy which resulted in a negligible steady-state error in the output voltage without a deterioration in the global asymptotic stability of the closed-loop system.In [1], the Lyapunov control strategy introduced in [15] is extended to a three-phase UPS system feeding linear and nonlinear loads.The incorporation of output voltage feedback loops into the control law resulted in strong robustness against variations in LC filter parameters, high-quality sinusoidal output voltage, acceptable THD values in the output voltage under linear and nonlinear loads, fast dynamic response under sudden load changes, and negligible error in the output voltage.However, due to harmonics introduced by nonlinear loads, the input control variables in dq format may have to be low-pass filtered to attenuate high-order harmonics and ensure robust control.The issue with works reported in [1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], and [15] is that they are implemented with detailed switching models.Detailed switching models in commercial software packages such as EMTP, PSCAD, and Simulink/Simscape require relatively high computational effort and long simulation times to obtain accurate results.To overcome the excessive computational cost imposed by detailed switching models, a lot of researchers have used the dynamic phasor (DP) method to model inverters and microgrids.At its core, the DP method is based on describing the dominant harmonics of a system via a set of time-varying Fourier coefficients.By leveraging the DP method, instantaneous time-domain quantities are converted to slow-varying variables which in turn enables the use of large step sizes to accelerate simulations.In addition, the DP method offers the modeler with the flexibility to include harmonics of interest in a model thereby enabling the possibility of reducing model complexity without a significant loss of accuracy [16], [17].The work in [18] describes the DP model of a single-phase two-stage inverter operating in standalone mode like a UPS inverter.A set of DPs is used to model harmonics based on the system frequency and boost converter/inverter switching frequencies.Results from [18] show that the DP-based single-phase inverter model is computationally more efficient than a detailed model built in Simulink-SimPowerSystems.However, the inverter feeds only a resistive load.In a UPS system, there will be a mixture of linear (resistive) and nonlinear loads.Therefore, the model in [18] is unsuitable for studying the robustness of a singlephase UPS inverter feeding both linear and nonlinear loads.To the best of the authors' knowledge, little attention has been paid to the modeling of Lyapunov-function-controlled single-phase grid-forming inverters using the DP method.
In this article, the DP method is used to develop a nonlinear controller based single-phase grid-forming (UPS) inverter feeding linear (resistive) and nonlinear [diode-bridge rectifier (DBR)] loads.Selective harmonic compensation is implemented by relying on a Lyapunov-function-based control strategy.The main advantage of the Lyapunov-functioncontrol strategy is its ability to provide global asymptotic stability, robustness against sudden load variations, and excellent dynamic response.The required Lyapunov energy function is constructed by using dominant DP components of state variables.This simplifies the control scheme without a significant loss of accuracy.Moreover, the nonlinear load is modeled with DPs, which removes the need to use low-pass filters to remove high-order harmonics in the inverter output current and voltages before feeding them into the Lyapunovfunction-based control scheme.
The rest of the article is organized as follows.In Section II, the DP method is briefly described.Section III outlines the DP-and time-domain averaged model of the power stage of the system under study.In Section IV, the DP-and timedomain model of a Lyapunov-function-based single-phase inverter is presented.In Section V, the performance of the proposed DP model is validated via simulations and comparative analyses.Experimental test results are given in Section VI.Finally, Section VII concludes this article.

II. THE DYNAMIC PHASOR METHOD
The theory behind the DP method is that a nearly periodic time-domain waveform, x(τ ) with a fundamental frequency, f and potential high-order harmonics, can be represented by a time-variant exponential Fourier series on the interval τ ∈ (t − T, t] [16], [17], [18] x where ω is the fundamental frequency of x(τ ) in rad/s, and T is the moving window length.Since x(τ ) may be aperiodic, the complex Fourier coefficient, x k (t ) has a varying amplitude and it is therefore referred to as the kth DP [16], [17], [18].x k (t ) can be determined by performing an averaging operation as follows: The kth DP obtained in ( 2) is a low-pass frequency version of x(τ ).This means that large step sizes can be used to simulate DP models since comparatively fewer time samples are required to accurately define low-pass signals compared to original instantaneous signals [16].The accuracy and complexity of DP models depends on the k value, i.e., a set of DPs.Including more harmonics during the modeling process decreases the error between the signal reconstructed using DPs and the original time-domain signal.However, the inclusion of higher-order DPs increases complexity and computational effort [16].Therefore, a good tradeoff between accuracy and complexity is a necessity.In practice, only a few dominant harmonics are considered in the modeling process.
Other useful DP properties are follows.Differentiation property: Conjugate property: where x * k is the complex conjugate of x k and * is the conjugate property.
Convolution property: Conversion of DP components to time-domain quantity: where x 0 , x R k and x I k denote the zeroth, real, and imaginary components of x k , respectively.

III. MODELING OF THE POWER STAGE
In this section, the principle of operation of a Lyapunovfunction-based single-phase grid-forming inverter connected to a resistive load and a single-phase DBR is described.Then, the averaged and DP models of the power stage are presented.In the process of deriving the DP model, the fundamental, third, fifth, and seventh harmonics are assumed to be dominant in the ac side whereas the dc source dynamics and switching harmonics are both neglected [19].

A. PRINCIPLE OF OPERATION
Fig. 1(a) shows the structure of the detailed model of a singlephase grid-forming inverter connected to a nonlinear load and a resistive load, R l .The nonlinear load is a single-phase DBR feeding an LCR (inductive-capacitive-resistive) load.
The DBR is assumed to be working in the continuous conduction mode (CCM) [19].The distorted current drawn by the nonlinear load is prevented from distorting the grid-forming inverter's output voltage by adopting a Lyapunov-functionbased control strategy.To derive the DP-based model, an averaged value model of the detailed model is derived as shown in Fig. 1(b).The averaged value model is obtained by replacing the detailed switching grid-forming converter model with a controlled voltage source and the detailed DBR with a transformer equivalent.Since an ideal dc source is used in the detailed model, the dc source is omitted in the DP model which results in a reduced-order DP model.

B. AVERAGED MODEL OF THE POWER STAGE
Applying Kirchhoff's circuit laws to the inverter power stage in Fig. 1(b) results in [19] where i T denotes the total load current.
For the DBR, the equations governing its operation are as follows: where S is a bipolar switching function that relates DBR's input voltage (current) to its output voltage (current).Since the DBR is directly connected across the inverter capacitor (that means there is no DBR input inductance), S can be defined as where D sn = (sin(nδ/2))/π n, is amplitude of the switching function, δ is the conduction angle of the diode switch in radians, and ϑ is the phase angle of the monopolar switching function relative to the reference voltage/current.Assuming that ϑ = 0 and δ = π (i.e., CCM mode) result in The dynamics of the LCR load network connected across the DBR output port are captured with
The equations governing the DBR operations in the DP domain are given as [19] In the DP domain, the dynamics of the LCR network are captured with [19] where the set of harmonics: {n = 0, 2, 4, 6} are modeled in the dc side of the DBR.

IV. LYAPUNOV-FUNCTION-BASED CONTROL SCHEME
In Lyapunov-based control method, the stability of a system is evaluated by studying a scalar energy storage function, V (x) often referred to as Lyapunov energy function.The Lyapunov energy function denotes the sum of total energy accumulation in the system storage devices (inductors and capacitors).According to the Lyapunov direct method, an equilibrium point of interest in the system is globally asymptotically stable if V (x) satisfies the four conditions below [15] V (x) = 0 if and only if x = 0 (23a) In this article, we are interested in leveraging the Lyapunov direct method to investigate the global asymptotic stability of a single-phase grid-forming inverter around a chosen equilibrium point [15].
First, the Lyapunov direct method as proposed in [15] is applied to design the control system of the detailed single-phase grid-forming inverter model shown in Fig 1 .Second, an analytical method of selecting suitable gains to impose the desired dynamic performance is outlined.Third, the Lyapunov-based dual-loop control system depicted in [15] is improved by: replacing the derivative block in the current loop with a filtered derivative block, and replacing the look-up table in the voltage loop with an all-pass filter.A pure derivative block introduces high-frequency noise and increases the complexity of practical control systems whereas a look-up table is not model agnostic.Fourth, the Lyapunov method is used to design the control system of a DP model of a single-phase grid-forming inverter.An analytical approach to calculating suitable gains to impose dynamic responses similar to those imposed on the detailed model is outlined.

A. LYAPUNOV-FUNCTION-BASED CONTROL SCHEME FOR A DETAILED TIME-DOMAIN MODEL
The Lyapunov-based control scheme for the detailed timedomain model is designed in the natural frame based on (7) and (8).To add the dc-link voltage to the Lyapunov-based control scheme, the variable v i is replaced with mV dc in ( 7) where m is the control input.
Let the control input be expressed as a sum of its steadystate value, M and perturbed value m Assuming that i i and v f track their setpoint values (i.e., i i = i * i and v f = v * f ) and m = 0, then ( 8) and ( 24) can be rewritten as where [15].Subtracting (26) from (24), and ( 27) from ( 8) while considering (25) result in where dx 1 dt (= ẋ1 ) and dx 2 dt (= ẋ2 ) are time derivatives of x 1 and x 2 , respectively.
The Lyapunov energy function of the system is given as Testing conditions #1 to #3 given by ( 23) on (30) confirms that the chosen Lyapunov energy function is suitable for the derivation task ahead.To test the global asymptotic stability of the inverter about a chosen equilibrium point, the time derivative of (30) is taken as follows: Substituting ( 28) and ( 29) into (31) gives The condition: V (x) < 0 is satisfied in (23) if the perturbed control input is given as where k pi is a real constant.The control input given by ( 25) can be rewritten as [15] If the inverter is controlled by implementing (34), the inverter closed-loop system will be globally asymptotically stable under perturbations away from the chosen operating point [15].However, by using (34), there will be a steady-state error in the tracking of the inverter output voltage because the voltage error, x 2 does not appear in (34) (i.e., there is no outer voltage loop in (34)).
To eliminate the steady-state error in v f , (34) is modified by adding an outer voltage loop with a gain, k pv to (33) Substituting ( 35) into (32) results in [15] V Evaluating (36) reveals that V (x) < 0 if Equation (37) gives the lower bound for k pv in addition to ensuring that V (x) is always negative by dominating the last term of (36) [15].Therefore, the global asymptotic stability of the inverter closed-loop system is unaffected by the inclusion of the outer voltage loop.Including the voltage feedback loop modifies the control input to

B. IMPROVEMENT OF LYAPUNOV-FUNCTION-BASED CONTROL SCHEME FOR A DETAILED MODEL
The detailed block diagram of a Lyapunov-function-based control scheme is depicted in [15, Fig. 3].The block diagram shows that a pure derivative block is used to differentiate i * i while the derivative of v * f is implemented by using a sine look-up table.As stated earlier, a pure derivative block amplifies high-frequency noise and discontinuities (e.g., a step change in setpoint).Additionally, it is difficult to practically implement a pure derivative block without incorporating a low-pass filter.Notably, a lookup table is not model agnostic.If v * f is equal to V * f sin ωt rather than V * f cos(ωt ), the lookup table has to be modified.In this article, the high-frequency noise that may be introduced by a pure derivative block is eliminated by using an all-pass filter to differentiate v * f while the inflexibility associated with a lookup table is obviated by using a filtered-derivative to differentiate i * i .

1) USING AN ALL-PASS FILTER TO DIFFERENTIATE v * f
An all-pass filter transfer function, G APF (s) is given by where Y APF and U APF are the output and input variables of the all-pass filter in the Laplace domain.An all-pass filter produces unity gain and a phase lead of π/2 at the corner frequency, ω.Notably, a derivative block introduces a phase lead of π/2 and a gain of ω when it is used to differentiate a sinusoidal function [e.g., cos(ωt )].Since an all-pass filter at the corner frequency, ω and a derivative block have similar phase responses, an all-pass can be used to differentiate V * f cos(ωt ) without requiring a look-up table.However, an all-pass filter may not yield a good result if used to differentiate i * i because i * i is composed of harmonics instead of a single frequency.
In the time domain, (39) is expressed as [19] where E er is the error between the input signal and output signal in the time domain.In this article, u APF = v * f and Note that an all-pass filter with a transfer function, ( ω−s ω+s ) introduces unity gain and a phase lag of π/2 at the corner frequency, ω.

2) USING A FILTERED DERIVATIVE TO DIFFERENTIATE i * i
The transfer function of a filtered derivative, G FD (s) is where U FD (s) and Y FD (s) are, respectively, the input and output signals in the Laplace domain, T FD and K FD are the time constant and gain of the filtered derivative block, respectively.Equation ( 41) is rearranged into where X FD (s) is the filtered derivative state variable in the Laplace domain.In the time domain, In this article, u FD = i * i and y FD = The structure of the Lyapunov-function-based control scheme is given in Fig. 2.

C. TUNING OF LYAPUNOV CONTROL SCHEME FOR A DETAILED MODEL
Substituting (35) into (28) results in The suitable values of k pi and k pv required to impose the desired inverter dynamic response are calculated by linearizing (29) and (44) around an operating point [15] where the Jacobian matrix, A is expressed as The characteristic equation of the linearized system is Solving (46) using the quadratic formula results in Comparing (47) with a pair of conjugate poles expressed as where ω bL and ε L are the Lyapunov-based control scheme's bandwidth and damping ratio, respectively.The desired bandwidth and damping ratio can be chosen by using [20] where t set is the time taken by the system to settle to 2% of the final value [20].
Applying the Routh-Hurwitz stability criterion to (46) yields the lower bound of k pv as The methodology for deriving the Lyapunov control scheme for the detailed model can be found in Appendix A.

D. LYAPUNOV-FUNCTION-BASED CONTROL FOR A DP MODEL
The Lyapunov-function-based control scheme for a DP-based grid-forming inverter model is derived by considering ( 15)- (16).To make the steps used in deriving the DP-based Lyapunov-function control scheme to conform to the steps used in deriving the detailed model, we substitute v i n = V dc m n into (15) to obtain Let the control input be expressed as a sum of its steadystate value and perturbed value as follows: Assuming that DP components of i i and v f track their setpoint values (i.e., ) and m n = 0, (52) and ( 16) can be rewritten as where n = {1, 3, 5, 7}.Let the state variables be defined as Subtracting (54) from (52), and (55) from ( 16) while also considering (56) results in Assume a Lyapunov candidate function of the form where The chosen Lyapunov candidate function obviously satisfies the first three conditions in (23).The next task is to make the Lyapunov candidate function to satisfy (23d).Taking the derivative of (59) results in Substituting ( 57) and ( 58) into (62) leads to: Equation ( 63) satisfies (23d) if the control inputs are chosen as where k pin < 0. Substituting (54) and (64) into (53) yields where n = {1, 3, 5, 7}.Equation ( 65) is suitable for implementing a control system that ensures that both v f (66) Thus, the control input in the DP domain is Note that m R n = m n and m I n = m n .Since the DP model of the power stage is in reduced-order form, then we can replace the term V dc m n with v i n in (67) to obtain a Lyapunov control model compatible with ( 15)

E. IMPROVEMENT OF LYAPUNOV-FUNCTION-BASED CONTROL SCHEME FOR A DP MODEL
As was done earlier for the detailed model, an all-pass filter is used to differentiate v * f whereas a filtered derivative block is used to differentiate i * i .The DP model equivalents of filtered derivative and all-pass filter are given below.

1) DP MODEL OF AN ALL-PASS FILTER USED FOR DIFFERENTIATING v * f
The DP model of an all-pass filter considering (40) is where dt .The proposed DP-based Lyapunov control system is given in Fig. 3.

2) DP MODEL OF A FILTERED DERIVATIVE BLOCK USED FOR DIFFERENTIATING i * i
The DP model of a filtered derivative given by (43) is where

F. TUNING OF DP-BASED LYAPUNOV CONTROL SCHEME
Substituting (66) into (57) result into these real equations Linearizing real and imaginary parts of (58) as well as (73) with respect to state variables, and then substituting (74) into the resulting equations: where the 4-by-4 matrix in (75) is the Jacobian matrix A.
The characteristic equation of the closed-loop system is [19] det (sI The coefficients of (76) are defined as Applying the Routh-Hurwitz stability criterion on (76) [1], [21] shows that the poles of a closed-loop system will be in the left-half plane of the complex plane if these inequalities hold The condition in (77a) holds if k pin < 0, and k pvn > −(1 + n 2 ω 2 L f C f ).The conditions given by (77b) and (77c) are: always satisfied irrespective of system parameters.Notice that there is a remarkable difference between linearized statespace equations for the detailed model and the DP model.This is due to the presence of complex variables in the DP model.
The methodology for deriving the Lyapunov control scheme for the DP model can be found in Appendix A.

G. STUDY OF CLOSED-LOOP POLES OF THE LYAPUNOV CONTROL 1) NATURAL FRAME-BASED LYAPUNOV CONTROL SCHEME
To investigate the closed-loop behaviour of the Lyapunovfunction-based control implemented in the natural frame for the detailed model, the roots of (46) are computed with k pv = 0 (i.e., the voltage feedback loop deactivated) and k pi increased from −10 −5 to −6 × 10 −4 .Fig. 4 shows the rootlocus of the poles.At start, the poles are conjugate pairs with the imaginary parts far larger than the real parts and located close to the imaginary axis in the left-half plane.As k pi is increased and k pv is kept constant, the poles move from the imaginary axis to the negative real axis, in an elliptical manner, with some poles moving toward the left and others moving toward the right.Fig. 5. shows the pole distribution when k pv = 0.007 and k pi is increased from −10 −5 to −6 × 10 −4 .Compared to Fig. 4, the poles in Fig. 5 slowly approach (i.e., the eccentricity of the elliptical path traced by  the poles increases) the negative real axis and are farther away from the right-hand plane unlike the poles in Fig. 4. Notice that the imaginary and real part of the poles in Fig. 5 are larger than the ones in Fig. 4.This indicates that k pv helps in stabilizing the system whereas k pi influences the speed of the closed-loop system.Fig. 6 shows the root loci of poles with k pi = −4 × 10 −4 and k pv increased from 0.001 to 0.01.As k pv is increased gradually, the poles on the left and right of the negative real axis move toward each other and then change to conjugate poles.Any further increase in k pv does not result in a change in the real part of the conjugate poles.This indicates that once the closed-loop poles become conjugate poles, increase in k pv does not influence the dynamic response of the system.

2) DYNAMIC PHASOR-BASED LYAPUNOV CONTROL SCHEME
The behaviour of the Lyapunov control in the DP domain is studied by plotting the root loci of eigenvalues of the system matrix given by (75).Fig. 7 shows the closed-loop poles when k pvn = 2.1 and k pin is increased from −0.9 to −54.The poles for each harmonic (n = {1, 3, 5, 7}), start as two pairs of conjugate poles with imaginary parts much greater than the real parts.As k pin is increased, two poles move towards the right while the other two move towards the left with no change in the value of their imaginary parts.These poles do not become real poles unlike the poles in Fig. 4 because of the presence of variables (nω) that introduce frequency coupling dynamics (sideband oscillations) [22] of the fundamental frequency into the system (see (75) to confirm the coupling variables).However, these poles are symmetrical around the real axis.Notice that the distance of the poles from the real axis increases with the harmonic level.Due to the presence of frequency-coupling dynamics in the system, it is important to carefully choose the control gains of the DP-based Lyapunov control to prevent inaccurate stability prediction [22].Hence, using the V dc value as a direct factor to convert the control gains (k pin and k pvn ) of the Lyapunov-function-based control scheme implemented in the DP domain to the control gains (k pi and k pv ) of the one implemented in the natural frame vice versa, might yield an unstable system (i.e., gains that yield a stable operation for the SW model might yield an unstable for the DP model.Therefore, extensive time-domain simulations should be conducted to ascertain the feasibility of chosen control gains. Fig. 8 displays the loci of eigenvalues of (75) when k pvn is varied from 0.3 to 30 and k pin = −36.As k pvn is gradually increased, the poles change from having invariant imaginary parts and varying real parts to poles with invariant real parts and varying imaginary parts.This finding indicates that once the system poles start having invariant real parts, the system dynamic response becomes unchanged even with a further increase in k pvn value.As a result, the k pvn that yields invariant change in real part of the poles should be chosen before choosing the k pin value.It is worth mentioning that the THD value of v f reduces with increase in k pvn value but at the expense of increase in THD of i T .

3) EFFECT OF PARAMETER VARIATIONS ON GLOBAL STABILITY
To analyze the global stability of the Lyapunov-function based control system for SHC single-phase inverter, a worst-case variation in parameters (±20%) is imposed on the natural frame and DP domain-based Lyapunov control schemes.
Fig. 9 shows the root locus of the closed-loop pole for a natural frame based Lyapunov control when k pv = 0.007 and k pi is increased from −10 −5 to −6 × 10 −4 considering 0%, +20%, and −20% variations in R f , L f , C f , and V dc .It is evident that the closed-loop poles still lie on the left-hand plane.Fig. 10 shows the root locus of the closed loop poles for a DP-based Lyapunov function control when k pvn = 2.1 and k pin is increased from −0.9 to −54 considering −20% and +20% variation in parameters.Again, the global asymptotic stability of the proposed DP-based Lyapunov control is unaffected by practical changes in parameters.

V. SIMULATION RESULTS
The fidelity of the proposed DP model of a Lyapunovfunction-based single-phase grid-forming inverter feeding linear and nonlinear loads is validated against a detailed switching (SW) model.User-written codes of the proposed DP model are scripted in MATLAB while the detailed switching model is built on a commercially available electromagnetic transient simulator (Simulink/Simscape environment).Simulations were conducted on an HP Envy Windows 10 laptop with Intel Core i5-7200U and CPU at 2.50 GHz.The SW and DP models are simulated with step sizes of 5 and 500 μs, respectively, for a period of 0.4 s.
Table 1 summarizes the power stage parameters of the system under study.The inverter switching frequency is denoted by f s .The control system parameters are listed on Table 2.

TABLE 2. Lyapunov-function-based Control System Parameters
These parameters are calculated by leveraging the expressions in Sections IV-C and IV-F as well as the findings outlined in Section IV-G.
The k pi and k pv gains are chosen as −0.001 and 0.1, respectively.For the DP model, the gains are k pin and k pvn are −0.3 and 30, respectively.Notice that k pin is equal to k pin V dc rather than k pin V 2 dc suggested by (74) in order to match the dynamics of natural frame-and DP-based Lyapunov-function-based control scheme.However, we have used k pin value that does not obey (74) to accommodate the influence of frequencycoupled dynamics on system stability.However, k pvn is equal to k pvn V dc as suggested by (74) because k pvn has little influence on dynamics once the poles become conjugate (see Fig. 7).
Two transient case studies involving step changes in R o and R l are used to assess the proposed DP model's fidelity.

A. CASE 1: STEP CHANGE IN R o
In this case study, the value of the resistive load coupled to the output dc ports of the DBR is varied.The aim of this test is to ascertain the fidelity of the DP model in capturing changes in harmonic current drawn by the nonlinear load.At t = 0.2 s, R o is changed from 20 to 25 with R l = 50 .The following subsections discuss the results.

1) TIME-DOMAIN WAVEFORMS
Fig. 11 displays the waveforms of the ac side variables of the system under study.We can observe that the increase in R o at t = 0.2 s resulted in a reduction in i T and i s .However, the inverter output voltage v f is unaffected by the load changes due to the grid-forming feature of the Lyapunov-function-based control scheme.In addition, the Lyapunov-function-based control is effective in keeping v f sinusoidal despite the nonlinear current drawn by the DBR.It is evident that the input DBR current i s contains significant amount of ripples due to odd (mainly third, fifth, and seventh) harmonics introduced by the DBR operation.However, the nearly sinusoidal current drawn by R l helps in reducing the high-order harmonic content in the total load current i T as revealed in Fig. 11(b).
Fig. 12 depicts the waveforms of the DBR's dc-side quantities.The dc-side voltage quantities (v d and v o ) are unaffected by the load change due to the small value of R d and L d .However, i d waveform shifts towards the origin when R o is increased due to a reduction in current.Overall, the DP model results excellently match the SW model results.These results prove the high fidelity of the proposed Lyapunov-functionbased SHC executed in the DP domain.
2) HARMONIC SPECTRUM Fig. 13 presents the results of the harmonic spectrum of i T and v f obtained from the SW and DP models.As expected, the DBR causes the third, fifth, and seventh harmonics to be significant in i T as shown in Fig. 13(a).This resulted in a high THD in i T .The DP model predicts a THD value of 29.3% while the SW model predicts 27.2%.However, due to the SHC features of the Lyapunov-function-based control, the high-order harmonics are severely suppressed in v f as shown in Fig. 13(b) which enables R l to draw sinusoidal current.The THD in v f is predicted to be 0.70% and 0.42%, respectively, by the DP and SW models.
The results indicate that the DP model accurately predicts the level of dominant harmonics in the system.The discrepancy in THD values is as a result of limited number of harmonics considered in the DP model.It is worth mentioning that the THD values were computed by considering only the fundamental, third, fifth, and seventh harmonics.This is a reasonable approximation since the proposed DP model does not consider odd harmonics greater than seventh as well as harmonics that are non-integer multiples of the fundamental frequency.Overall, the proposed DP model demonstrates high fidelity in replicating the behavior of the system during a step change in R o .In addition, the Lyapunov-based control is effective in keeping the THD in v f below 5% stipulated in IEEE Std.1547-2018.

3) ACCURACY
The accuracy of the DP model is quantified by computing the normalized root-mean-square-error (NRMSE) [23] of DP  3 shows the NRMSE values of the ac-and dc-side variables.We can see that the NRMSE is highest in i T , followed by i s .This is because these variables contain significant ripples which were represented in the DP model by including only fundamental, third, fifth, and seventh harmonics during the process of formulating the DP model.Moreover, the NRMSE in v o is least due to small magnitude of high-order harmonics in v o .Overall, the NRMSE results corroborate the high fidelity of the proposed DP model of a Lyapunov-function controlled single-phase grid-forming inverter feeding a combination of resistive and nonlinear loads in capturing dynamic changes in harmonic current drawn by a nonlinear load.

B. CASE 2: STEP CHANGE IN R l
In this case study, the value of the ac load coupled to the inverter output ports.At t = 0.3 s, R l is stepped from 50 to 100 , with R o = 20 .

1) TIME-DOMAIN WAVEFORMS
Fig. 14 shows the waveforms of the ac-side variables of the system under study.The increase in R l at t = 0.3 s does not affect v f significantly as confirmed by Fig. 14(a).However, the increase in R l resulted in an increase in the level of distortion in i T [see Fig. 14(b)].Due to no significant changes in v f following the step change in R l , i s waveform [see Fig. 14(c)] is also unaffected by the change in R l .Fig. 15 shows the waveforms of the dc-side variables.Again, due to the robustness of the Lyapunov-function based control scheme in keeping v f sinusoidal following the step change in ac load resistance, v d , i d , and v o waveforms are unaffected by the load change.The proposed DP model results highly correlate with the detailed switching model results.
2) HARMONIC SPECTRUM Fig. 16 shows the harmonic spectrum of i T and v f obtained from the SW and DP models.The THD in i T in this case study is greater than that of case study 1.The DP model predicts a THD value of 31.14% while the SW model predicts 28.56%.The increase in the THD value of i T is due to the reduction in current drawn by R l following the step change, and because R o averages 22.5 in case study 1 simulation while in this case study, it is 20 .Therefore, the harmonic current drawn by the nonlinear load is greater in this case study compared to case study 1.Nevertheless, due to the excellent SHC features of the Lyapunov-function-based control, the reduction in the nearly sinusoidal current drawn by R l does not affect v f significantly.The THD in v f is predicted to be 0.70% and 0.45%, respectively, by the DP and SW models.Again, the proposed DP model predicts a THD value that is very close to the one predicted by the SW model.The discrepancy in THD values given by the DP and SW models is due to the truncation of harmonics while formulating the DP model.

3) ACCURACY
Table 4 gives the NRMSE of DP model variables with respect to the SW model variables for the case wherein R l is stepped from 50 to 100 at t = 0.3 s while R o = 20 .We can see that there is no significant change in the accuracy levels of the voltage variables when compared with the accuracy values from case study 1.However, the accuracy levels of i T and i s are significantly impacted by the change in the value of R l .This is because a reduction in the current drawn by the linear load (or increase in the harmonic current drawn by the nonlinear load) increases the share of harmonic currents in i T .Due to the limited number of harmonics considered in the DP model, the accuracy of the DP model's i T reduces.The same reason can be attributed to the fall in the accuracy of i s for this

TABLE 5. Comparison of Simulation Execution Time
case study compared to case study 1.We can conclude that the greater the value of high-order harmonics in the variables, the lower the accuracy of the DP model because of truncation errors arising from limited number of harmonic components of variables included in the DP model.

C. COMPARISON OF COMPUTATIONAL SPEED
Table 5 gives the simulation execution times of the DP and SW models.When both the SW and DP models are simulated with a step size of 5 μs (a typical step size for electromagnetic transient models), the DP model demonstrates a speed-up factor of about 23.When the DP model is simulated with a step size of 0.5 ms, the DP mode achieves a speed-up factor of 31.When these execution time results and the accuracy results are juxtaposed, we can conclude from simulation study perspective that the proposed DP model provides more benefit in terms of reduced simulation time and acceptable accuracy.Hence, the proposed DP model is suitable for accelerated study of harmonic currents and control system performance for inverters well-suited for selective harmonic compensation.It is worth mentioning that a step size of 1 ms can successfully be used to simulate the proposed DP model.However, to compare the results of the DP model simulated with a step size of 1 ms with the SW model simulated with 5 μs, the DPs (i.e., envelopes or average values) of the DP model variables should be used rather than the DP-derived time-domain waveforms.This is because 1 ms is too large to sufficiently sample variables with harmonics up to 420 Hz.

D. COMPARISON OF PROPOSED MODEL RESULTS WITH THOSE FROM A PR-CONTROLLED SINGLE-PHASE INVERTER
The behavior of the proposed DP model of the Lyapunovfunction-based selective harmonic compensated single-phase inverter is compared with that of SW and DP models of a PR-based selective harmonic compensated single-phase inverter.The SW and DP models of the PR-based single-phase inverter are obtained from [23].The control gains listed in [23] were used to tune these models whereas the power stage parameters listed on Table 1 of this article were adopted as system parameters.
At t = 0.2 s, R o is changed from 20 to 25 with R l = 50 .Figs. 17 and 18 show the ac-side and dc-side waveforms, respectively, obtained from the SW and DP models of SW and DP models of a PR-based selective harmonic compensated single-phase inverter for a step change in nonlinear load's resistive load.There is a close match between these results and those shown in Figs.11 and 12 which were predicted by SW and DP models of a Lyapunov-controlled selective harmonic compensated single-phase inverter.However, there is a small overshoot in the inverter output voltage [see Fig. 17 [24].The Lyapunov-based control scheme is able to prevent the start-up transients from appearing across the inverter output voltage unlike the PR-based control scheme.This confirms the superiority of the Lyapunov-function-based control scheme over the PR-based control scheme in terms of disturbance rejection.Fig. 19 shows the harmonic spectrum of the PR-based selective harmonic compensated single-phase inverter.The harmonic spectrum shown in Fig. 19 highly correlates with the one shown in Fig. 13, which was obtained from the proposed Lyapunov-function controlled single-phase inverter.This result further validates the proposed DP model.

VI. EXPERIMENTAL RESULTS
To check the validity and effectiveness of the modeling approach and consolidate the theoretical analyses of the proposed DP-based Lyapunov-function control scheme for an SHC compensated single-phase inverter, an experimental prototype was designed, built, and tested in the laboratory.
Fig. 20 shows the experimental prototype built in the lab.The prototype consists of a SEMIKRON-based inverterrectifier-chopper module, load banks, inductors, and capacitors.The three-phase DBR module is reconfigured to serve as a single-phase DBR by utilizing only the two legs of the threephase DBR.Similarly, a full-bridge single-phase inverter is realized by using two legs of the three-phase inverter module.The Lyapunov control scheme was programmed into a digital microprocessor.Current and voltage measurements were obtained using hall-effect sensors and voltage sensors, respectively.Results were recorded and visualized using a keysight power analyzer.The microcontroller library has a PI controller component but no high-pass and all-pass filter components.To overcome this limitation, user-written models of high-pass and all-pass filters in C language are realized by using the PI controller component.These user-written math models of high-pass and all-pass filters are given in Appendix B.
The power stage parameters are the same with those given in Table 1, except that V * f = 25.46V, V dc = 30 V and f s = 5 kHz.Similar parameters are used to obtain results from the DP and SW models shown in this section of the article.

A. CASE 1: STEP CHANGE IN R o
In this case study, R o is changed from 37.5 to 25 with R l = 50 .Figs. 21 and 22 show the experimental and simulation results, respectively.For the simulation result, the step change is performed at t = 0.3 s.Before the step change (i.e., when R o = 37.5 ), notice that there is a notch in the v d waveforms obtained from the experimental test rig and the SW model.This is because the DBR is not strictly operating in the CCM mode (see [19]).As the DP model has been developed under the assumption of CCM operation, it is unable to capture that notch.When R o is 25 , the system enters CCM mode.As a result, there is no notch in v d waveforms obtained from the testbed and simulation models.Overall, the proposed DP model results match very well with experimental test and SW simulation model results.

B. CASE 2: STEP CHANGE IN R l
In this case study, R l is changed from 75 to 50 with R o = 25 .Figs. 23 and 24 depict the experimental test and simulation results, respectively.The output voltage of the inverter, v f remains sinusoidal with constant magnitude due to the strong robustness of the Lyapunov-function-based

C. CASE 3: STEADY-STATE OPERATION
In this case study, there is no step change in R o or R l .Figs. 25 and 26 show the experimental results.When R o is 25 and R l = 50 , the THD value of v f and i T are 4.76% and 24.53%, respectively.When R o is 25 and R l = 75 , the THD of i T increases to 28.04% while that of v f decreases to 4.58%.This is because when R l is increased, the fundamental harmonic current contribution from R l decreases thereby decreasing the THD value of i T .Due to the increase in the harmonic current in i T , the Lyapunov-based control system reacts by decreasing the harmonic content in v f , hence the reason for the decrease in the THD value of v f .This is similar to the observation given in Section V-B for the SW and DP model results.The reason why the THD value of v f obtained from the experiment is relatively higher than the one obtained from simulation is due to measurement noises and nonideal power stage components [15].

VII. CONCLUSION
This article leveraged the DP method to propose a new model for a Lyapunov-function-controlled single-phase gridforming (UPS) inverter feeding linear-and nonlinear loads.The Lyapunov-function-based control system consists of two (current and voltage) feedback loops which are designed to reduce the steady-state error and the distortion in the inverter output voltage.In the DP domain, the Lyapunovfunction-based control scheme is constructed by using the

B. DERIVING ALL-PASS, LOW-PASS, AND HIGH-PASS FILTERS FROM A PI CONTROLLER OR AN INTEGRATOR FOR EXPERIMENTAL STUDIES
Fig. 29 shows the general structure of the control scheme used to derive low-pass, high-pass, and all-pass filters from a PI controller.The transfer function y i (s)/u i (s) can be written as: The transfer function y o (s)/u i (s) is given by

1) ALL-PASS FILTER
To derive an all-pass filter, we set λ i = 0.5, λ o = ±2, λ f = 1, and K p = 0. Then where K i = ω is the frequency of the input signal.For the case being considered in this article, K i = 377 rad/s.

2) LOW-PASS FILTER
To derive a low-pass filter, we set λ i = 0, λ o = −1, λ f = 1, and K p = 0. Then where K i = ω cl is cut-off frequency of the low-pass filter.

3) HIGH-PASS FILTER
To derive a high-pass filter with a forward gain, λ o , we set λ i = 1, λ f = 1, and K p = 0. Then where K i = ω ch is cut-off frequency of the high-pass filter.Note that T f h = ω −1 ch is the filter's time constant.For the case study considered in this article, we set λ o = K i = 450.45,λ i = 1, λ f = 1, and K p = 0.These values yield T FD = 0.00222 and K FD = 1.
If λ o = 1, we get a high-pass filter with unity forward gain Note that the parameters we used transform the PI controller to an integrator with an integral gain, K i .

FIGURE 1 .
FIGURE 1. Structure of a Lyapunov-function-based single-phase grid-forming inverter feeding linear and nonlinear loads.(a) Detailed switching model (including controls) implemented in Simulink/Simscape.(b) Averaged model (including controls) used for developing an equivalent model in the DP domain.

FIGURE 2 .
FIGURE 2. Structure of Lyapunov-function-based control system implemented in the natural frame for the detailed switching model of a single-phase inverter.
track their respective setpoints, there will be steady-state errors in v f R n and v f I n due to the absence of an inverter capacitor voltage feedback loop in (65).To alleviate this problem, (65) is modified by adding an inverter capacitor voltage feedback loop:

FIGURE 3 .
FIGURE 3. Structure of Lyapunov-function-based control system implemented in the DP domain for the DP model of a single-phase grid-forming inverter.

FIGURE 4 .
FIGURE 4. Loci of closed-loop poles of Lyapunov-based control implemented in the natural frame with k pi varied from −10 −5 to −6 × 10 −4 and k pv = 0.

FIGURE 5 .
FIGURE 5. Loci of closed-loop poles of Lyapunov-based control implemented in the natural frame with k pi varied from −10 −5 to −6 × 10 −4 and k pv = 0.007.

FIGURE 6 .
FIGURE 6. Loci of closed-loop poles of Lyapunov-based control implemented in the natural frame with k pv varied from 10 −3 to 10 −2 and k pi = −0.0004.

FIGURE 7 . 1 .FIGURE 8 .
FIGURE 7. Loci of closed-loop poles of Lyapunov-based control implemented in the DP domain with k pin varied from −0.9 to −54 and k pvn = 2.1.

FIGURE
FIGURELoci of closed-loop poles of Lyapunov-based control implemented in the natural frame with k pi varied from −10 −5 to −6 × 10 −4 and k pv = 0.007 considering when there is 0%, +20 %, and −20% parameter variations.Note that parameters that deviated from their ideal values are R f , L f , C f , and V dc .

FIGURE 10 .
FIGURE 10.Loci of closed-loop poles of Lyapunov-based control system implemented in the DP domain with k pin varied from −0.9 to −54 and k pvn = 2.1 considering when there is (a) −20% variation in parameter value (b) +20% variation in parameter value.Note that parameters that deviated from their ideal values are R f , L f , C f , and V dc .

FIGURE 11 .
FIGURE 11.Simulation waveforms of ac-side variables for the case study wherein R o is changed from 20 to 25 at t = 0.2 s while R l = 50 .(a) Inverter output voltage.(b) Total load current.(c) DBR input current.

FIGURE 12 .FIGURE 13 .TABLE 3 .
FIGURE 12. Simulation waveforms of dc-side variables for the case study wherein R o is changed from 20 to 25 at t = 0.2 s while R l = 50 .(a) DBR output voltage.(b) DBR dc current.(c) Load voltage.

FIGURE 14 .
FIGURE 14. Simulation waveforms of ac-side variables for the case study wherein R l is changed from 50 to 100 at t = 0.3 s while R o = 20 .(a) Inverter output voltage.(b) Total load current.(c) DBR input current.

FIGURE 15 .TABLE 4 .
FIGURE 15.Simulation waveforms of dc-side variables for the case study wherein R l is changed from 50 to 100 at t = 0.3 s while R o = 20 .(a) DBR output voltage.(b) DBR dc current.(c) Load voltage.

FIGURE 16 .
FIGURE 16.Harmonic spectrum of i T and v f for the case study wherein R l is changed from 50 to 100 while R o = 20 .THD is calculated using the first four odd harmonics.(a) Total load current.(b) Inverter output voltage.

FIGURE 17 .
FIGURE 17. Simulation waveforms of ac-side variables from the SW and DP models of a PR-based selective harmonic compensated single-phase inverter connected to linear and nonlinear loads with R o changed from 20 to 25 at t = 0.2 s while R l = 50 .(a) Inverter output voltage.(b) Total load current.(c) DBR input current.

FIGURE 18 .
FIGURE 18. Simulation waveforms of dc-side variables from the SW and DP models of a PR-based selective harmonic compensated single-phase inverter connected to linear and nonlinear loads with R o changed from 20 to 25 at t = 0.2 s while R l = 50 .(a) DBR output voltage.(b) DBR dc current.(c) Load voltage.
(a)] and DBR's output voltage [see Fig. 18(a)] during start-up unlike in Figs.11(a) and 12(a).The start-up transient is caused by the interactions between R d , L d , C o , and R o

FIGURE 19 .FIGURE 20 .
FIGURE 19.Harmonic spectrum of i T and v f from the SW and DP models of a PR-based selective harmonic compensated single-phase inverter connected to linear and nonlinear loads with R o changed from 20 to 25 at t = 0.2 s while R l = 50 .(a) Total load current.(b) Inverter output voltage.

FIGURE 21 .
FIGURE 21.Experimental result for the case wherein R o is changed from 37.5 to 25 with R l = 50 .

FIGURE 22 .FIGURE 23 .
FIGURE 22. Simulation result for the case wherein R o is changed from 37.5 to 25 with R l = 50 .

FIGURE 24 .FIGURE 26 .
FIGURE 24.Simulation result for the case wherein R l is changed from 75 to 50 with R o = 25 .

FIGURE 27 .
FIGURE 27.Proposed methodology for natural frame domain-based Lyapunov-function control scheme.