1 Introduction: Fractional Calculus

Fractional calculus is an increasingly popular field due to its many potential applications. Analyses are performed concerning the usefulness of fractional derivatives and/or integrals in:

  • circuit analyses [17, 19], including the application of fractional capacitors [13, 15, 28, 56] (e.g., in modeling supercapacitors) and fractional coils (in modeling ferromagnetic coils [44]);

  • electromagnetic field analyses for materials with complex properties [9, 12, 16];

  • the design of fractional filters [1, 26, 40];

  • the analysis of fractional-order controllers [6, 38, 43];

  • temperature field analyses [7, 45];

  • viscoelasticity [14, 37].

Many theoretical considerations have been conducted concerning the behavior of fractional-order systems (e.g., stability and controllability analyses [27]). The most important theoretical aspect is, however, the ability to solve problems where fractional derivatives and integrals appear, as this is essential for all other analyses.

Various definitions of the fractional derivative can be found in the literature [25], but the most commonly used definitions are those of Riemann–Liouville [36] and Caputo [8].

This paper considers circuit analyses, specifically those with periodic steady-state sources and fractional or nonlinear elements, even elements that are both fractional and nonlinear. The motivation for the research is given in the next section.

2 Motivation

The current paper presents part of the studies concerning the design of numerical and semi-analytical methods (providing referential solutions) to solve problems with fractional derivatives. The study mainly concerns problems emerging in circuit analyses.

When designing a numerical method, it is appropriate to have means for a reliable assessment of its usefulness. The efficiency of a method is often estimated through analyses of errors [30, 58] and computational components (e.g., the number of basic operations of an algorithm [54] or computation time [33]). When a method has already been implemented, it is worthwhile to test it on selected problems, especially those for which the method is mainly intended. The correctness of the solutions obtained through the method can be determined through:

  • fulfillment of equations specific for the problem, e.g., basic laws, such as Kirchhoff’s laws or the power balance for a circuit problem [39];

  • comparison with results obtained through another method, preferably one operating on a very different basis (e.g., the results obtained through the application of numerical methods are compared with results from analytical solutions [35] and vice versa [53]).

The current study was motivated by the author’s work on the numerical method called SubIval [52] (the subinterval-based method for fractional derivatives in initial value problems). The method is designed mainly with circuit problems in mind, but it is not limited to them in its application.

While determining the accuracy of the method for solving circuit problems, it has been established that:

  • for selected transient problems, the solutions can be compared with results obtained through the evaluation of analytical solutions based on the Mittag–Leffler function [18, 22, 23, 34];

  • steady-state linear AC problems solved with the newly designed numerical methods can be compared with solutions obtained through the application of complex numbers.

It would also be useful to have the ability to obtain referential solutions for nonlinear problems. As suggested previously, it would be ideal if the method for obtaining these solutions had a basis that is very different from that of the method being examined.

The presented methodology has been designed for periodic steady-state nonlinear problems of circuit theory, where the time functions (of which the solution comprises) consist of limited numbers of significant harmonics. The methodology leads a problem to a harmonic balance form. Optionally, the methodology can be based on symbolic computation when acquiring dependencies that result from nonlinearities. The main goal is to obtain steady-state solutions for a selected class of problems that can be used for further improvement in the SubIval numerical method. The considered class of problems is one that results in Eq. (8) described in Sect. 4.

3 Assumptions and Complex Number Representation

The current study is simplified to the case where:

  1. (a)

    the circuit is in a periodic steady state;

  2. (b)

    nonlinearities consist of only strictly increasing odd functions;

  3. (c)

    each time function of the solution consists of odd harmonics, where the highest is represented by the integer \({h_\mathrm {max}}\);

  4. (d)

    the source time functions consist only of odd harmonics, where the first time harmonic is dominant and the highest harmonic (denoted by \({h_\mathrm {max\;src}}\)) is below \({h_\mathrm {max}}\).

Assumption (c) leads to an obvious source of error as harmonics above \(h_\mathrm {max}\) are removed from the result, whereas in reality, even higher harmonics will emerge. This motivates the “harmonic remainder error” defined in Sect. 9.

Every time function of the solution (for the moment denoted by w(t)) can be given by a vector of complex numbers representing the subsequent odd harmonics:

$$\begin{aligned} \underline{\mathbf {w}} = [ \begin{array}{ll l l} \underline{w}_1&\underline{w}_3&\ldots&\underline{w}_{h_\mathrm {max}} \end{array} ]^\mathrm {T}. \end{aligned}$$
(1)

Hence:

$$\begin{aligned} w(t) = \sum _{h=1, 3, 5, \ldots } ^{h_\mathrm {max}} {\text {Im}} \left( \underline{w}_h \exp ( \mathrm {j} \omega _h t ) \right) , \end{aligned}$$
(2)

where the parameter:

$$\begin{aligned} \omega _h = 2 \mathrm {\pi } h f_1 , \end{aligned}$$
(3)

with \(f_1\) being the base frequency.

The study considers the application of the Riemann–Liouville [36] and Caputo [8] definitions of the fractional derivative, where the order is \({\alpha \in (0, 1]}\). For a steady-state analysis, both definitions result in the same operation because they differ by only a component dependent on the initial value [2]. The fractional derivative (in the periodic steady state) can therefore be computed by:

$$\begin{aligned} {\text {D}}_{t}^{\alpha } w(t) = \sum _{h=1, 3, 5, \ldots } ^{h_\mathrm {max}} {\text {Im}} \left( \mathrm {j_\alpha } \omega _{h}^\alpha \underline{w}_h \exp ( \mathrm {j} \omega _h t ) \right) , \end{aligned}$$
(4)

where:

$$\begin{aligned} \mathrm {j_\alpha } = \exp \left( \mathrm {j} \frac{\mathrm {\pi }}{2} \alpha \right) . \end{aligned}$$
(5)

For a fractional integrodifferentiation in a complex vector representation (resulting in a vector \(\underline{\mathbf {d}}\)), one can use the Hadamard product:

$$\begin{aligned} \underline{\mathbf {d}} = \underline{\mathbf {s}}_\alpha \circ \underline{\mathbf {w}}, \end{aligned}$$
(6)

where:

$$\begin{aligned} \underline{\mathbf {s}}_\alpha = \left[ \begin{array}{ll l l} \mathrm {j_\alpha } \omega _{1}^\alpha&\mathrm {j_\alpha } \omega _{3}^\alpha&\ldots&\mathrm {j_\alpha } \omega _{h_\mathrm {max}}^\alpha \end{array} \right] ^\mathrm {T}. \end{aligned}$$
(7)

4 General Form of the Considered System of Equations

4.1 Time-Dependent Form

The methodology is designed for problems that yield a system of equations in the following form:

$$\begin{aligned} {\left\{ \begin{array}{ll} \mathbf {M}_\mathrm {I} \mathbf {y} (t) + \mathbf {M}_\mathrm {II} \mathbf {x} (t) = \mathbf {T} \mathbf {v} (t) + \left[ \begin{array}{c} \mathbf {0}_{n_y - n_\mathrm {NL}}\\ \mathbf {F}_\mathrm {NL}(\mathbf {w}(t)) \end{array} \right] ,\\ \mathbf {D} _t ^{ \varvec{\alpha } } \mathbf {x}(t) + \mathbf {M}_\mathrm {III} \mathbf {y} (t) + \mathbf {M}_\mathrm {IV} \mathbf {x} (t) = \mathbf {0}_{n_x}, \end{array}\right. } \end{aligned}$$
(8)

where \(\mathbf {x}(t)\) is a vector of \(n_x\) state variables, and \(\mathbf {y}(t)\) is a vector of all the remaining \(n_y\) variables. The vector \(\mathbf {v}(t)\) (of size \(n_v\)) contains all the source time functions. The vector \(\mathbf {w}(t)\) contains all the variables being computed:

$$\begin{aligned} \mathbf {w}(t) = \left[ \begin{array}{ll} \mathbf {y}(t) \\ \mathbf {x}(t) \end{array} \right] , \end{aligned}$$
(9)

hence, the total number of computed variables \(n_w = n_y + n_x\). The component \( \mathbf {D}_t ^{ \mathbf {\alpha } } \mathbf {x}(t) \) contains the fractional derivatives (each in either the Riemann–Liouville definition or Caputo definition):

$$\begin{aligned} \mathbf {D}_t ^{ \mathbf {\alpha } } \mathbf {x}(t) = \left[ \begin{array}{llll} \mathrm {D}_t ^{ \alpha _1 } x_1(t)&\mathrm {D} _t ^{ \alpha _2 } x_2(t)&\ldots&\mathrm {D} _t ^{ \alpha _{n_x} } x_{n_x}(t) \end{array} \right] ^\mathrm {T}, \end{aligned}$$
(10)

with \(\varvec{\alpha }\) denoting the vector of fractional derivative orders. As for the other components:

  • \(\mathbf {M}_\mathrm {I}\) is an \(n_y \times n_y\) matrix;

  • \(\mathbf {M}_\mathrm {II}\) is an \(n_y \times n_x\) matrix;

  • \(\mathbf {M}_\mathrm {III}\) is an \(n_x \times n_y\) matrix;

  • \(\mathbf {M}_\mathrm {IV}\) is an \(n_x \times n_x\) matrix;

  • \(\mathbf {T}\) is an \(n_y \times n_v\) matrix;

  • \(\mathbf {F}_\mathrm {NL}(\mathbf {w}(t))\) contains \(n_\mathrm {NL}\) nonlinear functions (generally dependent on \(\mathbf {w}(t)\), but in truth each depends on only one variable);

  • a vector denoted by \(\mathbf {0}_k\) is one consisting of k zeros.

Note that nonlinearities are given in the form:

$$\begin{aligned} w_{i_\mathrm {LHS}} = f_{\mathrm {NL}\;i}\left( w_{i_\mathrm {arg}}\right) , \end{aligned}$$
(11)

where \(i_\mathrm {LHS}\) is the index of the left-hand side variable, which depends on \(f_{\mathrm {NL}\;i}\). \(i_\mathrm {arg}\) is the index of the argument of the nonlinear function. Hence, the left-hand sides contribute to entries in \(\mathbf {M}_\mathrm {I}\) or \(\mathbf {M}_\mathrm {II}\), and each nonlinear dependency is stored in \(\mathbf {F}_\mathrm {NL}(\mathbf {w}(t))\).

For further convenience, the nonlinear dependencies are represented as follows:

$$\begin{aligned} \mathbf {F}_\mathrm {NL}\left( \mathbf {w}(t)\right) = \left[ \begin{array}{ll l l} f_\mathrm {NL\;1}\left( w_{\left( {\mathbf {i}_\mathrm {arg}}\right) _1}\right)&f_\mathrm {NL\;2}\left( w_{\left( {\mathbf {i}_\mathrm {arg}}\right) _2}\right)&\ldots&f_{\mathrm {NL}\;n_\mathrm {NL}} \left( w_{\left( {\mathbf {i}_\mathrm {arg}}\right) _{n_\mathrm {NL}}}\right) \end{array} \right] ^\mathrm {T}, \end{aligned}$$
(12)

where it is assumed that the dependencies on the appropriate variables are indexed by integers placed in the auxiliary vector \(\mathbf {i}_\mathrm {arg}\) (the notation \((\mathbf {i}_\mathrm {arg})_k\) denotes the kth element of the vector \(\mathbf {i}_\mathrm {arg}\)). Additionally, another auxiliary vector, called \(\mathbf {i}_\mathrm {LHS}\), has been used to store the indices of the left-hand side variables of the nonlinear functions in the form of (11). This application of auxiliary integer vectors has greatly aided the implementation of the methodology.

4.2 Conversion to the Harmonic Balance Form

The current subsection discusses the core of the proposed methodology. For a periodic steady-state problem resulting in a system of nonlinear equations in the form of (8) (including fractional differential equations), the proposed method provides the ability to obtain an alternative system of nonlinear equations representing relations of the sought variables’ harmonics.

The solution is sought in the form of real and imaginary parts (i.e., the sine and cosine components of the actual time function) for each harmonic h of variable \(w_i\). This approach is common [11, 29, 55], although the magnitude and angle of the complex number could also be considered (as in [31]). The harmonics are denoted by \(\underline{w}_{i,h} = w_{i, h\;\mathrm {s}}+\mathrm {j} w_{i, h\;\mathrm {c}}\).

The solution vector is:

$$\begin{aligned} \begin{array}{rlllll} \mathbf {w} = [ &{} w_{1,1\;\mathrm {s}} &{} w_{2,1\;\mathrm {s}} &{} \ldots &{} w_{n_w,1\;\mathrm {s}}\\ &{} w_{1,1\;\mathrm {c}} &{} w_{2,1\;\mathrm {c}} &{} \ldots &{} w_{n_w,1\;\mathrm {c}}\\ &{} w_{1,3\;\mathrm {s}} &{} w_{2,3\;\mathrm {s}} &{} \ldots &{} w_{n_w,3\;\mathrm {s}}\\ &{} w_{1,3\;\mathrm {c}} &{} w_{2,3\;\mathrm {c}} &{} \ldots &{} w_{n_w,3\;\mathrm {c}}\\ &{} \ldots \\ &{} w_{1,h_\mathrm {max}\;\mathrm {s}} &{} w_{2,h_\mathrm {max}\;\mathrm {s}} &{} \ldots &{} w_{n_w,h_\mathrm {max}\;\mathrm {s}}\\ &{} w_{1,h_\mathrm {max}\;\mathrm {c}} &{} w_{2,h_\mathrm {max}\;\mathrm {c}} &{} \ldots &{} w_{n_w,h_\mathrm {max}\;\mathrm {c}} &{} ]^\mathrm {T}. \end{array} \end{aligned}$$
(13)

The system of nonlinear equations has the form:

$$\begin{aligned} (\mathbf {A} + \mathbf {A}_\mathrm {j}) \mathbf {w} = \mathbf {b} + \mathbf {N}(\mathbf {w}). \end{aligned}$$
(14)

Subject to (13), matrix \(\mathbf {A}\) can be rewritten in the following convenient form:

$$\begin{aligned} \mathbf {A} = {\text {diag}} \left( \left[ \begin{array}{lllllll} \mathbf {A}_1&\mathbf {A}_1&\mathbf {A}_3&\mathbf {A}_3&\ldots&\mathbf {A}_{h_\mathrm {max}}&\mathbf {A}_{h_\mathrm {max}} \end{array} \right] \right) , \end{aligned}$$
(15)

where the auxiliary matrix:

$$\begin{aligned} \mathbf {A}_h = \left[ \begin{array}{c c} \mathbf {M}_\mathrm {I}&{} \mathbf {M}_\mathrm {II}\\ \mathbf {M}_\mathrm {III} &{} \mathbf {M}_\mathrm {IV} + \mathbf {S}_{h\;\mathrm {R}} \end{array} \right] \end{aligned}$$
(16)

contains the multipliers of both the sine and cosine components of harmonic h of the solution [which is why each \(\mathbf {A}_h\) appears twice in (15)]. The component \(\mathbf {S}_{h\;\mathrm {R}}\) results from (7); it is a diagonal matrix of the form:

$$\begin{aligned} \mathbf {S}_{h\;\mathrm {R}} = {\text {diag}} \left( {\text {Re}} \left( \left[ \begin{array}{ll l l} \mathrm {j}_{\alpha _1} \omega _{h}^{\alpha _1}&\mathrm {j}_{\alpha _2} \omega _{h}^{\alpha _2}&\ldots&\mathrm {j}_{\alpha _{n_x}} \omega _{h}^{\alpha _{n_x}} \end{array} \right] \right) \right) . \end{aligned}$$
(17)

The matrix denoted by \(\mathbf {A}_\mathrm {j}\) features only components that arise from (7); it can be presented as:

$$\begin{aligned} \mathbf {A}_\mathrm {j} = {\text {diag}} \left( \left[ \begin{array}{ll ll l ll} \mathbf {A}_\mathrm {j\;1}&\mathbf {A}_\mathrm {j\;3}&\ldots&\mathbf {A}_{\mathrm {j}\;h_\mathrm {max}} \end{array} \right] \right) , \end{aligned}$$
(18)

where all \(\mathbf {A}_{\mathrm {j}\;h}\) are sparse matrices of the form:

(19)

where the notation \(\mathbf {0}_{k \times j}\) represents a zero matrix with k rows and j columns. \(\mathbf {S}_{h\;\mathrm {I}}\) are diagonal matrices that (like \(\mathbf {S}_{h\;\mathrm {R}}\)) result from (7). They have the following form:

$$\begin{aligned} \mathbf {S}_{h\;\mathrm {I}} = {\text {diag}} \left( {\text {Im}} \left( \left[ \begin{array}{ll l l} \mathrm {j}_{\alpha _1} \omega _{h}^{\alpha _1}&\mathrm {j}_{\alpha _2} \omega _{h}^{\alpha _2}&\ldots&\mathrm {j}_{\alpha _{n_x}} \omega _{h}^{\alpha _{n_x}} \end{array} \right] \right) \right) . \end{aligned}$$
(20)

The right-hand side vector \(\mathbf {b}\) in (14) can be filled after determining the harmonics of each source \(v_i(t)\):

$$\begin{aligned} v_i(t) = \sum _{h = 1, 3, \ldots } ^{h_\mathrm {max\;src}} v_{i,h\;\mathrm {s}} \sin (\omega _h t) + v_{i,h\;\mathrm {c}} \cos (\omega _h t). \end{aligned}$$
(21)

Then:

(22)

\(\mathbf {N}(\mathbf {w})\) is a sparse vector filled only for entries resulting from the nonlinear equations of (8). Since each nonlinear function of \(\mathbf {F}_\mathrm {NL}(\mathbf {w}(t))\) in (8) actually depends on only one variable of \(\mathbf {w}(t)\), the dependencies can be written as:

(23)

where the nonlinear dependency \(N_{i, h, \mathrm {part}}(w_{(\mathbf {i}_\mathrm {arg})_i})\) is the appropriate part (sine or cosine) of the hth harmonic, resulting from the original nonlinear dependency \(f_{\mathrm {NL}\;i}(w_{(\mathbf {i}_\mathrm {arg})_i})\). Two methods of addressing the nonlinear dependencies are discussed in Sect. 6.

5 Remarks on Nonlinear Solver

Because of the composite form of the resulting nonlinear dependencies given in \(\mathbf {N}(\mathbf {w})\), which could introduce problems when attempting to solve the resulting nonlinear system of equations, a stage-based methodology is proposed. Such an approach, whether used for solving systems of equations or optimization problems [32], can be very useful when a large number of unknowns is considered and when there is uncertainty about what problems the nonlinearities can introduce for a selected solution technique.

In the first stage, a single-harmonic solution is assumed, and the resulting system of equations is solved. This solution is used as the starting point for the first time harmonic when seeking the solution in the next stage, i.e., for \(h_\mathrm {max} = 3\). In each subsequent stage (up to the actual \(h_\mathrm {max}\)), the solution of the previous stage is used as the initial guess for the harmonics up to \(h_\mathrm {max} - 2\).

Furthermore, only the final stage requires a low error tolerance for the internal iterative solver being used. The error tolerance for all the other stages can be much smaller as the role of these stages is only to get close to the solution.

6 Handling Nonlinear Dependencies

Two approaches to addressing the nonlinear dependencies in \(\mathbf {N}(\mathbf {w})\) are described in this paper. The first is based on symbolic computation, and the second relies on the extraction of harmonics from periodic time functions.

6.1 Symbolic Computation Approach

In this approach, it is assumed that the nonlinear dependencies are, or can be, approximated (with reasonable accuracy) by an odd power series with maximum power \({k_\mathrm {max}}\).

When assuming a complex harmonic representation, whenever a nonlinear dependency appears, it is first converted into a set of dependencies for the appropriate harmonics. A nonlinear function \({f_\mathrm {NL}}\) is represented by an odd power series following assumption (b) of Sect. 3:

$$\begin{aligned} f_\mathrm {NL}(w) = \sum _{k=1, 3, 5, \ldots } ^{k_\mathrm {max}} c_k w^k . \end{aligned}$$
(24)

The result has a maximum time harmonic \(h = k_\mathrm {max} h_\mathrm {max}\).

The result of each exponentiation of the time function w by the integer k, cut down to harmonics \(h = h_\mathrm {max}\) and below, can be represented by a collection of nonlinear dependencies:

$$\begin{aligned} \underline{\varvec{\Upsilon }}_k ( \underline{\mathbf {w}} ) = \left[ \begin{array}{ll l l} \underline{{\varUpsilon }}_{k,1} ( \underline{\mathbf {w}} )&\underline{{\varUpsilon }}_{k,3} ( \underline{\mathbf {w}} )&\ldots&\underline{{\varUpsilon }}_{k,h_\mathrm {max}} ( \underline{\mathbf {w}} ) \end{array} \right] ^\mathrm {T} , \end{aligned}$$
(25)

with \(\underline{\mathbf {w}}\) following Eq. (1).

To derive the dependencies in symbolic form, the author has applied a simple lightweight library for the symbolic computation of multivariate polynomials [48]. An efficient algorithm for multivariate polynomial multiplication greatly decreases the time needed to perform the required symbolic computations, even when considering many terms [50].

The base operation for obtaining the harmonics’ dependencies is multiplication between two harmonics \(h = i\) and \(j \le i\) of the harmonics vectors \(\underline{\mathbf {w}}\) and \(\underline{\mathbf {u}}\). This multiplication contributes to the harmonics \(h = i - j\) and \(h = i + j\) of the total result, as depicted in Fig. 1.

The real and imaginary parts of the nonlinear dependencies given by the symbol \(\underline{{\varUpsilon }}\) generally have the form of multivariate polynomials in expanded form:

$$\begin{aligned} {\varUpsilon }_\mathrm {part}(\underline{\mathbf {w}}) = \sum _{i = 1}^{N} a_i \prod _{h=1,3,5,...} ^{h_\mathrm {max}} {\text {Re}} ( \underline{w}_h ) ^{k_{i, h\;\mathrm {s}}} {\text {Im}} ( \underline{w}_h ) ^{k_{i, h\;\mathrm {c}}} , \end{aligned}$$
(26)

where \(a_i\) are real-valued multipliers, k represents nonnegative exponentiations, and N is the number of monomials.

Fig. 1
figure 1

Base operation for obtaining the harmonics emerging from nonlinear functions: multiplication of two harmonics

As \(h_\mathrm {max}\) and \(k_\mathrm {max}\) increase, the dependencies take the form of very large symbolic objects, where not only memory but also the computation time could be an issue. However, one advantage is that these computations need to be performed only once for all integers \(k \le k_\mathrm {max}\) and a selected \(h_\mathrm {max}\), and the results can be saved for later use. The formulation of any nonlinear dependency collection:

$$\begin{aligned} \underline{\mathbf {f}}_\mathrm {NL}(\underline{\mathbf {w}}) = \sum _{k=1, 3, 5, \ldots } ^{k_\mathrm {max}} c_k \underline{\varvec{\Upsilon }}_k ( \underline{\mathbf {w}} ) \end{aligned}$$
(27)

and other operations that could be required during the solution process (such as differentiation during Jacobian matrix evaluations) do not introduce much numerical weight for efficient symbolic computation implementations [49].

The dependencies in each \(\underline{\mathbf {f}}_\mathrm {NL}(\underline{\mathbf {w}})\) can be used when addressing \(\mathbf {N}(\mathbf {w})\) in (23).

6.2 Time Function Approach

The second proposed approach to address the nonlinear dependencies is based on a much simpler concept. Instead of knowing the form of \(\mathbf {N}(\mathbf {w})\), as in the symbolic approach, the actual dependencies are handled only during evaluations of a nonlinear system solver.

The evaluation of \(\mathbf {N}(\mathbf {w})\) is performed according to the following instructions:

  1. (a)

    for each nonlinear dependency \(f_{\mathrm {NL}\;i}(w_{(\mathbf {i}_\mathrm {arg})_i})\), the harmonics of \(\upsilon = w_{(\mathbf {i}_\mathrm {arg})_i}\) are used;

  2. (b)

    \(n_t\) points, denoted by \(t_1, t_2, \ldots t_{n_t}\) (inside the interval [0, T], with \(T = \frac{1}{f_1}\)), are selected;

  3. (c)

    for each of the points on the time axis, the time function of the nonlinear function’s argument \(\upsilon \) is evaluated, resulting in values denoted by \(\upsilon _1, \upsilon _2, \ldots \upsilon _{n_t}\);

  4. (d)

    the results (denoted by \(r_j\)) are computed:

    $$\begin{aligned} r_j = f_{\mathrm {NL}\;i}(\upsilon _j), \quad j = 1, 2, \ldots n_t; \end{aligned}$$
    (28)
  5. (e)

    the harmonics for \(h = 1, 3, \ldots h_\mathrm {max}\) are obtained with a selected algorithm (e.g., fast Fourier transform or the Vaníček method [57]); these harmonics are then used to fill the vector resulting from the evaluation of \(\mathbf {N}(\mathbf {w})\).

A comparison of some of the properties of the two approaches (with respect to how the nonlinear dependencies are handled) is given in Table 1.

Table 1 Comparison of the approaches for addressing the nonlinear dependencies in \(\mathbf {F}_\mathrm {NL}(\mathbf {w}(t))\)

7 Remarks on the Implementation

The conversion from (8) to (14), according to the harmonic balance methodology, is performed with programs and libraries written by the author in C#. The Math.NET Numerics library [42] is applied for matrix and vector operations.

The harmonic balance methodology can be applied for a problem in the form of 8. All the necessary information about the problem is put into an object, which is named prob. The base of the \(\mathbf {A}\) matrix, which is independent of frequency (formulated from the \(\mathbf {M}_\mathrm {I}\), \(\mathbf {M}_\mathrm {II}\), \(\mathbf {M}_\mathrm {III}\) and \(\mathbf {M}_\mathrm {IV}\) matrices), can be formulated using the following fragment of code.

figure a

The matrices are all \(\textit{Matrix} {<}{} \textit{double}{>}\) objects of the Math.NET Numerics library, and the vectors appear as \(\textit{Vector} {<}{} \textit{double}{>}\) objects. Next, the \(\mathbf {A} + \mathbf {A}_\mathrm {j}\) matrix and the \(\mathbf {b}\) vector of (14) are prepared. Additionally, the nonlinear dependencies of the problem are copied and are then applied to enable evaluation of \(\mathbf {N}(\mathbf {w})\) on the right-hand side of (14). The formulations must be done for all stages of the nonlinear solver described in Sect. 7. The following code fragment is applied.

figure b

The NLinfo object contains information about the nonlinear dependencies of the original system. A separate procedure controls the evaluations of \(\mathbf {N}(\mathbf {w})\), either using evaluations of symbolic expressions or following the time function approach described in Sect. 6.2.

8 Computational Examples

8.1 Example 1

The discussed methodology has been verified via computational examples. Two of these examples are presented in this paper. The first concerns the circuit presented in Fig. 2. The circuit is purely theoretical, but it features elements that appear in analyses of real circuits, e.g., strictly increasing nonlinearities, which ensure a unique solution.

Fig. 2
figure 2

Circuit with integer-order coil, fractional-order capacitor (of order \(\beta \)), fractional (nonlinear) coil (of order \(\gamma \)) and a nonlinear resistor. The fractional-order elements are marked with parentheses and the order of the respective element

The fractional capacitor is described by the equation:

$$\begin{aligned} C_\beta \mathrm {D}_t^\beta u_\mathrm {cmn} = i_C , \end{aligned}$$
(29)

where \(u_\mathrm {cmn}\) denotes the common voltage of the fractional capacitor, nonlinear coil and nonlinear resistor. For the fractional, nonlinear coil, the differential equation is:

$$\begin{aligned} \mathrm {D}_t^\gamma \psi = u_\mathrm {cmn} , \end{aligned}$$
(30)

where \(\psi \) is the pseudo-flux of the fractional coil (unit: \(\mathrm {Wb}\cdot \mathrm {s}^{\gamma -1}\)). The nonlinear function \(\psi (i_\psi )\) is given by:

$$\begin{aligned} \psi (i_\psi ) = \psi _0 {\text {arctan}}\left( \frac{i_\psi }{i_0} \right) , \end{aligned}$$
(31)

where \(\psi _0\) and \(i_0\) are the nonlinear function parameters:

$$\begin{aligned} \psi _0= & {} 1.05\;\mathrm {Wb}\cdot \mathrm {s}^{\gamma -1},\nonumber \\ i_0= & {} 0.18\;\mathrm {A}. \end{aligned}$$
(32)

The nonlinear resistor \(R_\mathrm {NL}\) is described by the equation:

$$\begin{aligned} i(u_\mathrm {cmn}) = g_1 u_\mathrm {cmn} + g_3 u_\mathrm {cmn}^3, \end{aligned}$$
(33)

with the nonlinear function parameters:

$$\begin{aligned} g_1= & {} 10^{-4}\;\mathrm {S},\nonumber \\ g_3= & {} 10^{-6}\;\mathrm {S\cdot V^{-2}}. \end{aligned}$$
(34)

For the considered circuit, it is possible to formulate equations in the form of (8) and, by applying the harmonic balance methodology, to transform the problem to the form of (14).

The transformation of presented problem to the form of (8) is described in Appendix A.

For the two approaches to addressing the nonlinear dependencies, if the symbolic approach is selected, then the arctangent function must first be approximated by a power series. First, however, it is worthwhile to modify the dependency from \(\psi (i_\psi )\) to \(i_\psi (\psi )\):

$$\begin{aligned} i_\psi (\psi ) = i_0 {\text {tan}} \left( \frac{\psi }{\psi _0} \right) , \end{aligned}$$
(35)

because fewer power series terms are required.

However, for the analysis presented in this paper, the time function approach is applied to directly address the original nonlinear dependencies.

The solution of the time periodic problem is obtained for \(h_\mathrm {max} = 25\) in the form of the vector \(\mathbf {w}\), as given in Eq. (13). Then, the solution is converted to a time-dependent form. The results (for 3 periods) are depicted in Fig. 3 along with a comparison with a numerical solution obtained by means of a solver using SubIval [47, 52].

The computations of SubIval use the author’s C# programs and apply a DLL available at [47]. The library uses part of the code given in [10] to compute the gamma function. The SubIval step size adaptive solver requires a system of nonlinear equations to be solved at each iteration. For this purpose, a modified Gauss–Newton method, which applies methods and classes from the Math.NET Numerics library, is implemented.

The solver can obtain a time-dependent solution; hence, \(n_T = 10\) periods of the solution are obtained. Then, only the final solution is compared with the periodic steady-state solution obtained by solving the system of equations resulting from the harmonic balance methodology. All the initial conditions for the state variables (\(i_L\), \(u_\mathrm {cmn}\) and \(\psi \)) are set to zero, and the variables selected for comparison are the state variables.

One can notice that as the number of periods increases, the results become closer to each other. To reliably ascertain how close the results are, two criteria have been proposed, both of which are explained in Sect. 9.

Fig. 3
figure 3

Comparison of the time functions for the analysis of the circuit in Fig. 2 obtained through the application of the harmonic balance methodology (periodic steady-state solution) and by applying the SubIval time step size adaptive solver (transient solution): a current \(i_L(t)\) through the coil L, b fractional capacitor \(C_\beta \) voltage \(u_\mathrm {cmn}(t)\), c pseudo-flux \(\psi \) in the fractional, nonlinear coil \(L_\psi \)

The time required to complete this taskFootnote 1 for \(h_\mathrm {max} = 5\) is only \(0.26\,\mathrm {s}\), whereas \(h_\mathrm {max} = 25\) requires \(14.73\,\mathrm {s}\). Naturally, the more complicated the problem is (especially when adding nonlinear elements), the more the computation time will increase when taking into account more harmonics, especially if the nonlinear system is to be solved with high accuracy (note that the final stage of the nonlinear solver is always executed with a lower tolerance for the objective function).

Naturally, the methodology can also be applied in an integer-order case where \(\beta \) and \(\gamma \) are equal to 1. The manner in which the general equations for the problem [i.e., in the form of (8)] are formulated is the same, but when applying the harmonic balance methodology, the matrix denoted by \(\mathbf {S}_{h\;\mathrm {R}}\) in Sect. 4.2 is empty and:

$$\begin{aligned} \mathbf {S}_{h\;\mathrm {I}} = {\text {diag}} \left( \left[ \begin{array}{ll l l} \omega _{h}^{\alpha _1}&\omega _{h}^{\alpha _2}&\ldots&\omega _{h}^{\alpha _{n_x}} \end{array} \right] \right) \end{aligned}$$
(36)

because all the derivative orders are equal to 1. The SubIval solver can still be applied because SubIval itself supports first-order time derivatives [52]. The results of the comparison in the integer-order case are presented in Fig. 4.

Fig. 4
figure 4

Comparison of the time functions for the analysis of the circuit in Fig. 2 when assuming integer-order time derivatives (i.e., \(\alpha = 1, \beta = 1\) and \(\gamma = 1\)). The results are obtained through the application of the harmonic balance methodology (periodic steady-state solution) and by applying the SubIval time step size adaptive solver (transient solution): a current \(i_L(t)\) through the coil L, b fractional capacitor \(C_\beta \) voltage \(u_\mathrm {cmn}(t)\), c magnetic flux \(\psi (t)\) through the fractional, nonlinear coil \(L_\psi \)

In the case of integer-order derivatives, the waveforms also indicate a steady-state result similar to the numerical solution. The results are also verified through the criteria discussed in Sect. 9.

8.2 Example 2

The second example concerns the steady-state solution of the circuit presented in Fig. 5. This example is also purely theoretical.

Fig. 5
figure 5

Circuit with fractional and nonlinear elements. The fractional-order elements are again indicated by parentheses and the order of the respective element

The circuit features two nonlinear coils, where the first (denoted by the symbol \(L_\psi \)) is described by the same nonlinear function as in the previous example [this time denoted by \(\psi = \psi (i_\psi )\), given in Eq. (31)] and the differential equation:

$$\begin{aligned} \mathrm {D}_t^\gamma \psi = u_\psi , \end{aligned}$$
(37)

this time appearing with a different order \(\gamma \).

The second coil is described by the fractional differential equation:

$$\begin{aligned} \mathrm {D}_t^\lambda {\varPhi } = u_{\varPhi } . \end{aligned}$$
(38)

\({\varPhi }\) is an artificial variable (referred to as the “pseudo-flux”, whose unit is \(\mathrm {Wb}\cdot \mathrm {s}^{\lambda -1}\)) of the second coil. The relation between \({\varPhi }\) and the current \(i_{\varPhi }\) is described by the nonlinear equation:

$$\begin{aligned} i_{\varPhi } ( {\varPhi } ) = c_{{\varPhi }\;1} {\varPhi } + c_{{\varPhi }\;5} {\varPhi }^5. \end{aligned}$$
(39)

The parameters taken for the computation in this paper are:

$$\begin{aligned} c_{{\varPhi }\;1}= & {} 0.03\;\frac{\mathrm {s}^{1-\lambda }}{\mathrm {H}},\nonumber \\ c_{{\varPhi }\;5}= & {} 4\;\frac{\mathrm {A}\cdot \mathrm {s}^{5-5 \lambda }}{\mathrm {Wb}^5}. \end{aligned}$$
(40)

The circuit features one more element that is both fractional and nonlinear, the capacitor denoted by \(C_q\). The relation between its voltage \(u_q\) and the variable q (with the unit \(\mathrm {C}\cdot \mathrm {s}^{\beta -1}\)) is described by the equation:

$$\begin{aligned} u_q ( q ) = b_1 q + b_3 q^3, \end{aligned}$$
(41)

where the following values are assumed:

$$\begin{aligned} b_1= & {} 1.25\times 10^{7}\;\frac{\mathrm {s}^{1-\beta }}{\mathrm {F}},\nonumber \\ b_3= & {} 10^{17}\;\frac{\mathrm {V}\cdot \mathrm {s}^{3- 3\beta }}{\mathrm {C}^3}. \end{aligned}$$
(42)

The differential equation for this element is:

$$\begin{aligned} \mathrm {D}_t^\beta q = i_q . \end{aligned}$$
(43)
Fig. 6
figure 6

Comparison of the time functions (3 periods) for the analysis of the circuit in Fig. 5 obtained through the application of the harmonic balance methodology (periodic steady-state solution with \(h_\mathrm {max} = 25\)) and by applying the SubIval time step size adaptive solver (transient solution): a \(\psi (t)\) of the coil \(L_\psi \), b \({\varPhi }(t)\) of the coil \(L_{\varPhi }\), c current \(i_L(t)\) through the coil L, d voltage \(u_C(t)\) over the capacitor C, e q(t) of the capacitor \(C_q\)

Fig. 7
figure 7

Comparison of the time functions for the analysis of the circuit in Fig. 5 (for integer-order time derivatives) obtained through the application of the harmonic balance methodology (periodic steady-state solution) and by applying the SubIval time step size adaptive solver (transient solution): a flux \(\psi (t)\) through the coil \(L_\psi \), b flux \({\varPhi }(t)\) through the coil \(L_{\varPhi }\), c current \(i_L(t)\) through the coil L, d voltage \(u_C(t)\) over the capacitor C, e charge q(t) in the capacitor \(C_q\)

The nonlinear resistor \(R_\mathrm {NL}\) follows the same nonlinear dependency as in the example in Sect. 8.1 (in this case, denoted by \(i_\psi (u_\mathrm {NL})\)).

The formulation of a system of equations in the form (8) for the discussed problem is presented in Appendix B.

The solution for the problem is obtained for \(h_\mathrm {max} = 25\), which was sufficient to obtain a solution with satisfactory accuracy (with respect to the criteria defined in Sect. 9). The solutions are again compared with those obtained through the time stepping solver applying SubIval. The final (\(n_T\)th) period of the solution is selected for the error calculations.

The state variable time functions (\(\psi \), \({\varPhi }\), \(i_L\), \(u_C\) and q) are selected for the comparison. The first three periods of the solutions are depicted in Fig. 6.

Because this problem contains more variables and more nonlinear dependencies than in the previous example, the computation times are longer. For \(h_\mathrm {max} = 5\), the task required only \(1.32\;\mathrm {s}\); however, for \(h_\mathrm {max} = 25\), the duration was much longer, i.e., \(264.66\;\mathrm {s}\).

For this example, the solution is also been verified through the criteria explained in Sect. 9.

As in the previous example, the harmonic balance methodology can also be applied for an integer-order case, where \(\mathbf {\alpha }\) is a vector of ones. The results for this case are presented in Fig. 7.

9 Accuracy Criteria

9.1 Comparison with the Numerical Result

The first criterion by which the accuracy of the solution is determined is comparison with results obtained through the SubIval solver, which can obtain highly accurate solutions for linear transient problems and AC problems [46, 51, 52]. The most important parameters for the SubIval solver are given in Table 2.

Table 2 Parameters for the numerical computations of the SubIval solver

The above parameters are used for both problems (note that T is dependent on the base frequency, which is 50 Hz for the first problem and 60 Hz for the second problem).

\(p_\mathrm {mov}\) is the order of the polynomial approximation used in the core computations of SubIval, \(e_\mathrm {max}\) is the maximum allowed estimated error, \(e_\mathrm {ctrl}\) is the desired value of the estimated error (according to which the adaptive solver modifies the time step), and \(\Delta t_\mathrm {min}\) and \(\Delta t_\mathrm {max}\) are, respectively, the minimum and maximum values of the step size.

The results obtained for the harmonic balance methodology are compared with the numerical solution for time nodes \(t_1, t_2, \ldots t_n\) of the last period (i.e., \(t \in [(n_T - 1) T, n_T T]\)). The time nodes are those selected by the SubIval solver during the time stepping process. The error for a selected variable w is computed according to the following formula:

$$\begin{aligned} e_\mathrm {an\;versus\;num} = 100\cdot \frac{| w(t_i) - w_{\mathrm {num}\;i} |}{\max \limits _{i = 1, 2, \ldots n} |w(t_i)|} \%, \end{aligned}$$
(44)

where \(w_{\mathrm {num}\;i}\) is the value obtained by the SubIval solver for the time instance \(t_i\).

9.1.1 Results for Example 1

The maximum and average of the obtained error values, for the selected variables (\(i_L\), \(u_\mathrm {cmn}\) and \(\psi \)), are given in Table 3. The error has been checked for the case of \(h_\mathrm {max} = 25\) (mentioned in the previous section), along with a less demanding solution obtained for \(h_\mathrm {max} = 5\).

Table 3 Average and maximum errors (relative differences between the analytical and numerical solutions) for the selected variables (values are rounded to 3 significant digits)

The error values show that as the number of considered harmonics increases, the results get closer to those obtained by means of the SubIval solver. Table 4 shows the average and maximum error values for the case where the inertial elements are replaced by their integer-order alternatives.

Table 4 Average and maximum errors (relative differences between the analytical and numerical solutions) for the selected variables in the integer-order derivative case (values are rounded to 3 significant digits)

Again, smaller error values are obtained for larger \(h_\mathrm {max}\), which indicates that the methodology also works for the integer-order case and can be applied to classic periodic steady-state nonlinear problems in circuit theory. Additionally, the errors are in a similar range as those for the fractional case.

9.1.2 Results for Example 2

Table 5 presents the error values obtained for the fractional case of the second example, and Table 6 gives the results for the integer-order case.

Table 5 Average and maximum errors (relative differences between the analytical and numerical solutions) for the selected variables (values are rounded to 3 significant digits)
Table 6 Average and maximum errors (relative differences between the analytical and numerical solutions) for the selected variables in the first-order derivative case (values are rounded to 3 significant digits)

As for the error values in the first example, more accurate solutions are obtained when \(h_\mathrm {max}\) is larger according to the considered criterion. Additionally, the same conclusion can be drawn for the integer-order case.

9.2 Harmonic Remainder Error

Clearly, for the \(h_\mathrm {max}\) harmonics, each nonlinear dependency will yield harmonics greater than this number (which are later not taken into account). This practice of cutting off harmonics is necessary when analyzing the result for each variable as coefficients of a Fourier series.

After the solution is obtained, one can estimate the harmonics that have been cut off for each nonlinear dependency, which can be done by evaluating the harmonics through multiplication (such as when the symbolic computation approach is selected to address the nonlinear dependencies). However, this process would require each of the nonlinear dependencies to be given as a power series. To directly address the nonlinear dependencies, the time function approach is selected for the computations described in this paper. The harmonics that have been cut off are determined in a similar way. This strategy can be viewed as simply the application of the time function approach with an attempt to obtain additional harmonics (\(h_\mathrm {remainder} > h_\mathrm {max}\)) in the final step (step (e) described in Sect. 6.2). \(h_\mathrm {remainder} = 51\) is selected for further computations.

Through this approach, one can estimate not only the omitted harmonics but also a measure of correctness for the harmonics appearing in the obtained solution. Both the included and omitted harmonics in the solution are taken into account in what is later called the “harmonic remainder error”.

For each nonlinear function, the harmonics of the right-hand side (denoted by \(\underline{R}_h\) each) are obtained for the mentioned harmonics up to \(h_\mathrm {remainder}\). Assuming that \(\underline{L}_h\) denotes the harmonics of the variable on the left-hand side of the nonlinear equation [note that the nonlinear functions still follow the form of Eq. (11)], an error value can be computed for each of the harmonics:

$$\begin{aligned} e_h = {\left\{ \begin{array}{ll} |\underline{L}_h - \underline{R}_h| &{} \text{ if } h \le h_\mathrm {max},\\ |\underline{R}_h| &{} \text{ if } h > h_\mathrm {max}. \end{array}\right. } \end{aligned}$$
(45)

The harmonic remainder error is computed by the formula:

$$\begin{aligned} e_\mathrm {harm.\;rem.} = 100 \cdot \frac{ \sqrt{ \sum _{h=1, 3, \ldots }^{h_\mathrm {remainder}} e_{h}^2 } }{ L_\mathrm {max} } \;\%, \end{aligned}$$
(46)

where \(L_\mathrm {max}\) denotes the maximum value of the time function obtained for the left-hand side variable of the nonlinear equation (i.e., the maximum taken from an arbitrarily selected sufficient number of points).

9.2.1 Results for Example 1

The harmonic remainder error values obtained for \(h_\mathrm {max} = 25\) and, once again, the less demanding \(h_\mathrm {max} = 5\), for the nonlinear functions \(i_\mathrm {NL}(u_\mathrm {cmn})\) (of the nonlinear resistor \(R_\mathrm {NL}\)) and \(\psi (i_\gamma )\) (of the fractional, nonlinear coil \(L_\psi \)) are given in Table 7. The harmonic remainder error values obtained for the integer-order case are given in Table 8.

Table 7 Harmonic remainder error values for the nonlinear functions of the first problem (values are rounded to 3 significant digits)
Table 8 Harmonic remainder error values for the nonlinear functions of the first problem (values are rounded to 3 significant digits) when all the time derivative orders are changed to 1

9.2.2 Results for Example 2

The harmonic remainder error is been computed for the second example (presented in Sect. 8.2). The results of these computations (for the nonlinear functions \(\psi (i_\psi )\), \(i_{\varPhi }({\varPhi })\), \(i_\psi (u_\mathrm {NL})\) and \(u_q(q)\)) are presented in Table 9. Again, the error is computed for two cases, i.e., \(h_\mathrm {max} = 5\) and the more demanding case of \(h_\mathrm {max} = 25\). The error is also computed for the integer-order time derivative case. The results (also for \(h_\mathrm {max} = 5\) and \(h_\mathrm {max} = 25\)) are given in Table 10.

Table 9 Harmonic remainder error values for the nonlinear functions of the second problem (values are rounded to 3 significant digits)
Table 10 Harmonic remainder error values for the nonlinear functions of the second problem (values are rounded to 3 significant digits) for the first-order time derivative case

10 Summary

For the class of nonlinear problems (with fractional derivatives) resulting in the system of Eq. (8), a methodology has been presented, which for a sought periodic steady-state solution, allows the problem to be converted to a harmonic balance form [generally described by Eq. (14)]. In the new form, the unknowns are the coefficients of the sought variables’ harmonics up to a selected \(h = h_\mathrm {max}\).

Two approaches have been proposed to address the nonlinear dependencies in the harmonic balance form. The first is a symbolic approach, whose advantage is that the computational weight is placed on a pre-solution process, the results of which can then be used conveniently (with a gain in efficiency when the solution is sought). The disadvantage of the symbolic approach is the requirement for each of the nonlinear dependencies to be given as a power series. The second approach (based on time functions) allows the original nonlinear dependencies to be used. Its disadvantage is that the entire computational weight is moved to the solution process.

Table 11 Non-time stepping (analytical and semi-analytical) methods for solving circuit problems with fractional-order elements

Two computational examples have been presented to demonstrate the usefulness of the harmonic balance methodology. The steady-state solutions have been compared with results obtained through a selected numerical method—an adaptive time step size solver applying SubIval [46, 51, 52].

To verify the results, two error criteria have been introduced. The first one is based on comparison with the numerical result, and the second determines the accuracy by estimating the significance of the harmonics not included in the result.

In future papers, more examples will be presented. The harmonic balance methodology has proven to be efficient for solving fractional nonlinear circuit problems in periodic steady states. It has been mainly designed to provide reference solutions for the analysis and improvement in SubIval and solvers applying it.

The methodology has the potential to be very accurate because it allows solutions to be obtained without errors emerging from the estimation of the fractional derivative.

In future analyses, it would be interesting to determine whether the methodology can be applied with equal success to other definitions of the fractional derivative that are commonly applied in circuit analyses, such as the Atangana–Baleanu definition [4, 20] and others [3, 5].

This methodology is valid only for steady-state analyses. An idea for its extension could be to seek a more general solution that applies generalized \(\cos _\alpha \) and \(\sin _\alpha \) functions, as presented in [41]. A future study on such a method could fill the spot in Table 11 where non-time stepping methods are given, which can provide reference solutions when assessing the accuracies of numerical solvers for circuit problems.